use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.
the class ServiceInterfaceMapping$JAXB method _read.
public static final ServiceInterfaceMapping _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final ServiceInterfaceMapping serviceInterfaceMapping = new ServiceInterfaceMapping();
context.beforeUnmarshal(serviceInterfaceMapping, LifecycleCallback.NONE);
List<PortMapping> portMapping = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("service-interface-mappingType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, ServiceInterfaceMapping.class);
}
}
// Read attributes
for (final Attribute attribute : reader.getAttributes()) {
if (("id" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
// ATTRIBUTE: id
final String id = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
context.addXmlId(reader, id, serviceInterfaceMapping);
serviceInterfaceMapping.id = id;
} else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
context.unexpectedAttribute(attribute, new QName("", "id"));
}
}
// Read elements
for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
if (("service-interface" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: serviceInterface
final String serviceInterfaceRaw = elementReader.getElementAsString();
final String serviceInterface;
try {
serviceInterface = Adapters.collapsedStringAdapterAdapter.unmarshal(serviceInterfaceRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
serviceInterfaceMapping.serviceInterface = serviceInterface;
} else if (("wsdl-service-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: wsdlServiceName
final QName wsdlServiceName = elementReader.getElementAsQName();
serviceInterfaceMapping.wsdlServiceName = wsdlServiceName;
} else if (("port-mapping" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: portMapping
final PortMapping portMappingItem = readPortMapping(elementReader, context);
if (portMapping == null) {
portMapping = serviceInterfaceMapping.portMapping;
if (portMapping != null) {
portMapping.clear();
} else {
portMapping = new ArrayList<PortMapping>();
}
}
portMapping.add(portMappingItem);
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "service-interface"), new QName("http://java.sun.com/xml/ns/javaee", "wsdl-service-name"), new QName("http://java.sun.com/xml/ns/javaee", "port-mapping"));
}
}
if (portMapping != null) {
serviceInterfaceMapping.portMapping = portMapping;
}
context.afterUnmarshal(serviceInterfaceMapping, LifecycleCallback.NONE);
return serviceInterfaceMapping;
}
use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.
the class Servlet$JAXB method _read.
public static final Servlet _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final Servlet servlet = new Servlet();
context.beforeUnmarshal(servlet, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
ArrayList<Text> displayNames = null;
LocalCollection<Icon> icon = null;
List<ParamValue> initParam = null;
List<SecurityRoleRef> securityRoleRef = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("servletType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, Servlet.class);
}
}
// Read attributes
for (final Attribute attribute : reader.getAttributes()) {
if (("id" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
// ATTRIBUTE: id
final String id = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
context.addXmlId(reader, id, servlet);
servlet.id = id;
} else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
context.unexpectedAttribute(attribute, new QName("", "id"));
}
}
// Read elements
for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
if (("description" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: descriptions
final Text descriptionsItem = readText(elementReader, context);
if (descriptions == null) {
descriptions = new ArrayList<Text>();
}
descriptions.add(descriptionsItem);
} else if (("display-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: displayNames
final Text displayNamesItem = readText(elementReader, context);
if (displayNames == null) {
displayNames = new ArrayList<Text>();
}
displayNames.add(displayNamesItem);
} else if (("icon" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: icon
final Icon iconItem = readIcon(elementReader, context);
if (icon == null) {
icon = servlet.icon;
if (icon != null) {
icon.clear();
} else {
icon = new LocalCollection<Icon>();
}
}
icon.add(iconItem);
} else if (("servlet-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: servletName
final String servletNameRaw = elementReader.getElementAsString();
final String servletName;
try {
servletName = Adapters.collapsedStringAdapterAdapter.unmarshal(servletNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
servlet.servletName = servletName;
} else if (("servlet-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: servletClass
final String servletClassRaw = elementReader.getElementAsString();
final String servletClass;
try {
servletClass = Adapters.collapsedStringAdapterAdapter.unmarshal(servletClassRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
servlet.servletClass = servletClass;
} else if (("jsp-file" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: jspFile
final String jspFileRaw = elementReader.getElementAsString();
final String jspFile;
try {
jspFile = Adapters.collapsedStringAdapterAdapter.unmarshal(jspFileRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
servlet.jspFile = jspFile;
} else if (("init-param" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: initParam
final ParamValue initParamItem = readParamValue(elementReader, context);
if (initParam == null) {
initParam = servlet.initParam;
if (initParam != null) {
initParam.clear();
} else {
initParam = new ArrayList<ParamValue>();
}
}
initParam.add(initParamItem);
} else if (("load-on-startup" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: loadOnStartup
final String loadOnStartupRaw = elementReader.getElementAsString();
final Integer loadOnStartup;
try {
loadOnStartup = Adapters.loadOnStartupAdapterAdapter.unmarshal(loadOnStartupRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, LoadOnStartupAdapter.class, Integer.class, Integer.class, e);
continue;
}
servlet.loadOnStartup = loadOnStartup;
} else if (("enabled" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: enabled
final Boolean enabled = ("1".equals(elementReader.getElementAsString()) || "true".equals(elementReader.getElementAsString()));
servlet.enabled = enabled;
} else if (("async-supported" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: asyncSupported
final Boolean asyncSupported = ("1".equals(elementReader.getElementAsString()) || "true".equals(elementReader.getElementAsString()));
servlet.asyncSupported = asyncSupported;
} else if (("run-as" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: runAs
final RunAs runAs = readRunAs(elementReader, context);
servlet.runAs = runAs;
} else if (("security-role-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: securityRoleRef
final SecurityRoleRef securityRoleRefItem = readSecurityRoleRef(elementReader, context);
if (securityRoleRef == null) {
securityRoleRef = servlet.securityRoleRef;
if (securityRoleRef != null) {
securityRoleRef.clear();
} else {
securityRoleRef = new ArrayList<SecurityRoleRef>();
}
}
securityRoleRef.add(securityRoleRefItem);
} else if (("multipart-config" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: multipartConfig
final MultipartConfig multipartConfig = readMultipartConfig(elementReader, context);
servlet.multipartConfig = multipartConfig;
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "display-name"), new QName("http://java.sun.com/xml/ns/javaee", "icon"), new QName("http://java.sun.com/xml/ns/javaee", "servlet-name"), new QName("http://java.sun.com/xml/ns/javaee", "servlet-class"), new QName("http://java.sun.com/xml/ns/javaee", "jsp-file"), new QName("http://java.sun.com/xml/ns/javaee", "init-param"), new QName("http://java.sun.com/xml/ns/javaee", "load-on-startup"), new QName("http://java.sun.com/xml/ns/javaee", "enabled"), new QName("http://java.sun.com/xml/ns/javaee", "async-supported"), new QName("http://java.sun.com/xml/ns/javaee", "run-as"), new QName("http://java.sun.com/xml/ns/javaee", "security-role-ref"), new QName("http://java.sun.com/xml/ns/javaee", "multipart-config"));
}
}
if (descriptions != null) {
try {
servlet.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, Servlet.class, "setDescriptions", Text[].class, e);
}
}
if (displayNames != null) {
try {
servlet.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
} catch (final Exception e) {
context.setterError(reader, Servlet.class, "setDisplayNames", Text[].class, e);
}
}
if (icon != null) {
servlet.icon = icon;
}
if (initParam != null) {
servlet.initParam = initParam;
}
if (securityRoleRef != null) {
servlet.securityRoleRef = securityRoleRef;
}
context.afterUnmarshal(servlet, LifecycleCallback.NONE);
return servlet;
}
use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.
the class ServletMapping$JAXB method _read.
public static final ServletMapping _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final ServletMapping servletMapping = new ServletMapping();
context.beforeUnmarshal(servletMapping, LifecycleCallback.NONE);
List<String> urlPattern = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("servlet-mappingType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, ServletMapping.class);
}
}
// Read attributes
for (final Attribute attribute : reader.getAttributes()) {
if (("id" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
// ATTRIBUTE: id
final String id = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
context.addXmlId(reader, id, servletMapping);
servletMapping.id = id;
} else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
context.unexpectedAttribute(attribute, new QName("", "id"));
}
}
// Read elements
for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
if (("servlet-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: servletName
final String servletNameRaw = elementReader.getElementAsString();
final String servletName;
try {
servletName = Adapters.collapsedStringAdapterAdapter.unmarshal(servletNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
servletMapping.servletName = servletName;
} else if (("url-pattern" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: urlPattern
final String urlPatternItemRaw = elementReader.getElementAsString();
final String urlPatternItem;
try {
urlPatternItem = Adapters.trimStringAdapterAdapter.unmarshal(urlPatternItemRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, TrimStringAdapter.class, String.class, String.class, e);
continue;
}
if (urlPattern == null) {
urlPattern = servletMapping.urlPattern;
if (urlPattern != null) {
urlPattern.clear();
} else {
urlPattern = new ArrayList<String>();
}
}
urlPattern.add(urlPatternItem);
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "servlet-name"), new QName("http://java.sun.com/xml/ns/javaee", "url-pattern"));
}
}
if (urlPattern != null) {
servletMapping.urlPattern = urlPattern;
}
context.afterUnmarshal(servletMapping, LifecycleCallback.NONE);
return servletMapping;
}
use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.
the class SessionBean$JAXB method _readDependsOn.
public static final void _readDependsOn(final XoXMLStreamReader reader, final RuntimeContext context, final SessionBean sessionBean) throws Exception {
List<String> dependsOn = null;
// Read elements
for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
if (("ejb-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: dependsOn
final String dependsOnItemRaw = elementReader.getElementAsString();
final String dependsOnItem;
try {
dependsOnItem = Adapters.collapsedStringAdapterAdapter.unmarshal(dependsOnItemRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
if (dependsOn == null) {
dependsOn = sessionBean.dependsOn;
if (dependsOn != null) {
dependsOn.clear();
} else {
dependsOn = new ArrayList<String>();
}
}
dependsOn.add(dependsOnItem);
}
}
if (dependsOn != null) {
sessionBean.dependsOn = dependsOn;
}
}
use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.
the class TagFile$JAXB method _read.
public static final TagFile _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final TagFile tagFile = new TagFile();
context.beforeUnmarshal(tagFile, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
ArrayList<Text> displayNames = null;
LocalCollection<Icon> icon = null;
List<TldExtension> tagExtension = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("tagFileType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, TagFile.class);
}
}
// Read attributes
for (final Attribute attribute : reader.getAttributes()) {
if (("id" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
// ATTRIBUTE: id
final String id = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
context.addXmlId(reader, id, tagFile);
tagFile.id = id;
} else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
context.unexpectedAttribute(attribute, new QName("", "id"));
}
}
// Read elements
for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
if (("description" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: descriptions
final Text descriptionsItem = readText(elementReader, context);
if (descriptions == null) {
descriptions = new ArrayList<Text>();
}
descriptions.add(descriptionsItem);
} else if (("display-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: displayNames
final Text displayNamesItem = readText(elementReader, context);
if (displayNames == null) {
displayNames = new ArrayList<Text>();
}
displayNames.add(displayNamesItem);
} else if (("icon" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: icon
final Icon iconItem = readIcon(elementReader, context);
if (icon == null) {
icon = tagFile.icon;
if (icon != null) {
icon.clear();
} else {
icon = new LocalCollection<Icon>();
}
}
icon.add(iconItem);
} else if (("name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: name
final String nameRaw = elementReader.getElementAsString();
final String name;
try {
name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
tagFile.name = name;
} else if (("path" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: path
final String pathRaw = elementReader.getElementAsString();
final String path;
try {
path = Adapters.collapsedStringAdapterAdapter.unmarshal(pathRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
tagFile.path = path;
} else if (("example" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: example
final String exampleRaw = elementReader.getElementAsString();
final String example;
try {
example = Adapters.collapsedStringAdapterAdapter.unmarshal(exampleRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
tagFile.example = example;
} else if (("tag-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: tagExtension
final TldExtension tagExtensionItem = readTldExtension(elementReader, context);
if (tagExtension == null) {
tagExtension = tagFile.tagExtension;
if (tagExtension != null) {
tagExtension.clear();
} else {
tagExtension = new ArrayList<TldExtension>();
}
}
tagExtension.add(tagExtensionItem);
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "display-name"), new QName("http://java.sun.com/xml/ns/javaee", "icon"), new QName("http://java.sun.com/xml/ns/javaee", "name"), new QName("http://java.sun.com/xml/ns/javaee", "path"), new QName("http://java.sun.com/xml/ns/javaee", "example"), new QName("http://java.sun.com/xml/ns/javaee", "tag-extension"));
}
}
if (descriptions != null) {
try {
tagFile.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, TagFile.class, "setDescriptions", Text[].class, e);
}
}
if (displayNames != null) {
try {
tagFile.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
} catch (final Exception e) {
context.setterError(reader, TagFile.class, "setDisplayNames", Text[].class, e);
}
}
if (icon != null) {
tagFile.icon = icon;
}
if (tagExtension != null) {
tagFile.tagExtension = tagExtension;
}
context.afterUnmarshal(tagFile, LifecycleCallback.NONE);
return tagFile;
}
Aggregations