Package javax.naming

Examples of javax.naming.Name


    public synchronized void start(StartContext context) throws StartException {
        try {
            final JMSServerManager jmsServer = new JMSServerManagerImpl(hornetQServer.getValue());

            // TODO: This is a temp solution; see HORNETQ-650 for more info
            final Name emptyName = new CompositeName("");
            jmsServer.setContext(new MockContext((NamingContext)namingStore.getValue().lookup(emptyName), emptyName));

            try {
                // FIXME - we also need the TCCL here in case the JMSServerManager starts the HornetQServer
                final ClassLoader loader = getClass().getClassLoader();
View Full Code Here


   private void bind(String jndiName, Object who, Class<?> classType, Context ctx) throws Exception
   {
      // Ah ! This service isn't serializable, so we use a helper class
      //
      NonSerializableFactory.bind(jndiName, who);
      Name n = ctx.getNameParser("").parse(jndiName);
      while (n.size () > 1)
      {
         String ctxName = n.get (0);
         try
         {
            ctx = (Context)ctx.lookup (ctxName);
         }
         catch (NameNotFoundException e)
         {
            log.debug ("creating Subcontext " + ctxName);
            ctx = ctx.createSubcontext (ctxName);
         }
         n = n.getSuffix (1);
      }

      // The helper class NonSerializableFactory uses address type nns, we go on to
      // use the helper class to bind the service object in JNDI
      //
      StringRefAddr addr = new StringRefAddr("nns", jndiName);
      Reference ref = new Reference(classType.getName (), addr, NonSerializableFactory.class.getName (), null);
      ctx.rebind (n.get (0), ref);
   }
View Full Code Here

   private void bind(String jndiName, Object who, Class<?> classType, Context ctx) throws Exception
   {
      // Ah ! This service isn't serializable, so we use a helper class
      //
      NonSerializableFactory.bind(jndiName, who);
      Name n = ctx.getNameParser("").parse(jndiName);
      while (n.size () > 1)
      {
         String ctxName = n.get (0);
         try
         {
            ctx = (Context)ctx.lookup (ctxName);
         }
         catch (NameNotFoundException e)
         {
            log.debug ("creating Subcontext " + ctxName);
            ctx = ctx.createSubcontext (ctxName);
         }
         n = n.getSuffix (1);
      }

      // The helper class NonSerializableFactory uses address type nns, we go on to
      // use the helper class to bind the service object in JNDI
      //
      StringRefAddr addr = new StringRefAddr("nns", jndiName);
      Reference ref = new Reference(classType.getName (), addr, NonSerializableFactory.class.getName (), null);
      ctx.rebind (n.get (0), ref);
   }
View Full Code Here

  }

  @Override
  public Object locate(String jndiName) {
    final InitialContext initialContext = buildInitialContext();
    final Name name = parseName( jndiName, initialContext );
    try {
      return initialContext.lookup( name );
    }
    catch ( NamingException e ) {
      throw new JndiException( "Unable to lookup JNDI name [" + jndiName + "]", e );
View Full Code Here

  }

  @Override
  public void bind(String jndiName, Object value) {
    final InitialContext initialContext = buildInitialContext();
    final Name name = parseName( jndiName, initialContext );
    try {
      bind( name, value, initialContext );
    }
    finally {
      cleanUp( initialContext );
View Full Code Here

  }

  @Override
  public void unbind(String jndiName) {
    final InitialContext initialContext = buildInitialContext();
    final Name name = parseName( jndiName, initialContext );
    try {
      initialContext.unbind( name );
    }
    catch (Exception e) {
      throw new JndiException( "Error performing unbind [" + name + "]", e );
View Full Code Here

  }

  @Override
  public void addListener(String jndiName, NamespaceChangeListener listener) {
    final InitialContext initialContext = buildInitialContext();
    final Name name = parseName( jndiName, initialContext );
    try {
      ( (EventContext) initialContext ).addNamingListener( name, EventContext.OBJECT_SCOPE, listener );
    }
    catch (Exception e) {
      throw new JndiException( "Unable to bind listener to namespace [" + name + "]", e );
View Full Code Here

    try {
      log.trace("binding: " + name);
      ctx.rebind(name, val);
    }
    catch (Exception e) {
      Name n = ctx.getNameParser("").parse(name);
      while ( n.size() > 1 ) {
        String ctxName = n.get(0);

        Context subctx=null;
        try {
          log.trace("lookup: " + ctxName);
          subctx = (Context) ctx.lookup(ctxName);
        }
        catch (NameNotFoundException nfe) {}

        if (subctx!=null) {
          log.debug("Found subcontext: " + ctxName);
          ctx = subctx;
        }
        else {
          log.info("Creating subcontext: " + ctxName);
          ctx = ctx.createSubcontext(ctxName);
        }
        n = n.getSuffix(1);
      }
      log.trace("binding: " + n);
      ctx.rebind(n, val);
    }
    log.debug("Bound name: " + name);
View Full Code Here

    try {
      log.trace("binding: " + name);
      ctx.rebind(name, val);
    }
    catch (Exception e) {
      Name n = ctx.getNameParser("").parse(name);
      while ( n.size() > 1 ) {
        String ctxName = n.get(0);

        Context subctx=null;
        try {
          log.trace("lookup: " + ctxName);
          subctx = (Context) ctx.lookup(ctxName);
        }
        catch (NameNotFoundException nfe) {}

        if (subctx!=null) {
          log.debug("Found subcontext: " + ctxName);
          ctx = subctx;
        }
        else {
          log.info("Creating subcontext: " + ctxName);
          ctx = ctx.createSubcontext(ctxName);
        }
        n = n.getSuffix(1);
      }
      log.trace("binding: " + n);
      ctx.rebind(n, val);
    }
    log.debug("Bound name: " + name);
View Full Code Here

     */
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        Context ctx = new InitialContext();
        NameParser parser = ctx.getNameParser("");
        String securityDomain = null;
        Name name = null;

        final JNDIBasedSecurityManagement securityManagement = JNDIBasedSecurityManagement.class.cast(securityManagementValue
                .getValue());
        final ConcurrentHashMap<String, SecurityDomainContext> securityManagerMap = securityManagement.getSecurityManagerMap();

        String methodName = method.getName();
        if (methodName.equals("toString"))
            return SecurityConstants.JAAS_CONTEXT_ROOT + " Context proxy";

        if (methodName.equals("list"))
            return new DomainEnumeration(securityManagerMap.keys(), securityManagerMap);

        if (methodName.equals("bind") || methodName.equals("rebind")) {
            if (args[0] instanceof String)
                name = parser.parse((String) args[0]);
            else
                name = (Name) args[0];
            securityDomain = name.get(0);
            SecurityDomainContext val = (SecurityDomainContext) args[1];
            securityManagerMap.put(securityDomain, val);
            return proxy;
        }
        if (!methodName.equals("lookup"))
            throw new OperationNotSupportedException("Operation not supported: " + method);
        if (args[0] instanceof String)
            name = parser.parse((String) args[0]);
        else
            name = (Name) args[0];
        securityDomain = name.get(0);
        SecurityDomainContext securityDomainCtx = lookupSecurityDomain(securityManagement, securityManagerMap, securityDomain);
        Object binding = securityDomainCtx.getAuthenticationManager();
        // Look for requests against the security domain context
        if (name.size() == 2) {
            String request = name.get(1);
            binding = securityDomainCtx.lookup(request);
        }
        return binding;
    }
View Full Code Here

TOP

Related Classes of javax.naming.Name

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.