use of org.apache.openejb.jee.EnvEntry$JAXB.writeEnvEntry 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$JAXB.writeEnvEntry 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$JAXB.writeEnvEntry in project tomee by apache.
the class StatelessConstructorInjectionTest method setUp.
protected void setUp() throws Exception {
super.setUp();
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
// containers
final StatelessSessionContainerInfo statelessContainerInfo = config.configureService(StatelessSessionContainerInfo.class);
assembler.createContainer(statelessContainerInfo);
// Setup the descriptor information
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(FooBean.class));
final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
bean.getEnvEntry().add(new EnvEntry("count", Integer.class.getName(), "10"));
assembler.createApplication(config.configureApplication(new EjbModule(ejbJar).withCdi()));
}
use of org.apache.openejb.jee.EnvEntry$JAXB.writeEnvEntry in project tomee by apache.
the class CleanEnvEntries method removeUnsetEnvEntries.
public AppModule removeUnsetEnvEntries(final AppModule appModule) throws OpenEJBException {
final Map<String, EnvEntry> appEnvEntryMap = getAppEnvEntryMap(appModule);
for (final ClientModule module : appModule.getClientModules()) {
final JndiConsumer consumer = module.getApplicationClient();
if (consumer == null) {
continue;
}
removeUnsetEnvEntries(appEnvEntryMap, consumer);
}
for (final WebModule module : appModule.getWebModules()) {
final JndiConsumer consumer = module.getWebApp();
if (consumer == null) {
continue;
}
removeUnsetEnvEntries(appEnvEntryMap, consumer);
}
for (final EjbModule module : appModule.getEjbModules()) {
final EjbJar ejbJar = module.getEjbJar();
if (ejbJar == null) {
continue;
}
for (final EnterpriseBean consumer : ejbJar.getEnterpriseBeans()) {
if (CompManagedBean.class.isInstance(consumer)) {
// unused can be used by CDI (ear lib using webapp contextual binding)
continue;
}
removeUnsetEnvEntries(appEnvEntryMap, consumer);
}
}
return appModule;
}
use of org.apache.openejb.jee.EnvEntry$JAXB.writeEnvEntry 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));
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