private static SessionBeanComponentDescription.SessionBeanType descriptionOf(
     final SessionType sessionType) {
   if (sessionType == null) return null;
   switch (sessionType) {
     case Stateless:
       return SessionBeanComponentDescription.SessionBeanType.STATELESS;
     case Stateful:
       return SessionBeanComponentDescription.SessionBeanType.STATEFUL;
     case Singleton:
       return SessionBeanComponentDescription.SessionBeanType.SINGLETON;
     default:
       throw EjbMessages.MESSAGES.unknownSessionBeanType(sessionType.name());
   }
 }
  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 EjbMessages.MESSAGES.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 EjbMessages.MESSAGES.sessionTypeNotSpecified(beanName);
      }
    }

    final String beanClassName = sessionBean.getEjbClass();
    final SessionBeanComponentDescription sessionBeanDescription;
    switch (sessionType) {
      case Stateless:
        sessionBeanDescription =
            new StatelessComponentDescription(
                beanName,
                beanClassName,
                ejbJarDescription,
                deploymentUnit.getServiceName(),
                sessionBean);
        break;
      case Stateful:
        sessionBeanDescription =
            new StatefulComponentDescription(
                beanName,
                beanClassName,
                ejbJarDescription,
                deploymentUnit.getServiceName(),
                sessionBean);
        // TODO: Handle passivation capable for stateful beans in EJB3.2
        break;
      case Singleton:
        sessionBeanDescription =
            new SingletonComponentDescription(
                beanName,
                beanClassName,
                ejbJarDescription,
                deploymentUnit.getServiceName(),
                sessionBean);
        break;
      default:
        throw EjbMessages.MESSAGES.unknownSessionBeanType(sessionType.name());
    }
    addComponent(deploymentUnit, sessionBeanDescription);
  }