Search in sources :

Example 46 with EjbSessionDescriptor

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

the class AccessTimeoutHandler 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 {
    EjbSessionDescriptor ejbDesc = (EjbSessionDescriptor) ejbContext.getDescriptor();
    // At this point, all method-level specific annotations have been processed.
    // For non-private methods, find the ones from the EjbContext's
    // component definition view that are declared on this class.  This will correctly
    // eliminate any overridden methods and provide the most-derived version of each.
    // Use the Class's declared methods list to get the private methods.
    Class classAn = (Class) ainfo.getAnnotatedElement();
    AccessTimeout timeoutAnn = (AccessTimeout) ainfo.getAnnotation();
    List<Method> toProcess = new ArrayList<Method>();
    for (Method m : ejbContext.getComponentDefinitionMethods()) {
        if (classAn.equals(m.getDeclaringClass())) {
            toProcess.add(m);
        }
    }
    for (Method m : classAn.getDeclaredMethods()) {
        if (Modifier.isPrivate(m.getModifiers())) {
            toProcess.add(m);
        }
    }
    for (Method m : toProcess) {
        // descriptor, set it.
        if (!matchesExistingAccessTimeoutMethod(m, ejbDesc)) {
            MethodDescriptor newMethodDesc = new MethodDescriptor(m);
            ejbDesc.addAccessTimeoutMethod(newMethodDesc, timeoutAnn.value(), timeoutAnn.unit());
        }
    }
}
Also used : AccessTimeout(javax.ejb.AccessTimeout) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 47 with EjbSessionDescriptor

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

the class AsynchronousHandler method setAsynchronous.

/**
 * Designate a method as asynchronous in the deployment descriptor
 * @param methodIntf  null if processed on bean class / superclass.  Otherwise,
 *                    set to the remote/local client view of the associated interface
 * @throws AnnotationProcessorException
 */
private void setAsynchronous(Method m0, EjbDescriptor ejbDesc, String methodIntf) throws AnnotationProcessorException {
    if (!ejbDesc.getType().equals(EjbSessionDescriptor.TYPE)) {
        throw new AnnotationProcessorException("Invalid asynchronous method " + m0 + "@Asynchronous is only permitted for session beans");
    }
    EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc;
    MethodDescriptor methodDesc = (methodIntf == null) ? new MethodDescriptor(m0) : new MethodDescriptor(m0, methodIntf);
    if (logger.isLoggable(Level.FINE)) {
        logger.fine("Adding asynchronous method " + methodDesc);
    }
    // There is no way to "turn off" the asynchronous designation in the
    // deployment descriptor, so we don't need to do any override checks
    // here.  Just always add any async methods.
    sessionDesc.addAsynchronousMethod(methodDesc);
}
Also used : AnnotationProcessorException(org.glassfish.apf.AnnotationProcessorException) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 48 with EjbSessionDescriptor

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

the class ConcurrencyManagementHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    ConcurrencyManagement cmAn = (ConcurrencyManagement) ainfo.getAnnotation();
    ConcurrencyManagementType cmType = cmAn.value();
    for (EjbContext ejbContext : ejbContexts) {
        EjbDescriptor ejbDesc = ejbContext.getDescriptor();
        if (ejbDesc instanceof EjbSessionDescriptor) {
            EjbSessionDescriptor.ConcurrencyManagementType descCMType;
            switch(cmType) {
                case CONTAINER:
                    descCMType = EjbSessionDescriptor.ConcurrencyManagementType.Container;
                    break;
                case BEAN:
                    descCMType = EjbSessionDescriptor.ConcurrencyManagementType.Bean;
                    break;
                default:
                    throw new AnnotationProcessorException("Unsupported concurrency management " + "type = " + cmType);
            }
            EjbSessionDescriptor sDesc = (EjbSessionDescriptor) ejbDesc;
            // Set value on descriptor unless it has been set by .xml
            sDesc.setConcurrencyManagementTypeIfNotSet(descCMType);
        }
    }
    return getDefaultProcessedResult();
}
Also used : ConcurrencyManagement(javax.ejb.ConcurrencyManagement) ConcurrencyManagementType(javax.ejb.ConcurrencyManagementType) EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) AnnotationProcessorException(org.glassfish.apf.AnnotationProcessorException) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Example 49 with EjbSessionDescriptor

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

the class PostActivateHandler method processAnnotation.

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

Example 50 with EjbSessionDescriptor

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

the class RemoveHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    Remove remove = (Remove) ainfo.getAnnotation();
    for (EjbContext next : ejbContexts) {
        EjbSessionDescriptor sessionDescriptor = (EjbSessionDescriptor) next.getDescriptor();
        Method m = (Method) ainfo.getAnnotatedElement();
        MethodDescriptor removeMethod = new MethodDescriptor(m, MethodDescriptor.EJB_BEAN);
        EjbRemovalInfo removalInfo = sessionDescriptor.getRemovalInfo(removeMethod);
        if (removalInfo == null) {
            // if this element is not defined in xml
            // use all information from annotation
            removalInfo = new EjbRemovalInfo();
            removalInfo.setRemoveMethod(removeMethod);
            removalInfo.setRetainIfException(remove.retainIfException());
            sessionDescriptor.addRemoveMethod(removalInfo);
        } else {
            // is not defined in xml
            if (!removalInfo.isRetainIfExceptionSet()) {
                removalInfo.setRetainIfException(remove.retainIfException());
            }
        }
    }
    return getDefaultProcessedResult();
}
Also used : EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) EjbRemovalInfo(org.glassfish.ejb.deployment.descriptor.EjbRemovalInfo) Remove(javax.ejb.Remove) Method(java.lang.reflect.Method) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Aggregations

EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)78 Result (com.sun.enterprise.tools.verifier.Result)28 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)28 Method (java.lang.reflect.Method)25 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)23 EjbEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor)18 VerifierTestContext (com.sun.enterprise.tools.verifier.VerifierTestContext)11 EjbContext (com.sun.enterprise.deployment.annotation.context.EjbContext)10 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)7 Iterator (java.util.Iterator)6 ContainerTransaction (org.glassfish.ejb.deployment.descriptor.ContainerTransaction)6 Set (java.util.Set)5 EJBException (javax.ejb.EJBException)4 Container (com.sun.ejb.Container)3 EjbInterceptor (com.sun.enterprise.deployment.EjbInterceptor)3 LifecycleCallbackDescriptor (com.sun.enterprise.deployment.LifecycleCallbackDescriptor)3 AnnotatedElement (java.lang.reflect.AnnotatedElement)3 ArrayList (java.util.ArrayList)3 Enumeration (java.util.Enumeration)3 NoSuchEJBException (javax.ejb.NoSuchEJBException)3