Search in sources :

Example 1 with ResourceEnvRef$JAXB.writeResourceEnvRef

use of org.apache.openejb.jee.ResourceEnvRef$JAXB.writeResourceEnvRef in project tomee by apache.

the class BuiltInEnvironmentEntries method add.

private void add(final JndiConsumer jndi, final DeploymentModule module, final DeploymentModule app, final boolean defaults) {
    // Standard names
    add(jndi.getEnvEntryMap(), new EnvEntry().name("java:module/ModuleName").value(module.getModuleId()).type(String.class));
    add(jndi.getEnvEntryMap(), new EnvEntry().name("java:app/AppName").value(app.getModuleId()).type(String.class));
    // Standard References to built-in objects
    add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/BeanManager").type(BeanManager.class));
    add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/Validator").type(Validator.class));
    add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/ValidatorFactory").type(ValidatorFactory.class));
    add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/TransactionManager").type(TransactionManager.class));
    add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/TransactionSynchronizationRegistry").type(TransactionSynchronizationRegistry.class));
    if (defaults) {
        add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/DefaultManagedExecutorService").type(ManagedExecutorService.class));
        add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/DefaultManagedScheduledExecutorService").type(ManagedScheduledExecutorService.class));
        add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/DefaultManagedThreadFactory").type(ManagedThreadFactory.class));
        add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/DefaultContextService").type(ContextService.class));
        try {
            final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
            contextClassLoader.loadClass("org.apache.activemq.ActiveMQSslConnectionFactory");
            final ResourceEnvRef ref = new ResourceEnvRef().name("java:comp/DefaultJMSConnectionFactory").type(contextClassLoader.loadClass("javax.jms.ConnectionFactory"));
            add(jndi.getResourceEnvRefMap(), ref);
        } catch (final ClassNotFoundException | NoClassDefFoundError notThere) {
        // no-op
        }
    }
    // OpenEJB specific feature
    add(jndi.getEnvEntryMap(), new EnvEntry().name("java:comp/ComponentName").value(jndi.getJndiConsumerName()).type(String.class));
}
Also used : ContextService(javax.enterprise.concurrent.ContextService) ValidatorFactory(javax.validation.ValidatorFactory) ManagedThreadFactory(javax.enterprise.concurrent.ManagedThreadFactory) ManagedExecutorService(javax.enterprise.concurrent.ManagedExecutorService) TransactionManager(javax.transaction.TransactionManager) TransactionSynchronizationRegistry(javax.transaction.TransactionSynchronizationRegistry) BeanManager(javax.enterprise.inject.spi.BeanManager) ResourceEnvRef(org.apache.openejb.jee.ResourceEnvRef) Validator(javax.validation.Validator) ManagedScheduledExecutorService(javax.enterprise.concurrent.ManagedScheduledExecutorService) EnvEntry(org.apache.openejb.jee.EnvEntry)

Example 2 with ResourceEnvRef$JAXB.writeResourceEnvRef

use of org.apache.openejb.jee.ResourceEnvRef$JAXB.writeResourceEnvRef in project tomee by apache.

the class ApplyOpenejbJar method deploy.

public AppModule deploy(final AppModule appModule) throws OpenEJBException {
    for (final EjbModule ejbModule : appModule.getEjbModules()) {
        final Map<String, EjbDeployment> ejbDeployments = ejbModule.getOpenejbJar().getDeploymentsByEjbName();
        for (final EnterpriseBean enterpriseBean : ejbModule.getEjbJar().getEnterpriseBeans()) {
            // Get the OpenEJB deployment from openejb-jar.xml
            final EjbDeployment ejbDeployment = ejbDeployments.get(enterpriseBean.getEjbName());
            enterpriseBean.setId(ejbDeployment.getDeploymentId());
            for (final ResourceRef ref : enterpriseBean.getResourceRef()) {
                final ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
                if (resourceLink != null && resourceLink.getResId() != null) /* don't overwrite with null */
                {
                    ref.setMappedName(resourceLink.getResId());
                }
            }
            for (final ResourceEnvRef ref : enterpriseBean.getResourceEnvRef()) {
                final ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
                if (resourceLink != null && resourceLink.getResId() != null) /* don't overwrite with null */
                {
                    ref.setMappedName(resourceLink.getResId());
                }
            }
            for (final MessageDestinationRef ref : enterpriseBean.getMessageDestinationRef()) {
                final ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
                if (resourceLink != null && resourceLink.getResId() != null) /* don't overwrite with null */
                {
                    ref.setMappedName(resourceLink.getResId());
                }
            }
            for (final EjbRef ref : enterpriseBean.getEjbRef()) {
                final EjbLink ejbLink = ejbDeployment.getEjbLink(ref.getName());
                if (ejbLink != null && ejbLink.getDeployentId() != null) /* don't overwrite with null */
                {
                    ref.setMappedName(ejbLink.getDeployentId());
                }
            }
            for (final EjbLocalRef ref : enterpriseBean.getEjbLocalRef()) {
                final EjbLink ejbLink = ejbDeployment.getEjbLink(ref.getName());
                if (ejbLink != null && ejbLink.getDeployentId() != null) /* don't overwrite with null */
                {
                    ref.setMappedName(ejbLink.getDeployentId());
                }
            }
        }
    }
    return appModule;
}
Also used : EjbLocalRef(org.apache.openejb.jee.EjbLocalRef) MessageDestinationRef(org.apache.openejb.jee.MessageDestinationRef) EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) ResourceLink(org.apache.openejb.jee.oejb3.ResourceLink) EjbRef(org.apache.openejb.jee.EjbRef) EjbDeployment(org.apache.openejb.jee.oejb3.EjbDeployment) ResourceRef(org.apache.openejb.jee.ResourceRef) ResourceEnvRef(org.apache.openejb.jee.ResourceEnvRef) EjbLink(org.apache.openejb.jee.oejb3.EjbLink)

Example 3 with ResourceEnvRef$JAXB.writeResourceEnvRef

use of org.apache.openejb.jee.ResourceEnvRef$JAXB.writeResourceEnvRef in project tomee by apache.

the class DebuggableVmHackery method pruneRefs.

private void pruneRefs(final JndiConsumer bean, final EjbDeployment ejbDeployment) {
    for (final ResourceRef ref : copy(bean.getResourceRef())) {
        if (ref.getResType().startsWith("javax.jms.")) {
            final ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
            ejbDeployment.getResourceLink().remove(resourceLink);
            bean.getResourceRef().remove(ref);
        }
    }
    for (final ResourceEnvRef ref : bean.getResourceEnvRef()) {
        final ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
        ejbDeployment.getResourceLink().remove(resourceLink);
    }
    bean.getResourceEnvRef().clear();
    for (final MessageDestinationRef ref : bean.getMessageDestinationRef()) {
        final ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
        ejbDeployment.getResourceLink().remove(resourceLink);
    }
    bean.getMessageDestinationRef().clear();
    bean.getPersistenceContextRef().clear();
    bean.getPersistenceUnitRef().clear();
}
Also used : MessageDestinationRef(org.apache.openejb.jee.MessageDestinationRef) ResourceLink(org.apache.openejb.jee.oejb3.ResourceLink) ResourceRef(org.apache.openejb.jee.ResourceRef) ResourceEnvRef(org.apache.openejb.jee.ResourceEnvRef)

Example 4 with ResourceEnvRef$JAXB.writeResourceEnvRef

use of org.apache.openejb.jee.ResourceEnvRef$JAXB.writeResourceEnvRef in project tomee by apache.

the class GeronimoMappedName method mapReferences.

private void mapReferences(final EjbJar ejbJar) {
    if (ejbJar == null) {
        return;
    }
    for (final EnterpriseBean enterpriseBean : ejbJar.getEnterpriseBeans()) {
        for (final EjbRef ref : enterpriseBean.getEjbRef()) {
            // remap only corba references
            final String mappedName = ref.getMappedName();
            if (mappedName != null && (mappedName.startsWith("jndi:corbaloc") || mappedName.startsWith("jndi:corbaname"))) {
                final String refName = ref.getEjbRefName();
                ref.setMappedName(MAPPED_NAME_PREFIX + refName);
            }
            if (null == mappedName && ref.getEjbRefName().equals("ejb/MEJB")) {
                ref.setMappedName("mejb/ejb/mgmt/MEJB");
            }
        }
        for (final MessageDestinationRef ref : enterpriseBean.getMessageDestinationRef()) {
            final String refName = ref.getMessageDestinationRefName();
            ref.setMappedName(MAPPED_NAME_PREFIX + refName);
        }
        for (final PersistenceContextRef ref : enterpriseBean.getPersistenceContextRef()) {
            final String refName = ref.getPersistenceContextRefName();
            ref.setMappedName(MAPPED_NAME_PREFIX + refName);
        }
        for (final PersistenceUnitRef ref : enterpriseBean.getPersistenceUnitRef()) {
            final String refName = ref.getPersistenceUnitRefName();
            ref.setMappedName(MAPPED_NAME_PREFIX + refName);
        }
        for (final ResourceRef ref : enterpriseBean.getResourceRef()) {
            final String refName = ref.getResRefName();
            ref.setMappedName(MAPPED_NAME_PREFIX + refName);
        }
        for (final ResourceEnvRef ref : enterpriseBean.getResourceEnvRef()) {
            final String refName = ref.getResourceEnvRefName();
            ref.setMappedName(MAPPED_NAME_PREFIX + refName);
        }
        for (final ServiceRef ref : enterpriseBean.getServiceRef()) {
            final String refName = ref.getServiceRefName();
            ref.setMappedName(MAPPED_NAME_PREFIX + refName);
        }
    }
}
Also used : MessageDestinationRef(org.apache.openejb.jee.MessageDestinationRef) EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) EjbRef(org.apache.openejb.jee.EjbRef) PersistenceContextRef(org.apache.openejb.jee.PersistenceContextRef) ResourceRef(org.apache.openejb.jee.ResourceRef) ServiceRef(org.apache.openejb.jee.ServiceRef) PersistenceUnitRef(org.apache.openejb.jee.PersistenceUnitRef) ResourceEnvRef(org.apache.openejb.jee.ResourceEnvRef)

Example 5 with ResourceEnvRef$JAXB.writeResourceEnvRef

use of org.apache.openejb.jee.ResourceEnvRef$JAXB.writeResourceEnvRef in project tomee by apache.

the class LegacyProcessor method process.

public static void process(final Class<?> clazz, final EnterpriseBean bean) {
    if (bean instanceof SessionBean) {
        final SessionBean sessionBean = (SessionBean) bean;
        if (sessionBean.getSessionType() == STATEFUL && SessionSynchronization.class.isAssignableFrom(clazz)) {
            try {
                sessionBean.getAfterBegin().add(new LifecycleCallback(clazz.getMethod("afterBegin")));
                sessionBean.getBeforeCompletion().add(new LifecycleCallback(clazz.getMethod("beforeCompletion")));
                sessionBean.getAfterCompletion().add(new LifecycleCallback(clazz.getMethod("afterCompletion", boolean.class)));
            } catch (final NoSuchMethodException e) {
            // Ignore, should never happen
            }
        }
        if (javax.ejb.SessionBean.class.isAssignableFrom(clazz)) {
            final ResourceEnvRef ref = new ResourceEnvRef("javax.ejb.SessionBean/sessionContext", SessionContext.class);
            final InjectionTarget target = new InjectionTarget();
            target.setInjectionTargetClass(clazz);
            target.setInjectionTargetName("sessionContext");
            ref.getInjectionTarget().add(target);
            sessionBean.getResourceEnvRef().add(ref);
        }
    }
    if (bean instanceof MessageDrivenBean) {
        final MessageDrivenBean messageDrivenBean = (MessageDrivenBean) bean;
        if (javax.ejb.MessageDrivenBean.class.isAssignableFrom(clazz)) {
            final ResourceEnvRef ref = new ResourceEnvRef("javax.ejb.MessageDrivenBean/messageDrivenContext", MessageDrivenContext.class);
            final InjectionTarget target = new InjectionTarget();
            target.setInjectionTargetClass(clazz);
            target.setInjectionTargetName("messageDrivenContext");
            ref.getInjectionTarget().add(target);
            messageDrivenBean.getResourceEnvRef().add(ref);
        }
    }
}
Also used : SessionSynchronization(javax.ejb.SessionSynchronization) MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) InjectionTarget(org.apache.openejb.jee.InjectionTarget) LifecycleCallback(org.apache.openejb.jee.LifecycleCallback) SessionBean(org.apache.openejb.jee.SessionBean) ResourceEnvRef(org.apache.openejb.jee.ResourceEnvRef)

Aggregations

DataSource$JAXB.readDataSource (org.apache.openejb.jee.DataSource$JAXB.readDataSource)14 DataSource$JAXB.writeDataSource (org.apache.openejb.jee.DataSource$JAXB.writeDataSource)14 EjbLocalRef$JAXB.readEjbLocalRef (org.apache.openejb.jee.EjbLocalRef$JAXB.readEjbLocalRef)14 EjbLocalRef$JAXB.writeEjbLocalRef (org.apache.openejb.jee.EjbLocalRef$JAXB.writeEjbLocalRef)14 EjbRef$JAXB.readEjbRef (org.apache.openejb.jee.EjbRef$JAXB.readEjbRef)14 EjbRef$JAXB.writeEjbRef (org.apache.openejb.jee.EjbRef$JAXB.writeEjbRef)14 EnvEntry$JAXB.readEnvEntry (org.apache.openejb.jee.EnvEntry$JAXB.readEnvEntry)14 EnvEntry$JAXB.writeEnvEntry (org.apache.openejb.jee.EnvEntry$JAXB.writeEnvEntry)14 MessageDestinationRef$JAXB.readMessageDestinationRef (org.apache.openejb.jee.MessageDestinationRef$JAXB.readMessageDestinationRef)14 MessageDestinationRef$JAXB.writeMessageDestinationRef (org.apache.openejb.jee.MessageDestinationRef$JAXB.writeMessageDestinationRef)14 PersistenceContextRef$JAXB.readPersistenceContextRef (org.apache.openejb.jee.PersistenceContextRef$JAXB.readPersistenceContextRef)14 PersistenceContextRef$JAXB.writePersistenceContextRef (org.apache.openejb.jee.PersistenceContextRef$JAXB.writePersistenceContextRef)14 PersistenceUnitRef$JAXB.readPersistenceUnitRef (org.apache.openejb.jee.PersistenceUnitRef$JAXB.readPersistenceUnitRef)14 PersistenceUnitRef$JAXB.writePersistenceUnitRef (org.apache.openejb.jee.PersistenceUnitRef$JAXB.writePersistenceUnitRef)14 ResourceEnvRef$JAXB.readResourceEnvRef (org.apache.openejb.jee.ResourceEnvRef$JAXB.readResourceEnvRef)14 ResourceEnvRef$JAXB.writeResourceEnvRef (org.apache.openejb.jee.ResourceEnvRef$JAXB.writeResourceEnvRef)14 ResourceRef$JAXB.readResourceRef (org.apache.openejb.jee.ResourceRef$JAXB.readResourceRef)14 ResourceRef$JAXB.writeResourceRef (org.apache.openejb.jee.ResourceRef$JAXB.writeResourceRef)14 ServiceRef$JAXB.readServiceRef (org.apache.openejb.jee.ServiceRef$JAXB.readServiceRef)14 ServiceRef$JAXB.writeServiceRef (org.apache.openejb.jee.ServiceRef$JAXB.writeServiceRef)14