Search in sources :

Example 1 with SessionType

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

the class SessionBeanComponentDescriptionFactory method processSessionBeanMetaData.

private void processSessionBeanMetaData(final DeploymentUnit deploymentUnit, final SessionBeanMetaData sessionBean) throws DeploymentUnitProcessingException {
    final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit);
    final CompositeIndex compositeIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
    final String beanName = sessionBean.getName();
    SessionType sessionType = sessionBean.getSessionType();
    if (sessionType == null && sessionBean instanceof GenericBeanMetaData) {
        final GenericBeanMetaData bean = (GenericBeanMetaData) sessionBean;
        if (bean.getEjbType() == EjbType.SESSION) {
            sessionType = determineSessionType(sessionBean.getEjbClass(), compositeIndex);
            if (sessionType == null) {
                throw EjbLogger.ROOT_LOGGER.sessionTypeNotSpecified(beanName);
            }
        } else {
            // it is not a session bean, so we ignore it
            return;
        }
    } else if (sessionType == null) {
        sessionType = determineSessionType(sessionBean.getEjbClass(), compositeIndex);
        if (sessionType == null) {
            throw EjbLogger.ROOT_LOGGER.sessionTypeNotSpecified(beanName);
        }
    }
    final String beanClassName = sessionBean.getEjbClass();
    final SessionBeanComponentDescription sessionBeanDescription;
    switch(sessionType) {
        case Stateless:
            sessionBeanDescription = new StatelessComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnit, sessionBean, defaultSlsbPoolAvailable);
            break;
        case Stateful:
            sessionBeanDescription = new StatefulComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnit, sessionBean);
            if (sessionBean instanceof SessionBean32MetaData && ((SessionBean32MetaData) sessionBean).isPassivationCapable() != null) {
                ((StatefulComponentDescription) sessionBeanDescription).setPassivationApplicable(((SessionBean32MetaData) sessionBean).isPassivationCapable());
            }
            break;
        case Singleton:
            sessionBeanDescription = new SingletonComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnit, sessionBean);
            break;
        default:
            throw EjbLogger.ROOT_LOGGER.unknownSessionBeanType(sessionType.name());
    }
    addComponent(deploymentUnit, sessionBeanDescription);
}
Also used : SessionType(org.jboss.metadata.ejb.spec.SessionType) StatelessComponentDescription(org.jboss.as.ejb3.component.stateless.StatelessComponentDescription) StatefulComponentDescription(org.jboss.as.ejb3.component.stateful.StatefulComponentDescription) AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.getEjbJarDescription(org.jboss.as.ejb3.deployment.processors.AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.getEjbJarDescription) EjbJarDescription(org.jboss.as.ejb3.deployment.EjbJarDescription) SessionBean32MetaData(org.jboss.metadata.ejb.spec.SessionBean32MetaData) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) GenericBeanMetaData(org.jboss.metadata.ejb.spec.GenericBeanMetaData) SingletonComponentDescription(org.jboss.as.ejb3.component.singleton.SingletonComponentDescription) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)

Aggregations

SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)1 SingletonComponentDescription (org.jboss.as.ejb3.component.singleton.SingletonComponentDescription)1 StatefulComponentDescription (org.jboss.as.ejb3.component.stateful.StatefulComponentDescription)1 StatelessComponentDescription (org.jboss.as.ejb3.component.stateless.StatelessComponentDescription)1 EjbJarDescription (org.jboss.as.ejb3.deployment.EjbJarDescription)1 AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.getEjbJarDescription (org.jboss.as.ejb3.deployment.processors.AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.getEjbJarDescription)1 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)1 GenericBeanMetaData (org.jboss.metadata.ejb.spec.GenericBeanMetaData)1 SessionBean32MetaData (org.jboss.metadata.ejb.spec.SessionBean32MetaData)1 SessionType (org.jboss.metadata.ejb.spec.SessionType)1