Search in sources :

Example 16 with EjbBundleDescriptorImpl

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

the class ApplicationExceptionHandler method processAnnotation.

public HandlerProcessingResult processAnnotation(AnnotationInfo ainfo) throws AnnotationProcessorException {
    AnnotatedElement ae = ainfo.getAnnotatedElement();
    Annotation annotation = ainfo.getAnnotation();
    AnnotatedElementHandler aeHandler = ainfo.getProcessingContext().getHandler();
    if (aeHandler instanceof EjbBundleContext) {
        EjbBundleContext ejbBundleContext = (EjbBundleContext) aeHandler;
        EjbBundleDescriptorImpl ejbBundle = (EjbBundleDescriptorImpl) ejbBundleContext.getDescriptor();
        ApplicationException appExcAnn = (ApplicationException) annotation;
        EjbApplicationExceptionInfo appExcInfo = new EjbApplicationExceptionInfo();
        Class annotatedClass = (Class) ae;
        appExcInfo.setExceptionClassName(annotatedClass.getName());
        appExcInfo.setRollback(appExcAnn.rollback());
        appExcInfo.setInherited(appExcAnn.inherited());
        // in ejb-jar.xml
        if (!ejbBundle.getApplicationExceptions().containsKey(annotatedClass.getName())) {
            ejbBundle.addApplicationException(appExcInfo);
        }
    }
    return getDefaultProcessedResult();
}
Also used : ApplicationException(javax.ejb.ApplicationException) EjbBundleContext(com.sun.enterprise.deployment.annotation.context.EjbBundleContext) EjbApplicationExceptionInfo(org.glassfish.ejb.deployment.descriptor.EjbApplicationExceptionInfo) AnnotatedElement(java.lang.reflect.AnnotatedElement) AnnotatedElementHandler(org.glassfish.apf.AnnotatedElementHandler) Annotation(java.lang.annotation.Annotation) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Example 17 with EjbBundleDescriptorImpl

use of org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl 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 18 with EjbBundleDescriptorImpl

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

the class EjbBundleTracerVisitor method accept.

@Override
public void accept(BundleDescriptor descriptor) {
    if (descriptor instanceof EjbBundleDescriptorImpl) {
        EjbBundleDescriptorImpl ejbBundle = (EjbBundleDescriptorImpl) descriptor;
        accept(ejbBundle);
        for (EjbDescriptor anEjb : ejbBundle.getEjbs()) {
            anEjb.visit(getSubDescriptorVisitor(anEjb));
        }
        if (ejbBundle.hasRelationships()) {
            for (RelationshipDescriptor rd : ejbBundle.getRelationships()) {
                accept(rd);
            }
        }
        for (WebService ws : ejbBundle.getWebServices().getWebServices()) {
            accept(ws);
        }
    }
    super.accept(descriptor);
}
Also used : WebService(com.sun.enterprise.deployment.WebService) RelationshipDescriptor(org.glassfish.ejb.deployment.descriptor.RelationshipDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Example 19 with EjbBundleDescriptorImpl

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

the class EjbBundleValidator method accept.

@Override
public void accept(BundleDescriptor descriptor) {
    this.bundleDescriptor = descriptor;
    this.application = descriptor.getApplication();
    if (descriptor instanceof EjbBundleDescriptorImpl) {
        EjbBundleDescriptorImpl ejbBundle = (EjbBundleDescriptorImpl) descriptor;
        accept(ejbBundle);
        for (EjbDescriptor anEjb : ejbBundle.getEjbs()) {
            anEjb.visit(getSubDescriptorVisitor(anEjb));
        }
        if (ejbBundle.hasRelationships()) {
            for (Iterator itr = ejbBundle.getRelationships().iterator(); itr.hasNext(); ) {
                RelationshipDescriptor rd = (RelationshipDescriptor) itr.next();
                accept(rd);
            }
        }
        for (WebService aWebService : ejbBundle.getWebServices().getWebServices()) {
            accept(aWebService);
        }
        // inject field.
        for (InjectionCapable injectable : ejbBundle.getInjectableResources(ejbBundle)) {
            accept(injectable);
        }
        super.accept(descriptor);
    } else {
        super.accept(descriptor);
    }
}
Also used : InjectionCapable(com.sun.enterprise.deployment.InjectionCapable) WebService(com.sun.enterprise.deployment.WebService) Iterator(java.util.Iterator) RelationshipDescriptor(org.glassfish.ejb.deployment.descriptor.RelationshipDescriptor) DummyEjbDescriptor(org.glassfish.ejb.deployment.descriptor.DummyEjbDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Example 20 with EjbBundleDescriptorImpl

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

the class EjbNode method addDescriptor.

@Override
public void addDescriptor(Object newDescriptor) {
    if (newDescriptor instanceof EjbReference) {
        if (DOLUtils.getDefaultLogger().isLoggable(Level.FINE)) {
            DOLUtils.getDefaultLogger().fine("Adding ejb ref " + newDescriptor);
        }
        getEjbDescriptor().addEjbReferenceDescriptor((EjbReference) newDescriptor);
    } else if (newDescriptor instanceof RunAsIdentityDescriptor) {
        if (DOLUtils.getDefaultLogger().isLoggable(Level.FINE)) {
            DOLUtils.getDefaultLogger().fine("Adding security-identity" + newDescriptor);
        }
        getEjbDescriptor().setUsesCallerIdentity(false);
        getEjbDescriptor().setRunAsIdentity((RunAsIdentityDescriptor) newDescriptor);
    } else if (newDescriptor instanceof MessageDestinationReferenceDescriptor) {
        MessageDestinationReferenceDescriptor msgDestRef = (MessageDestinationReferenceDescriptor) newDescriptor;
        EjbBundleDescriptorImpl ejbBundle = (EjbBundleDescriptorImpl) getParentNode().getDescriptor();
        // EjbBundle might not be set yet on EjbDescriptor, so set it
        // explicitly here.
        msgDestRef.setReferringBundleDescriptor(ejbBundle);
        getEjbDescriptor().addMessageDestinationReferenceDescriptor(msgDestRef);
    } else {
        super.addDescriptor(newDescriptor);
    }
}
Also used : EjbReference(com.sun.enterprise.deployment.types.EjbReference) MessageDestinationReferenceDescriptor(com.sun.enterprise.deployment.MessageDestinationReferenceDescriptor) RunAsIdentityDescriptor(com.sun.enterprise.deployment.RunAsIdentityDescriptor) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Aggregations

EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)37 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)19 Iterator (java.util.Iterator)12 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)11 Result (com.sun.enterprise.tools.verifier.Result)9 Method (java.lang.reflect.Method)7 Application (com.sun.enterprise.deployment.Application)6 Set (java.util.Set)6 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)5 EjbContext (com.sun.enterprise.deployment.annotation.context.EjbContext)4 DeploymentException (org.glassfish.deployment.common.DeploymentException)4 Constructor (java.lang.reflect.Constructor)3 Role (org.glassfish.security.common.Role)3 ResourceReferenceDescriptor (com.sun.enterprise.deployment.ResourceReferenceDescriptor)2 RoleReference (com.sun.enterprise.deployment.RoleReference)2 RunAsIdentityDescriptor (com.sun.enterprise.deployment.RunAsIdentityDescriptor)2 WebService (com.sun.enterprise.deployment.WebService)2 EjbBundleContext (com.sun.enterprise.deployment.annotation.context.EjbBundleContext)2 IASSecurityException (com.sun.enterprise.security.util.IASSecurityException)2 File (java.io.File)2