use of org.apache.openejb.jee.Text$JAXB.writeText in project tomee by apache.
the class Interceptor$JAXB method _read.
public static final Interceptor _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final Interceptor interceptor = new Interceptor();
context.beforeUnmarshal(interceptor, org.metatype.sxc.jaxb.LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
List<AroundInvoke> aroundInvoke = null;
List<AroundTimeout> aroundTimeout = null;
KeyedCollection<String, EnvEntry> envEntry = null;
KeyedCollection<String, EjbRef> ejbRef = null;
KeyedCollection<String, EjbLocalRef> ejbLocalRef = null;
KeyedCollection<String, ServiceRef> serviceRef = null;
KeyedCollection<String, ResourceRef> resourceRef = null;
KeyedCollection<String, ResourceEnvRef> resourceEnvRef = null;
KeyedCollection<String, MessageDestinationRef> messageDestinationRef = null;
KeyedCollection<String, PersistenceContextRef> persistenceContextRef = null;
KeyedCollection<String, PersistenceUnitRef> persistenceUnitRef = null;
List<org.apache.openejb.jee.LifecycleCallback> postConstruct = null;
List<org.apache.openejb.jee.LifecycleCallback> preDestroy = null;
KeyedCollection<String, DataSource> dataSource = null;
List<org.apache.openejb.jee.LifecycleCallback> postActivate = null;
List<org.apache.openejb.jee.LifecycleCallback> prePassivate = null;
List<org.apache.openejb.jee.LifecycleCallback> afterBegin = null;
List<org.apache.openejb.jee.LifecycleCallback> beforeCompletion = null;
List<org.apache.openejb.jee.LifecycleCallback> afterCompletion = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("interceptorType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, Interceptor.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, interceptor);
interceptor.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 (("interceptor-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: interceptorClass
final String interceptorClassRaw = elementReader.getElementAsString();
final String interceptorClass;
try {
interceptorClass = Adapters.collapsedStringAdapterAdapter.unmarshal(interceptorClassRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
interceptor.interceptorClass = interceptorClass;
} else if (("around-invoke" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: aroundInvoke
final AroundInvoke aroundInvokeItem = readAroundInvoke(elementReader, context);
if (aroundInvoke == null) {
aroundInvoke = interceptor.aroundInvoke;
if (aroundInvoke != null) {
aroundInvoke.clear();
} else {
aroundInvoke = new ArrayList<AroundInvoke>();
}
}
aroundInvoke.add(aroundInvokeItem);
} else if (("around-timeout" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: aroundTimeout
final AroundTimeout aroundTimeoutItem = readAroundTimeout(elementReader, context);
if (aroundTimeout == null) {
aroundTimeout = interceptor.aroundTimeout;
if (aroundTimeout != null) {
aroundTimeout.clear();
} else {
aroundTimeout = new ArrayList<AroundTimeout>();
}
}
aroundTimeout.add(aroundTimeoutItem);
} else if (("env-entry" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: envEntry
final EnvEntry envEntryItem = readEnvEntry(elementReader, context);
if (envEntry == null) {
envEntry = interceptor.envEntry;
if (envEntry != null) {
envEntry.clear();
} else {
envEntry = new KeyedCollection<String, EnvEntry>();
}
}
envEntry.add(envEntryItem);
} else if (("ejb-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbRef
final EjbRef ejbRefItem = readEjbRef(elementReader, context);
if (ejbRef == null) {
ejbRef = interceptor.ejbRef;
if (ejbRef != null) {
ejbRef.clear();
} else {
ejbRef = new KeyedCollection<String, EjbRef>();
}
}
ejbRef.add(ejbRefItem);
} else if (("ejb-local-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbLocalRef
final EjbLocalRef ejbLocalRefItem = readEjbLocalRef(elementReader, context);
if (ejbLocalRef == null) {
ejbLocalRef = interceptor.ejbLocalRef;
if (ejbLocalRef != null) {
ejbLocalRef.clear();
} else {
ejbLocalRef = new KeyedCollection<String, EjbLocalRef>();
}
}
ejbLocalRef.add(ejbLocalRefItem);
} else if (("service-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: serviceRef
final ServiceRef serviceRefItem = readServiceRef(elementReader, context);
if (serviceRef == null) {
serviceRef = interceptor.serviceRef;
if (serviceRef != null) {
serviceRef.clear();
} else {
serviceRef = new KeyedCollection<String, ServiceRef>();
}
}
serviceRef.add(serviceRefItem);
} else if (("resource-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: resourceRef
final ResourceRef resourceRefItem = readResourceRef(elementReader, context);
if (resourceRef == null) {
resourceRef = interceptor.resourceRef;
if (resourceRef != null) {
resourceRef.clear();
} else {
resourceRef = new KeyedCollection<String, ResourceRef>();
}
}
resourceRef.add(resourceRefItem);
} else if (("resource-env-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: resourceEnvRef
final ResourceEnvRef resourceEnvRefItem = readResourceEnvRef(elementReader, context);
if (resourceEnvRef == null) {
resourceEnvRef = interceptor.resourceEnvRef;
if (resourceEnvRef != null) {
resourceEnvRef.clear();
} else {
resourceEnvRef = new KeyedCollection<String, ResourceEnvRef>();
}
}
resourceEnvRef.add(resourceEnvRefItem);
} else if (("message-destination-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: messageDestinationRef
final MessageDestinationRef messageDestinationRefItem = readMessageDestinationRef(elementReader, context);
if (messageDestinationRef == null) {
messageDestinationRef = interceptor.messageDestinationRef;
if (messageDestinationRef != null) {
messageDestinationRef.clear();
} else {
messageDestinationRef = new KeyedCollection<String, MessageDestinationRef>();
}
}
messageDestinationRef.add(messageDestinationRefItem);
} else if (("persistence-context-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: persistenceContextRef
final PersistenceContextRef persistenceContextRefItem = readPersistenceContextRef(elementReader, context);
if (persistenceContextRef == null) {
persistenceContextRef = interceptor.persistenceContextRef;
if (persistenceContextRef != null) {
persistenceContextRef.clear();
} else {
persistenceContextRef = new KeyedCollection<String, PersistenceContextRef>();
}
}
persistenceContextRef.add(persistenceContextRefItem);
} else if (("persistence-unit-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: persistenceUnitRef
final PersistenceUnitRef persistenceUnitRefItem = readPersistenceUnitRef(elementReader, context);
if (persistenceUnitRef == null) {
persistenceUnitRef = interceptor.persistenceUnitRef;
if (persistenceUnitRef != null) {
persistenceUnitRef.clear();
} else {
persistenceUnitRef = new KeyedCollection<String, PersistenceUnitRef>();
}
}
persistenceUnitRef.add(persistenceUnitRefItem);
} else if (("post-construct" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: postConstruct
final org.apache.openejb.jee.LifecycleCallback postConstructItem = readLifecycleCallback(elementReader, context);
if (postConstruct == null) {
postConstruct = interceptor.postConstruct;
if (postConstruct != null) {
postConstruct.clear();
} else {
postConstruct = new ArrayList<org.apache.openejb.jee.LifecycleCallback>();
}
}
postConstruct.add(postConstructItem);
} else if (("pre-destroy" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: preDestroy
final org.apache.openejb.jee.LifecycleCallback preDestroyItem = readLifecycleCallback(elementReader, context);
if (preDestroy == null) {
preDestroy = interceptor.preDestroy;
if (preDestroy != null) {
preDestroy.clear();
} else {
preDestroy = new ArrayList<org.apache.openejb.jee.LifecycleCallback>();
}
}
preDestroy.add(preDestroyItem);
} else if (("data-source" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: dataSource
final DataSource dataSourceItem = readDataSource(elementReader, context);
if (dataSource == null) {
dataSource = interceptor.dataSource;
if (dataSource != null) {
dataSource.clear();
} else {
dataSource = new KeyedCollection<String, DataSource>();
}
}
dataSource.add(dataSourceItem);
} else if (("post-activate" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: postActivate
final org.apache.openejb.jee.LifecycleCallback postActivateItem = readLifecycleCallback(elementReader, context);
if (postActivate == null) {
postActivate = interceptor.postActivate;
if (postActivate != null) {
postActivate.clear();
} else {
postActivate = new ArrayList<org.apache.openejb.jee.LifecycleCallback>();
}
}
postActivate.add(postActivateItem);
} else if (("pre-passivate" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: prePassivate
final org.apache.openejb.jee.LifecycleCallback prePassivateItem = readLifecycleCallback(elementReader, context);
if (prePassivate == null) {
prePassivate = interceptor.prePassivate;
if (prePassivate != null) {
prePassivate.clear();
} else {
prePassivate = new ArrayList<org.apache.openejb.jee.LifecycleCallback>();
}
}
prePassivate.add(prePassivateItem);
} else if (("after-begin" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: afterBegin
final org.apache.openejb.jee.LifecycleCallback afterBeginItem = readLifecycleCallback(elementReader, context);
if (afterBegin == null) {
afterBegin = interceptor.afterBegin;
if (afterBegin != null) {
afterBegin.clear();
} else {
afterBegin = new ArrayList<org.apache.openejb.jee.LifecycleCallback>();
}
}
afterBegin.add(afterBeginItem);
} else if (("before-completion" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: beforeCompletion
final org.apache.openejb.jee.LifecycleCallback beforeCompletionItem = readLifecycleCallback(elementReader, context);
if (beforeCompletion == null) {
beforeCompletion = interceptor.beforeCompletion;
if (beforeCompletion != null) {
beforeCompletion.clear();
} else {
beforeCompletion = new ArrayList<org.apache.openejb.jee.LifecycleCallback>();
}
}
beforeCompletion.add(beforeCompletionItem);
} else if (("after-completion" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: afterCompletion
final org.apache.openejb.jee.LifecycleCallback afterCompletionItem = readLifecycleCallback(elementReader, context);
if (afterCompletion == null) {
afterCompletion = interceptor.afterCompletion;
if (afterCompletion != null) {
afterCompletion.clear();
} else {
afterCompletion = new ArrayList<org.apache.openejb.jee.LifecycleCallback>();
}
}
afterCompletion.add(afterCompletionItem);
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "interceptor-class"), new QName("http://java.sun.com/xml/ns/javaee", "around-invoke"), new QName("http://java.sun.com/xml/ns/javaee", "around-timeout"), new QName("http://java.sun.com/xml/ns/javaee", "env-entry"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-ref"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-local-ref"), new QName("http://java.sun.com/xml/ns/javaee", "service-ref"), new QName("http://java.sun.com/xml/ns/javaee", "resource-ref"), new QName("http://java.sun.com/xml/ns/javaee", "resource-env-ref"), new QName("http://java.sun.com/xml/ns/javaee", "message-destination-ref"), new QName("http://java.sun.com/xml/ns/javaee", "persistence-context-ref"), new QName("http://java.sun.com/xml/ns/javaee", "persistence-unit-ref"), new QName("http://java.sun.com/xml/ns/javaee", "post-construct"), new QName("http://java.sun.com/xml/ns/javaee", "pre-destroy"), new QName("http://java.sun.com/xml/ns/javaee", "data-source"), new QName("http://java.sun.com/xml/ns/javaee", "post-activate"), new QName("http://java.sun.com/xml/ns/javaee", "pre-passivate"), new QName("http://java.sun.com/xml/ns/javaee", "after-begin"), new QName("http://java.sun.com/xml/ns/javaee", "before-completion"), new QName("http://java.sun.com/xml/ns/javaee", "after-completion"));
}
}
if (descriptions != null) {
try {
interceptor.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, Interceptor.class, "setDescriptions", Text[].class, e);
}
}
if (aroundInvoke != null) {
interceptor.aroundInvoke = aroundInvoke;
}
if (aroundTimeout != null) {
interceptor.aroundTimeout = aroundTimeout;
}
if (envEntry != null) {
interceptor.envEntry = envEntry;
}
if (ejbRef != null) {
interceptor.ejbRef = ejbRef;
}
if (ejbLocalRef != null) {
interceptor.ejbLocalRef = ejbLocalRef;
}
if (serviceRef != null) {
interceptor.serviceRef = serviceRef;
}
if (resourceRef != null) {
interceptor.resourceRef = resourceRef;
}
if (resourceEnvRef != null) {
interceptor.resourceEnvRef = resourceEnvRef;
}
if (messageDestinationRef != null) {
interceptor.messageDestinationRef = messageDestinationRef;
}
if (persistenceContextRef != null) {
interceptor.persistenceContextRef = persistenceContextRef;
}
if (persistenceUnitRef != null) {
interceptor.persistenceUnitRef = persistenceUnitRef;
}
if (postConstruct != null) {
interceptor.postConstruct = postConstruct;
}
if (preDestroy != null) {
interceptor.preDestroy = preDestroy;
}
if (dataSource != null) {
interceptor.dataSource = dataSource;
}
if (postActivate != null) {
interceptor.postActivate = postActivate;
}
if (prePassivate != null) {
interceptor.prePassivate = prePassivate;
}
if (afterBegin != null) {
interceptor.afterBegin = afterBegin;
}
if (beforeCompletion != null) {
interceptor.beforeCompletion = beforeCompletion;
}
if (afterCompletion != null) {
interceptor.afterCompletion = afterCompletion;
}
context.afterUnmarshal(interceptor, org.metatype.sxc.jaxb.LifecycleCallback.NONE);
return interceptor;
}
use of org.apache.openejb.jee.Text$JAXB.writeText in project tomee by apache.
the class InterceptorBinding$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final InterceptorBinding interceptorBinding, RuntimeContext context) throws Exception {
if (interceptorBinding == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (InterceptorBinding.class != interceptorBinding.getClass()) {
context.unexpectedSubclass(writer, interceptorBinding, InterceptorBinding.class);
return;
}
context.beforeMarshal(interceptorBinding, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = interceptorBinding.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(interceptorBinding, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: descriptions
Text[] descriptions = null;
try {
descriptions = interceptorBinding.getDescriptions();
} catch (final Exception e) {
context.getterError(interceptorBinding, "descriptions", InterceptorBinding.class, "getDescriptions", e);
}
if (descriptions != null) {
for (final Text descriptionsItem : descriptions) {
if (descriptionsItem != null) {
writer.writeStartElement(prefix, "description", "http://java.sun.com/xml/ns/javaee");
writeText(writer, descriptionsItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(interceptorBinding, "descriptions");
}
}
}
// ELEMENT: ejbName
final String ejbNameRaw = interceptorBinding.ejbName;
String ejbName = null;
try {
ejbName = Adapters.collapsedStringAdapterAdapter.marshal(ejbNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(interceptorBinding, "ejbName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (ejbName != null) {
writer.writeStartElement(prefix, "ejb-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(ejbName);
writer.writeEndElement();
} else {
context.unexpectedNullValue(interceptorBinding, "ejbName");
}
// ELEMENT: interceptorClass
final List<String> interceptorClassRaw = interceptorBinding.interceptorClass;
if (interceptorClassRaw != null) {
for (final String interceptorClassItem : interceptorClassRaw) {
String interceptorClass = null;
try {
interceptorClass = Adapters.collapsedStringAdapterAdapter.marshal(interceptorClassItem);
} catch (final Exception e) {
context.xmlAdapterError(interceptorBinding, "interceptorClass", CollapsedStringAdapter.class, List.class, List.class, e);
}
if (interceptorClass != null) {
writer.writeStartElement(prefix, "interceptor-class", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(interceptorClass);
writer.writeEndElement();
} else {
context.unexpectedNullValue(interceptorBinding, "interceptorClass");
}
}
}
// ELEMENT: interceptorOrder
final InterceptorOrder interceptorOrder = interceptorBinding.interceptorOrder;
if (interceptorOrder != null) {
writer.writeStartElement(prefix, "interceptor-order", "http://java.sun.com/xml/ns/javaee");
writeInterceptorOrder(writer, interceptorOrder, context);
writer.writeEndElement();
}
// ELEMENT: excludeDefaultInterceptors
final Boolean excludeDefaultInterceptors = interceptorBinding.excludeDefaultInterceptors;
writer.writeStartElement(prefix, "exclude-default-interceptors", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(Boolean.toString(excludeDefaultInterceptors));
writer.writeEndElement();
// ELEMENT: excludeClassInterceptors
final Boolean excludeClassInterceptors = interceptorBinding.excludeClassInterceptors;
writer.writeStartElement(prefix, "exclude-class-interceptors", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(Boolean.toString(excludeClassInterceptors));
writer.writeEndElement();
// ELEMENT: method
final NamedMethod method = interceptorBinding.method;
if (method != null) {
writer.writeStartElement(prefix, "method", "http://java.sun.com/xml/ns/javaee");
writeNamedMethod(writer, method, context);
writer.writeEndElement();
}
context.afterMarshal(interceptorBinding, LifecycleCallback.NONE);
}
use of org.apache.openejb.jee.Text$JAXB.writeText in project tomee by apache.
the class InterceptorBinding$JAXB method _read.
public static final InterceptorBinding _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final InterceptorBinding interceptorBinding = new InterceptorBinding();
context.beforeUnmarshal(interceptorBinding, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
List<String> interceptorClass = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("interceptor-bindingType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, InterceptorBinding.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, interceptorBinding);
interceptorBinding.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 (("ejb-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbName
final String ejbNameRaw = elementReader.getElementAsString();
final String ejbName;
try {
ejbName = Adapters.collapsedStringAdapterAdapter.unmarshal(ejbNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
interceptorBinding.ejbName = ejbName;
} else if (("interceptor-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: interceptorClass
final String interceptorClassItemRaw = elementReader.getElementAsString();
final String interceptorClassItem;
try {
interceptorClassItem = Adapters.collapsedStringAdapterAdapter.unmarshal(interceptorClassItemRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
if (interceptorClass == null) {
interceptorClass = interceptorBinding.interceptorClass;
if (interceptorClass != null) {
interceptorClass.clear();
} else {
interceptorClass = new ArrayList<String>();
}
}
interceptorClass.add(interceptorClassItem);
} else if (("interceptor-order" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: interceptorOrder
final InterceptorOrder interceptorOrder = readInterceptorOrder(elementReader, context);
interceptorBinding.interceptorOrder = interceptorOrder;
} else if (("exclude-default-interceptors" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: excludeDefaultInterceptors
final Boolean excludeDefaultInterceptors = ("1".equals(elementReader.getElementAsString()) || "true".equals(elementReader.getElementAsString()));
interceptorBinding.excludeDefaultInterceptors = excludeDefaultInterceptors;
} else if (("exclude-class-interceptors" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: excludeClassInterceptors
final Boolean excludeClassInterceptors = ("1".equals(elementReader.getElementAsString()) || "true".equals(elementReader.getElementAsString()));
interceptorBinding.excludeClassInterceptors = excludeClassInterceptors;
} else if (("method" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: method
final NamedMethod method = readNamedMethod(elementReader, context);
interceptorBinding.method = method;
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-name"), new QName("http://java.sun.com/xml/ns/javaee", "interceptor-class"), new QName("http://java.sun.com/xml/ns/javaee", "interceptor-order"), new QName("http://java.sun.com/xml/ns/javaee", "exclude-default-interceptors"), new QName("http://java.sun.com/xml/ns/javaee", "exclude-class-interceptors"), new QName("http://java.sun.com/xml/ns/javaee", "method"));
}
}
if (descriptions != null) {
try {
interceptorBinding.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, InterceptorBinding.class, "setDescriptions", Text[].class, e);
}
}
if (interceptorClass != null) {
interceptorBinding.interceptorClass = interceptorClass;
}
context.afterUnmarshal(interceptorBinding, LifecycleCallback.NONE);
return interceptorBinding;
}
use of org.apache.openejb.jee.Text$JAXB.writeText in project tomee by apache.
the class JMSConnectionFactory$JAXB method _read.
public static final JMSConnectionFactory _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final JMSConnectionFactory JMSConnectionFactory = new JMSConnectionFactory();
context.beforeUnmarshal(JMSConnectionFactory, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
List<Property> property = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("jms-connection-factoryType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, JMSConnectionFactory.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, JMSConnectionFactory);
JMSConnectionFactory.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 (("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;
}
JMSConnectionFactory.name = name;
} else if (("class-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;
}
JMSConnectionFactory.className = name;
} else if (("interface-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;
}
JMSConnectionFactory.className = name;
} else if (("resource-adapter" == 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;
}
JMSConnectionFactory.resourceAdapter = name;
} else if (("user" == 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;
}
JMSConnectionFactory.user = name;
} else if (("password" == 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;
}
JMSConnectionFactory.password = name;
} else if (("client-id" == 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;
}
JMSConnectionFactory.clientId = name;
} else if (("max-pool-size" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
final Integer portNumber = Integer.valueOf(elementReader.getElementAsString());
JMSConnectionFactory.maxPoolSize = portNumber;
} else if (("min-pool-size" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
final Integer portNumber = Integer.valueOf(elementReader.getElementAsString());
JMSConnectionFactory.minPoolSize = portNumber;
} else if (("transactional" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
JMSConnectionFactory.transactional = Boolean.parseBoolean(elementReader.getElementAsString());
} else if (("property" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: property
final Property propertyItem = readProperty(elementReader, context);
if (property == null) {
property = JMSConnectionFactory.property;
if (property != null) {
property.clear();
} else {
property = new ArrayList<>();
}
}
property.add(propertyItem);
} else if (!Boolean.getBoolean("tomee.xml.passthrough")) {
// so to pass if not important
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "name"), new QName("http://java.sun.com/xml/ns/javaee", "class-name"), new QName("http://java.sun.com/xml/ns/javaee", "server-name"), new QName("http://java.sun.com/xml/ns/javaee", "port-number"), new QName("http://java.sun.com/xml/ns/javaee", "database-name"), new QName("http://java.sun.com/xml/ns/javaee", "url"), new QName("http://java.sun.com/xml/ns/javaee", "user"), new QName("http://java.sun.com/xml/ns/javaee", "password"), new QName("http://java.sun.com/xml/ns/javaee", "property"), new QName("http://java.sun.com/xml/ns/javaee", "login-timeout"), new QName("http://java.sun.com/xml/ns/javaee", "transactional"), new QName("http://java.sun.com/xml/ns/javaee", "isolation-level"), new QName("http://java.sun.com/xml/ns/javaee", "initial-pool-size"), new QName("http://java.sun.com/xml/ns/javaee", "max-pool-size"), new QName("http://java.sun.com/xml/ns/javaee", "min-pool-size"), new QName("http://java.sun.com/xml/ns/javaee", "max-idle-time"), new QName("http://java.sun.com/xml/ns/javaee", "max-statements"));
}
}
if (descriptions != null) {
try {
JMSConnectionFactory.description.set(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, JMSConnectionFactory.class, "setDescriptions", Text[].class, e);
}
}
if (property != null) {
JMSConnectionFactory.property = property;
}
context.afterUnmarshal(JMSConnectionFactory, LifecycleCallback.NONE);
return JMSConnectionFactory;
}
use of org.apache.openejb.jee.Text$JAXB.writeText in project tomee by apache.
the class Handler$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final Handler handler, RuntimeContext context) throws Exception {
if (handler == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (Handler.class != handler.getClass()) {
context.unexpectedSubclass(writer, handler, Handler.class);
return;
}
context.beforeMarshal(handler, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = handler.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(handler, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: descriptions
Text[] descriptions = null;
try {
descriptions = handler.getDescriptions();
} catch (final Exception e) {
context.getterError(handler, "descriptions", Handler.class, "getDescriptions", e);
}
if (descriptions != null) {
for (final Text descriptionsItem : descriptions) {
if (descriptionsItem != null) {
writer.writeStartElement(prefix, "description", "http://java.sun.com/xml/ns/javaee");
writeText(writer, descriptionsItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(handler, "descriptions");
}
}
}
// ELEMENT: displayNames
Text[] displayNames = null;
try {
displayNames = handler.getDisplayNames();
} catch (final Exception e) {
context.getterError(handler, "displayNames", Handler.class, "getDisplayNames", e);
}
if (displayNames != null) {
for (final Text displayNamesItem : displayNames) {
if (displayNamesItem != null) {
writer.writeStartElement(prefix, "display-name", "http://java.sun.com/xml/ns/javaee");
writeText(writer, displayNamesItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(handler, "displayNames");
}
}
}
// ELEMENT: icon
final LocalCollection<Icon> icon = handler.icon;
if (icon != null) {
for (final Icon iconItem : icon) {
if (iconItem != null) {
writer.writeStartElement(prefix, "icon", "http://java.sun.com/xml/ns/javaee");
writeIcon(writer, iconItem, context);
writer.writeEndElement();
}
}
}
// ELEMENT: handlerName
final String handlerNameRaw = handler.handlerName;
String handlerName = null;
try {
handlerName = Adapters.collapsedStringAdapterAdapter.marshal(handlerNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(handler, "handlerName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (handlerName != null) {
writer.writeStartElement(prefix, "handler-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(handlerName);
writer.writeEndElement();
} else {
context.unexpectedNullValue(handler, "handlerName");
}
// ELEMENT: handlerClass
final String handlerClassRaw = handler.handlerClass;
String handlerClass = null;
try {
handlerClass = Adapters.collapsedStringAdapterAdapter.marshal(handlerClassRaw);
} catch (final Exception e) {
context.xmlAdapterError(handler, "handlerClass", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (handlerClass != null) {
writer.writeStartElement(prefix, "handler-class", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(handlerClass);
writer.writeEndElement();
} else {
context.unexpectedNullValue(handler, "handlerClass");
}
// ELEMENT: initParam
final List<ParamValue> initParam = handler.initParam;
if (initParam != null) {
for (final ParamValue initParamItem : initParam) {
if (initParamItem != null) {
writer.writeStartElement(prefix, "init-param", "http://java.sun.com/xml/ns/javaee");
writeParamValue(writer, initParamItem, context);
writer.writeEndElement();
}
}
}
// ELEMENT: soapHeader
final List<QName> soapHeader = handler.soapHeader;
if (soapHeader != null) {
for (final QName soapHeaderItem : soapHeader) {
if (soapHeaderItem != null) {
writer.writeStartElement(prefix, "soap-header", "http://java.sun.com/xml/ns/javaee");
writer.writeQName(soapHeaderItem);
writer.writeEndElement();
}
}
}
// ELEMENT: soapRole
final List<String> soapRoleRaw = handler.soapRole;
if (soapRoleRaw != null) {
for (final String soapRoleItem : soapRoleRaw) {
String soapRole = null;
try {
soapRole = Adapters.collapsedStringAdapterAdapter.marshal(soapRoleItem);
} catch (final Exception e) {
context.xmlAdapterError(handler, "soapRole", CollapsedStringAdapter.class, List.class, List.class, e);
}
if (soapRole != null) {
writer.writeStartElement(prefix, "soap-role", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(soapRole);
writer.writeEndElement();
}
}
}
// ELEMENT: portName
final List<String> portNameRaw = handler.portName;
if (portNameRaw != null) {
for (final String portNameItem : portNameRaw) {
String portName = null;
try {
portName = Adapters.collapsedStringAdapterAdapter.marshal(portNameItem);
} catch (final Exception e) {
context.xmlAdapterError(handler, "portName", CollapsedStringAdapter.class, List.class, List.class, e);
}
if (portName != null) {
writer.writeStartElement(prefix, "port-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(portName);
writer.writeEndElement();
} else {
context.unexpectedNullValue(handler, "portName");
}
}
}
context.afterMarshal(handler, LifecycleCallback.NONE);
}
Aggregations