Search in sources :

Example 16 with EjbDescriptor

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

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

the class EjbBundleValidator method handleOverloadedInterceptorMethodBindings.

private void handleOverloadedInterceptorMethodBindings(EjbBundleDescriptorImpl bundleDesc) {
    List<InterceptorBindingDescriptor> origBindings = bundleDesc.getInterceptorBindings();
    if (origBindings.isEmpty()) {
        return;
    }
    ClassLoader cl = bundleDesc.getClassLoader();
    List<InterceptorBindingDescriptor> newBindings = new LinkedList<InterceptorBindingDescriptor>();
    for (InterceptorBindingDescriptor next : origBindings) {
        if (next.getNeedsOverloadResolution()) {
            MethodDescriptor overloadedMethodDesc = next.getBusinessMethod();
            String methodName = overloadedMethodDesc.getName();
            // For method-specific interceptors, there must be an ejb-name.
            String ejbName = next.getEjbName();
            EjbDescriptor ejbDesc = bundleDesc.getEjbByName(ejbName);
            Class ejbClass = null;
            try {
                ejbClass = cl.loadClass(ejbDesc.getEjbClassName());
            } catch (Exception e) {
                RuntimeException re = new RuntimeException("Error loading ejb class " + ejbDesc.getEjbClassName());
                re.initCause(e);
                throw re;
            }
            boolean isMethod = false;
            for (Method ejbClassMethod : ejbClass.getDeclaredMethods()) {
                if (ejbClassMethod.getName().equals(methodName)) {
                    isMethod = true;
                    InterceptorBindingDescriptor newInterceptorBinding = new InterceptorBindingDescriptor();
                    MethodDescriptor newMethodDesc = new MethodDescriptor(ejbClassMethod, MethodDescriptor.EJB_BEAN);
                    newInterceptorBinding.setEjbName(ejbName);
                    newInterceptorBinding.setBusinessMethod(newMethodDesc);
                    for (String interceptorClass : next.getInterceptorClasses()) {
                        newInterceptorBinding.appendInterceptorClass(interceptorClass);
                    }
                    newInterceptorBinding.setIsTotalOrdering(next.getIsTotalOrdering());
                    newInterceptorBinding.setExcludeDefaultInterceptors(next.getExcludeDefaultInterceptors());
                    newInterceptorBinding.setExcludeClassInterceptors(next.getExcludeClassInterceptors());
                    newBindings.add(newInterceptorBinding);
                }
            }
            // check if it's a constructor
            if (!isMethod && methodName.equals(ejbClass.getSimpleName())) {
                // Constructor - will resolve via implicit comparison
                newBindings.add(next);
                continue;
            }
        } else {
            newBindings.add(next);
        }
    }
    bundleDesc.setInterceptorBindings(newBindings);
}
Also used : InterceptorBindingDescriptor(org.glassfish.ejb.deployment.descriptor.InterceptorBindingDescriptor) Method(java.lang.reflect.Method) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) LinkedList(java.util.LinkedList) DummyEjbDescriptor(org.glassfish.ejb.deployment.descriptor.DummyEjbDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor)

Example 18 with EjbDescriptor

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

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

the class EjbContainerServicesImpl method isRemoved.

public boolean isRemoved(Object ejbRef) {
    EJBLocalObjectImpl localObjectImpl = getEJBLocalObject(ejbRef);
    if (localObjectImpl == null) {
        throw new UnsupportedOperationException("Invalid ejb ref");
    }
    Container container = localObjectImpl.getContainer();
    EjbDescriptor ejbDesc = container.getEjbDescriptor();
    boolean isStatefulBean = false;
    if (ejbDesc.getType().equals(EjbSessionDescriptor.TYPE)) {
        EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc;
        isStatefulBean = sessionDesc.isStateful();
    }
    if (!isStatefulBean) {
        // stateless/singleton references via 299 will fail until bug is fixed.
        return false;
    // TODO reenable this per SessionObjectReference.isRemoved SPI
    // throw new UnsupportedOperationException("ejbRef for ejb " +
    // ejbDesc.getName() + " is not a stateful bean ");
    }
    boolean removed = false;
    try {
        ((BaseContainer) container).checkExists(localObjectImpl);
    } catch (Exception e) {
        removed = true;
    }
    return removed;
}
Also used : Container(com.sun.ejb.Container) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor) NoSuchEJBException(javax.ejb.NoSuchEJBException) EJBException(javax.ejb.EJBException)

Example 20 with EjbDescriptor

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

the class EjbContainerServicesImpl method remove.

public void remove(Object ejbRef) {
    EJBLocalObjectImpl localObjectImpl = getEJBLocalObject(ejbRef);
    if (localObjectImpl == null) {
        throw new UnsupportedOperationException("Invalid ejb ref");
    }
    Container container = localObjectImpl.getContainer();
    EjbDescriptor ejbDesc = container.getEjbDescriptor();
    boolean isStatefulBean = false;
    if (ejbDesc.getType().equals(EjbSessionDescriptor.TYPE)) {
        EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc;
        isStatefulBean = sessionDesc.isStateful();
    }
    if (!isStatefulBean) {
        // stateless/singleton references via 299 could fail until bug is fixed.
        return;
    // TODO reenable this after bug is fixed
    // throw new UnsupportedOperationException("ejbRef for ejb " +
    // ejbDesc.getName() + " is not a stateful bean ");
    }
    try {
        localObjectImpl.remove();
    } catch (EJBException e) {
        LogFacade.getLogger().log(Level.FINE, "EJBException during remove. ", e);
    } catch (javax.ejb.RemoveException re) {
        throw new NoSuchEJBException(re.getMessage(), re);
    }
}
Also used : NoSuchEJBException(javax.ejb.NoSuchEJBException) Container(com.sun.ejb.Container) NoSuchEJBException(javax.ejb.NoSuchEJBException) EJBException(javax.ejb.EJBException) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor)

Aggregations

EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)48 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)19 Iterator (java.util.Iterator)18 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)16 Result (com.sun.enterprise.tools.verifier.Result)14 Method (java.lang.reflect.Method)13 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)11 EjbContext (com.sun.enterprise.deployment.annotation.context.EjbContext)10 Set (java.util.Set)8 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)7 EjbEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor)6 EjbCMPEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor)5 Container (com.sun.ejb.Container)4 Field (java.lang.reflect.Field)4 ContainerTransaction (org.glassfish.ejb.deployment.descriptor.ContainerTransaction)4 DummyEjbDescriptor (org.glassfish.ejb.deployment.descriptor.DummyEjbDescriptor)4 VerifierTestContext (com.sun.enterprise.tools.verifier.VerifierTestContext)3 Constructor (java.lang.reflect.Constructor)3 Descriptor (org.glassfish.deployment.common.Descriptor)3 InterceptorBindingDescriptor (org.glassfish.ejb.deployment.descriptor.InterceptorBindingDescriptor)3