Search in sources :

Example 11 with SessionBeanMetaData

use of org.jboss.metadata.ejb.spec.SessionBeanMetaData in project wildfly by wildfly.

the class HomeViewMergingProcessor method processComponentConfig.

private void processComponentConfig(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final Module module, final DeploymentReflectionIndex deploymentReflectionIndex, final SessionBeanComponentDescription description) throws DeploymentUnitProcessingException, ClassNotFoundException {
    String home = null;
    String localHome = null;
    //first check for annotations
    if (!MetadataCompleteMarker.isMetadataComplete(deploymentUnit)) {
        final EEModuleClassDescription clazz = applicationClasses.getClassByName(description.getComponentClassName());
        //we only care about annotations on the bean class itself
        if (clazz != null) {
            final ClassAnnotationInformation<LocalHome, String> localAnnotations = clazz.getAnnotationInformation(LocalHome.class);
            if (localAnnotations != null) {
                if (!localAnnotations.getClassLevelAnnotations().isEmpty()) {
                    localHome = localAnnotations.getClassLevelAnnotations().get(0);
                    if (description.getEjbLocalView() == null) {
                        //If the local home is specified via annotation then the corresponding business interface is implied
                        //by the signature of the create method
                        //See EJB 3.1 21.4.5
                        final String localClassName = this.inferLocalInterfaceFromLocalHome(localHome, module, deploymentReflectionIndex, description);
                        description.addEjbLocalObjectView(localClassName);
                    }
                }
            }
            final ClassAnnotationInformation<RemoteHome, String> remoteAnnotations = clazz.getAnnotationInformation(RemoteHome.class);
            if (remoteAnnotations != null) {
                if (!remoteAnnotations.getClassLevelAnnotations().isEmpty()) {
                    home = remoteAnnotations.getClassLevelAnnotations().get(0);
                    if (description.getEjbRemoteView() == null) {
                        //If the remote home is specified via annotation then the corresponding business interface is implied
                        //by the signature of the create method
                        //See EJB 3.1 21.4.5
                        final String remoteClassName = this.inferRemoteInterfaceFromHome(home, module, deploymentReflectionIndex, description);
                        description.addEjbObjectView(remoteClassName);
                    }
                }
            }
        }
    }
    //now allow the annotations to be overridden by the DD
    final SessionBeanMetaData descriptorData = description.getDescriptorData();
    if (descriptorData != null) {
        if (descriptorData.getHome() != null) {
            home = descriptorData.getHome();
        }
        if (descriptorData.getLocalHome() != null) {
            localHome = descriptorData.getLocalHome();
        }
    }
    if (localHome != null) {
        description.addLocalHome(localHome);
    }
    if (home != null) {
        description.addRemoteHome(home);
    }
    // finally see if we have to infer the remote or local interface from the home/local home views, respectively
    if (description.getEjbHomeView() != null && description.getEjbRemoteView() == null) {
        final String remoteClassName = this.inferRemoteInterfaceFromHome(description.getEjbHomeView().getViewClassName(), module, deploymentReflectionIndex, description);
        description.addEjbObjectView(remoteClassName);
    }
    if (description.getEjbLocalHomeView() != null && description.getEjbLocalView() == null) {
        final String localClassName = this.inferLocalInterfaceFromLocalHome(description.getEjbLocalHomeView().getViewClassName(), module, deploymentReflectionIndex, description);
        description.addEjbLocalObjectView(localClassName);
    }
}
Also used : SessionBeanMetaData(org.jboss.metadata.ejb.spec.SessionBeanMetaData) RemoteHome(javax.ejb.RemoteHome) EEModuleClassDescription(org.jboss.as.ee.component.EEModuleClassDescription) LocalHome(javax.ejb.LocalHome)

Aggregations

SessionBeanMetaData (org.jboss.metadata.ejb.spec.SessionBeanMetaData)11 SessionBean31MetaData (org.jboss.metadata.ejb.spec.SessionBean31MetaData)7 Method (java.lang.reflect.Method)4 MethodIdentifier (org.jboss.invocation.proxy.MethodIdentifier)4 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)2 StatefulComponentDescription (org.jboss.as.ejb3.component.stateful.StatefulComponentDescription)2 ClassReflectionIndex (org.jboss.as.server.deployment.reflect.ClassReflectionIndex)2 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)2 HashSet (java.util.HashSet)1 TimeUnit (java.util.concurrent.TimeUnit)1 ConcurrencyManagementType (javax.ejb.ConcurrencyManagementType)1 LocalHome (javax.ejb.LocalHome)1 RemoteHome (javax.ejb.RemoteHome)1 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)1 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)1 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)1 DependencyConfigurator (org.jboss.as.ee.component.DependencyConfigurator)1 EEModuleClassDescription (org.jboss.as.ee.component.EEModuleClassDescription)1 ViewConfiguration (org.jboss.as.ee.component.ViewConfiguration)1 ViewConfigurator (org.jboss.as.ee.component.ViewConfigurator)1