List of usage examples for javax.naming Binding isRelative
public boolean isRelative()
list()
method). 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 w w .j a v a 2 s. c o m 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;/* w ww. j a v a 2 s.c o m*/ ClassLoader cl = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(RepositoryStatus.class.getClassLoader()); try { 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 {/*from ww w . ja va 2s . c om*/ 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; }