use of org.apache.tomcat.util.descriptor.web.ContextTransaction in project tomee by apache.
the class TomcatJndiBuilder method mergeJndi.
public void mergeJndi() throws OpenEJBException {
final NamingResourcesImpl naming = standardContext.getNamingResources();
final URI moduleUri = URLs.uri(webAppInfo.moduleId);
for (final EnvEntryInfo ref : webAppInfo.jndiEnc.envEntries) {
mergeRef(naming, ref);
}
for (final EjbReferenceInfo ref : webAppInfo.jndiEnc.ejbReferences) {
mergeRef(naming, ref);
}
for (final EjbLocalReferenceInfo ref : webAppInfo.jndiEnc.ejbLocalReferences) {
mergeRef(naming, ref);
}
for (final PersistenceContextReferenceInfo ref : webAppInfo.jndiEnc.persistenceContextRefs) {
mergeRef(naming, ref, moduleUri);
}
for (final PersistenceUnitReferenceInfo ref : webAppInfo.jndiEnc.persistenceUnitRefs) {
mergeRef(naming, ref, moduleUri);
}
for (final ResourceReferenceInfo ref : webAppInfo.jndiEnc.resourceRefs) {
mergeRef(naming, ref);
}
for (final ResourceEnvReferenceInfo ref : webAppInfo.jndiEnc.resourceEnvRefs) {
mergeRef(naming, ref);
}
for (final ServiceReferenceInfo ref : webAppInfo.jndiEnc.serviceRefs) {
mergeRef(naming, ref);
}
final ContextTransaction contextTransaction = new ContextTransaction();
contextTransaction.setProperty(Constants.FACTORY, UserTransactionFactory.class.getName());
naming.setTransaction(contextTransaction);
}
use of org.apache.tomcat.util.descriptor.web.ContextTransaction in project tomee by apache.
the class TomcatWebAppBuilder method configureStart.
@Override
public void configureStart(final LifecycleEvent event, final StandardContext standardContext) {
final ContextTransaction contextTransaction = new ContextTransaction();
contextTransaction.setProperty(org.apache.naming.factory.Constants.FACTORY, UserTransactionFactory.class.getName());
standardContext.getNamingResources().setTransaction(contextTransaction);
if (event != null) {
// ensure NamingContext is available for eager usage (@Observes @Initialized(ApplicationScoped) for instance)
standardContext.getNamingContextListener().lifecycleEvent(event);
}
TomcatHelper.configureJarScanner(standardContext);
startInternal(standardContext);
// clear a bit log for default case
addMyFacesDefaultParameters(standardContext.getLoader().getClassLoader(), standardContext.getServletContext());
// breaks cdi
standardContext.setTldValidation(Boolean.parseBoolean(SystemInstance.get().getProperty("tomee.tld.validation", "false")));
// breaks jstl
standardContext.setXmlValidation(Boolean.parseBoolean(SystemInstance.get().getProperty("tomee.xml.validation", "false")));
}
use of org.apache.tomcat.util.descriptor.web.ContextTransaction in project tomcat by apache.
the class NamingContextListener method createNamingContext.
/**
* Create and initialize the JNDI naming context.
*/
private void createNamingContext() throws NamingException {
// Creating the comp subcontext
if (container instanceof Server) {
compCtx = namingContext;
envCtx = namingContext;
} else {
compCtx = namingContext.createSubcontext("comp");
envCtx = compCtx.createSubcontext("env");
}
int i;
if (log.isDebugEnabled()) {
log.debug("Creating JNDI naming context");
}
if (namingResources == null) {
namingResources = new NamingResourcesImpl();
namingResources.setContainer(container);
}
// Resource links
ContextResourceLink[] resourceLinks = namingResources.findResourceLinks();
for (i = 0; i < resourceLinks.length; i++) {
addResourceLink(resourceLinks[i]);
}
// Resources
ContextResource[] resources = namingResources.findResources();
for (i = 0; i < resources.length; i++) {
addResource(resources[i]);
}
// Resources Env
ContextResourceEnvRef[] resourceEnvRefs = namingResources.findResourceEnvRefs();
for (i = 0; i < resourceEnvRefs.length; i++) {
addResourceEnvRef(resourceEnvRefs[i]);
}
// Environment entries
ContextEnvironment[] contextEnvironments = namingResources.findEnvironments();
for (i = 0; i < contextEnvironments.length; i++) {
addEnvironment(contextEnvironments[i]);
}
// EJB references
ContextEjb[] ejbs = namingResources.findEjbs();
for (i = 0; i < ejbs.length; i++) {
addEjb(ejbs[i]);
}
// Message Destination References
MessageDestinationRef[] mdrs = namingResources.findMessageDestinationRefs();
for (i = 0; i < mdrs.length; i++) {
addMessageDestinationRef(mdrs[i]);
}
// WebServices references
ContextService[] services = namingResources.findServices();
for (i = 0; i < services.length; i++) {
addService(services[i]);
}
// Binding a User Transaction reference
if (container instanceof Context) {
try {
Reference ref = new TransactionRef();
compCtx.bind("UserTransaction", ref);
ContextTransaction transaction = namingResources.getTransaction();
if (transaction != null) {
Iterator<String> params = transaction.listProperties();
while (params.hasNext()) {
String paramName = params.next();
String paramValue = (String) transaction.getProperty(paramName);
StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
ref.add(refAddr);
}
}
} catch (NameAlreadyBoundException e) {
// Ignore because UserTransaction was obviously
// added via ResourceLink
} catch (NamingException e) {
log.error(sm.getString("naming.bindFailed", e));
}
}
// Binding the resources directory context
if (container instanceof Context) {
try {
compCtx.bind("Resources", ((Context) container).getResources());
} catch (NamingException e) {
log.error(sm.getString("naming.bindFailed", e));
}
}
}
Aggregations