Package javax.naming

Examples of javax.naming.Context


                String value = env.getProperty(name);
                LOG.log(Level.FINE, "Context property: " + name + " | " + value);
            }   
        }
       
        Context context = new InitialContext(env);

        return context;
    }
View Full Code Here


            context.createSubcontext("dir3");
            context.bind("dir1/first", new String("first"));
            context.bind("dir1/second", new String("first"));
            context.bind("dir1/third", new String("first"));
                    
            Context ctx = (Context)context.lookup("dir2");
            ctx.bind("first", new String("first"));
            ctx.bind("second", new String("first"));
            ctx.bind("third", new String("first"));
         }
        
         System.out.println("================JNDI CONTENT START=============");
         JndiDumper.scanContext(null, context, System.out);
         System.out.println("================JNDI CONTENT END  =============");
View Full Code Here

            InitialContext ic = new InitialContext();
            for (Iterator i = this.objectsToCreate.keySet().iterator(); i.hasNext();) {
                String name = (String) i.next();
                try {
                    Name fullName = new CompositeName(name);
                    Context currentContext = ic;
                    while (fullName.size() > 1) {
                        // Make contexts that are not already present
                        try {
                            currentContext = currentContext
                                    .createSubcontext(fullName.get(0));
                        } catch (NamingException err) {
                            currentContext = (Context) currentContext
                                    .lookup(fullName.get(0));
                        }
                        fullName = fullName.getSuffix(1);
                    }
                    ic.bind(name, this.objectsToCreate.get(name));
View Full Code Here

                } finally {
                    ((Context) ctx).close();
                }
        }

        Context childContext = null;
        synchronized (this.contextLock) {
            if (this.bindings.get(childName.get(0)) != null)
                throw new NamingException(ContainerJNDIManager.JNDI_RESOURCES.getString(
                        "WinstoneContext.AlreadyExists", childName.get(0)));
            else {
View Full Code Here

                } finally {
                    ((Context) ctx).close();
                }
        } else
            synchronized (this.contextLock) {
                Context childContext = (Context) lookup(childName.get(0));
                childContext.close();
                this.bindings.remove(childName.get(0));
            }
    }
View Full Code Here

         catch(NameNotFoundException e)
         {
            // OK
         }     

         Context c = JNDIUtil.createContext(initialContext, parentContext);        
        
         JBossDestination jbDest;
        
         if (destination.isQueue())
         {
            if (destination.isTemporary())
            {
               jbDest = new JBossTemporaryQueue(destination.getName());
            }
            else
            {
               jbDest = new JBossQueue(destination.getName());
            }
         }
         else
         {
            if (destination.isTemporary())
            {
               jbDest = new JBossTemporaryTopic(destination.getName());
            }
            else
            {
               jbDest = new JBossTopic(destination.getName());
            }
         }
        
         c.rebind(jndiNameInContext, jbDest);        
      }
           
      if (destination.isQueue())
      {
         queueMap.put(destination.getName(), destination);
View Full Code Here

   /**
    * Create a context path recursively.
    */
   public static Context createContext(Context c, String path) throws NamingException
   {
      Context crtContext = c;
      for(StringTokenizer st = new StringTokenizer(path, "/"); st.hasMoreTokens(); )
      {
         String tok = st.nextToken();

         try
         {
            Object o = crtContext.lookup(tok);
            if (!(o instanceof Context))
            {
               throw new NamingException("Path " + path + " overwrites and already bound object");
            }
            crtContext = (Context)o;
            continue;
         }
         catch(NameNotFoundException e)
         {
            // OK
         }
         crtContext = crtContext.createSubcontext(tok);
      }
      return crtContext;
   }
View Full Code Here

    * NameNotFoundException is thrown. This method behaves similar to Context.rebind(), but creates
    * intermediate contexts, if necessary.
    */
   public static void rebind(Context c, String jndiName, Object o) throws NamingException
   {
      Context context = c;
      String name = jndiName;

      int idx = jndiName.lastIndexOf('/');
      if (idx != -1)
      {
         context = createContext(c, jndiName.substring(0, idx));
         name = jndiName.substring(idx + 1);
      }
      boolean failed=false;
      try
      {
         context.rebind(name,o);
      }
      catch (Exception ignored)
      {
         failed=true;
      }
      if (failed)
      {
         context.bind(name, o);
      }
   }
View Full Code Here

      else
      {
         targetAdaptor = (JMSProviderAdapter)ic.lookup(targetProviderAdaptorLookup);
      }
     
      Context icSource = sourceAdaptor.getInitialContext();
     
      Context icTarget = targetAdaptor.getInitialContext();
     
      Destination sourceDest = (Destination)icSource.lookup(sourceDestinationLookup);
     
      Destination targetDest = (Destination)icTarget.lookup(targetDestinationLookup);
           
      String sourceCFRef = sourceAdaptor.getFactoryRef();
     
      String targetCFRef = targetAdaptor.getFactoryRef();
     
View Full Code Here

            if (this.warService == null) {
                logger.warn("There are WAR files in the EAR ''{0}'' but the 'web' service is not available", earDeployable);
            } else {

                // Build context for sending parameters
                Context ctx = new ContextImpl(earURL.toExternalForm());
                try {
                    ctx.rebind("earURL", earURL);
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the EAR URL parameter '" + earURL + "'", e);
                }
                // Get URLS of the wars and context-root
                List<URL> urls = new LinkedList<URL>();
                List<String> ctxRoots = new LinkedList<String>();
                for (WARDeployable warDeployable : wars) {

                    // URL
                    URL url = null;
                    try {
                        url = warDeployable.getArchive().getURL();
                    } catch (ArchiveException e) {
                        throw new DeployerException("Cannot get the URL for the archive '" + warDeployable.getArchive() + "'",
                                e);
                    }
                    urls.add(url);

                    // Context-root
                    ctxRoots.add(warDeployable.getContextRoot());

                }
                try {
                    ctx.rebind("urls", urls.toArray(new URL[urls.size()]));
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the urls parameter '" + urls + "'", e);
                }

                // Bind the parent classloader of the web application
                try {
                    ctx.rebind("parentClassLoader", parentClassLoader);
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the parentClassLoader parameter '" + parentClassLoader + "'", e);
                }

                // Bind the earClassLoader of the web application
                try {
                    ctx.rebind("earClassLoader", earClassLoader);
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the earClassLoader parameter '" + earClassLoader + "'", e);
                }

                // No alt-dd yet, give an empty array
                try {
                    ctx.rebind("altDDs", new URL[urls.size()]);
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the altDDs parameter.'", e);
                }

                // Build context roots
                try {
                    ctx.rebind("contextRoots", ctxRoots.toArray(new String[ctxRoots.size()]));
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the contextRoots parameter '" + urls + "'", e);
                }

                try {
View Full Code Here

TOP

Related Classes of javax.naming.Context

Copyright © 2018 www.massapicom. 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.