Search in sources :

Example 1 with Init

use of javax.ejb.Init 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)

Aggregations

EjbContext (com.sun.enterprise.deployment.annotation.context.EjbContext)1 Method (java.lang.reflect.Method)1 Init (javax.ejb.Init)1 AnnotationProcessorException (org.glassfish.apf.AnnotationProcessorException)1 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)1