Examples of NamingContext


Examples of org.jboss.as.naming.NamingContext

                final ServiceName appContextName = ContextNames.contextServiceNameOfApplication(appName);
                final ServiceController<?> appContextController = serviceRegistry.getService(appContextName);
                if (appContextController != null) {
                    final NamingStore appStore = NamingStore.class.cast(appContextController.getValue());
                    try {
                        context.addEntries(deploymentNode.get("java:app"), new NamingContext(appStore, null));
                    } catch (NamingException e) {
                        throw new OperationFailedException(e, new ModelNode().set("Failed to read java:app entries for application [" + appName + "]"));
                    }
                }
View Full Code Here

Examples of org.jboss.as.naming.NamingContext

        final ServiceName moduleContextName = ContextNames.contextServiceNameOfModule(appName, moduleName);
        final ServiceController<?> moduleContextController = serviceRegistry.getService(moduleContextName);
        if (moduleContextController != null) {
            final NamingStore moduleStore = NamingStore.class.cast(moduleContextController.getValue());
            try {
                context.addEntries(moduleNode.get("java:module"), new NamingContext(moduleStore, null));
            } catch (NamingException e) {
                throw new OperationFailedException(e, new ModelNode().set("Failed to read java:module entries for module [" + appName + ", " + moduleName + "]"));
            }

            final Collection<ComponentDescription> componentDescriptions = moduleDescription.getComponentDescriptions();
            for (ComponentDescription componentDescription : componentDescriptions) {
                final String componentName = componentDescription.getComponentName();
                final ServiceName compContextServiceName = ContextNames.contextServiceNameOfComponent(appName, moduleName, componentName);
                final ServiceController<?> compContextController = serviceRegistry.getService(compContextServiceName);
                if (compContextController != null) {
                    final ModelNode componentNode = moduleNode.get("components").get(componentName);
                    final NamingStore compStore = NamingStore.class.cast(compContextController.getValue());
                    try {
                        context.addEntries(componentNode.get("java:comp"), new NamingContext(compStore, null));
                    } catch (NamingException e) {
                        throw new OperationFailedException(e, new ModelNode().set("Failed to read java:comp entries for component [" + appName + ", " + moduleName + ", " + componentName + "]"));
                    }
                }
            }
View Full Code Here

Examples of org.jboss.as.naming.NamingContext

    private final InjectedValue<NamingStore> namingStore = new InjectedValue<NamingStore>();
    private RemoteNamingService remoteNamingService;

    public synchronized void start(StartContext context) throws StartException {
        try {
            final Context namingContext = new NamingContext(namingStore.getValue(), new Hashtable<String, Object>());
            remoteNamingService = new RemoteNamingService(namingContext, executorService.getValue(), RemoteNamingLogger.INSTANCE);
            remoteNamingService.start(endpoint.getValue());
        } catch (Exception e) {
            throw new StartException("Failed to start remote naming service", e);
        }
View Full Code Here

Examples of org.jnp.interfaces.NamingContext

         throw ex;
      }

      // Copy the context env
      env = (Hashtable) env.clone();
      return new NamingContext(env, null, namingServer);
   }
View Full Code Here

Examples of org.mortbay.jndi.NamingContext

        {
            initCtx.lookup( "java:comp" );
        }
        catch ( NameNotFoundException e )
        {
            Util.bind( initCtx, "java:comp", new NamingContext() );
            NamingContext compCtx = (NamingContext) initCtx.lookup( "java:comp" );
            compCtx.setNameParser( new InitialContextFactory.DefaultParser() );
            log.info( "No JNDI java:comp namespace found; creating it," );
            // Context envCtx = compCtx.createSubcontext( "env" );
            // System.out.println( envCtx );
        }
        log.info( "Initialized JNDI java:comp namespace.=" + contextFactoryClass );
View Full Code Here

Examples of org.mortbay.naming.NamingContext

            n = n.getSuffix(1);
            if(Log.isDebugEnabled())Log.debug("getSuffix(1)="+n);
            if(Log.isDebugEnabled())Log.debug("get(0)="+n.get(0));
            if(Log.isDebugEnabled())Log.debug("getPrefix(1)="+n.getPrefix(1));

            NamingContext ncontext = (NamingContext)sub0;

            Name nn = ncontext.toCanonicalName(ncontext.getNameParser("").parse("/yellow/blue/"));
            Log.debug(nn.toString());
            assertEquals (2, nn.size());

            nn = ncontext.toCanonicalName(ncontext.getNameParser("").parse("/yellow/blue"));
            Log.debug(nn.toString());
            assertEquals (2, nn.size());

            nn = ncontext.toCanonicalName(ncontext.getNameParser("").parse("/"));
            if(Log.isDebugEnabled())Log.debug("/ parses as: "+nn+" with size="+nn.size());
            Log.debug(nn.toString());
            assertEquals (1, nn.size());

            nn = ncontext.toCanonicalName(ncontext.getNameParser("").parse(""));
            Log.debug(nn.toString());
            assertEquals (0, nn.size());

            Context fee = ncontext.createSubcontext("fee");
            fee.bind ("fi", "88");
            assertEquals("88", initCtxA.lookup("java:/fee/fi"));
            assertEquals("88", initCtxA.lookup("java:/fee/fi/"));
            assertTrue (initCtxA.lookup("java:/fee/") instanceof javax.naming.Context);
View Full Code Here

Examples of org.omg.CosNaming.NamingContext

               nameXmlBlaster = new NameComponent[1];
               nameXmlBlaster[0] = new NameComponent();
               nameXmlBlaster[0].id = contextId;      // old style: "xmlBlaster-Authenticate"
               nameXmlBlaster[0].kind = contextKind;  // kind is like a file extension (does not make much sense here)
               NamingContext relativeContext = null;
               int numTries = 5// We need to retry
               for(int i=0; i<numTries; i++) {
                  try {
                     relativeContext = namingContextExt.bind_new_context(nameXmlBlaster);
                     if (relativeContext != null) {
                        break;
                     }
                  }
                  catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound ex) {
                     if (log.isLoggable(Level.FINE)) log.fine("Can't register CORBA NameService context '" +
                                    OrbInstanceFactory.getString(nameXmlBlaster) + "': " + ex.toString());
                     try {
                        org.omg.CORBA.Object obj = namingContextExt.resolve(nameXmlBlaster);
                        relativeContext = org.omg.CosNaming.NamingContextExtHelper.narrow(obj);
                        break;
                     }
                     catch (Throwable e) {
                        log.severe("Can't register CORBA NameService context '" +
                                   OrbInstanceFactory.getString(nameXmlBlaster) + "', #"+i+"/"+numTries+": " + e.toString());
                     }
                  }
                  catch (org.omg.CORBA.NO_IMPLEMENT ex) {  // JacORB 1.3.x bug (remove this catch when updated to JacORB 1.4x)
                     if (log.isLoggable(Level.FINE)) log.fine("Can't register CORBA NameService context '" +
                                    OrbInstanceFactory.getString(nameXmlBlaster) + "': " + ex.toString());
                     try {
                        org.omg.CORBA.Object obj = namingContextExt.resolve(nameXmlBlaster);
                        relativeContext = org.omg.CosNaming.NamingContextExtHelper.narrow(obj);
                        break;
                     }
                     catch (Throwable e) {
                        log.severe("Can't register CORBA NameService context '" +
                                   OrbInstanceFactory.getString(nameXmlBlaster) + "', #"+i+"/"+numTries+": " + e.toString());
                     }
                  }
               }
               if (relativeContext != null) {
                  String clusterId = this.addressServer.getEnv("NameService.node.id", glob.getStrippedId()).getValue();
                  String clusterKind = this.addressServer.getEnv("NameService.node.kind", "MOM").getValue();
                  nameNode = new NameComponent[] { new NameComponent(clusterId, clusterKind) };
                  relativeContext.rebind(nameNode, this.authRef);
               }
               else {
                  // delegate error handling
                  throw new XmlBlasterException(glob, ErrorCode.RESOURCE_UNAVAILABLE, ME, "Can't bind to naming service");
               }
View Full Code Here

Examples of org.omg.CosNaming.NamingContext

         log.severe(e.getMessage());
      }

      try {
         if (namingContextExt != null && nameXmlBlaster != null) {
            NamingContext relativeContext = null;
            try {
               org.omg.CORBA.Object obj = namingContextExt.resolve(nameXmlBlaster);
               relativeContext = org.omg.CosNaming.NamingContextExtHelper.narrow(obj);
            }
            catch (Throwable e) {
               log.warning("Can't unregister CORBA NameService context id=" + nameXmlBlaster[0].id + " kind=" + nameXmlBlaster[0].kind + " failed: " + e.toString());
            }
            if (relativeContext != null) {
               relativeContext.unbind(nameNode);
            }
         }
         namingContextExt = null;
      }
      catch (Throwable e) {
View Full Code Here

Examples of org.omg.CosNaming.NamingContext

               NameComponent [] nameXmlBlaster = new NameComponent[] { new NameComponent(contextId, contextKind) };
               if (log.isLoggable(Level.FINE)) log.fine("Query NameServer -ORBInitRef NameService=" + glob.getProperty().get("ORBInitRef","") +
                             ((System.getProperty("ORBInitRef.NameService") != null) ? System.getProperty("ORBInitRef.NameService") : "") +
                             " to find the xmlBlaster root context " + OrbInstanceFactory.getString(nameXmlBlaster));
               org.omg.CORBA.Object obj = namingContextExt.resolve(nameXmlBlaster);
               NamingContext relativeContext = org.omg.CosNaming.NamingContextExtHelper.narrow(obj);

               if (relativeContext == null) {
                  throw new Exception("Can't resolve CORBA NameService");
               }

               NameComponent [] nameNode = new NameComponent[] { new NameComponent(clusterId, clusterKind) };

               AuthServer authServerFirst = null;
               String tmpId = "";           // for logging only
               String tmpServerName = "";   // for logging only
               String firstServerName = ""; // for logging only
               int countServerFound = 0;    // for logging only
               String serverNameList = ""// for logging only
               try {
                  this.authServer = AuthServerHelper.narrow(relativeContext.resolve(nameNode));
               }
               catch (Exception ex) {
                  if (log.isLoggable(Level.FINE)) log.fine("Query NameServer to find a suitable xmlBlaster server for " + OrbInstanceFactory.getString(nameXmlBlaster) + "/" + OrbInstanceFactory.getString(nameNode));
                  BindingListHolder bl = new BindingListHolder();
                  BindingIteratorHolder bi = new BindingIteratorHolder();
                  relativeContext.list(0, bl, bi);
                  //for (int i=0; i<bl.value.length; i++) { // bl.value.length should be 0
                  //   String id = bl.value[i].binding_name[0].id;
                  //   String kind = bl.value[i].binding_name[0].kind;

                  // process the remaining bindings if an iterator exists:
                  if (this.authServer == null && bi.value != null) {
                     BindingHolder bh = new BindingHolder();
                     int i = 0;
                     while ( bi.value.next_one(bh) ) {
                        String id = bh.value.binding_name[0].id;
                        String kind = bh.value.binding_name[0].kind;
                        NameComponent [] nameNodeTmp = new NameComponent[] { new NameComponent(id, kind) };

                        tmpId = id;
                        countServerFound++;
                        tmpServerName = OrbInstanceFactory.getString(nameXmlBlaster)+"/"+OrbInstanceFactory.getString(nameNodeTmp);
                        if (i>0) serverNameList += ", ";
                        i++;
                        serverNameList += tmpServerName;

                        if (clusterId.equals(id) && clusterKind.equals(kind)) {
                           try {
                              if (log.isLoggable(Level.FINE)) log.fine("Trying to resolve NameService entry '"+OrbInstanceFactory.getString(nameNodeTmp)+"'");
                              this.authServer = AuthServerHelper.narrow(relativeContext.resolve(nameNodeTmp));
                              break; // found a matching server
                           }
                           catch (Exception exc) {
                              log.warning("Connecting to NameService entry '"+tmpServerName+"' failed: " + exc.toString());
                           }
                        }

                        if (authServerFirst == null) {
                           if (log.isLoggable(Level.FINE)) log.fine("Remember the first server");
                           try {
                              firstServerName = tmpServerName;
                              if (log.isLoggable(Level.FINE)) log.fine("Remember the first reachable xmlBlaster server from NameService entry '"+firstServerName+"'");
                              authServerFirst = AuthServerHelper.narrow(relativeContext.resolve(nameNodeTmp));
                           }
                           catch (Exception exc) {
                              log.warning("Connecting to NameService entry '"+tmpServerName+"' failed: " + exc.toString());
                           }
                        }
View Full Code Here

Examples of org.omg.CosNaming.NamingContext

   public static void rebind(NamingContextExt ctx,
                             String strName, org.omg.CORBA.Object obj)
          throws Exception
   {
      NameComponent[] name = ctx.to_name(strName);
      NamingContext intermediateCtx = ctx;

      for (int i = 0; i < name.length - 1; i++ ) {
         NameComponent[] relativeName = new NameComponent[] { name[i] };
         try {
            intermediateCtx = NamingContextHelper.narrow(
                  intermediateCtx.resolve(relativeName));
         }
         catch (NotFound e) {
            intermediateCtx = intermediateCtx.bind_new_context(relativeName);
         }
      }
      intermediateCtx.rebind(new NameComponent[] { name[name.length - 1] },
                             obj);
   }
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.