use of org.apache.openejb.jee.EnvEntry 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);
}
}
use of org.apache.openejb.jee.EnvEntry 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());
}
}
}
}
use of org.apache.openejb.jee.EnvEntry 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;
}
use of org.apache.openejb.jee.EnvEntry 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;
}
use of org.apache.openejb.jee.EnvEntry 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));
}
Aggregations