Java Code Examples for javax.naming.Binding#getName()

The following examples show how to use javax.naming.Binding#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApplicationContext.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * List resource paths (recursively), and store all of them in the given
 * Set.
 */
private static void listCollectionPaths(Set<String> set,
        DirContext resources, String path) throws NamingException {

    Enumeration<Binding> childPaths = resources.listBindings(path);
    while (childPaths.hasMoreElements()) {
        Binding binding = childPaths.nextElement();
        String name = binding.getName();
        StringBuilder childPath = new StringBuilder(path);
        if (!"/".equals(path) && !path.endsWith("/"))
            childPath.append("/");
        childPath.append(name);
        Object object = binding.getObject();
        if (object instanceof DirContext) {
            childPath.append("/");
        }
        set.add(childPath.toString());
    }

}
 
Example 2
Source File: ApplicationContext.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * List resource paths (recursively), and store all of them in the given
 * Set.
 */
private static void listCollectionPaths(Set<String> set,
        DirContext resources, String path) throws NamingException {

    Enumeration<Binding> childPaths = resources.listBindings(path);
    while (childPaths.hasMoreElements()) {
        Binding binding = childPaths.nextElement();
        String name = binding.getName();
        StringBuilder childPath = new StringBuilder(path);
        if (!"/".equals(path) && !path.endsWith("/"))
            childPath.append("/");
        childPath.append(name);
        Object object = binding.getObject();
        if (object instanceof DirContext) {
            childPath.append("/");
        }
        set.add(childPath.toString());
    }

}
 
Example 3
Source File: JndiBinding.java    From javamelody with Apache License 2.0 5 votes vote down vote up
private static String getBindingName(String path, Binding binding) {
	// nécessaire pour glassfish 3.0.1
	String result = binding.getName();
	if (result.startsWith(JNDI_PREFIX)) {
		result = result.substring(JNDI_PREFIX.length());
	}
	if (result.startsWith(path)) {
		result = result.substring(path.length());
	}
	if (!result.isEmpty() && result.charAt(0) == '/') {
		result = result.substring(1);
	}
	return result;
}
 
Example 4
Source File: JNDIUtil.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
public static void tearDownRecursively(final Context c) throws Exception {
   for (NamingEnumeration<Binding> ne = c.listBindings(""); ne.hasMore(); ) {
      Binding b = ne.next();
      String name = b.getName();
      Object object = b.getObject();
      if (object instanceof Context) {
         JNDIUtil.tearDownRecursively((Context) object);
      }
      c.unbind(name);
   }
}
 
Example 5
Source File: Debug.java    From tomee with Apache License 2.0 5 votes vote down vote up
public static void contextToMap(final Context context, final String baseName, final Map<String, Object> results) throws NamingException {
    final NamingEnumeration<Binding> namingEnumeration = context.listBindings("");
    while (namingEnumeration.hasMoreElements()) {
        final Binding binding = namingEnumeration.nextElement();
        final String name = binding.getName();
        final String fullName = baseName + name;
        final Object object = binding.getObject();
        results.put(fullName, object);
        if (object instanceof Context) {
            contextToMap((Context) object, fullName + "/", results);
        }
    }
}