List of usage examples for javax.naming InitialContext listBindings
public NamingEnumeration<Binding> listBindings(Name name) throws NamingException
From source file:de.micromata.genome.util.runtime.jndi.JndiDumper.java
public static void dumpJndi(StringBuilder sb, String indent) throws NamingException { InitialContext initialContext = new InitialContext(); NamingEnumeration<Binding> bindings = initialContext.listBindings(""); while (bindings.hasMore()) { Binding binding = bindings.next(); dumpJndiBinding(initialContext, "", binding, sb, indent); }//from w w w. j a va 2s . c o m bindings = initialContext.listBindings("java:comp"); while (bindings.hasMore()) { Binding binding = bindings.next(); dumpJndiBinding(initialContext, "java:comp", binding, sb, indent); } }
From source file:de.griffel.confluence.plugins.plantuml.DatasourceHelper.java
/** * Determines data sources configured in Tomcat. * * @return List of data source names/*ww w. j a va 2s . c om*/ */ public static List<String> listAvailableDataSources() { final List<String> results = new LinkedList<String>(); // Workaround for classloader problems, see https://answers.atlassian.com/questions/6374/how-do-i-access-jndi-from-a-version-2-osgi-plugin final ClassLoader origCL = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(ComponentManager.class.getClassLoader()); final InitialContext jndiContext = new InitialContext(); final NamingEnumeration<Binding> bindings = jndiContext.listBindings(JDBC_CONTEXT); while (bindings != null && bindings.hasMore()) { results.add(bindings.next().getName()); } } catch (NamingException e) { log.debug("NamingException listBindings", e); results.add(e.toString()); } finally { Thread.currentThread().setContextClassLoader(origCL); } return results; }
From source file:org.eclipse.ecr.core.storage.sql.reload.RepositoryReloader.java
public static List<Repository> getRepositories() throws NamingException { List<Repository> list = new LinkedList<Repository>(); InitialContext context = new InitialContext(); // we search both JBoss-like and Glassfish-like prefixes // @see NXCore#getRepository for (String prefix : new String[] { "java:NXRepository", "NXRepository" }) { NamingEnumeration<Binding> bindings; try {//from w ww . ja v a2 s . com bindings = context.listBindings(prefix); } catch (NamingException e) { continue; } for (NamingEnumeration<Binding> e = bindings; e.hasMore();) { Binding binding = e.nextElement(); String name = binding.getName(); if (binding.isRelative()) { name = prefix + '/' + name; } Object object = context.lookup(name); if (!(object instanceof Repository)) { continue; } list.add((Repository) object); } } return list; }
From source file:org.nuxeo.ecm.core.storage.sql.management.RepositoryStatus.java
protected List<RepositoryManagement> getRepositories() throws NamingException { List<RepositoryManagement> list = new LinkedList<RepositoryManagement>(); InitialContext context; ClassLoader cl = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(RepositoryStatus.class.getClassLoader()); try {//w w w . ja v a 2 s . com context = new InitialContext(); } finally { Thread.currentThread().setContextClassLoader(cl); } // we search both JBoss-like and Glassfish-like prefixes // @see NXCore#getRepository for (String prefix : new String[] { "java:NXRepository", "NXRepository" }) { NamingEnumeration<Binding> bindings; try { bindings = context.listBindings(prefix); } catch (NamingException e) { continue; } NamingEnumeration<Binding> e = null; try { for (e = bindings; e.hasMore();) { Binding binding = e.nextElement(); String name = binding.getName(); if (binding.isRelative()) { name = prefix + '/' + name; } Object object = context.lookup(name); if (!(object instanceof RepositoryManagement)) { continue; } list.add((RepositoryManagement) object); } } finally { if (e != null) { e.close(); } } } if (list.size() == 0) { List<Repository> repos = RepositoryResolver.getRepositories(); for (Repository repo : repos) { list.add(repo); } } return list; }
From source file:org.nuxeo.ecm.core.storage.sql.reload.RepositoryReloader.java
public static List<Repository> getRepositories() throws NamingException { List<Repository> list = new LinkedList<Repository>(); InitialContext context = new InitialContext(); // we search both JBoss-like and Glassfish-like prefixes // @see NXCore#getRepository for (String prefix : new String[] { "java:NXRepository", "NXRepository" }) { NamingEnumeration<Binding> bindings; try {// www . j a v a2s . co m bindings = context.listBindings(prefix); } catch (NamingException e) { continue; } NamingEnumeration<Binding> e = null; try { for (e = bindings; e.hasMore();) { Binding binding = e.nextElement(); String name = binding.getName(); if (binding.isRelative()) { name = prefix + '/' + name; } Object object = context.lookup(name); if (!(object instanceof Repository)) { continue; } list.add((Repository) object); } } finally { if (e != null) { e.close(); } } } return list; }