Search in sources :

Example 21 with EjbDescriptor

use of org.glassfish.ejb.deployment.descriptor.EjbDescriptor in project Payara by payara.

the class ContainerTransactionNode method endElement.

@Override
public boolean endElement(XMLElement element) {
    boolean doneWithNode = super.endElement(element);
    if (doneWithNode) {
        ContainerTransaction ct = new ContainerTransaction(trans_attribute, description);
        for (Iterator methodsIterator = methods.iterator(); methodsIterator.hasNext(); ) {
            MethodDescriptor md = (MethodDescriptor) methodsIterator.next();
            EjbBundleDescriptorImpl bundle = (EjbBundleDescriptorImpl) getParentNode().getDescriptor();
            EjbDescriptor ejb = bundle.getEjbByName(md.getEjbName(), true);
            ejb.getMethodContainerTransactions().put(md, ct);
        }
    }
    return doneWithNode;
}
Also used : ContainerTransaction(org.glassfish.ejb.deployment.descriptor.ContainerTransaction) Iterator(java.util.Iterator) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Example 22 with EjbDescriptor

use of org.glassfish.ejb.deployment.descriptor.EjbDescriptor in project Payara by payara.

the class AroundTimeoutHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    for (EjbContext next : ejbContexts) {
        EjbDescriptor ejbDescriptor = (EjbDescriptor) next.getDescriptor();
        ejbDescriptor.addAroundTimeoutDescriptor(getAroundInvocationDescriptor(ainfo));
    }
    return getDefaultProcessedResult();
}
Also used : EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor)

Example 23 with EjbDescriptor

use of org.glassfish.ejb.deployment.descriptor.EjbDescriptor in project Payara by payara.

the class ExcludeClassInterceptorsHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    EjbBundleDescriptorImpl ejbBundle = ((EjbDescriptor) ejbContexts[0].getDescriptor()).getEjbBundleDescriptor();
    for (EjbContext next : ejbContexts) {
        EjbDescriptor ejbDescriptor = (EjbDescriptor) next.getDescriptor();
        // Create binding information.
        InterceptorBindingDescriptor binding = new InterceptorBindingDescriptor();
        binding.setEjbName(ejbDescriptor.getName());
        binding.setExcludeClassInterceptors(true);
        // Annotation can be defined at a method level or constructor level.
        MethodDescriptor md = null;
        if (ElementType.METHOD.equals(ainfo.getElementType())) {
            Method m = (Method) ainfo.getAnnotatedElement();
            md = new MethodDescriptor(m, MethodDescriptor.EJB_BEAN);
        } else if (ElementType.CONSTRUCTOR.equals(ainfo.getElementType())) {
            Constructor c = (Constructor) ainfo.getAnnotatedElement();
            Class cl = c.getDeclaringClass();
            Class[] ctorParamTypes = c.getParameterTypes();
            String[] parameterClassNames = (new MethodDescriptor()).getParameterClassNamesFor(null, ctorParamTypes);
            md = new MethodDescriptor(cl.getSimpleName(), null, parameterClassNames, MethodDescriptor.EJB_BEAN);
        }
        // else throw Exception?
        binding.setBusinessMethod(md);
        ejbBundle.prependInterceptorBinding(binding);
    }
    return getDefaultProcessedResult();
}
Also used : EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) InterceptorBindingDescriptor(org.glassfish.ejb.deployment.descriptor.InterceptorBindingDescriptor) Constructor(java.lang.reflect.Constructor) Method(java.lang.reflect.Method) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Example 24 with EjbDescriptor

use of org.glassfish.ejb.deployment.descriptor.EjbDescriptor in project Payara by payara.

the class InterceptorsHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    Interceptors interceptors = (Interceptors) ainfo.getAnnotation();
    EjbBundleDescriptorImpl ejbBundle = ((EjbDescriptor) ejbContexts[0].getDescriptor()).getEjbBundleDescriptor();
    // Process each of the interceptor classes.
    for (Class interceptor : interceptors.value()) {
        processInterceptorClass(interceptor, ejbBundle, ainfo);
    }
    for (EjbContext next : ejbContexts) {
        EjbDescriptor ejbDescriptor = (EjbDescriptor) next.getDescriptor();
        // Create binding information.
        InterceptorBindingDescriptor binding = new InterceptorBindingDescriptor();
        binding.setEjbName(ejbDescriptor.getName());
        for (Class interceptor : interceptors.value()) {
            binding.appendInterceptorClass(interceptor.getName());
        }
        if (ElementType.METHOD.equals(ainfo.getElementType())) {
            Method m = (Method) ainfo.getAnnotatedElement();
            MethodDescriptor md = new MethodDescriptor(m, MethodDescriptor.EJB_BEAN);
            binding.setBusinessMethod(md);
        } else if (ElementType.CONSTRUCTOR.equals(ainfo.getElementType())) {
            Constructor c = (Constructor) ainfo.getAnnotatedElement();
            Class cl = c.getDeclaringClass();
            Class[] ctorParamTypes = c.getParameterTypes();
            String[] parameterClassNames = (new MethodDescriptor()).getParameterClassNamesFor(null, ctorParamTypes);
            MethodDescriptor md = new MethodDescriptor(cl.getSimpleName(), null, parameterClassNames, MethodDescriptor.EJB_BEAN);
            binding.setBusinessMethod(md);
        }
        // All binding information processed from annotations should go
        // before the binding information processed from the descriptors.
        // Since descriptors are processed first, always place the binding
        // info at the front.  The binding information from the descriptor
        // is ordered, but there is no prescribed order in which the
        // annotations are processed, so all that matters is that it's
        // before the descriptor bindings and that the descriptor binding
        // order is preserved.
        ejbBundle.prependInterceptorBinding(binding);
    }
    return getDefaultProcessedResult();
}
Also used : Interceptors(javax.interceptor.Interceptors) EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) InterceptorBindingDescriptor(org.glassfish.ejb.deployment.descriptor.InterceptorBindingDescriptor) Constructor(java.lang.reflect.Constructor) Method(java.lang.reflect.Method) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Example 25 with EjbDescriptor

use of org.glassfish.ejb.deployment.descriptor.EjbDescriptor in project Payara by payara.

the class TransactionAttributeHandler method postProcessAnnotation.

/**
 * Set the default value (from class type annotation) on all
 * methods that don't have a value.
 */
public void postProcessAnnotation(AnnotationInfo ainfo, EjbContext ejbContext) throws AnnotationProcessorException {
    EjbDescriptor ejbDesc = (EjbDescriptor) ejbContext.getDescriptor();
    TransactionAttribute taAn = (TransactionAttribute) ainfo.getAnnotation();
    ContainerTransaction containerTransaction = getContainerTransaction(taAn.value());
    Class classAn = (Class) ainfo.getAnnotatedElement();
    Set txBusMethods = ejbDesc.getTxBusinessMethodDescriptors();
    for (Object mdObj : txBusMethods) {
        MethodDescriptor md = (MethodDescriptor) mdObj;
        // override by xml
        if (classAn.equals(ejbContext.getDeclaringClass(md)) && ejbDesc.getContainerTransactionFor(md) == null) {
            ejbDesc.setContainerTransactionFor(md, containerTransaction);
        }
    }
}
Also used : Set(java.util.Set) TransactionAttribute(javax.ejb.TransactionAttribute) ContainerTransaction(org.glassfish.ejb.deployment.descriptor.ContainerTransaction) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor)

Aggregations

EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)48 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)19 Iterator (java.util.Iterator)18 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)16 Result (com.sun.enterprise.tools.verifier.Result)14 Method (java.lang.reflect.Method)13 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)11 EjbContext (com.sun.enterprise.deployment.annotation.context.EjbContext)10 Set (java.util.Set)8 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)7 EjbEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor)6 EjbCMPEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor)5 Container (com.sun.ejb.Container)4 Field (java.lang.reflect.Field)4 ContainerTransaction (org.glassfish.ejb.deployment.descriptor.ContainerTransaction)4 DummyEjbDescriptor (org.glassfish.ejb.deployment.descriptor.DummyEjbDescriptor)4 VerifierTestContext (com.sun.enterprise.tools.verifier.VerifierTestContext)3 Constructor (java.lang.reflect.Constructor)3 Descriptor (org.glassfish.deployment.common.Descriptor)3 InterceptorBindingDescriptor (org.glassfish.ejb.deployment.descriptor.InterceptorBindingDescriptor)3