Search in sources :

Example 1 with ContainerTransaction$JAXB.writeContainerTransaction

use of org.apache.openejb.jee.ContainerTransaction$JAXB.writeContainerTransaction 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;
}
Also used : SecurityRole$JAXB.readSecurityRole(org.apache.openejb.jee.SecurityRole$JAXB.readSecurityRole) SecurityRole$JAXB.writeSecurityRole(org.apache.openejb.jee.SecurityRole$JAXB.writeSecurityRole) Attribute(org.metatype.sxc.util.Attribute) ArrayList(java.util.ArrayList) MethodPermission$JAXB.readMethodPermission(org.apache.openejb.jee.MethodPermission$JAXB.readMethodPermission) MethodPermission$JAXB.writeMethodPermission(org.apache.openejb.jee.MethodPermission$JAXB.writeMethodPermission) InterceptorBinding$JAXB.writeInterceptorBinding(org.apache.openejb.jee.InterceptorBinding$JAXB.writeInterceptorBinding) InterceptorBinding$JAXB.readInterceptorBinding(org.apache.openejb.jee.InterceptorBinding$JAXB.readInterceptorBinding) ContainerConcurrency$JAXB.writeContainerConcurrency(org.apache.openejb.jee.ContainerConcurrency$JAXB.writeContainerConcurrency) ContainerConcurrency$JAXB.readContainerConcurrency(org.apache.openejb.jee.ContainerConcurrency$JAXB.readContainerConcurrency) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader) ExcludeList$JAXB.writeExcludeList(org.apache.openejb.jee.ExcludeList$JAXB.writeExcludeList) ExcludeList$JAXB.readExcludeList(org.apache.openejb.jee.ExcludeList$JAXB.readExcludeList) MessageDestination$JAXB.readMessageDestination(org.apache.openejb.jee.MessageDestination$JAXB.readMessageDestination) MessageDestination$JAXB.writeMessageDestination(org.apache.openejb.jee.MessageDestination$JAXB.writeMessageDestination) QName(javax.xml.namespace.QName) ApplicationException$JAXB.readApplicationException(org.apache.openejb.jee.ApplicationException$JAXB.readApplicationException) ApplicationException$JAXB.writeApplicationException(org.apache.openejb.jee.ApplicationException$JAXB.writeApplicationException) ContainerTransaction$JAXB.writeContainerTransaction(org.apache.openejb.jee.ContainerTransaction$JAXB.writeContainerTransaction) ContainerTransaction$JAXB.readContainerTransaction(org.apache.openejb.jee.ContainerTransaction$JAXB.readContainerTransaction) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext)

Example 2 with ContainerTransaction$JAXB.writeContainerTransaction

use of org.apache.openejb.jee.ContainerTransaction$JAXB.writeContainerTransaction in project tomee by apache.

the class DebuggableVmHackery method deploy.

public AppModule deploy(final AppModule appModule) throws OpenEJBException {
    for (final EjbModule ejbModule : appModule.getEjbModules()) {
        final EjbJar ejbJar = ejbModule.getEjbJar();
        final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
        final Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName();
        ejbJar.setRelationships(null);
        final List<String> removed = new ArrayList<String>();
        for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {
            final String ejbName = bean.getEjbName();
            final EjbDeployment ejbDeployment = deployments.get(ejbName);
            pruneRefs(bean, ejbDeployment);
            //                }
            if (!(bean instanceof MessageDrivenBean) && !(bean instanceof EntityBean)) {
                continue;
            }
            ejbJar.removeEnterpriseBean(ejbName);
            openejbJar.removeEjbDeployment(ejbDeployment);
            removed.add(ejbName);
            final AssemblyDescriptor assemblyDescriptor = ejbJar.getAssemblyDescriptor();
            if (assemblyDescriptor != null) {
                for (final MethodPermission permission : copy(assemblyDescriptor.getMethodPermission())) {
                    for (final Method method : copy(permission.getMethod())) {
                        if (method.getEjbName().equals(ejbName)) {
                            permission.getMethod().remove(method);
                        }
                    }
                    if (permission.getMethod().size() == 0) {
                        assemblyDescriptor.getMethodPermission().remove(permission);
                    }
                }
                for (final ContainerTransaction transaction : copy(assemblyDescriptor.getContainerTransaction())) {
                    for (final Method method : copy(transaction.getMethod())) {
                        if (method.getEjbName().equals(ejbName)) {
                            transaction.getMethod().remove(method);
                        }
                    }
                    if (transaction.getMethod().size() == 0) {
                        assemblyDescriptor.getContainerTransaction().remove(transaction);
                    }
                }
                for (final InterceptorBinding binding : copy(assemblyDescriptor.getInterceptorBinding())) {
                    if (binding.getEjbName().equals(ejbName)) {
                        assemblyDescriptor.getInterceptorBinding().remove(binding);
                    }
                }
            }
        }
        // Drop any ejb ref to with an ejb-link to a removed ejb
        for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {
            bean.getEjbLocalRefMap().keySet().removeAll(removed);
            bean.getEjbRefMap().keySet().removeAll(removed);
        }
        for (final Interceptor interceptor : ejbJar.getInterceptors()) {
            pruneRefs(interceptor, new EjbDeployment());
        }
    }
    return appModule;
}
Also used : EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) ArrayList(java.util.ArrayList) Method(org.apache.openejb.jee.Method) MethodPermission(org.apache.openejb.jee.MethodPermission) InterceptorBinding(org.apache.openejb.jee.InterceptorBinding) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) ContainerTransaction(org.apache.openejb.jee.ContainerTransaction) EntityBean(org.apache.openejb.jee.EntityBean) EjbDeployment(org.apache.openejb.jee.oejb3.EjbDeployment) AssemblyDescriptor(org.apache.openejb.jee.AssemblyDescriptor) Interceptor(org.apache.openejb.jee.Interceptor) EjbJar(org.apache.openejb.jee.EjbJar)

Example 3 with ContainerTransaction$JAXB.writeContainerTransaction

use of org.apache.openejb.jee.ContainerTransaction$JAXB.writeContainerTransaction in project tomee by apache.

the class EjbJarInfoBuilder method initMethodTransactions.

private void initMethodTransactions(final EjbModule jar, final Map ejbds, final EjbJarInfo ejbJarInfo) {
    final List<ContainerTransaction> containerTransactions = jar.getEjbJar().getAssemblyDescriptor().getContainerTransaction();
    for (final ContainerTransaction cTx : containerTransactions) {
        final MethodTransactionInfo info = new MethodTransactionInfo();
        info.description = cTx.getDescription();
        info.transAttribute = cTx.getTransAttribute().toString();
        info.methods.addAll(getMethodInfos(cTx.getMethod(), ejbds));
        ejbJarInfo.methodTransactions.add(info);
    }
}
Also used : MethodTransactionInfo(org.apache.openejb.assembler.classic.MethodTransactionInfo) ContainerTransaction(org.apache.openejb.jee.ContainerTransaction)

Example 4 with ContainerTransaction$JAXB.writeContainerTransaction

use of org.apache.openejb.jee.ContainerTransaction$JAXB.writeContainerTransaction in project tomee by apache.

the class StatefulTransactionAttributesTest 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();
    ejbJar.addEnterpriseBean(new StatefulBean(Color.class));
    ejbJar.addEnterpriseBean(new StatefulBean(Red.class));
    ejbJar.addEnterpriseBean(new StatefulBean(Crimson.class));
    ejbJar.addEnterpriseBean(new StatefulBean(Scarlet.class));
    final List<ContainerTransaction> declared = ejbJar.getAssemblyDescriptor().getContainerTransaction();
    declared.add(new ContainerTransaction(TransAttribute.REQUIRED, "*", "Crimson", "*"));
    declared.add(new ContainerTransaction(TransAttribute.REQUIRES_NEW, "*", "Crimson", "create"));
    final ContainerTransaction o = new ContainerTransaction(TransAttribute.SUPPORTS, "*", "Crimson", "create");
    o.getMethod().get(0).setMethodIntf(MethodIntf.HOME);
    declared.add(o);
    declared.add(new ContainerTransaction(TransAttribute.REQUIRES_NEW, "*", "Crimson", "remove"));
    declared.add(new ContainerTransaction(TransAttribute.REQUIRES_NEW, Color.class.getName(), "Scarlet", "*"));
    declared.add(new ContainerTransaction(TransAttribute.NEVER, Red.class.getName(), "Scarlet", "red"));
    declared.add(new ContainerTransaction(TransAttribute.REQUIRED, "Scarlet", Scarlet.class.getMethod("scarlet")));
    final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
    assembler.createApplication(ejbJarInfo);
    final InitialContext context = new InitialContext();
    {
        final ColorLocal color = (ColorLocal) context.lookup("ColorLocal");
        assertEquals("Never", color.color());
        assertEquals("RequiresNew", color.color((Object) null));
        assertEquals("Supports", color.color((String) null));
        assertEquals("Supports", color.color((Boolean) null));
        assertEquals("Supports", color.color((Integer) null));
    }
    {
        final ColorRemote color = (ColorRemote) context.lookup("ColorRemote");
        assertEquals("Never", color.color());
        assertEquals("RequiresNew", color.color((Object) null));
        assertEquals("Supports", color.color((String) null));
        assertEquals("Supports", color.color((Boolean) null));
        assertEquals("Supports", color.color((Integer) null));
    }
    {
        final ColorEjbLocalHome home = (ColorEjbLocalHome) context.lookup("ColorLocalHome");
        final ColorEjbLocalObject color = home.create("Supports");
        assertEquals("Never", color.color());
        assertEquals("RequiresNew", color.color((Object) null));
        assertEquals("Supports", color.color((String) null));
        assertEquals("Supports", color.color((Boolean) null));
        assertEquals("Supports", color.color((Integer) null));
        expected.set("Supports");
        color.remove();
    }
    {
        final ColorEjbHome home = (ColorEjbHome) context.lookup("ColorRemoteHome");
        final ColorEjbObject color = home.create("Supports");
        assertEquals("Never", color.color());
        assertEquals("RequiresNew", color.color((Object) null));
        assertEquals("Supports", color.color((String) null));
        assertEquals("Supports", color.color((Boolean) null));
        assertEquals("Supports", color.color((Integer) null));
        expected.set("Supports");
        color.remove();
    }
    {
        final RedLocal red = (RedLocal) context.lookup("RedLocal");
        assertEquals("Never", red.color());
        assertEquals("Required", red.color((Object) null));
        assertEquals("Supports", red.color((String) null));
        assertEquals("Supports", red.color((Boolean) null));
        assertEquals("Supports", red.color((Integer) null));
        assertEquals("RequiresNew", red.red());
        assertEquals("Required", red.red((Object) null));
        assertEquals("Required", red.red((String) null));
    }
    {
        final RedRemote red = (RedRemote) context.lookup("RedRemote");
        assertEquals("Never", red.color());
        assertEquals("Required", red.color((Object) null));
        assertEquals("Supports", red.color((String) null));
        assertEquals("Supports", red.color((Boolean) null));
        assertEquals("Supports", red.color((Integer) null));
        assertEquals("RequiresNew", red.red());
        assertEquals("Required", red.red((Object) null));
        assertEquals("Required", red.red((String) null));
    }
    {
        final RedEjbLocalHome home = (RedEjbLocalHome) context.lookup("RedLocalHome");
        final RedEjbLocalObject red = home.create("Supports");
        assertEquals("Never", red.color());
        assertEquals("Required", red.color((Object) null));
        assertEquals("Supports", red.color((String) null));
        assertEquals("Supports", red.color((Boolean) null));
        assertEquals("Supports", red.color((Integer) null));
        assertEquals("RequiresNew", red.red());
        assertEquals("Required", red.red((Object) null));
        assertEquals("Required", red.red((String) null));
        expected.set("Supports");
        red.remove();
    }
    {
        final RedEjbHome home = (RedEjbHome) context.lookup("RedRemoteHome");
        final RedEjbObject red = home.create("Supports");
        assertEquals("Never", red.color());
        assertEquals("Required", red.color((Object) null));
        assertEquals("Supports", red.color((String) null));
        assertEquals("Supports", red.color((Boolean) null));
        assertEquals("Supports", red.color((Integer) null));
        assertEquals("RequiresNew", red.red());
        assertEquals("Required", red.red((Object) null));
        assertEquals("Required", red.red((String) null));
        expected.set("Supports");
        red.remove();
    }
    {
        final CrimsonLocal crimson = (CrimsonLocal) context.lookup("CrimsonLocal");
        assertEquals("Required", crimson.color());
        assertEquals("Required", crimson.color((Object) null));
        assertEquals("Required", crimson.color((String) null));
        assertEquals("Required", crimson.color((Boolean) null));
        assertEquals("Required", crimson.color((Integer) null));
        assertEquals("RequiresNew", crimson.red());
        assertEquals("Required", crimson.red((Object) null));
        assertEquals("Required", crimson.red((String) null));
        assertEquals("RequiresNew", crimson.crimson());
        assertEquals("Required", crimson.crimson((String) null));
    }
    {
        final CrimsonRemote crimson = (CrimsonRemote) context.lookup("CrimsonRemote");
        assertEquals("Required", crimson.color());
        assertEquals("Required", crimson.color((Object) null));
        assertEquals("Required", crimson.color((String) null));
        assertEquals("Required", crimson.color((Boolean) null));
        assertEquals("Required", crimson.color((Integer) null));
        assertEquals("RequiresNew", crimson.red());
        assertEquals("Required", crimson.red((Object) null));
        assertEquals("Required", crimson.red((String) null));
        assertEquals("RequiresNew", crimson.crimson());
        assertEquals("Required", crimson.crimson((String) null));
    }
    {
        final CrimsonEjbLocalHome home = (CrimsonEjbLocalHome) context.lookup("CrimsonLocalHome");
        final CrimsonEjbLocalObject crimson = home.create("RequiresNew");
        assertEquals("Required", crimson.color());
        assertEquals("Required", crimson.color((Object) null));
        assertEquals("Required", crimson.color((String) null));
        assertEquals("Required", crimson.color((Boolean) null));
        assertEquals("Required", crimson.color((Integer) null));
        assertEquals("RequiresNew", crimson.red());
        assertEquals("Required", crimson.red((Object) null));
        assertEquals("Required", crimson.red((String) null));
        assertEquals("RequiresNew", crimson.crimson());
        assertEquals("Required", crimson.crimson((String) null));
        expected.set("RequiresNew");
        crimson.remove();
    }
    {
        final CrimsonEjbHome home = (CrimsonEjbHome) context.lookup("CrimsonRemoteHome");
        final CrimsonEjbObject crimson = home.create("Supports");
        assertEquals("Required", crimson.color());
        assertEquals("Required", crimson.color((Object) null));
        assertEquals("Required", crimson.color((String) null));
        assertEquals("Required", crimson.color((Boolean) null));
        assertEquals("Required", crimson.color((Integer) null));
        assertEquals("RequiresNew", crimson.red());
        assertEquals("Required", crimson.red((Object) null));
        assertEquals("Required", crimson.red((String) null));
        assertEquals("RequiresNew", crimson.crimson());
        assertEquals("Required", crimson.crimson((String) null));
        expected.set("RequiresNew");
        crimson.remove();
    }
    {
        final ScarletLocal scarlet = (ScarletLocal) context.lookup("ScarletLocal");
        assertEquals("Never", scarlet.color());
        assertEquals("Required", scarlet.color((Object) null));
        assertEquals("RequiresNew", scarlet.color((String) null));
        assertEquals("RequiresNew", scarlet.color((Boolean) null));
        assertEquals("RequiresNew", scarlet.color((Integer) null));
        assertEquals("RequiresNew", scarlet.red());
        assertEquals("Never", scarlet.red((Object) null));
        assertEquals("Never", scarlet.red((String) null));
        assertEquals("Required", scarlet.scarlet());
        assertEquals("NotSupported", scarlet.scarlet((String) null));
    }
    {
        final ScarletRemote scarlet = (ScarletRemote) context.lookup("ScarletRemote");
        assertEquals("Never", scarlet.color());
        assertEquals("Required", scarlet.color((Object) null));
        assertEquals("RequiresNew", scarlet.color((String) null));
        assertEquals("RequiresNew", scarlet.color((Boolean) null));
        assertEquals("RequiresNew", scarlet.color((Integer) null));
        assertEquals("RequiresNew", scarlet.red());
        assertEquals("Never", scarlet.red((Object) null));
        assertEquals("Never", scarlet.red((String) null));
        assertEquals("Required", scarlet.scarlet());
        assertEquals("NotSupported", scarlet.scarlet((String) null));
    }
    {
        final ScarletEjbLocalHome home = (ScarletEjbLocalHome) context.lookup("ScarletLocalHome");
        final ScarletEjbLocalObject scarlet = home.create("RequiresNew");
        assertEquals("Never", scarlet.color());
        assertEquals("Required", scarlet.color((Object) null));
        assertEquals("RequiresNew", scarlet.color((String) null));
        assertEquals("RequiresNew", scarlet.color((Boolean) null));
        assertEquals("RequiresNew", scarlet.color((Integer) null));
        assertEquals("RequiresNew", scarlet.red());
        assertEquals("Never", scarlet.red((Object) null));
        assertEquals("Never", scarlet.red((String) null));
        assertEquals("Required", scarlet.scarlet());
        assertEquals("NotSupported", scarlet.scarlet((String) null));
    }
    {
        final ScarletEjbHome home = (ScarletEjbHome) context.lookup("ScarletRemoteHome");
        final ScarletEjbObject scarlet = home.create("RequiresNew");
        assertEquals("Never", scarlet.color());
        assertEquals("Required", scarlet.color((Object) null));
        assertEquals("RequiresNew", scarlet.color((String) null));
        assertEquals("RequiresNew", scarlet.color((Boolean) null));
        assertEquals("RequiresNew", scarlet.color((Integer) null));
        assertEquals("RequiresNew", scarlet.red());
        assertEquals("Never", scarlet.red((Object) null));
        assertEquals("Never", scarlet.red((String) null));
        assertEquals("Required", scarlet.scarlet());
        assertEquals("NotSupported", scarlet.scarlet((String) null));
    }
}
Also used : LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar) StatefulBean(org.apache.openejb.jee.StatefulBean) InitialContext(javax.naming.InitialContext) ProxyFactoryInfo(org.apache.openejb.assembler.classic.ProxyFactoryInfo) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) ContainerTransaction(org.apache.openejb.jee.ContainerTransaction) Assembler(org.apache.openejb.assembler.classic.Assembler) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo)

Example 5 with ContainerTransaction$JAXB.writeContainerTransaction

use of org.apache.openejb.jee.ContainerTransaction$JAXB.writeContainerTransaction in project tomee by apache.

the class CheckInvalidTransactionAttributeTest method xml.

@Keys(@Key(value = "xml.invalidTransactionAttribute", type = KeyType.WARNING))
public EjbJar xml() throws SecurityException, NoSuchMethodException {
    final EjbJar ejbJar = new EjbJar();
    final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(CheeseEjb.class));
    bean.setTransactionType(TransactionType.BEAN);
    final ContainerTransaction tx = new ContainerTransaction();
    tx.getMethod().add(new Method(bean.getEjbName(), CheeseEjb.class.getMethod("sayCheesePlease", null)));
    tx.setTransAttribute(TransAttribute.REQUIRED);
    ejbJar.getAssemblyDescriptor().getContainerTransaction().add(tx);
    return ejbJar;
}
Also used : StatelessBean(org.apache.openejb.jee.StatelessBean) ContainerTransaction(org.apache.openejb.jee.ContainerTransaction) Method(org.apache.openejb.jee.Method) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

ContainerTransaction (org.apache.openejb.jee.ContainerTransaction)10 EjbJar (org.apache.openejb.jee.EjbJar)8 Method (org.apache.openejb.jee.Method)6 InterceptorBinding (org.apache.openejb.jee.InterceptorBinding)4 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)3 AssemblyDescriptor (org.apache.openejb.jee.AssemblyDescriptor)3 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)3 MethodPermission (org.apache.openejb.jee.MethodPermission)3 ArrayList (java.util.ArrayList)2 Assembler (org.apache.openejb.assembler.classic.Assembler)2 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)2 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)2 ApplicationException$JAXB.readApplicationException (org.apache.openejb.jee.ApplicationException$JAXB.readApplicationException)2 ApplicationException$JAXB.writeApplicationException (org.apache.openejb.jee.ApplicationException$JAXB.writeApplicationException)2 ContainerConcurrency$JAXB.readContainerConcurrency (org.apache.openejb.jee.ContainerConcurrency$JAXB.readContainerConcurrency)2 ContainerConcurrency$JAXB.writeContainerConcurrency (org.apache.openejb.jee.ContainerConcurrency$JAXB.writeContainerConcurrency)2 ContainerTransaction$JAXB.readContainerTransaction (org.apache.openejb.jee.ContainerTransaction$JAXB.readContainerTransaction)2 ContainerTransaction$JAXB.writeContainerTransaction (org.apache.openejb.jee.ContainerTransaction$JAXB.writeContainerTransaction)2 EntityBean (org.apache.openejb.jee.EntityBean)2 ExcludeList$JAXB.readExcludeList (org.apache.openejb.jee.ExcludeList$JAXB.readExcludeList)2