private MessageDrivenBean createJaxbMdb(
      String ejbName, String mdbClass, String messageListenerInterface) {
    MessageDrivenBean bean = new MessageDrivenBean(ejbName);
    bean.setEjbClass(mdbClass);
    bean.setMessagingType(messageListenerInterface);

    ActivationConfig activationConfig = new ActivationConfig();
    activationConfig
        .getActivationConfigProperty()
        .add(new ActivationConfigProperty("destination", ejbName));
    activationConfig
        .getActivationConfigProperty()
        .add(new ActivationConfigProperty("destinationType", "javax.jms.Queue"));
    bean.setActivationConfig(activationConfig);

    return bean;
  }
Пример #2
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;
  }