use of org.apache.openejb.jee.MessageDestination in project tomee by apache.
the class AssemblyDescriptor$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final AssemblyDescriptor assemblyDescriptor, RuntimeContext context) throws Exception {
if (assemblyDescriptor == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (AssemblyDescriptor.class != assemblyDescriptor.getClass()) {
context.unexpectedSubclass(writer, assemblyDescriptor, AssemblyDescriptor.class);
return;
}
context.beforeMarshal(assemblyDescriptor, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = assemblyDescriptor.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(assemblyDescriptor, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: securityRole
final List<SecurityRole> securityRole = assemblyDescriptor.securityRole;
if (securityRole != null) {
for (final SecurityRole securityRoleItem : securityRole) {
if (securityRoleItem != null) {
writer.writeStartElement(prefix, "security-role", "http://java.sun.com/xml/ns/javaee");
writeSecurityRole(writer, securityRoleItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(assemblyDescriptor, "securityRole");
}
}
}
// ELEMENT: methodPermission
final List<MethodPermission> methodPermission = assemblyDescriptor.methodPermission;
if (methodPermission != null) {
for (final MethodPermission methodPermissionItem : methodPermission) {
if (methodPermissionItem != null) {
writer.writeStartElement(prefix, "method-permission", "http://java.sun.com/xml/ns/javaee");
writeMethodPermission(writer, methodPermissionItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(assemblyDescriptor, "methodPermission");
}
}
}
// ELEMENT: containerTransaction
final List<ContainerTransaction> containerTransaction = assemblyDescriptor.containerTransaction;
if (containerTransaction != null) {
for (final ContainerTransaction containerTransactionItem : containerTransaction) {
if (containerTransactionItem != null) {
writer.writeStartElement(prefix, "container-transaction", "http://java.sun.com/xml/ns/javaee");
writeContainerTransaction(writer, containerTransactionItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(assemblyDescriptor, "containerTransaction");
}
}
}
// ELEMENT: containerConcurrency
final List<ContainerConcurrency> containerConcurrency = assemblyDescriptor.containerConcurrency;
if (containerConcurrency != null) {
for (final ContainerConcurrency containerConcurrencyItem : containerConcurrency) {
if (containerConcurrencyItem != null) {
writer.writeStartElement(prefix, "container-concurrency", "http://java.sun.com/xml/ns/javaee");
writeContainerConcurrency(writer, containerConcurrencyItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(assemblyDescriptor, "containerConcurrency");
}
}
}
// ELEMENT: interceptorBinding
final List<InterceptorBinding> interceptorBinding = assemblyDescriptor.interceptorBinding;
if (interceptorBinding != null) {
for (final InterceptorBinding interceptorBindingItem : interceptorBinding) {
if (interceptorBindingItem != null) {
writer.writeStartElement(prefix, "interceptor-binding", "http://java.sun.com/xml/ns/javaee");
writeInterceptorBinding(writer, interceptorBindingItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(assemblyDescriptor, "interceptorBinding");
}
}
}
// ELEMENT: messageDestination
final List<MessageDestination> messageDestination = assemblyDescriptor.messageDestination;
if (messageDestination != null) {
for (final MessageDestination messageDestinationItem : messageDestination) {
if (messageDestinationItem != null) {
writer.writeStartElement(prefix, "message-destination", "http://java.sun.com/xml/ns/javaee");
writeMessageDestination(writer, messageDestinationItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(assemblyDescriptor, "messageDestination");
}
}
}
// ELEMENT: excludeList
final ExcludeList excludeList = assemblyDescriptor.excludeList;
if (excludeList != null) {
writer.writeStartElement(prefix, "exclude-list", "http://java.sun.com/xml/ns/javaee");
writeExcludeList(writer, excludeList, context);
writer.writeEndElement();
}
// ELEMENT: applicationException
final KeyedCollection<String, ApplicationException> applicationException = assemblyDescriptor.applicationException;
if (applicationException != null) {
for (final ApplicationException applicationExceptionItem : applicationException) {
if (applicationExceptionItem != null) {
writer.writeStartElement(prefix, "application-exception", "http://java.sun.com/xml/ns/javaee");
writeApplicationException(writer, applicationExceptionItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(assemblyDescriptor, "applicationException");
}
}
}
context.afterMarshal(assemblyDescriptor, LifecycleCallback.NONE);
}
use of org.apache.openejb.jee.MessageDestination in project tomee by apache.
the class MessageDestinationTest method test.
public void test() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
final ClassLoader cl = this.getClass().getClassLoader();
final AppModule app = new AppModule(cl, "app");
final MessageDestinationRef webMessageDestRef = new MessageDestinationRef();
webMessageDestRef.setMessageDestinationRefName("jms/myqueue");
webMessageDestRef.setMessageDestinationType("javax.jms.Queue");
webMessageDestRef.setMessageDestinationUsage(MessageDestinationUsage.PRODUCES);
webMessageDestRef.setMessageDestinationLink("ejb.jar#myqueue");
final WebApp webApp = new WebApp();
webApp.setMetadataComplete(true);
webApp.getMessageDestinationRef().add(webMessageDestRef);
final WebModule webModule = new WebModule(webApp, "web", cl, "war", "web");
app.getWebModules().add(webModule);
final EjbJar ejbJar = new EjbJar();
final StatelessBean statelessBean = new StatelessBean(GreenBean.class);
final MessageDestinationRef ejbMessageDestRef = new MessageDestinationRef();
ejbMessageDestRef.setMessageDestinationRefName("jms/myqueue");
ejbMessageDestRef.setMessageDestinationType("javax.jms.Queue");
ejbMessageDestRef.setMessageDestinationUsage(MessageDestinationUsage.PRODUCES);
ejbMessageDestRef.setMessageDestinationLink("myqueue");
statelessBean.getMessageDestinationRef().add(ejbMessageDestRef);
ejbJar.addEnterpriseBean(statelessBean);
final MessageDestination queue = new MessageDestination();
queue.setMessageDestinationName("myqueue");
ejbJar.getAssemblyDescriptor().getMessageDestination().add(queue);
final EjbModule ejbModule = new EjbModule(cl, "ejb.jar", ejbJar, new OpenejbJar());
app.getEjbModules().add(ejbModule);
final AppInfo info = config.configureApplication(app);
assembler.createApplication(info);
final Object beanQueue = assembler.getContainerSystem().getBeanContext("GreenBean").getJndiContext().lookup("comp/env/jms/myqueue");
Assert.assertTrue(beanQueue instanceof Queue);
Assert.assertEquals(1, info.webApps.size());
final List<ResourceEnvReferenceInfo> resourceEnvRefs = info.webApps.get(0).jndiEnc.resourceEnvRefs;
boolean found = false;
for (final ResourceEnvReferenceInfo resourceEnvRef : resourceEnvRefs) {
if (!"comp/env/jms/myqueue".equals(resourceEnvRef.referenceName))
continue;
found = true;
Assert.assertEquals("jms/myqueue", resourceEnvRef.resourceID);
Assert.assertEquals("javax.jms.Queue", resourceEnvRef.resourceEnvRefType);
}
Assert.assertTrue(found);
}
Aggregations