Package javax.naming

Examples of javax.naming.Name


           if (containerLog.isTraceEnabled()) {
               containerLog.trace("  search returned relative name: " +
                       result.getName());
           }
           NameParser parser = context.getNameParser("");
           Name contextName = parser.parse(context.getNameInNamespace());
           Name baseName = parser.parse(base);
  
           // Bugzilla 32269
           Name entryName =
               parser.parse(new CompositeName(result.getName()).get(0));
  
           Name name = contextName.addAll(baseName);
           name = name.addAll(entryName);
           return name.toString();
        } else {
           String absoluteName = result.getName();
           if (containerLog.isTraceEnabled())
               containerLog.trace("  search returned absolute name: " +
                       result.getName());
           try {
               // Normalize the name by running it through the name parser.
               NameParser parser = context.getNameParser("");
               URI userNameUri = new URI(absoluteName);
               String pathComponent = userNameUri.getPath();
               // Should not ever have an empty path component, since that is /{DN}
               if (pathComponent.length() < 1 ) {
                   throw new InvalidNameException(
                           "Search returned unparseable absolute name: " +
                           absoluteName );
               }
               Name name = parser.parse(pathComponent.substring(1));
               return name.toString();
           } catch ( URISyntaxException e ) {
               throw new InvalidNameException(
                       "Search returned unparseable absolute name: " +
                       absoluteName );
           }
View Full Code Here


    public Object lookupLink(String name) throws NamingException {
        return lookup(name);
    }

    public Name composeName(Name name, Name prefix) throws NamingException {
        Name result = (Name) prefix.clone();
        result.addAll(name);
        return result;
    }
View Full Code Here

    public NameParser getNameParser(Name name) throws NamingException {
        return getNameParser(name.toString());
    }

    public String composeName(String name, String prefix) throws NamingException {
        Name result = composeName(new CompositeName(name),
                                  new CompositeName(prefix));
        return result.toString();
    }
View Full Code Here

        map.put("string", STRING_VAL);
        map.put("nested/context/string", STRING_VAL);

        Context context = EnterpriseNamingContext.createEnterpriseNamingContext(map);

        Name stringName = context.getNameParser("").parse("string");
        assertEquals(STRING_VAL, context.lookup("string"));
        assertEquals(STRING_VAL, context.lookup(stringName));
        assertEquals(STRING_VAL, context.lookupLink("string"));
        assertEquals(STRING_VAL, context.lookupLink(stringName));

        Name nestedContextStringName = context.getNameParser("").parse("nested/context/string");
        assertEquals(STRING_VAL, context.lookup("nested/context/string"));
        assertEquals(STRING_VAL, context.lookup(nestedContextStringName));
        assertEquals(STRING_VAL, context.lookupLink("nested/context/string"));
        assertEquals(STRING_VAL, context.lookupLink(nestedContextStringName));
    }
View Full Code Here

    public final Name composeName(Name name, Name prefix) throws NamingException {
        if (name == null) throw new NullPointerException("name is null");
        if (prefix == null) throw new NullPointerException("prefix is null");

        Name result = (Name) prefix.clone();
        result.addAll(name);
        return result;
    }
View Full Code Here

            String name = (String) entry.getKey();
            Object value = entry.getValue();

            Node parentContext = rootContext;

            Name compoundName = EnterpriseNamingContextNameParser.INSTANCE.parse(name);
            for (Enumeration parts = compoundName.getAll(); parts.hasMoreElements(); ) {
                String part = (String) parts.nextElement();
                // the last element in the path is the name of the value
                if (parts.hasMoreElements()) {
                    // nest context into parent
                    Node bindings = (Node) parentContext.get(part);
                    if (bindings == null) {
                        bindings = new Node();
                        parentContext.put(part, bindings);
                    }

                    parentContext = bindings;
                }
            }

            parentContext.put(compoundName.get(compoundName.size() - 1), value);
        }
        return rootContext;
    }
View Full Code Here

            while (enumeration.hasMoreElements())
            {
                try
                {
                    NameClassPair binding = enumeration.nextElement();
                    Name bindingName = nameParser.parse(name).add(binding.getName());               
                    result.put(binding.getName(), lookup(bindingName, type));
                }
                catch (NamingException e)
                {
                    if (LOG.isLoggable(Level.FINEST))
View Full Code Here

        if (!initialContext && !name.isEmpty() &&
                name.get(0).startsWith(prefix)) {
            if (name.get(0).equals(prefix)) {
                return name.getSuffix(1);
            } else {
                Name result = name.getSuffix(1);
                result.add(0, name.get(0).substring(prefixLength));
                return result;
            }
        } else {
            if (initialContext) {
                return name;
View Full Code Here

            if (results.hasMore()) {
                //ignore for now
            }
            NameParser parser = context.getNameParser("");
            Name contextName = parser.parse(context.getNameInNamespace());
            Name baseName = parser.parse(userBase);
            Name entryName = parser.parse(result.getName());
            Name name = contextName.addAll(baseName);
            name = name.addAll(entryName);
            String dn = name.toString();

            Attributes attrs = result.getAttributes();
            if (attrs == null) {
                return false;
            }
View Full Code Here

     * @return the object bound to name
     */
    @Override
    protected Object doLookup(String strName) {

        Name name;
        try {
            name = getEscapedJndiName(strName);
        } catch (InvalidNameException e) {
            log.info(sm.getString("resources.invalidName", strName), e);
            return null;
        }

        if (name.isEmpty())
            return this;
        Entry entry = treeLookup(name);
        if (entry == null)
            return null;
           
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.