use of javax.naming.Context in project spring-framework by spring-projects.
the class SimpleNamingContext method createSubcontext.
@Override
public Context createSubcontext(String name) {
String subcontextName = this.root + name;
if (!subcontextName.endsWith("/")) {
subcontextName += "/";
}
Context subcontext = new SimpleNamingContext(subcontextName, this.boundObjects, this.environment);
bind(name, subcontext);
return subcontext;
}
use of javax.naming.Context in project spring-framework by spring-projects.
the class JmsTemplateTests method createTemplate.
private JmsTemplate createTemplate() {
JmsTemplate template = new JmsTemplate();
JndiDestinationResolver destMan = new JndiDestinationResolver();
destMan.setJndiTemplate(new JndiTemplate() {
@Override
protected Context createInitialContext() {
return jndiContext;
}
});
template.setDestinationResolver(destMan);
template.setSessionTransacted(useTransactedTemplate());
return template;
}
use of javax.naming.Context in project spring-framework by spring-projects.
the class SimpleNamingContext method createSubcontext.
@Override
public Context createSubcontext(String name) {
String subcontextName = this.root + name;
if (!subcontextName.endsWith("/")) {
subcontextName += "/";
}
Context subcontext = new SimpleNamingContext(subcontextName, this.boundObjects, this.environment);
bind(name, subcontext);
return subcontext;
}
use of javax.naming.Context in project liquibase by liquibase.
the class MultiTenantSpringLiquibase method resolveDataSources.
private void resolveDataSources() throws NamingException {
Context context = new InitialContext();
int lastIndexOf = jndiBase.lastIndexOf("/");
String jndiRoot = jndiBase.substring(0, lastIndexOf);
String jndiParent = jndiBase.substring(lastIndexOf + 1);
Context base = (Context) context.lookup(jndiRoot);
NamingEnumeration<NameClassPair> list = base.list(jndiParent);
while (list.hasMoreElements()) {
NameClassPair entry = list.nextElement();
String name = entry.getName();
String jndiUrl;
if (entry.isRelative()) {
jndiUrl = jndiBase + "/" + name;
} else {
jndiUrl = name;
}
Object lookup = context.lookup(jndiUrl);
if (lookup instanceof DataSource) {
dataSources.add((DataSource) lookup);
log.debug("Added a data source at " + jndiUrl);
} else {
log.info("Skipping a resource " + jndiUrl + " not compatible with DataSource.");
}
}
}
use of javax.naming.Context in project gitblit by gitblit.
the class GitblitContext method lookupBaseFolderFromJndi.
private String lookupBaseFolderFromJndi() {
try {
// try to lookup JNDI env-entry for the baseFolder
InitialContext ic = new InitialContext();
Context env = (Context) ic.lookup("java:comp/env");
return (String) env.lookup("baseFolder");
} catch (NamingException n) {
logger.error("Failed to get JNDI env-entry: " + n.getExplanation());
}
return null;
}
Aggregations