use of org.apache.openejb.jee.ContainerConcurrency$JAXB.readContainerConcurrency in project tomee by apache.
the class AssemblyDescriptor$JAXB method _read.
public static final AssemblyDescriptor _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final AssemblyDescriptor assemblyDescriptor = new AssemblyDescriptor();
context.beforeUnmarshal(assemblyDescriptor, LifecycleCallback.NONE);
List<SecurityRole> securityRole = null;
List<MethodPermission> methodPermission = null;
List<ContainerTransaction> containerTransaction = null;
List<ContainerConcurrency> containerConcurrency = null;
List<InterceptorBinding> interceptorBinding = null;
List<MessageDestination> messageDestination = null;
KeyedCollection<String, ApplicationException> applicationException = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("assembly-descriptorType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, AssemblyDescriptor.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, assemblyDescriptor);
assemblyDescriptor.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 (("security-role" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: securityRole
final SecurityRole securityRoleItem = readSecurityRole(elementReader, context);
if (securityRole == null) {
securityRole = assemblyDescriptor.securityRole;
if (securityRole != null) {
securityRole.clear();
} else {
securityRole = new ArrayList<SecurityRole>();
}
}
securityRole.add(securityRoleItem);
} else if (("method-permission" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: methodPermission
final MethodPermission methodPermissionItem = readMethodPermission(elementReader, context);
if (methodPermission == null) {
methodPermission = assemblyDescriptor.methodPermission;
if (methodPermission != null) {
methodPermission.clear();
} else {
methodPermission = new ArrayList<MethodPermission>();
}
}
methodPermission.add(methodPermissionItem);
} else if (("container-transaction" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: containerTransaction
final ContainerTransaction containerTransactionItem = readContainerTransaction(elementReader, context);
if (containerTransaction == null) {
containerTransaction = assemblyDescriptor.containerTransaction;
if (containerTransaction != null) {
containerTransaction.clear();
} else {
containerTransaction = new ArrayList<ContainerTransaction>();
}
}
containerTransaction.add(containerTransactionItem);
} else if (("container-concurrency" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: containerConcurrency
final ContainerConcurrency containerConcurrencyItem = readContainerConcurrency(elementReader, context);
if (containerConcurrency == null) {
containerConcurrency = assemblyDescriptor.containerConcurrency;
if (containerConcurrency != null) {
containerConcurrency.clear();
} else {
containerConcurrency = new ArrayList<ContainerConcurrency>();
}
}
containerConcurrency.add(containerConcurrencyItem);
} else if (("interceptor-binding" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: interceptorBinding
final InterceptorBinding interceptorBindingItem = readInterceptorBinding(elementReader, context);
if (interceptorBinding == null) {
interceptorBinding = assemblyDescriptor.interceptorBinding;
if (interceptorBinding != null) {
interceptorBinding.clear();
} else {
interceptorBinding = new ArrayList<InterceptorBinding>();
}
}
interceptorBinding.add(interceptorBindingItem);
} else if (("message-destination" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: messageDestination
final MessageDestination messageDestinationItem = readMessageDestination(elementReader, context);
if (messageDestination == null) {
messageDestination = assemblyDescriptor.messageDestination;
if (messageDestination != null) {
messageDestination.clear();
} else {
messageDestination = new ArrayList<MessageDestination>();
}
}
messageDestination.add(messageDestinationItem);
} else if (("exclude-list" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: excludeList
final ExcludeList excludeList = readExcludeList(elementReader, context);
assemblyDescriptor.excludeList = excludeList;
} else if (("application-exception" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: applicationException
final ApplicationException applicationExceptionItem = readApplicationException(elementReader, context);
if (applicationException == null) {
applicationException = assemblyDescriptor.applicationException;
if (applicationException != null) {
applicationException.clear();
} else {
applicationException = new KeyedCollection<String, ApplicationException>();
}
}
applicationException.add(applicationExceptionItem);
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "security-role"), new QName("http://java.sun.com/xml/ns/javaee", "method-permission"), new QName("http://java.sun.com/xml/ns/javaee", "container-transaction"), new QName("http://java.sun.com/xml/ns/javaee", "container-concurrency"), new QName("http://java.sun.com/xml/ns/javaee", "interceptor-binding"), new QName("http://java.sun.com/xml/ns/javaee", "message-destination"), new QName("http://java.sun.com/xml/ns/javaee", "exclude-list"), new QName("http://java.sun.com/xml/ns/javaee", "application-exception"));
}
}
if (securityRole != null) {
assemblyDescriptor.securityRole = securityRole;
}
if (methodPermission != null) {
assemblyDescriptor.methodPermission = methodPermission;
}
if (containerTransaction != null) {
assemblyDescriptor.containerTransaction = containerTransaction;
}
if (containerConcurrency != null) {
assemblyDescriptor.containerConcurrency = containerConcurrency;
}
if (interceptorBinding != null) {
assemblyDescriptor.interceptorBinding = interceptorBinding;
}
if (messageDestination != null) {
assemblyDescriptor.messageDestination = messageDestination;
}
if (applicationException != null) {
assemblyDescriptor.applicationException = applicationException;
}
context.afterUnmarshal(assemblyDescriptor, LifecycleCallback.NONE);
return assemblyDescriptor;
}
use of org.apache.openejb.jee.ContainerConcurrency$JAXB.readContainerConcurrency in project tomee by apache.
the class ConcurrentLockTypeTest method test.
public void test() throws Exception {
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();
ejbJar.addEnterpriseBean(new SingletonBean(Color.class));
ejbJar.addEnterpriseBean(new SingletonBean(Red.class));
ejbJar.addEnterpriseBean(new SingletonBean(Crimson.class));
ejbJar.addEnterpriseBean(new SingletonBean(Scarlet.class));
final List<ContainerConcurrency> declared = ejbJar.getAssemblyDescriptor().getContainerConcurrency();
declared.add(new ContainerConcurrency(ConcurrentLockType.WRITE, "*", "*", "*"));
declared.add(new ContainerConcurrency(ConcurrentLockType.READ, "*", "Crimson", "*"));
declared.add(new ContainerConcurrency(ConcurrentLockType.READ, Color.class.getName(), "Scarlet", "*"));
declared.add(new ContainerConcurrency(ConcurrentLockType.READ, Red.class.getName(), "Scarlet", "red"));
declared.add(new ContainerConcurrency(ConcurrentLockType.WRITE, "Scarlet", Scarlet.class.getMethod("scarlet")));
final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
assembler.createApplication(ejbJarInfo);
loadAttributes(ejbJarInfo, "Color");
assertAttribute("Read", Color.class.getMethod("color"));
assertAttribute("Write", Color.class.getMethod("color", Object.class));
assertAttribute("Write", Color.class.getMethod("color", String.class));
assertAttribute("Write", Color.class.getMethod("color", Boolean.class));
assertAttribute("Write", Color.class.getMethod("color", Integer.class));
loadAttributes(ejbJarInfo, "Red");
assertAttribute("Read", Red.class.getMethod("color"));
assertAttribute("Write", Red.class.getMethod("color", Object.class));
assertAttribute("Write", Red.class.getMethod("color", String.class));
assertAttribute("Write", Red.class.getMethod("color", Boolean.class));
assertAttribute("Write", Red.class.getMethod("color", Integer.class));
assertAttribute("Write", Red.class.getMethod("red"));
assertAttribute("Write", Red.class.getMethod("red", Object.class));
assertAttribute("Write", Red.class.getMethod("red", String.class));
loadAttributes(ejbJarInfo, "Crimson");
assertAttribute("Read", Crimson.class.getMethod("color"));
assertAttribute("Read", Crimson.class.getMethod("color", Object.class));
assertAttribute("Read", Crimson.class.getMethod("color", String.class));
assertAttribute("Read", Crimson.class.getMethod("color", Boolean.class));
assertAttribute("Read", Crimson.class.getMethod("color", Integer.class));
assertAttribute("Write", Crimson.class.getMethod("red"));
assertAttribute("Read", Crimson.class.getMethod("red", Object.class));
assertAttribute("Read", Crimson.class.getMethod("red", String.class));
assertAttribute("Write", Crimson.class.getMethod("crimson"));
assertAttribute("Read", Crimson.class.getMethod("crimson", String.class));
loadAttributes(ejbJarInfo, "Scarlet");
assertAttribute("Read", Scarlet.class.getMethod("color"));
assertAttribute("Write", Scarlet.class.getMethod("color", Object.class));
assertAttribute("Read", Scarlet.class.getMethod("color", String.class));
assertAttribute("Read", Scarlet.class.getMethod("color", Boolean.class));
assertAttribute("Read", Scarlet.class.getMethod("color", Integer.class));
assertAttribute("Write", Scarlet.class.getMethod("red"));
assertAttribute("Read", Scarlet.class.getMethod("red", Object.class));
assertAttribute("Read", Scarlet.class.getMethod("red", String.class));
assertAttribute("Write", Scarlet.class.getMethod("scarlet"));
assertAttribute("Read", Scarlet.class.getMethod("scarlet", String.class));
}
use of org.apache.openejb.jee.ContainerConcurrency$JAXB.readContainerConcurrency in project tomee by apache.
the class EjbJarInfoBuilder method initMethodConcurrency.
private void initMethodConcurrency(final EjbModule jar, final Map ejbds, final EjbJarInfo ejbJarInfo) {
final List<ContainerConcurrency> containerConcurrency = jar.getEjbJar().getAssemblyDescriptor().getContainerConcurrency();
for (final ContainerConcurrency att : containerConcurrency) {
final MethodConcurrencyInfo info = new MethodConcurrencyInfo();
info.description = att.getDescription();
if (att.getLock() != null) {
info.concurrencyAttribute = att.getLock().toString();
}
info.accessTimeout = toInfo(att.getAccessTimeout());
info.methods.addAll(getMethodInfos(att.getMethod(), ejbds));
ejbJarInfo.methodConcurrency.add(info);
}
}
use of org.apache.openejb.jee.ContainerConcurrency$JAXB.readContainerConcurrency 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);
}
Aggregations