Search in sources :

Example 6 with AnnotatedElementHandler

use of org.glassfish.apf.AnnotatedElementHandler in project Payara by payara.

the class EjbBundleContext method createContextForEjb.

/**
 * This methods create a context for Ejb(s) by using descriptor(s)
 * associated to given ejbClassName.
 * Return null if corresponding descriptor is not found.
 */
public AnnotatedElementHandler createContextForEjb() {
    Class ejbClass = (Class) this.getProcessingContext().getProcessor().getLastAnnotatedElement(ElementType.TYPE);
    EjbDescriptor[] ejbDescs = null;
    String ejbClassName = null;
    if (ejbClass != null) {
        ejbClassName = ejbClass.getName();
        ejbDescs = this.getDescriptor().getEjbByClassName(ejbClassName);
    }
    AnnotatedElementHandler aeHandler = null;
    if (ejbDescs != null && ejbDescs.length > 1) {
        aeHandler = new EjbsContext(ejbDescs, ejbClass);
    } else if (ejbDescs != null && ejbDescs.length == 1) {
        aeHandler = new EjbContext(ejbDescs[0], ejbClass);
    }
    if (aeHandler != null) {
        // push a EjbContext to stack
        this.getProcessingContext().pushHandler(aeHandler);
    }
    return aeHandler;
}
Also used : AnnotatedElementHandler(org.glassfish.apf.AnnotatedElementHandler)

Example 7 with AnnotatedElementHandler

use of org.glassfish.apf.AnnotatedElementHandler in project Payara by payara.

the class EjbBundleContext method createContextForEjbInterceptor.

/**
 * This methods create a context for EjbInterceptor associated to
 * given className.
 * Return null if corresponding descriptor is not found.
 */
public AnnotatedElementHandler createContextForEjbInterceptor() {
    Class interceptorClass = (Class) this.getProcessingContext().getProcessor().getLastAnnotatedElement(ElementType.TYPE);
    EjbInterceptor ejbInterceptor = this.getDescriptor().getInterceptorByClassName(interceptorClass.getName());
    AnnotatedElementHandler aeHandler = null;
    if (ejbInterceptor != null) {
        aeHandler = new EjbInterceptorContext(ejbInterceptor);
        // push a EjbInterceptorContext to stack
        this.getProcessingContext().pushHandler(aeHandler);
    }
    return aeHandler;
}
Also used : AnnotatedElementHandler(org.glassfish.apf.AnnotatedElementHandler)

Example 8 with AnnotatedElementHandler

use of org.glassfish.apf.AnnotatedElementHandler in project Payara by payara.

the class WebBundleContext method createContextForWeb.

/**
 * This method create a context for web component(s) by using
 * descriptor(s) associated to given webComponet impl class.
 * Return null if corresponding descriptor is not found.
 */
public AnnotatedElementHandler createContextForWeb() {
    AnnotatedElement anTypeElement = this.getProcessingContext().getProcessor().getLastAnnotatedElement(ElementType.TYPE);
    WebComponentDescriptor[] webComps = null;
    if (anTypeElement != null) {
        String implClassName = ((Class) anTypeElement).getName();
        webComps = getDescriptor().getWebComponentByImplName(implClassName);
    }
    AnnotatedElementHandler aeHandler = null;
    if (webComps != null && webComps.length > 1) {
        aeHandler = new WebComponentsContext(webComps);
    } else if (webComps != null && webComps.length == 1) {
        aeHandler = new WebComponentContext(webComps[0]);
    }
    if (aeHandler != null) {
        // push a WebComponent(s)Context to stack
        this.getProcessingContext().pushHandler(aeHandler);
    }
    return aeHandler;
}
Also used : WebComponentDescriptor(com.sun.enterprise.deployment.WebComponentDescriptor) AnnotatedElement(java.lang.reflect.AnnotatedElement) AnnotatedElementHandler(org.glassfish.apf.AnnotatedElementHandler)

Example 9 with AnnotatedElementHandler

use of org.glassfish.apf.AnnotatedElementHandler in project Payara by payara.

the class AbstractResourceHandler method processAnnotation.

/**
 * Process a particular annotation which type is the same as the
 * one returned by @see getAnnotationType(). All information
 * pertinent to the annotation and its context is encapsulated
 * in the passed AnnotationInfo instance.
 *
 * @param ainfo the annotation information
 * @return
 * @throws AnnotationProcessorException
 */
@Override
public HandlerProcessingResult processAnnotation(AnnotationInfo ainfo) throws AnnotationProcessorException {
    AnnotatedElementHandler aeHandler = ainfo.getProcessingContext().getHandler();
    if (aeHandler instanceof EjbBundleContext) {
        EjbBundleContext ejbBundleContext = (EjbBundleContext) aeHandler;
        aeHandler = ejbBundleContext.createContextForEjb();
        if (aeHandler == null) {
            aeHandler = ejbBundleContext.createContextForEjbInterceptor();
        }
        // If it's still null and we're in an ejb-jar, use the EjbBundleContext.
        // This way we process dependencies on any classes (other than ejbs ,
        // interceptors , and their super-classes) that have annotations in case
        // we need the info for managed classes we wouldn't normally know about
        // (e.g. 299 classes).   In a .war, those are already processed during the
        // .war annotation scanning.
        EjbBundleDescriptor bundleDesc = ejbBundleContext.getDescriptor();
        RootDeploymentDescriptor enclosingBundle = bundleDesc.getModuleDescriptor().getDescriptor();
        boolean ejbJar = enclosingBundle instanceof EjbBundleDescriptor;
        if ((aeHandler == null) && ejbJar) {
            aeHandler = ejbBundleContext;
        }
    }
    if (aeHandler == null) {
        // not an ejb, interceptor in ejbBundle
        return getInvalidAnnotatedElementHandlerResult(ainfo.getProcessingContext().getHandler(), ainfo);
    }
    ResourceContainerContext[] rcContexts = null;
    if (aeHandler instanceof EjbsContext) {
        EjbsContext ejbsContext = (EjbsContext) aeHandler;
        rcContexts = (ResourceContainerContext[]) ejbsContext.getEjbContexts();
    } else if (aeHandler instanceof WebComponentsContext) {
        WebComponentsContext webCompsContext = (WebComponentsContext) aeHandler;
        rcContexts = (ResourceContainerContext[]) webCompsContext.getWebComponentContexts();
    } else if (aeHandler instanceof ResourceContainerContext) {
        rcContexts = new ResourceContainerContext[] { (ResourceContainerContext) aeHandler };
    } else {
        return getInvalidAnnotatedElementHandlerResult(aeHandler, ainfo);
    }
    return processAnnotation(ainfo, rcContexts);
}
Also used : EjbBundleContext(com.sun.enterprise.deployment.annotation.context.EjbBundleContext) ResourceContainerContext(com.sun.enterprise.deployment.annotation.context.ResourceContainerContext) WebComponentsContext(com.sun.enterprise.deployment.annotation.context.WebComponentsContext) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor) AnnotatedElementHandler(org.glassfish.apf.AnnotatedElementHandler) EjbsContext(com.sun.enterprise.deployment.annotation.context.EjbsContext)

Example 10 with AnnotatedElementHandler

use of org.glassfish.apf.AnnotatedElementHandler in project Payara by payara.

the class AbstractWebHandler method processAnnotation.

/**
 * Process a particular annotation which type is the same as the
 * one returned by @see getAnnotationType(). All information
 * pertinent to the annotation and its context is encapsulated
 * in the passed AnnotationInfo instance.
 * This is a method in interface AnnotationHandler.
 *
 * @param ainfo the annotation information
 */
@Override
public HandlerProcessingResult processAnnotation(AnnotationInfo ainfo) throws AnnotationProcessorException {
    AnnotatedElementHandler aeHandler = ainfo.getProcessingContext().getHandler();
    if (aeHandler instanceof WebBundleContext) {
        WebBundleContext webBundleContext = (WebBundleContext) aeHandler;
        AnnotatedElementHandler aeh = webBundleContext.createContextForWeb();
        if (aeh != null) {
            aeHandler = aeh;
        }
    }
    // no inheritance
    HandlerProcessingResult procResult = null;
    if (aeHandler instanceof WebComponentContext) {
        procResult = processAnnotation(ainfo, new WebComponentContext[] { (WebComponentContext) aeHandler });
    } else if (aeHandler instanceof WebComponentsContext) {
        WebComponentsContext webCompsContext = (WebComponentsContext) aeHandler;
        procResult = processAnnotation(ainfo, webCompsContext.getWebComponentContexts());
    } else if (aeHandler instanceof WebBundleContext) {
        WebBundleContext webBundleContext = (WebBundleContext) aeHandler;
        procResult = processAnnotation(ainfo, webBundleContext);
    } else {
        return getInvalidAnnotatedElementHandlerResult(aeHandler, ainfo);
    }
    return procResult;
}
Also used : WebBundleContext(com.sun.enterprise.deployment.annotation.context.WebBundleContext) WebComponentsContext(com.sun.enterprise.deployment.annotation.context.WebComponentsContext) WebComponentContext(com.sun.enterprise.deployment.annotation.context.WebComponentContext) HandlerProcessingResult(org.glassfish.apf.HandlerProcessingResult) AnnotatedElementHandler(org.glassfish.apf.AnnotatedElementHandler)

Aggregations

AnnotatedElementHandler (org.glassfish.apf.AnnotatedElementHandler)13 EjbBundleContext (com.sun.enterprise.deployment.annotation.context.EjbBundleContext)5 HandlerProcessingResult (org.glassfish.apf.HandlerProcessingResult)5 EjbsContext (com.sun.enterprise.deployment.annotation.context.EjbsContext)3 WebBundleContext (com.sun.enterprise.deployment.annotation.context.WebBundleContext)3 Annotation (java.lang.annotation.Annotation)3 AnnotatedElement (java.lang.reflect.AnnotatedElement)3 EjbContext (com.sun.enterprise.deployment.annotation.context.EjbContext)2 WebComponentContext (com.sun.enterprise.deployment.annotation.context.WebComponentContext)2 WebComponentsContext (com.sun.enterprise.deployment.annotation.context.WebComponentsContext)2 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)2 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)1 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)1 AppClientContext (com.sun.enterprise.deployment.annotation.context.AppClientContext)1 ComponentContext (com.sun.enterprise.deployment.annotation.context.ComponentContext)1 EjbInterceptorContext (com.sun.enterprise.deployment.annotation.context.EjbInterceptorContext)1 RarBundleContext (com.sun.enterprise.deployment.annotation.context.RarBundleContext)1 ResourceContainerContext (com.sun.enterprise.deployment.annotation.context.ResourceContainerContext)1 Constructor (java.lang.reflect.Constructor)1 Field (java.lang.reflect.Field)1