use of org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget in project tomee by apache.
the class EjbRef$JAXB method _read.
public static final EjbRef _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final EjbRef ejbRef = new EjbRef();
context.beforeUnmarshal(ejbRef, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
Set<InjectionTarget> injectionTarget = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("ejb-refType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, EjbRef.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, ejbRef);
ejbRef.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-ref-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbRefName
final String ejbRefNameRaw = elementReader.getElementAsString();
final String ejbRefName;
try {
ejbRefName = Adapters.collapsedStringAdapterAdapter.unmarshal(ejbRefNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
ejbRef.ejbRefName = ejbRefName;
} else if (("ejb-ref-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbRefType
final EjbRefType ejbRefType = parseEjbRefType(elementReader, context, elementReader.getElementAsString());
if (ejbRefType != null) {
ejbRef.ejbRefType = ejbRefType;
}
} else if (("home" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: home
final String homeRaw = elementReader.getElementAsString();
final String home;
try {
home = Adapters.collapsedStringAdapterAdapter.unmarshal(homeRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
ejbRef.home = home;
} else if (("remote" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: remote
final String remoteRaw = elementReader.getElementAsString();
final String remote;
try {
remote = Adapters.collapsedStringAdapterAdapter.unmarshal(remoteRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
ejbRef.remote = remote;
} else if (("ejb-link" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbLink
final String ejbLinkRaw = elementReader.getElementAsString();
final String ejbLink;
try {
ejbLink = Adapters.collapsedStringAdapterAdapter.unmarshal(ejbLinkRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
ejbRef.ejbLink = ejbLink;
} else if (("mapped-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: mappedName
final String mappedNameRaw = elementReader.getElementAsString();
final String mappedName;
try {
mappedName = Adapters.collapsedStringAdapterAdapter.unmarshal(mappedNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
ejbRef.mappedName = mappedName;
} else if (("injection-target" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: injectionTarget
final InjectionTarget injectionTargetItem = readInjectionTarget(elementReader, context);
if (injectionTarget == null) {
injectionTarget = ejbRef.injectionTarget;
if (injectionTarget != null) {
injectionTarget.clear();
} else {
injectionTarget = new LinkedHashSet<InjectionTarget>();
}
}
injectionTarget.add(injectionTargetItem);
} else if (("lookup-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: lookupName
final String lookupNameRaw = elementReader.getElementAsString();
final String lookupName;
try {
lookupName = Adapters.collapsedStringAdapterAdapter.unmarshal(lookupNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
ejbRef.lookupName = lookupName;
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-ref-name"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-ref-type"), new QName("http://java.sun.com/xml/ns/javaee", "home"), new QName("http://java.sun.com/xml/ns/javaee", "remote"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-link"), new QName("http://java.sun.com/xml/ns/javaee", "mapped-name"), new QName("http://java.sun.com/xml/ns/javaee", "injection-target"), new QName("http://java.sun.com/xml/ns/javaee", "lookup-name"));
}
}
if (descriptions != null) {
try {
ejbRef.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, EjbRef.class, "setDescriptions", Text[].class, e);
}
}
if (injectionTarget != null) {
ejbRef.injectionTarget = injectionTarget;
}
context.afterUnmarshal(ejbRef, LifecycleCallback.NONE);
return ejbRef;
}
use of org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget in project tomee by apache.
the class EnvEntry$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final EnvEntry envEntry, RuntimeContext context) throws Exception {
if (envEntry == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (EnvEntry.class != envEntry.getClass()) {
context.unexpectedSubclass(writer, envEntry, EnvEntry.class);
return;
}
context.beforeMarshal(envEntry, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = envEntry.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(envEntry, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: descriptions
Text[] descriptions = null;
try {
descriptions = envEntry.getDescriptions();
} catch (final Exception e) {
context.getterError(envEntry, "descriptions", EnvEntry.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(envEntry, "descriptions");
}
}
}
// ELEMENT: envEntryName
final String envEntryNameRaw = envEntry.envEntryName;
String envEntryName = null;
try {
envEntryName = Adapters.collapsedStringAdapterAdapter.marshal(envEntryNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(envEntry, "envEntryName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (envEntryName != null) {
writer.writeStartElement(prefix, "env-entry-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(envEntryName);
writer.writeEndElement();
} else {
context.unexpectedNullValue(envEntry, "envEntryName");
}
// ELEMENT: envEntryType
final String envEntryTypeRaw = envEntry.envEntryType;
String envEntryType = null;
try {
envEntryType = Adapters.collapsedStringAdapterAdapter.marshal(envEntryTypeRaw);
} catch (final Exception e) {
context.xmlAdapterError(envEntry, "envEntryType", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (envEntryType != null) {
writer.writeStartElement(prefix, "env-entry-type", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(envEntryType);
writer.writeEndElement();
}
// ELEMENT: envEntryValue
final String envEntryValueRaw = envEntry.envEntryValue;
String envEntryValue = null;
try {
envEntryValue = Adapters.stringAdapterAdapter.marshal(envEntryValueRaw);
} catch (final Exception e) {
context.xmlAdapterError(envEntry, "envEntryValue", StringAdapter.class, String.class, String.class, e);
}
if (envEntryValue != null) {
writer.writeStartElement(prefix, "env-entry-value", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(envEntryValue);
writer.writeEndElement();
}
// ELEMENT: mappedName
final String mappedNameRaw = envEntry.mappedName;
String mappedName = null;
try {
mappedName = Adapters.collapsedStringAdapterAdapter.marshal(mappedNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(envEntry, "mappedName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (mappedName != null) {
writer.writeStartElement(prefix, "mapped-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(mappedName);
writer.writeEndElement();
}
// ELEMENT: injectionTarget
final Set<InjectionTarget> injectionTarget = envEntry.injectionTarget;
if (injectionTarget != null) {
for (final InjectionTarget injectionTargetItem : injectionTarget) {
if (injectionTargetItem != null) {
writer.writeStartElement(prefix, "injection-target", "http://java.sun.com/xml/ns/javaee");
writeInjectionTarget(writer, injectionTargetItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(envEntry, "injectionTarget");
}
}
}
// ELEMENT: lookupName
final String lookupNameRaw = envEntry.lookupName;
String lookupName = null;
try {
lookupName = Adapters.collapsedStringAdapterAdapter.marshal(lookupNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(envEntry, "lookupName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (lookupName != null) {
writer.writeStartElement(prefix, "lookup-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(lookupName);
writer.writeEndElement();
}
context.afterMarshal(envEntry, LifecycleCallback.NONE);
}
use of org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget in project tomee by apache.
the class MessageDestinationRef$JAXB method _read.
public static final MessageDestinationRef _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final MessageDestinationRef messageDestinationRef = new MessageDestinationRef();
context.beforeUnmarshal(messageDestinationRef, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
Set<InjectionTarget> injectionTarget = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("message-destination-refType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, MessageDestinationRef.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, messageDestinationRef);
messageDestinationRef.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 (("message-destination-ref-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: messageDestinationRefName
final String messageDestinationRefNameRaw = elementReader.getElementAsString();
final String messageDestinationRefName;
try {
messageDestinationRefName = Adapters.collapsedStringAdapterAdapter.unmarshal(messageDestinationRefNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
messageDestinationRef.messageDestinationRefName = messageDestinationRefName;
} else if (("message-destination-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: messageDestinationType
final String messageDestinationTypeRaw = elementReader.getElementAsString();
final String messageDestinationType;
try {
messageDestinationType = Adapters.collapsedStringAdapterAdapter.unmarshal(messageDestinationTypeRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
messageDestinationRef.messageDestinationType = messageDestinationType;
} else if (("message-destination-usage" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: messageDestinationUsage
final MessageDestinationUsage messageDestinationUsage = parseMessageDestinationUsage(elementReader, context, elementReader.getElementAsString());
if (messageDestinationUsage != null) {
messageDestinationRef.messageDestinationUsage = messageDestinationUsage;
}
} else if (("message-destination-link" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: messageDestinationLink
final String messageDestinationLinkRaw = elementReader.getElementAsString();
final String messageDestinationLink;
try {
messageDestinationLink = Adapters.collapsedStringAdapterAdapter.unmarshal(messageDestinationLinkRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
messageDestinationRef.messageDestinationLink = messageDestinationLink;
} else if (("mapped-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: mappedName
final String mappedNameRaw = elementReader.getElementAsString();
final String mappedName;
try {
mappedName = Adapters.collapsedStringAdapterAdapter.unmarshal(mappedNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
messageDestinationRef.mappedName = mappedName;
} else if (("injection-target" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: injectionTarget
final InjectionTarget injectionTargetItem = readInjectionTarget(elementReader, context);
if (injectionTarget == null) {
injectionTarget = messageDestinationRef.injectionTarget;
if (injectionTarget != null) {
injectionTarget.clear();
} else {
injectionTarget = new LinkedHashSet<InjectionTarget>();
}
}
injectionTarget.add(injectionTargetItem);
} else if (("lookup-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: lookupName
final String lookupNameRaw = elementReader.getElementAsString();
final String lookupName;
try {
lookupName = Adapters.collapsedStringAdapterAdapter.unmarshal(lookupNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
messageDestinationRef.lookupName = lookupName;
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "message-destination-ref-name"), new QName("http://java.sun.com/xml/ns/javaee", "message-destination-type"), new QName("http://java.sun.com/xml/ns/javaee", "message-destination-usage"), new QName("http://java.sun.com/xml/ns/javaee", "message-destination-link"), new QName("http://java.sun.com/xml/ns/javaee", "mapped-name"), new QName("http://java.sun.com/xml/ns/javaee", "injection-target"), new QName("http://java.sun.com/xml/ns/javaee", "lookup-name"));
}
}
if (descriptions != null) {
try {
messageDestinationRef.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, MessageDestinationRef.class, "setDescriptions", Text[].class, e);
}
}
if (injectionTarget != null) {
messageDestinationRef.injectionTarget = injectionTarget;
}
context.afterUnmarshal(messageDestinationRef, LifecycleCallback.NONE);
return messageDestinationRef;
}
use of org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget in project tomee by apache.
the class PersistenceContextRef$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final PersistenceContextRef persistenceContextRef, RuntimeContext context) throws Exception {
if (persistenceContextRef == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (PersistenceContextRef.class != persistenceContextRef.getClass()) {
context.unexpectedSubclass(writer, persistenceContextRef, PersistenceContextRef.class);
return;
}
context.beforeMarshal(persistenceContextRef, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = persistenceContextRef.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(persistenceContextRef, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: descriptions
Text[] descriptions = null;
try {
descriptions = persistenceContextRef.getDescriptions();
} catch (final Exception e) {
context.getterError(persistenceContextRef, "descriptions", PersistenceContextRef.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(persistenceContextRef, "descriptions");
}
}
}
// ELEMENT: persistenceContextRefName
final String persistenceContextRefNameRaw = persistenceContextRef.persistenceContextRefName;
String persistenceContextRefName = null;
try {
persistenceContextRefName = Adapters.collapsedStringAdapterAdapter.marshal(persistenceContextRefNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(persistenceContextRef, "persistenceContextRefName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (persistenceContextRefName != null) {
writer.writeStartElement(prefix, "persistence-context-ref-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(persistenceContextRefName);
writer.writeEndElement();
} else {
context.unexpectedNullValue(persistenceContextRef, "persistenceContextRefName");
}
// ELEMENT: persistenceUnitName
final String persistenceUnitNameRaw = persistenceContextRef.persistenceUnitName;
String persistenceUnitName = null;
try {
persistenceUnitName = Adapters.collapsedStringAdapterAdapter.marshal(persistenceUnitNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(persistenceContextRef, "persistenceUnitName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (persistenceUnitName != null) {
writer.writeStartElement(prefix, "persistence-unit-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(persistenceUnitName);
writer.writeEndElement();
}
// ELEMENT: persistenceContextType
final PersistenceContextType persistenceContextType = persistenceContextRef.persistenceContextType;
if (persistenceContextType != null) {
writer.writeStartElement(prefix, "persistence-context-type", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(toStringPersistenceContextType(persistenceContextRef, null, context, persistenceContextType));
writer.writeEndElement();
}
// ELEMENT: persistenceProperty
final List<Property> persistenceProperty = persistenceContextRef.persistenceProperty;
if (persistenceProperty != null) {
for (final Property persistencePropertyItem : persistenceProperty) {
if (persistencePropertyItem != null) {
writer.writeStartElement(prefix, "persistence-property", "http://java.sun.com/xml/ns/javaee");
writeProperty(writer, persistencePropertyItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(persistenceContextRef, "persistenceProperty");
}
}
}
// ELEMENT: mappedName
final String mappedNameRaw = persistenceContextRef.mappedName;
String mappedName = null;
try {
mappedName = Adapters.collapsedStringAdapterAdapter.marshal(mappedNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(persistenceContextRef, "mappedName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (mappedName != null) {
writer.writeStartElement(prefix, "mapped-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(mappedName);
writer.writeEndElement();
}
// ELEMENT: injectionTarget
final Set<InjectionTarget> injectionTarget = persistenceContextRef.injectionTarget;
if (injectionTarget != null) {
for (final InjectionTarget injectionTargetItem : injectionTarget) {
if (injectionTargetItem != null) {
writer.writeStartElement(prefix, "injection-target", "http://java.sun.com/xml/ns/javaee");
writeInjectionTarget(writer, injectionTargetItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(persistenceContextRef, "injectionTarget");
}
}
}
// ELEMENT: lookupName
final String lookupNameRaw = persistenceContextRef.lookupName;
String lookupName = null;
try {
lookupName = Adapters.collapsedStringAdapterAdapter.marshal(lookupNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(persistenceContextRef, "lookupName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (lookupName != null) {
writer.writeStartElement(prefix, "lookup-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(lookupName);
writer.writeEndElement();
}
context.afterMarshal(persistenceContextRef, LifecycleCallback.NONE);
}
use of org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget in project tomee by apache.
the class PersistenceUnitRef$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final PersistenceUnitRef persistenceUnitRef, RuntimeContext context) throws Exception {
if (persistenceUnitRef == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (PersistenceUnitRef.class != persistenceUnitRef.getClass()) {
context.unexpectedSubclass(writer, persistenceUnitRef, PersistenceUnitRef.class);
return;
}
context.beforeMarshal(persistenceUnitRef, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = persistenceUnitRef.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(persistenceUnitRef, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: descriptions
Text[] descriptions = null;
try {
descriptions = persistenceUnitRef.getDescriptions();
} catch (final Exception e) {
context.getterError(persistenceUnitRef, "descriptions", PersistenceUnitRef.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(persistenceUnitRef, "descriptions");
}
}
}
// ELEMENT: persistenceUnitRefName
final String persistenceUnitRefNameRaw = persistenceUnitRef.persistenceUnitRefName;
String persistenceUnitRefName = null;
try {
persistenceUnitRefName = Adapters.collapsedStringAdapterAdapter.marshal(persistenceUnitRefNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(persistenceUnitRef, "persistenceUnitRefName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (persistenceUnitRefName != null) {
writer.writeStartElement(prefix, "persistence-unit-ref-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(persistenceUnitRefName);
writer.writeEndElement();
} else {
context.unexpectedNullValue(persistenceUnitRef, "persistenceUnitRefName");
}
// ELEMENT: persistenceUnitName
final String persistenceUnitNameRaw = persistenceUnitRef.persistenceUnitName;
String persistenceUnitName = null;
try {
persistenceUnitName = Adapters.collapsedStringAdapterAdapter.marshal(persistenceUnitNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(persistenceUnitRef, "persistenceUnitName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (persistenceUnitName != null) {
writer.writeStartElement(prefix, "persistence-unit-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(persistenceUnitName);
writer.writeEndElement();
}
// ELEMENT: mappedName
final String mappedNameRaw = persistenceUnitRef.mappedName;
String mappedName = null;
try {
mappedName = Adapters.collapsedStringAdapterAdapter.marshal(mappedNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(persistenceUnitRef, "mappedName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (mappedName != null) {
writer.writeStartElement(prefix, "mapped-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(mappedName);
writer.writeEndElement();
}
// ELEMENT: injectionTarget
final Set<InjectionTarget> injectionTarget = persistenceUnitRef.injectionTarget;
if (injectionTarget != null) {
for (final InjectionTarget injectionTargetItem : injectionTarget) {
if (injectionTargetItem != null) {
writer.writeStartElement(prefix, "injection-target", "http://java.sun.com/xml/ns/javaee");
writeInjectionTarget(writer, injectionTargetItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(persistenceUnitRef, "injectionTarget");
}
}
}
// ELEMENT: lookupName
final String lookupNameRaw = persistenceUnitRef.lookupName;
String lookupName = null;
try {
lookupName = Adapters.collapsedStringAdapterAdapter.marshal(lookupNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(persistenceUnitRef, "lookupName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (lookupName != null) {
writer.writeStartElement(prefix, "lookup-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(lookupName);
writer.writeEndElement();
}
context.afterMarshal(persistenceUnitRef, LifecycleCallback.NONE);
}
Aggregations