Search in sources :

Example 1 with Method$JAXB.writeMethod

use of org.apache.openejb.jee.Method$JAXB.writeMethod in project tomee by apache.

the class EjbJarInfoBuilder method getMethodInfos.

private List<MethodInfo> getMethodInfos(final List<Method> ms, final Map ejbds) {
    if (ms == null) {
        return Collections.emptyList();
    }
    final List<MethodInfo> mi = new ArrayList<>(ms.size());
    for (final Method method : ms) {
        final MethodInfo methodInfo = getMethodInfo(method, ejbds);
        mi.add(methodInfo);
    }
    return mi;
}
Also used : ArrayList(java.util.ArrayList) MethodInfo(org.apache.openejb.assembler.classic.MethodInfo) InitMethodInfo(org.apache.openejb.assembler.classic.InitMethodInfo) NamedMethodInfo(org.apache.openejb.assembler.classic.NamedMethodInfo) RemoveMethodInfo(org.apache.openejb.assembler.classic.RemoveMethodInfo) RemoveMethod(org.apache.openejb.jee.RemoveMethod) AsyncMethod(org.apache.openejb.jee.AsyncMethod) CallbackMethod(org.apache.openejb.jee.CallbackMethod) QueryMethod(org.apache.openejb.jee.QueryMethod) ConcurrentMethod(org.apache.openejb.jee.ConcurrentMethod) Method(org.apache.openejb.jee.Method) NamedMethod(org.apache.openejb.jee.NamedMethod) InitMethod(org.apache.openejb.jee.InitMethod)

Example 2 with Method$JAXB.writeMethod

use of org.apache.openejb.jee.Method$JAXB.writeMethod 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 Method$JAXB.writeMethod

use of org.apache.openejb.jee.Method$JAXB.writeMethod in project tomee by apache.

the class EjbJarInfoBuilder method copyConcurrentMethods.

private void copyConcurrentMethods(final SessionBean bean, final EjbJarInfo ejbJarInfo, final Map ejbds) {
    for (final ConcurrentMethod method : bean.getConcurrentMethod()) {
        final MethodConcurrencyInfo info = new MethodConcurrencyInfo();
        if (method.getLock() != null) {
            info.concurrencyAttribute = method.getLock().toString();
        }
        info.accessTimeout = toInfo(method.getAccessTimeout());
        final Method m = new Method(bean.getEjbName(), null, method.getMethod().getMethodName());
        m.setMethodParams(method.getMethod().getMethodParams());
        info.methods.add(getMethodInfo(m, ejbds));
        ejbJarInfo.methodConcurrency.add(info);
    }
}
Also used : ConcurrentMethod(org.apache.openejb.jee.ConcurrentMethod) RemoveMethod(org.apache.openejb.jee.RemoveMethod) AsyncMethod(org.apache.openejb.jee.AsyncMethod) CallbackMethod(org.apache.openejb.jee.CallbackMethod) QueryMethod(org.apache.openejb.jee.QueryMethod) ConcurrentMethod(org.apache.openejb.jee.ConcurrentMethod) Method(org.apache.openejb.jee.Method) NamedMethod(org.apache.openejb.jee.NamedMethod) InitMethod(org.apache.openejb.jee.InitMethod) MethodConcurrencyInfo(org.apache.openejb.assembler.classic.MethodConcurrencyInfo)

Example 4 with Method$JAXB.writeMethod

use of org.apache.openejb.jee.Method$JAXB.writeMethod in project tomee by apache.

the class CheckInvalidMethodPermissionsTest method test.

@Keys({ @Key("methodPermission.ejbNameRequired"), @Key("methodPermission.noSuchEjbName") })
public EjbJar test() throws Exception {
    final EjbJar ejbJar = new EjbJar();
    final MethodPermission permission = new MethodPermission(new Method((String) null, (String) null));
    ejbJar.getAssemblyDescriptor().getMethodPermission().add(permission);
    final MethodPermission permission1 = new MethodPermission(new Method("wrongEjbName", "wrongMethodName"));
    ejbJar.getAssemblyDescriptor().getMethodPermission().add(permission1);
    return ejbJar;
}
Also used : Method(org.apache.openejb.jee.Method) MethodPermission(org.apache.openejb.jee.MethodPermission) EjbJar(org.apache.openejb.jee.EjbJar)

Example 5 with Method$JAXB.writeMethod

use of org.apache.openejb.jee.Method$JAXB.writeMethod 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

Method (org.apache.openejb.jee.Method)9 Method$JAXB.readMethod (org.apache.openejb.jee.Method$JAXB.readMethod)8 Method$JAXB.writeMethod (org.apache.openejb.jee.Method$JAXB.writeMethod)8 Text$JAXB.readText (org.apache.openejb.jee.Text$JAXB.readText)8 Text$JAXB.writeText (org.apache.openejb.jee.Text$JAXB.writeText)8 RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)8 ArrayList (java.util.ArrayList)7 ContainerTransaction (org.apache.openejb.jee.ContainerTransaction)6 EjbJar (org.apache.openejb.jee.EjbJar)6 CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)4 QName (javax.xml.namespace.QName)4 MethodPermission (org.apache.openejb.jee.MethodPermission)4 Attribute (org.metatype.sxc.util.Attribute)4 XoXMLStreamReader (org.metatype.sxc.util.XoXMLStreamReader)4 AssemblyDescriptor (org.apache.openejb.jee.AssemblyDescriptor)3 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)3 InterceptorBinding (org.apache.openejb.jee.InterceptorBinding)3 AsyncMethod (org.apache.openejb.jee.AsyncMethod)2 CallbackMethod (org.apache.openejb.jee.CallbackMethod)2 ConcurrentLockType$JAXB.parseConcurrentLockType (org.apache.openejb.jee.ConcurrentLockType$JAXB.parseConcurrentLockType)2