Search in sources :

Example 31 with EjbSessionDescriptor

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

the class AfterCompletionHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    for (EjbContext ejbContext : ejbContexts) {
        EjbSessionDescriptor ejbDesc = (EjbSessionDescriptor) ejbContext.getDescriptor();
        Method annMethod = (Method) ainfo.getAnnotatedElement();
        checkValid(annMethod);
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("Setting AfterCompletion method " + annMethod);
        }
        ejbDesc.setAfterCompletionMethodIfNotSet(new MethodDescriptor(annMethod));
    }
    return getDefaultProcessedResult();
}
Also used : EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) Method(java.lang.reflect.Method) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 32 with EjbSessionDescriptor

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

the class BeforeCompletionHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    for (EjbContext ejbContext : ejbContexts) {
        EjbSessionDescriptor ejbDesc = (EjbSessionDescriptor) ejbContext.getDescriptor();
        Method annMethod = (Method) ainfo.getAnnotatedElement();
        checkValid(annMethod);
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("Setting BeforeCompletion method " + annMethod);
        }
        ejbDesc.setBeforeCompletionMethodIfNotSet(new MethodDescriptor(annMethod));
    }
    return getDefaultProcessedResult();
}
Also used : EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) Method(java.lang.reflect.Method) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 33 with EjbSessionDescriptor

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

the class InitHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    Init init = (Init) ainfo.getAnnotation();
    for (EjbContext next : ejbContexts) {
        EjbSessionDescriptor sessionDescriptor = (EjbSessionDescriptor) next.getDescriptor();
        Method m = (Method) ainfo.getAnnotatedElement();
        // Check for matching method on home and/or local home interface.
        int numMatches = 0;
        String adaptedCreateMethodName = init.value();
        try {
            if (sessionDescriptor.isRemoteInterfacesSupported()) {
                addInitMethod(sessionDescriptor, m, adaptedCreateMethodName, false);
                numMatches++;
            }
        } catch (Exception e) {
        }
        try {
            if (sessionDescriptor.isLocalInterfacesSupported()) {
                addInitMethod(sessionDescriptor, m, adaptedCreateMethodName, true);
                numMatches++;
            }
        } catch (Exception e) {
        }
        if (numMatches == 0) {
            log(Level.SEVERE, ainfo, localStrings.getLocalString("enterprise.deployment.annotation.handlers.notmatchcreate", "Unable to find matching Home create method for Init method {0} on bean {1}.", new Object[] { m, sessionDescriptor.getName() }));
            return getDefaultFailedResult();
        }
    }
    return getDefaultProcessedResult();
}
Also used : Init(javax.ejb.Init) EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) Method(java.lang.reflect.Method) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) AnnotationProcessorException(org.glassfish.apf.AnnotationProcessorException)

Example 34 with EjbSessionDescriptor

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

the class LockHandler 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();
    Class classAn = (Class) ainfo.getAnnotatedElement();
    Lock lockAnn = (Lock) ainfo.getAnnotation();
    // 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.
    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 (!matchesExistingReadOrWriteLockMethod(m, ejbDesc)) {
            MethodDescriptor newMethodDesc = new MethodDescriptor(m);
            if (lockAnn.value() == LockType.WRITE) {
                ejbDesc.addWriteLockMethod(newMethodDesc);
            } else {
                ejbDesc.addReadLockMethod(newMethodDesc);
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) Lock(javax.ejb.Lock)

Example 35 with EjbSessionDescriptor

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

the class PrePassivateHandler method processAnnotation.

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

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