Examples of NamingEnumeration


Examples of javax.naming.NamingEnumeration

      {
         log.info("Dumping JNDI context:" + context);

         // dump out the context name-value bindings
         InitialContext ic = getInitialContext();
         NamingEnumeration list = ic.list(context);

         while (list.hasMore())
         {
            NameClassPair nc = (NameClassPair) list.next();
            log.info(nc.toString());
         }
         log.info("Dumped JNDI context");
      }
      catch (Exception e)
View Full Code Here

Examples of javax.naming.NamingEnumeration

      redeployNaming();
     
      Context ctx2 = new InitialContext(env);
      try
      {
         NamingEnumeration list = ctx2.list(ObjectBinder.SUBCONTEXT_NAME);
         assertNotNull("NamingEnumeration returned", list);
         assertTrue("NamingEnumeration has entry", list.hasMoreElements());
         NameClassPair pair = (NameClassPair) list.next();
         assertEquals(ObjectBinder.NAME, pair.getName());
      }
      catch (NamingException e)
      {
         log.error("Caught NamingException", e);
View Full Code Here

Examples of javax.naming.NamingEnumeration

      redeployNaming();
     
      Context ctx2 = new InitialContext(env);
      try
      {
         NamingEnumeration list = ctx2.listBindings(ObjectBinder.SUBCONTEXT_NAME);
         assertNotNull("NamingEnumeration returned", list);
         assertTrue("NamingEnumeration has entry", list.hasMoreElements());
         Binding binding = (Binding) list.next();
         assertEquals(ObjectBinder.NAME, binding.getName());
      }
      catch (NamingException e)
      {
         log.error("Caught NamingException", e);
View Full Code Here

Examples of javax.naming.NamingEnumeration

         boolean verbose)
   {
      ClassLoader loader = Thread.currentThread().getContextClassLoader();
      try
      {
         NamingEnumeration ne = ctx.list("");
         while (ne.hasMore())
         {
            NameClassPair pair = (NameClassPair) ne.next();

            String name = pair.getName();
            String className = pair.getClassName();
            boolean recursive = false;
            boolean isLinkRef = false;
            boolean isProxy = false;
            Class c = null;
            try
            {
               c = loader.loadClass(className);

               if (Context.class.isAssignableFrom(c))
                  recursive = true;
               if (LinkRef.class.isAssignableFrom(c))
                  isLinkRef = true;

               isProxy = Proxy.isProxyClass(c);
            }
            catch (ClassNotFoundException cnfe)
            {
               // If this is a $Proxy* class its a proxy
               if (className.startsWith("$Proxy"))
               {
                  isProxy = true;
                  // We have to get the class from the binding
                  try
                  {
                     Object p = ctx.lookup(name);
                     c = p.getClass();
                  }
                  catch (NamingException e)
                  {
                     Throwable t = e.getRootCause();
                     if (t instanceof ClassNotFoundException)
                     {
                        // Get the class name from the exception msg
                        String msg = t.getMessage();
                        if (msg != null)
                        {
                           // Reset the class name to the CNFE class
                           className = msg;
                        }
                     }
                  }
               }
            }

            buffer.append(indent + " +- " + name);

            // Display reference targets
            if (isLinkRef)
            {
               // Get the
               try
               {
                  Object obj = ctx.lookupLink(name);

                  LinkRef link = (LinkRef) obj;
                  buffer.append("[link -> ");
                  buffer.append(link.getLinkName());
                  buffer.append(']');
               }
               catch (Throwable t)
               {
                  buffer.append("invalid]");
               }
            }

            // Display proxy interfaces
            if (isProxy)
            {
               buffer.append(" (proxy: " + pair.getClassName());
               if (c != null)
               {
                  Class[] ifaces = c.getInterfaces();
                  buffer.append(" implements ");
                  for (int i = 0; i < ifaces.length; i++)
                  {
                     buffer.append(ifaces[i]);
                     buffer.append(',');
                  }
                  buffer.setCharAt(buffer.length() - 1, ')');
               }
               else
               {
                  buffer.append(" implements " + className + ")");
               }
            }
            else if (verbose)
            {
               buffer.append(" (class: " + pair.getClassName() + ")");
            }

            buffer.append('\n');
            if (recursive)
            {
               try
               {
                  Object value = ctx.lookup(name);
                  if (value instanceof Context)
                  {
                     Context subctx = (Context) value;
                     list(subctx, indent + " |  ", buffer, verbose);
                  }
                  else
                  {
                     buffer.append(indent + " |   NonContext: " + value);
                     buffer.append('\n');
                  }
               }
               catch (Throwable t)
               {
                  buffer.append("Failed to lookup: " + name + ", errmsg=" + t.getMessage());
                  buffer.append('\n');
               }
            }
         }
         ne.close();
      }
      catch (NamingException ne)
      {
         buffer.append("error while listing context " + ctx.toString() + ": " + ne.toString(true));
         formatException(buffer, ne);
      }
   }
View Full Code Here

Examples of javax.naming.NamingEnumeration

            hosts[v] = addr.toString();
         }
      }
      else
      {
         NamingEnumeration iter = ctx.list("/HAPartition");
         while( iter.hasMore() )
         {
            NameClassPair pair = (NameClassPair) iter.next();
            partitionName = pair.getName();
            String partitionJndiName = "/HAPartition/" + partitionName;
            HAPartition partition = (HAPartition) ctx.lookup(partitionJndiName);
            env.setProperty(NamingContext.JNP_PARTITION_NAME, partitionName);
            Vector view = partition.getCurrentView();
View Full Code Here

Examples of javax.naming.NamingEnumeration

   {
      String[] hosts = {};
      env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      env.setProperty(Context.PROVIDER_URL, hostname+":"+port);
      InitialContext ctx = new InitialContext(env);
      NamingEnumeration iter = ctx.list("/HAPartition");
      String partitionName = null;
      while( iter.hasMore() )
      {
         NameClassPair pair = (NameClassPair) iter.next();
         partitionName = pair.getName();
         break;
      }
      if( partitionName == null )
         throw new NamingException("Failed to find any parition");
View Full Code Here

Examples of javax.naming.NamingEnumeration

        try {

            // Render the directory entries within this directory
            DirContext directory = resourceInfo.directory;
            NamingEnumeration enumeration =
                resourceInfo.resources.list(resourceInfo.path);
            boolean shade = false;
            while (enumeration.hasMoreElements()) {

                NameClassPair ncPair = (NameClassPair) enumeration.nextElement();
                String resourceName = ncPair.getName();
                ResourceInfo childResourceInfo =
                    new ResourceInfo(resourceName, directory);

                String trimmed = resourceName/*.substring(trim)*/;
 
View Full Code Here

Examples of javax.naming.NamingEnumeration

                }

                if ((object instanceof DirContext) && (depth > 0)) {

                    try {
                        NamingEnumeration enumeration = resources.list(currentPath);
                        while (enumeration.hasMoreElements()) {
                            NameClassPair ncPair =
                                (NameClassPair) enumeration.nextElement();
                            String newPath = currentPath;
                            if (!(newPath.endsWith("/")))
                                newPath += "/";
                            newPath += ncPair.getName();
                            stackBelow.push(newPath);
View Full Code Here

Examples of javax.naming.NamingEnumeration

   
    private void getCategories(InitialDirContext ctx,Configuration config) {
        try {
            SearchControls sctrl = new SearchControls();
            String filter = "(&(objectclass=organizationalUnit)(ou=*))";                       
            NamingEnumeration enm = ctx.search(baseDN, filter, sctrl);
            while (enm.hasMore()) {
                SearchResult sr = (SearchResult) enm.next();               
                config.setCategory(sr.getName());               
            }

        } catch (Exception e) {  
          ErrorReporter.getErrorHandler().reportError(e.getLocalizedMessage(), e);
View Full Code Here

Examples of javax.naming.NamingEnumeration

    // Result
    Vector<HashMap<String, String>>  result = new Vector<HashMap<String, String>>() ;
   
    try{
      // search
      NamingEnumeration results = authContext.search(searchScope, filter, constraints);
     
      int y = 0;
     
      // Stepping through the data
      while (results != null && results.hasMore()) {
           HashMap<String, String> innerMap = new HashMap<String, String>();
          
         y++;
        
         // Next result
           SearchResult si = (SearchResult) results.next();
          
           if(si == null){
             continue;
           }
          
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.