Search in sources :

Example 36 with EjbBundleDescriptorImpl

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

the class ExcludeDefaultInterceptorsHandler 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.setExcludeDefaultInterceptors(true);
        if (ElementType.METHOD.equals(ainfo.getElementType())) {
            Method m = (Method) ainfo.getAnnotatedElement();
            MethodDescriptor md = new MethodDescriptor(m, MethodDescriptor.EJB_BEAN);
            binding.setBusinessMethod(md);
        } 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);
            MethodDescriptor md = new MethodDescriptor(cl.getSimpleName(), null, parameterClassNames, MethodDescriptor.EJB_BEAN);
            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 37 with EjbBundleDescriptorImpl

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

the class NameMapper method initGeneratedRelationshipMaps.

private void initGeneratedRelationshipMaps() {
    EjbBundleDescriptorImpl bundleDescriptor = getBundleDescriptor();
    Set relationships = bundleDescriptor.getRelationships();
    _generatedRelToInverseRelMap = new HashMap();
    _relToInverseGeneratedRelMap = new HashMap();
    // null check
    if (relationships != null) {
        Iterator iterator = relationships.iterator();
        List generatedRels = new ArrayList();
        int counter = 0;
        // gather list of generated cmr fields by examining source and sink
        while (iterator.hasNext()) {
            RelationshipDescriptor relationship = (RelationshipDescriptor) iterator.next();
            if (relationship.getSource().getCMRField() == null)
                generatedRels.add(relationship);
            if (relationship.getSink().getCMRField() == null)
                generatedRels.add(relationship);
        }
        // now update the maps to contain this info
        iterator = generatedRels.iterator();
        while (iterator.hasNext()) {
            RelationshipDescriptor relationship = (RelationshipDescriptor) iterator.next();
            RelationRoleDescriptor source = relationship.getSource();
            String sourceEjbName = source.getOwner().getName();
            String sourceCMRField = source.getCMRField();
            boolean sourceIsNull = (sourceCMRField == null);
            RelationRoleDescriptor sink = relationship.getSink();
            String sinkEjbName = sink.getOwner().getName();
            String ejbName = (sourceIsNull ? sourceEjbName : sinkEjbName);
            String otherEjbName = (sourceIsNull ? sinkEjbName : sourceEjbName);
            List ejbField = Arrays.asList(new String[] { otherEjbName, (sourceIsNull ? sink.getCMRField() : sourceCMRField) });
            PersistenceDescriptor pDescriptor = ((EjbCMPEntityDescriptor) bundleDescriptor.getEjbByName(ejbName)).getPersistenceDescriptor();
            List generatedField = null;
            String uniqueName = null;
            // with this name
            do {
                counter++;
                uniqueName = GENERATED_CMR_FIELD_PREFIX + counter;
            } while (hasField(pDescriptor, uniqueName));
            generatedField = Arrays.asList(new String[] { ejbName, uniqueName });
            _generatedRelToInverseRelMap.put(generatedField, ejbField);
            _relToInverseGeneratedRelMap.put(ejbField, generatedField);
        }
    }
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RelationshipDescriptor(org.glassfish.ejb.deployment.descriptor.RelationshipDescriptor) RelationRoleDescriptor(org.glassfish.ejb.deployment.descriptor.RelationRoleDescriptor) PersistenceDescriptor(org.glassfish.ejb.deployment.descriptor.PersistenceDescriptor) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) EjbCMPEntityDescriptor(org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor) 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