Example #1
0
  private EnterpriseBeanInfo initMessageBean(final MessageDrivenBean mdb, final Map m)
      throws OpenEJBException {
    final MessageDrivenBeanInfo bean = new MessageDrivenBeanInfo();

    bean.timeoutMethod = toInfo(mdb.getTimeoutMethod());
    copyCallbacks(mdb.getAroundTimeout(), bean.aroundTimeout);

    copyCallbacks(mdb.getAroundInvoke(), bean.aroundInvoke);
    copyCallbacks(mdb.getPostConstruct(), bean.postConstruct);
    copyCallbacks(mdb.getPreDestroy(), bean.preDestroy);

    copySchedules(mdb.getTimer(), bean.methodScheduleInfos);

    final EjbDeployment d = (EjbDeployment) m.get(mdb.getEjbName());
    if (d == null) {
      throw new OpenEJBException(
          "No deployment information in openejb-jar.xml for bean "
              + mdb.getEjbName()
              + ". Please redeploy the jar");
    }
    bean.ejbDeploymentId = d.getDeploymentId();
    bean.containerId = d.getContainerId();

    final Icon icon = mdb.getIcon();
    bean.largeIcon = icon == null ? null : icon.getLargeIcon();
    bean.smallIcon = icon == null ? null : icon.getSmallIcon();
    bean.description = mdb.getDescription();
    bean.displayName = mdb.getDisplayName();
    bean.ejbClass = mdb.getEjbClass();
    bean.ejbName = mdb.getEjbName();
    final TransactionType txType = mdb.getTransactionType();
    bean.transactionType =
        txType != null ? txType.toString() : TransactionType.CONTAINER.toString();
    bean.properties.putAll(d.getProperties());

    if (mdb.getMessagingType() != null) {
      bean.mdbInterface = mdb.getMessagingType();
    } else {
      bean.mdbInterface = "javax.jms.MessageListener";
    }

    final ResourceLink resourceLink = d.getResourceLink("openejb/destination");
    if (resourceLink != null) {
      bean.destinationId = resourceLink.getResId();
    }

    if (mdb.getMessageDestinationType() != null) {
      bean.activationProperties.put("destinationType", mdb.getMessageDestinationType());
    }

    final ActivationConfig activationConfig = mdb.getActivationConfig();
    if (activationConfig != null) {
      for (final ActivationConfigProperty property :
          activationConfig.getActivationConfigProperty()) {
        final String name = property.getActivationConfigPropertyName();
        final String value = property.getActivationConfigPropertyValue();
        bean.activationProperties.put(name, value);
      }
    }

    return bean;
  }
Example #2
0
  private EnterpriseBeanInfo initEntityBean(final EntityBean e, final Map m)
      throws OpenEJBException {
    final EntityBeanInfo bean = new EntityBeanInfo();

    final EjbDeployment d = (EjbDeployment) m.get(e.getEjbName());
    if (d == null) {
      throw new OpenEJBException(
          "No deployment information in openejb-jar.xml for bean "
              + e.getEjbName()
              + ". Please redeploy the jar");
    }
    bean.ejbDeploymentId = d.getDeploymentId();
    bean.containerId = d.getContainerId();

    final Icon icon = e.getIcon();
    bean.largeIcon = icon == null ? null : icon.getLargeIcon();
    bean.smallIcon = icon == null ? null : icon.getSmallIcon();
    bean.description = e.getDescription();
    bean.displayName = e.getDisplayName();
    bean.ejbClass = e.getEjbClass();
    bean.abstractSchemaName = e.getAbstractSchemaName();
    bean.ejbName = e.getEjbName();
    bean.home = e.getHome();
    bean.remote = e.getRemote();
    bean.localHome = e.getLocalHome();
    bean.local = e.getLocal();
    bean.transactionType = "Container";

    bean.primKeyClass = e.getPrimKeyClass();
    bean.primKeyField = e.getPrimkeyField();
    bean.persistenceType = e.getPersistenceType().toString();
    bean.reentrant = String.valueOf(e.getReentrant());
    bean.properties.putAll(d.getProperties());

    final CmpVersion cmpVersion = e.getCmpVersion();
    if (e.getPersistenceType() == PersistenceType.CONTAINER) {
      if (cmpVersion != null && cmpVersion == CmpVersion.CMP1) {
        bean.cmpVersion = 1;
      } else {
        bean.cmpVersion = 2;
      }
    }

    final List<CmpField> cmpFields = e.getCmpField();
    for (final CmpField cmpField : cmpFields) {
      bean.cmpFieldNames.add(cmpField.getFieldName());
    }

    if (bean.persistenceType.equalsIgnoreCase("Container")) {
      for (final Query q : e.getQuery()) {
        final QueryInfo query = new QueryInfo();
        query.queryStatement = q.getEjbQl().trim();

        final MethodInfo method = new MethodInfo();
        method.ejbName = bean.ejbName;
        method.className = "*";

        final QueryMethod qm = q.getQueryMethod();
        method.methodName = qm.getMethodName();
        if (qm.getMethodParams() != null) {
          method.methodParams = qm.getMethodParams().getMethodParam();
        }
        query.method = method;
        final ResultTypeMapping resultType = q.getResultTypeMapping();
        if (ResultTypeMapping.REMOTE.equals(resultType)) {
          query.remoteResultType = true;
        }
        bean.queries.add(query);
      }

      for (final org.apache.openejb.jee.oejb3.Query q : d.getQuery()) {
        final QueryInfo query = new QueryInfo();
        query.description = q.getDescription();
        query.queryStatement = q.getObjectQl().trim();

        final MethodInfo method = new MethodInfo();
        method.ejbName = bean.ejbName;
        method.className = "*";
        final org.apache.openejb.jee.oejb3.QueryMethod qm = q.getQueryMethod();
        method.methodName = qm.getMethodName();
        if (qm.getMethodParams() != null) {
          method.methodParams = qm.getMethodParams().getMethodParam();
        }
        query.method = method;
        bean.queries.add(query);
      }
    }
    return bean;
  }
Example #3
0
  private EnterpriseBeanInfo initSessionBean(
      final SessionBean s, final EjbJarInfo ejbJar, final Map m) throws OpenEJBException {
    EnterpriseBeanInfo bean = null;

    if (s.getSessionType() == SessionType.STATEFUL) {
      bean = new StatefulBeanInfo();
      bean.passivable = s.getPassivationCapable();
      final StatefulBeanInfo stateful = (StatefulBeanInfo) bean;

      copyCallbacks(s.getPostActivate(), stateful.postActivate);
      copyCallbacks(s.getPrePassivate(), stateful.prePassivate);

      copyCallbacks(s.getAfterBegin(), stateful.afterBegin);
      copyCallbacks(s.getBeforeCompletion(), stateful.beforeCompletion);
      copyCallbacks(s.getAfterCompletion(), stateful.afterCompletion);

      for (final InitMethod initMethod : s.getInitMethod()) {
        final InitMethodInfo init = new InitMethodInfo();
        init.beanMethod = toInfo(initMethod.getBeanMethod());
        init.createMethod = toInfo(initMethod.getCreateMethod());
        stateful.initMethods.add(init);
      }

      for (final RemoveMethod removeMethod : s.getRemoveMethod()) {
        final RemoveMethodInfo remove = new RemoveMethodInfo();
        remove.beanMethod = toInfo(removeMethod.getBeanMethod());
        remove.retainIfException = removeMethod.getRetainIfException();
        stateful.removeMethods.add(remove);
      }

      copyConcurrentMethods(s, ejbJar, m);

    } else if (s.getSessionType() == SessionType.MANAGED) {
      bean = new ManagedBeanInfo();
      final ManagedBeanInfo managed = (ManagedBeanInfo) bean;
      if (s
          instanceof
          ManagedBean) { // this way we support managed beans in ejb-jar.xml (not in the spec but
        // can be useful)
        managed.hidden = ((ManagedBean) s).isHidden();
      } else {
        managed.hidden = true;
      }

      copyCallbacks(s.getPostActivate(), managed.postActivate);
      copyCallbacks(s.getPrePassivate(), managed.prePassivate);

      for (final RemoveMethod removeMethod : s.getRemoveMethod()) {
        final RemoveMethodInfo remove = new RemoveMethodInfo();
        remove.beanMethod = toInfo(removeMethod.getBeanMethod());
        remove.retainIfException = removeMethod.getRetainIfException();
        managed.removeMethods.add(remove);
      }

    } else if (s.getSessionType() == SessionType.SINGLETON) {
      bean = new SingletonBeanInfo();
      final ConcurrencyManagementType type = s.getConcurrencyManagementType();
      bean.concurrencyType =
          type != null ? type.toString() : ConcurrencyManagementType.CONTAINER.toString();
      bean.loadOnStartup = s.getInitOnStartup();

      copyCallbacks(s.getAroundTimeout(), bean.aroundTimeout);
      copySchedules(s.getTimer(), bean.methodScheduleInfos);
      // See JndiEncInfoBuilder.buildDependsOnRefs for processing of DependsOn
      // bean.dependsOn.addAll(s.getDependsOn());

      copyConcurrentMethods(s, ejbJar, m);
    } else {
      bean = new StatelessBeanInfo();
      copySchedules(s.getTimer(), bean.methodScheduleInfos);
    }

    if (s.getSessionType() != SessionType.STATEFUL) {
      copyCallbacks(s.getAroundTimeout(), bean.aroundTimeout);
    }

    bean.localbean = s.getLocalBean() != null;

    bean.timeoutMethod = toInfo(s.getTimeoutMethod());

    copyCallbacks(s.getAroundInvoke(), bean.aroundInvoke);
    copyCallbacks(s.getPostConstruct(), bean.postConstruct);
    copyCallbacks(s.getPreDestroy(), bean.preDestroy);

    copyAsynchronous(s.getAsyncMethod(), bean.asynchronous);
    bean.asynchronousClasses.addAll(s.getAsynchronousClasses());

    final EjbDeployment d = (EjbDeployment) m.get(s.getEjbName());
    if (d == null) {
      throw new OpenEJBException(
          "No deployment information in openejb-jar.xml for bean "
              + s.getEjbName()
              + ". Please redeploy the jar");
    }
    bean.ejbDeploymentId = d.getDeploymentId();
    bean.containerId = d.getContainerId();

    final Icon icon = s.getIcon();
    bean.largeIcon = icon == null ? null : icon.getLargeIcon();
    bean.smallIcon = icon == null ? null : icon.getSmallIcon();
    bean.description = s.getDescription();
    bean.displayName = s.getDisplayName();
    bean.ejbClass = s.getEjbClass();
    bean.ejbName = s.getEjbName();
    bean.home = s.getHome();
    bean.remote = s.getRemote();
    bean.localHome = s.getLocalHome();
    bean.local = s.getLocal();
    bean.proxy = s.getProxy();
    bean.parents.addAll(s.getParents());
    bean.businessLocal.addAll(s.getBusinessLocal());
    bean.businessRemote.addAll(s.getBusinessRemote());
    final TransactionType txType = s.getTransactionType();
    bean.transactionType =
        txType != null ? txType.toString() : TransactionType.CONTAINER.toString();
    bean.serviceEndpoint = s.getServiceEndpoint();
    bean.properties.putAll(d.getProperties());

    bean.statefulTimeout = toInfo(s.getStatefulTimeout());

    bean.restService = s.isRestService() && !(s instanceof StatefulBean);

    return bean;
  }