use of org.apache.openejb.jee.NamedMethod$JAXB.writeNamedMethod in project tomee by apache.
the class MessageDrivenBean$JAXB method _read.
public static final MessageDrivenBean _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final MessageDrivenBean messageDrivenBean = new MessageDrivenBean();
context.beforeUnmarshal(messageDrivenBean, org.metatype.sxc.jaxb.LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
ArrayList<Text> displayNames = null;
LocalCollection<Icon> icon = null;
List<Timer> timer = 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<SecurityRoleRef> securityRoleRef = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("message-driven-beanType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, MessageDrivenBean.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, messageDrivenBean);
messageDrivenBean.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 = messageDrivenBean.icon;
if (icon != null) {
icon.clear();
} else {
icon = new LocalCollection<Icon>();
}
}
icon.add(iconItem);
} 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;
}
messageDrivenBean.ejbName = ejbName;
} 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;
}
messageDrivenBean.mappedName = mappedName;
} else if (("ejb-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbClass
final String ejbClassRaw = elementReader.getElementAsString();
final String ejbClass;
try {
ejbClass = Adapters.collapsedStringAdapterAdapter.unmarshal(ejbClassRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
messageDrivenBean.ejbClass = ejbClass;
} else if (("messaging-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: messagingType
final String messagingTypeRaw = elementReader.getElementAsString();
final String messagingType;
try {
messagingType = Adapters.collapsedStringAdapterAdapter.unmarshal(messagingTypeRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
messageDrivenBean.messagingType = messagingType;
} else if (("timeout-method" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: timeoutMethod
final NamedMethod timeoutMethod = readNamedMethod(elementReader, context);
messageDrivenBean.timeoutMethod = timeoutMethod;
} else if (("timer" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: timer
final Timer timerItem = readTimer(elementReader, context);
if (timer == null) {
timer = messageDrivenBean.timer;
if (timer != null) {
timer.clear();
} else {
timer = new ArrayList<Timer>();
}
}
timer.add(timerItem);
} else if (("transaction-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: transactionType
final TransactionType transactionType = parseTransactionType(elementReader, context, elementReader.getElementAsString());
if (transactionType != null) {
messageDrivenBean.transactionType = transactionType;
}
} else if (("message-selector" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: messageSelector
final String messageSelectorRaw = elementReader.getElementAsString();
final String messageSelector;
try {
messageSelector = Adapters.collapsedStringAdapterAdapter.unmarshal(messageSelectorRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
try {
messageDrivenBean.setMessageSelector(messageSelector);
} catch (final Exception e) {
context.setterError(reader, MessageDrivenBean.class, "setMessageSelector", String.class, e);
}
} else if (("acknowledge-mode" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: acknowledgeMode
final String acknowledgeModeRaw = elementReader.getElementAsString();
final String acknowledgeMode;
try {
acknowledgeMode = Adapters.collapsedStringAdapterAdapter.unmarshal(acknowledgeModeRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
try {
messageDrivenBean.setAcknowledgeMode(acknowledgeMode);
} catch (final Exception e) {
context.setterError(reader, MessageDrivenBean.class, "setAcknowledgeMode", String.class, e);
}
} else if (("message-driven-destination" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: messageDrivenDestination
final MessageDrivenDestination messageDrivenDestination = readMessageDrivenDestination(elementReader, context);
try {
messageDrivenBean.setMessageDrivenDestination(messageDrivenDestination);
} catch (final Exception e) {
context.setterError(reader, MessageDrivenBean.class, "setMessageDrivenDestination", MessageDrivenDestination.class, e);
}
} 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;
}
messageDrivenBean.messageDestinationType = messageDestinationType;
} 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;
}
messageDrivenBean.messageDestinationLink = messageDestinationLink;
} else if (("activation-config" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: activationConfig
final ActivationConfig activationConfig = readActivationConfig(elementReader, context);
messageDrivenBean.activationConfig = activationConfig;
} 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 = messageDrivenBean.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 = messageDrivenBean.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 = messageDrivenBean.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 = messageDrivenBean.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 = messageDrivenBean.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 = messageDrivenBean.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 = messageDrivenBean.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 = messageDrivenBean.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 = messageDrivenBean.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 = messageDrivenBean.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 = messageDrivenBean.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 = messageDrivenBean.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 = messageDrivenBean.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 = messageDrivenBean.dataSource;
if (dataSource != null) {
dataSource.clear();
} else {
dataSource = new KeyedCollection<String, DataSource>();
}
}
dataSource.add(dataSourceItem);
} 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 = messageDrivenBean.securityRoleRef;
if (securityRoleRef != null) {
securityRoleRef.clear();
} else {
securityRoleRef = new ArrayList<SecurityRoleRef>();
}
}
securityRoleRef.add(securityRoleRefItem);
} else if (("security-identity" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: securityIdentity
final SecurityIdentity securityIdentity = readSecurityIdentity(elementReader, context);
messageDrivenBean.securityIdentity = securityIdentity;
} 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", "ejb-name"), new QName("http://java.sun.com/xml/ns/javaee", "mapped-name"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-class"), new QName("http://java.sun.com/xml/ns/javaee", "messaging-type"), new QName("http://java.sun.com/xml/ns/javaee", "timeout-method"), new QName("http://java.sun.com/xml/ns/javaee", "timer"), new QName("http://java.sun.com/xml/ns/javaee", "transaction-type"), new QName("http://java.sun.com/xml/ns/javaee", "message-selector"), new QName("http://java.sun.com/xml/ns/javaee", "acknowledge-mode"), new QName("http://java.sun.com/xml/ns/javaee", "message-driven-destination"), new QName("http://java.sun.com/xml/ns/javaee", "message-destination-type"), new QName("http://java.sun.com/xml/ns/javaee", "message-destination-link"), new QName("http://java.sun.com/xml/ns/javaee", "activation-config"), 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", "security-role-ref"), new QName("http://java.sun.com/xml/ns/javaee", "security-identity"));
}
}
if (descriptions != null) {
try {
messageDrivenBean.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, MessageDrivenBean.class, "setDescriptions", Text[].class, e);
}
}
if (displayNames != null) {
try {
messageDrivenBean.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
} catch (final Exception e) {
context.setterError(reader, MessageDrivenBean.class, "setDisplayNames", Text[].class, e);
}
}
if (icon != null) {
messageDrivenBean.icon = icon;
}
if (timer != null) {
messageDrivenBean.timer = timer;
}
if (aroundInvoke != null) {
messageDrivenBean.aroundInvoke = aroundInvoke;
}
if (aroundTimeout != null) {
messageDrivenBean.aroundTimeout = aroundTimeout;
}
if (envEntry != null) {
messageDrivenBean.envEntry = envEntry;
}
if (ejbRef != null) {
messageDrivenBean.ejbRef = ejbRef;
}
if (ejbLocalRef != null) {
messageDrivenBean.ejbLocalRef = ejbLocalRef;
}
if (serviceRef != null) {
messageDrivenBean.serviceRef = serviceRef;
}
if (resourceRef != null) {
messageDrivenBean.resourceRef = resourceRef;
}
if (resourceEnvRef != null) {
messageDrivenBean.resourceEnvRef = resourceEnvRef;
}
if (messageDestinationRef != null) {
messageDrivenBean.messageDestinationRef = messageDestinationRef;
}
if (persistenceContextRef != null) {
messageDrivenBean.persistenceContextRef = persistenceContextRef;
}
if (persistenceUnitRef != null) {
messageDrivenBean.persistenceUnitRef = persistenceUnitRef;
}
if (postConstruct != null) {
messageDrivenBean.postConstruct = postConstruct;
}
if (preDestroy != null) {
messageDrivenBean.preDestroy = preDestroy;
}
if (dataSource != null) {
messageDrivenBean.dataSource = dataSource;
}
if (securityRoleRef != null) {
messageDrivenBean.securityRoleRef = securityRoleRef;
}
context.afterUnmarshal(messageDrivenBean, org.metatype.sxc.jaxb.LifecycleCallback.NONE);
return messageDrivenBean;
}
use of org.apache.openejb.jee.NamedMethod$JAXB.writeNamedMethod in project tomee by apache.
the class InitMethod$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final InitMethod initMethod, RuntimeContext context) throws Exception {
if (initMethod == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (InitMethod.class != initMethod.getClass()) {
context.unexpectedSubclass(writer, initMethod, InitMethod.class);
return;
}
context.beforeMarshal(initMethod, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = initMethod.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(initMethod, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: createMethod
final NamedMethod createMethod = initMethod.createMethod;
if (createMethod != null) {
writer.writeStartElement(prefix, "create-method", "http://java.sun.com/xml/ns/javaee");
writeNamedMethod(writer, createMethod, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(initMethod, "createMethod");
}
// ELEMENT: beanMethod
final NamedMethod beanMethod = initMethod.beanMethod;
if (beanMethod != null) {
writer.writeStartElement(prefix, "bean-method", "http://java.sun.com/xml/ns/javaee");
writeNamedMethod(writer, beanMethod, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(initMethod, "beanMethod");
}
context.afterMarshal(initMethod, LifecycleCallback.NONE);
}
use of org.apache.openejb.jee.NamedMethod$JAXB.writeNamedMethod in project tomee by apache.
the class EjbJarInfoBuilder method copySchedules.
private void copySchedules(final List<Timer> timers, final List<MethodScheduleInfo> scheduleInfos) {
final Map<NamedMethod, MethodScheduleInfo> methodScheduleInfoMap = new HashMap<>();
for (final Timer timer : timers) {
final NamedMethod timeoutMethod = timer.getTimeoutMethod();
MethodScheduleInfo methodScheduleInfo = methodScheduleInfoMap.get(timer.getTimeoutMethod());
if (methodScheduleInfo == null) {
methodScheduleInfo = new MethodScheduleInfo();
methodScheduleInfoMap.put(timeoutMethod, methodScheduleInfo);
methodScheduleInfo.method = toInfo(timeoutMethod);
}
final ScheduleInfo scheduleInfo = new ScheduleInfo();
//Copy TimerSchedule
final TimerSchedule timerSchedule = timer.getSchedule();
if (timerSchedule != null) {
scheduleInfo.second = timerSchedule.getSecond();
scheduleInfo.minute = timerSchedule.getMinute();
scheduleInfo.hour = timerSchedule.getHour();
scheduleInfo.dayOfWeek = timerSchedule.getDayOfWeek();
scheduleInfo.dayOfMonth = timerSchedule.getDayOfMonth();
scheduleInfo.month = timerSchedule.getMonth();
scheduleInfo.year = timerSchedule.getYear();
}
//Copy other attributes
scheduleInfo.timezone = timer.getTimezone();
if (timer.getStart() != null) {
scheduleInfo.start = timer.getStart().toGregorianCalendar().getTime();
}
if (timer.getEnd() != null) {
scheduleInfo.end = timer.getEnd().toGregorianCalendar().getTime();
}
scheduleInfo.info = timer.getInfo();
if (timer.getPersistent() != null) {
scheduleInfo.persistent = timer.getPersistent();
}
methodScheduleInfo.schedules.add(scheduleInfo);
}
scheduleInfos.addAll(methodScheduleInfoMap.values());
}
use of org.apache.openejb.jee.NamedMethod$JAXB.writeNamedMethod in project tomee by apache.
the class StatefulInterceptorTest method buildTestApp.
public EjbModule buildTestApp() {
final EjbJar ejbJar = new EjbJar();
final AssemblyDescriptor ad = ejbJar.getAssemblyDescriptor();
final EnterpriseBean bean = ejbJar.addEnterpriseBean(new StatefulBean(TargetBean.class));
Interceptor interceptor;
interceptor = ejbJar.addInterceptor(new Interceptor(ClassInterceptor.class));
ad.addInterceptorBinding(new InterceptorBinding(bean, interceptor));
interceptor = ejbJar.addInterceptor(new Interceptor(DefaultInterceptor.class));
ad.addInterceptorBinding(new InterceptorBinding("*", interceptor));
interceptor = ejbJar.addInterceptor(new Interceptor(EchoMethodInterceptor.class));
final InterceptorBinding binding = ad.addInterceptorBinding(new InterceptorBinding(bean, interceptor));
binding.setMethod(new NamedMethod("echo"));
return new EjbModule(this.getClass().getClassLoader(), this.getClass().getSimpleName(), "test", ejbJar, null);
}
use of org.apache.openejb.jee.NamedMethod$JAXB.writeNamedMethod in project tomee by apache.
the class StatefulSessionSynchronizationTest method test.
public void test() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
final Assembler assembler = new Assembler();
final ConfigurationFactory config = new ConfigurationFactory();
assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
final EjbJar ejbJar = new EjbJar();
final AssemblyDescriptor assemblyDescriptor = ejbJar.getAssemblyDescriptor();
final Interceptor interceptor = new Interceptor(SimpleInterceptor.class);
ejbJar.addInterceptor(interceptor);
//Test SessionSynchronization interface
final StatefulBean subBeanA = new StatefulBean(SubBeanA.class);
ejbJar.addEnterpriseBean(subBeanA);
assemblyDescriptor.addInterceptorBinding(new InterceptorBinding(subBeanA, interceptor));
//Test configure session synchronization callback methods in deployment plan
final StatefulBean subBeanB = new StatefulBean(SubBeanB.class);
subBeanB.setAfterBeginMethod(new NamedMethod(SubBeanB.class.getDeclaredMethod("afterBegin")));
subBeanB.setBeforeCompletionMethod(new NamedMethod(SubBeanB.class.getDeclaredMethod("beforeCompletion")));
subBeanB.setAfterCompletionMethod(new NamedMethod(SubBeanB.class.getDeclaredMethod("afterCompletion", boolean.class)));
ejbJar.addEnterpriseBean(subBeanB);
assemblyDescriptor.addInterceptorBinding(new InterceptorBinding(subBeanB, interceptor));
//Test session synchronization methods via annotations
final StatefulBean subBeanC = new StatefulBean(SubBeanC.class);
ejbJar.addEnterpriseBean(subBeanC);
assemblyDescriptor.addInterceptorBinding(new InterceptorBinding(subBeanC, interceptor));
//Test override the annotations by deployment plan
final StatefulBean subBeanD = new StatefulBean(SubBeanD.class);
subBeanD.setAfterBeginMethod(new NamedMethod(SubBeanD.class.getDeclaredMethod("afterBeginNew")));
subBeanD.setBeforeCompletionMethod(new NamedMethod(SubBeanD.class.getDeclaredMethod("beforeCompletionNew")));
subBeanD.setAfterCompletionMethod(new NamedMethod(SubBeanD.class.getDeclaredMethod("afterCompletionNew", boolean.class)));
ejbJar.addEnterpriseBean(subBeanD);
assemblyDescriptor.addInterceptorBinding(new InterceptorBinding(subBeanD, interceptor));
//Test only one session synchronization method @AfterBegin
final StatefulBean subBeanE = new StatefulBean(SubBeanE.class);
ejbJar.addEnterpriseBean(subBeanE);
assemblyDescriptor.addInterceptorBinding(new InterceptorBinding(subBeanE, interceptor));
//Test only one session synchronization method @AfterCompletion
final StatefulBean subBeanF = new StatefulBean(SubBeanF.class);
ejbJar.addEnterpriseBean(subBeanF);
assemblyDescriptor.addInterceptorBinding(new InterceptorBinding(subBeanF, interceptor));
//Test only one session synchronization method @BeforeCompletion
final StatefulBean subBeanG = new StatefulBean(SubBeanG.class);
ejbJar.addEnterpriseBean(subBeanG);
assemblyDescriptor.addInterceptorBinding(new InterceptorBinding(subBeanG, interceptor));
//Test SessionSynchronization interface but methods are in the parent class
//Interceptor is declared on the bean method
final StatefulBean subBeanH = new StatefulBean(SubBeanH.class);
ejbJar.addEnterpriseBean(subBeanH);
//Test SessionSynchronization interface but methods are in the parent class
//using @LocalBean
final StatefulBean subBeanI = new StatefulBean(SubBeanI.class);
ejbJar.addEnterpriseBean(subBeanI);
final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
assembler.createApplication(ejbJarInfo);
final InitialContext context = new InitialContext();
final List<Call> expectedResult = Arrays.asList(Call.INTERCEPTOR_AFTER_BEGIN, Call.BEAN_AFTER_BEGIN, Call.INTERCEPTOR_AROUND_INVOKE_BEGIN, Call.BEAN_AROUND_INVOKE_BEGIN, Call.BEAN_METHOD, Call.BEAN_AROUND_INVOKE_AFTER, Call.INTERCEPTOR_AROUND_INVOKE_AFTER, Call.INTERCEPTOR_BEFORE_COMPLETION, Call.BEAN_BEFORE_COMPLETION, Call.INTERCEPTOR_AFTER_COMPLETION, Call.BEAN_AFTER_COMPLETION);
{
final BeanInterface beanA = (BeanInterface) context.lookup("SubBeanALocal");
beanA.simpleMethod();
assertEquals(expectedResult, result);
result.clear();
}
{
final BeanInterface beanB = (BeanInterface) context.lookup("SubBeanBLocal");
beanB.simpleMethod();
assertEquals(expectedResult, result);
result.clear();
}
{
final BeanInterface beanC = (BeanInterface) context.lookup("SubBeanCLocal");
beanC.simpleMethod();
assertEquals(expectedResult, result);
result.clear();
}
{
final BeanInterface beanD = (BeanInterface) context.lookup("SubBeanDLocal");
beanD.simpleMethod();
assertEquals(expectedResult, result);
result.clear();
}
{
final BeanInterface beanE = (BeanInterface) context.lookup("SubBeanELocal");
beanE.simpleMethod();
assertEquals(Arrays.asList(Call.INTERCEPTOR_AFTER_BEGIN, Call.BEAN_AFTER_BEGIN, Call.INTERCEPTOR_AROUND_INVOKE_BEGIN, Call.BEAN_AROUND_INVOKE_BEGIN, Call.BEAN_METHOD, Call.BEAN_AROUND_INVOKE_AFTER, Call.INTERCEPTOR_AROUND_INVOKE_AFTER, Call.INTERCEPTOR_BEFORE_COMPLETION, Call.INTERCEPTOR_AFTER_COMPLETION), result);
result.clear();
}
{
final BeanInterface beanF = (BeanInterface) context.lookup("SubBeanFLocal");
beanF.simpleMethod();
assertEquals(Arrays.asList(Call.INTERCEPTOR_AFTER_BEGIN, Call.INTERCEPTOR_AROUND_INVOKE_BEGIN, Call.BEAN_AROUND_INVOKE_BEGIN, Call.BEAN_METHOD, Call.BEAN_AROUND_INVOKE_AFTER, Call.INTERCEPTOR_AROUND_INVOKE_AFTER, Call.INTERCEPTOR_BEFORE_COMPLETION, Call.INTERCEPTOR_AFTER_COMPLETION, Call.BEAN_AFTER_COMPLETION), result);
result.clear();
}
{
final BeanInterface beanG = (BeanInterface) context.lookup("SubBeanGLocal");
beanG.simpleMethod();
assertEquals(Arrays.asList(Call.INTERCEPTOR_AFTER_BEGIN, Call.INTERCEPTOR_AROUND_INVOKE_BEGIN, Call.BEAN_AROUND_INVOKE_BEGIN, Call.BEAN_METHOD, Call.BEAN_AROUND_INVOKE_AFTER, Call.INTERCEPTOR_AROUND_INVOKE_AFTER, Call.INTERCEPTOR_BEFORE_COMPLETION, Call.BEAN_BEFORE_COMPLETION, Call.INTERCEPTOR_AFTER_COMPLETION), result);
result.clear();
}
final List<Call> synchAndArroundInvokeResult = Arrays.asList(Call.BEAN_AFTER_BEGIN, Call.INTERCEPTOR_AROUND_INVOKE_BEGIN, Call.BEAN_AROUND_INVOKE_BEGIN, Call.BEAN_METHOD, Call.BEAN_AROUND_INVOKE_AFTER, Call.INTERCEPTOR_AROUND_INVOKE_AFTER, Call.BEAN_BEFORE_COMPLETION, Call.BEAN_AFTER_COMPLETION);
{
final BeanInterface beanH = (BeanInterface) context.lookup("SubBeanHLocal");
beanH.simpleMethod();
assertEquals(synchAndArroundInvokeResult, result);
result.clear();
}
{
final BeanInterface beanI = (BeanInterface) context.lookup("SubBeanILocalBean");
beanI.simpleMethod();
assertEquals(synchAndArroundInvokeResult, result);
result.clear();
}
}
Aggregations