Search in sources :

Example 1 with EnvEntry$JAXB.readEnvEntry

use of org.apache.openejb.jee.EnvEntry$JAXB.readEnvEntry in project tomee by apache.

the class JndiEncInfoBuilder method buildEnvEntryInfos.

private void buildEnvEntryInfos(final JndiConsumer item, final JndiEncInfo moduleJndiEnc, final JndiEncInfo compJndiEnc) {
    for (final EnvEntry env : item.getEnvEntry()) {
        // If the the reference name of the environment entry is belong to those shareable JNDI name space, it somewhat is a valid one
        if (env.getEnvEntryValue() == null && env.getLookupName() == null && !isShareableJNDINamespace(env.getEnvEntryName()) && !CompManagedBean.class.isInstance(item)) /* in this case we can desire to contextually lookup webapp value from an ear lib */
        {
            continue;
        }
        final EnvEntryInfo info = new EnvEntryInfo();
        info.referenceName = env.getEnvEntryName();
        info.type = env.getEnvEntryType();
        info.value = env.getEnvEntryValue();
        info.location = buildLocationInfo(env);
        info.targets.addAll(buildInjectionInfos(env));
        insert(info, appInfo.globalJndiEnc.envEntries, appInfo.appJndiEnc.envEntries, moduleJndiEnc.envEntries, compJndiEnc.envEntries);
    }
}
Also used : EnvEntryInfo(org.apache.openejb.assembler.classic.EnvEntryInfo) EnvEntry(org.apache.openejb.jee.EnvEntry)

Example 2 with EnvEntry$JAXB.readEnvEntry

use of org.apache.openejb.jee.EnvEntry$JAXB.readEnvEntry in project tomee by apache.

the class MergeWebappJndiContext method copy.

private <R extends JndiReference> void copy(final Map<String, R> from, final Map<String, R> to) {
    for (final R a : from.values()) {
        if (isPrivateReference(a)) {
            continue;
        }
        final R b = to.get(a.getKey());
        // New entry
        if (b == null) {
            if (!isExtendedPersistenceContext(a)) {
                to.put(a.getKey(), a);
            }
            continue;
        }
        // Update existing entry
        // merge injection points
        b.getInjectionTarget().addAll(a.getInjectionTarget());
        // merge env-entry values
        if (b instanceof EnvEntry && a instanceof EnvEntry) {
            final EnvEntry eb = (EnvEntry) b;
            final EnvEntry ea = (EnvEntry) a;
            if (eb.getEnvEntryValue() == null) {
                eb.setEnvEntryValue(ea.getEnvEntryValue());
            }
            if (eb.getEnvEntryType() == null) {
                eb.setEnvEntryType(ea.getEnvEntryType());
            }
        }
    }
}
Also used : EnvEntry(org.apache.openejb.jee.EnvEntry)

Example 3 with EnvEntry$JAXB.readEnvEntry

use of org.apache.openejb.jee.EnvEntry$JAXB.readEnvEntry in project tomee by apache.

the class EnvEntriesPropertiesDeployer method deploy.

public WebModule deploy(final WebModule webModule) {
    for (final Map.Entry<String, String> entry : getEnvEntries(webModule).entrySet()) {
        final EnvEntry envEntry = new EnvEntry(entry.getKey(), "java.lang.String", entry.getValue());
        apply(webModule.getWebApp(), envEntry, "WebApp");
    }
    return webModule;
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) EnvEntry(org.apache.openejb.jee.EnvEntry)

Example 4 with EnvEntry$JAXB.readEnvEntry

use of org.apache.openejb.jee.EnvEntry$JAXB.readEnvEntry in project tomee by apache.

the class EnvEntriesPropertiesDeployer method deploy.

public AppModule deploy(final AppModule appModule) throws OpenEJBException {
    // ApplicationClient META-INF/env-entries.properties
    for (final ClientModule module : appModule.getClientModules()) {
        if (module.getApplicationClient() == null) {
            continue;
        }
        for (final Map.Entry<String, String> entry : getEnvEntries(module).entrySet()) {
            final EnvEntry envEntry = new EnvEntry(entry.getKey(), "java.lang.String", entry.getValue());
            apply(module.getApplicationClient(), envEntry, "AppClient");
        }
    }
    // WebModule META-INF/env-entries.properties
    for (final WebModule webModule : appModule.getWebModules()) {
        deploy(webModule);
    }
    // EjbJar META-INF/env-entries.properties
    for (final EjbModule module : appModule.getEjbModules()) {
        for (final Map.Entry<String, String> entry : getEnvEntries(module).entrySet()) {
            final EnvEntry envEntry = new EnvEntry(entry.getKey(), "java.lang.String", entry.getValue());
            // <ejb-name>.name = value
            if (envEntry.getName().contains(".")) {
                String name = envEntry.getName();
                final String ejbName = name.substring(0, name.indexOf('.'));
                name = name.substring(name.indexOf('.') + 1);
                final EnterpriseBean bean = module.getEjbJar().getEnterpriseBean(ejbName);
                if (bean != null) {
                    // Set the new property name without the <ejb-name>. prefix
                    envEntry.setName(name);
                    apply(bean, envEntry, bean.getEjbName());
                    continue;
                }
            }
            for (final EnterpriseBean bean : module.getEjbJar().getEnterpriseBeans()) {
                apply(bean, envEntry, bean.getEjbName());
            }
        }
    }
    return appModule;
}
Also used : EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) HashMap(java.util.HashMap) Map(java.util.Map) EnvEntry(org.apache.openejb.jee.EnvEntry)

Example 5 with EnvEntry$JAXB.readEnvEntry

use of org.apache.openejb.jee.EnvEntry$JAXB.readEnvEntry 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)

Aggregations

EnvEntry (org.apache.openejb.jee.EnvEntry)19 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