當前位置: 首頁>>代碼示例>>Java>>正文


Java Name類代碼示例

本文整理匯總了Java中javax.naming.Name的典型用法代碼示例。如果您正苦於以下問題:Java Name類的具體用法?Java Name怎麽用?Java Name使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Name類屬於javax.naming包,在下文中一共展示了Name類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: lookup

import javax.naming.Name; //導入依賴的package包/類
/**
 * Retrieves the named object. If name is empty, returns a new instance 
 * of this context (which represents the same naming context as this 
 * context, but its environment may be modified independently and it may 
 * be accessed concurrently).
 * 
 * @param name the name of the object to look up
 * @return the object bound to name
 * @exception NamingException if a naming exception is encountered
 */
public Object lookup(Name name)
    throws NamingException {
    CacheEntry entry = cacheLookup(name.toString());
    if (entry != null) {
        if (!entry.exists) {
            throw notFoundException;
        }
        if (entry.resource != null) {
            // Check content caching.
            return entry.resource;
        } else {
            return entry.context;
        }
    }
    Object object = dirContext.lookup(parseName(name));
    if (object instanceof InputStream)
        return new Resource((InputStream) object);
    else
        return object;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:31,代碼來源:ProxyDirContext.java

示例2: list

import javax.naming.Name; //導入依賴的package包/類
/**
 * Enumerates the names bound in the named context, along with the class 
 * names of objects bound to them. The contents of any subcontexts are 
 * not included.
 * <p>
 * If a binding is added to or removed from this context, its effect on 
 * an enumeration previously returned is undefined.
 * 
 * @param name the name of the context to list
 * @return an enumeration of the names and class names of the bindings in 
 * this context. Each element of the enumeration is of type NameClassPair.
 * @exception NamingException if a naming exception is encountered
 */
public NamingEnumeration list(Name name)
    throws NamingException {
    // Removing empty parts
    while ((!name.isEmpty()) && (name.get(0).length() == 0))
        name = name.getSuffix(1);
    if (name.isEmpty()) {
        return new NamingContextEnumeration(bindings.values().iterator());
    }
    
    NamingEntry entry = (NamingEntry) bindings.get(name.get(0));
    
    if (entry == null) {
        throw new NameNotFoundException
            (sm.getString("namingContext.nameNotBound", name.get(0)));
    }
    
    if (entry.type != NamingEntry.CONTEXT) {
        throw new NamingException
            (sm.getString("namingContext.contextExpected"));
    }
    return ((Context) entry.value).list(name.getSuffix(1));
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:36,代碼來源:NamingContext.java

示例3: matches

import javax.naming.Name; //導入依賴的package包/類
private boolean matches(int beg, int end, Name n) {
    if (n instanceof LdapName) {
        LdapName ln = (LdapName) n;
        return doesListMatch(beg, end, ln.rdns);
    } else {
        for (int i = beg; i < end; i++) {
            Rdn rdn;
            String rdnString = n.get(i - beg);
            try {
                rdn = (new Rfc2253Parser(rdnString)).parseRdn();
            } catch (InvalidNameException e) {
                return false;
            }
            if (!rdn.equals(rdns.get(i))) {
                return false;
            }
        }
    }
    return true;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:LdapName.java

示例4: getAttributes

import javax.naming.Name; //導入依賴的package包/類
/**
 * Retrieves all of the attributes associated with a named object. 
 * 
 * @return the set of attributes associated with name. 
 * Returns an empty attribute set if name has no attributes; never null.
 * @param name the name of the object from which to retrieve attributes
 * @exception NamingException if a naming exception is encountered
 */
public Attributes getAttributes(Name name, String[] attrIds)
    throws NamingException {
    
    Entry entry = null;
    if (name.isEmpty())
        entry = entries;
    else
        entry = treeLookup(name);
    if (entry == null)
        throw new NamingException
            (sm.getString("resources.notFound", name));
    
    ZipEntry zipEntry = entry.getEntry();

    ResourceAttributes attrs = new ResourceAttributes();
    attrs.setCreationDate(new Date(zipEntry.getTime()));
    attrs.setName(entry.getName());
    if (!zipEntry.isDirectory())
        attrs.setResourceType("");
    attrs.setContentLength(zipEntry.getSize());
    attrs.setLastModified(new Date(zipEntry.getTime()));
    
    return attrs;
    
}
 
開發者ID:c-rainstorm,項目名稱:jerrydog,代碼行數:34,代碼來源:WARDirContext.java

示例5: doListBindings

import javax.naming.Name; //導入依賴的package包/類
/**
 * Enumerates the names bound in the named context, along with the 
 * objects bound to them. The contents of any subcontexts are not 
 * included.
 * <p>
 * If a binding is added to or removed from this context, its effect on 
 * an enumeration previously returned is undefined.
 * 
 * @param strName the name of the context to list
 * @return an enumeration of the bindings in this context. 
 * Each element of the enumeration is of type Binding.
 * @exception NamingException if a naming exception is encountered
 */
@Override
protected List<NamingEntry> doListBindings(String strName)
    throws NamingException {
    
    Name name = getEscapedJndiName(strName);

    if (name.isEmpty())
        return list(entries);

    Entry entry = treeLookup(name);
    if (entry == null)
        return null;
    
    return list(entry);
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:29,代碼來源:WARDirContext.java

示例6: getGroupResult

import javax.naming.Name; //導入依賴的package包/類
public LDAPResult getGroupResult(DirContext ctx, String groupID, String[] attrs)
{
	if( !Check.isEmpty(groupIdField) )
	{
		SingleFilter nv1 = new SingleFilter(OBJECTCLASS, getGroupObject());
		SingleFilter nv2 = new SingleFilter(groupIdField, groupID);
		return searchFirstResultAllBases(ctx, new AndFilter(nv1, nv2), new LdapResultHitsCollector(attrs), true);
	}

	try
	{
		Name name = LDAP.parse(groupID);
		return new LDAPResult(name, getAttributes(ctx, name, attrs));
	}
	catch( InvalidNameException e )
	{
		LOGGER.debug(e, e);
		return null;
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:21,代碼來源:LDAP.java

示例7: collectAllSubGroupFullNames

import javax.naming.Name; //導入依賴的package包/類
private void collectAllSubGroupFullNames(Set<String> results, DirContext ctx, Name parent)
{
	final String fullname = parent.toString();
	if( results.add(fullname) )
	{
		for( Name child : ldap.searchAllBases(ctx, getSubgroupsByMemberOfFilter(fullname),
			new FullNameHitsCollector(), true) )
		{
			collectAllSubGroupFullNames(results, ctx, child);
		}
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:13,代碼來源:MemberOfGroupSearch.java

示例8: createSubcontext

import javax.naming.Name; //導入依賴的package包/類
/**
 * Creates and binds a new context. Creates a new context with the given 
 * name and binds it in the target context (that named by all but 
 * terminal atomic component of the name). All intermediate contexts and 
 * the target context must already exist.
 * 
 * @param name the name of the context to create; may not be empty
 * @return the newly created context
 * @exception NameAlreadyBoundException if name is already bound
 * @exception javax.naming.directory.InvalidAttributesException if creation
 * of the sub-context requires specification of mandatory attributes
 * @exception NamingException if a naming exception is encountered
 */
@Override
public Context createSubcontext(Name name) throws NamingException {
    if (!checkWritable()) {
        return null;
    }
    
    NamingContext newContext = new NamingContext(env, this.name);
    bind(name, newContext);
    
    newContext.setExceptionOnFailedWrite(getExceptionOnFailedWrite());

    return newContext;
}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:27,代碼來源:NamingContext.java

示例9: lookup

import javax.naming.Name; //導入依賴的package包/類
@Override
public Object lookup(Name name) throws NamingException {
	if (name.isEmpty())
		return cloneCtx();

	Name nm = getMyComponents(name);
	String atom = nm.get(0);
	Object inter = iBindings.get(atom);

	if (nm.size() == 1) {
		if (inter == null)
			throw new NameNotFoundException(name + " not found");

		try {
			return NamingManager.getObjectInstance(inter, new CompositeName().add(atom), this, iEnv);
		} catch (Exception e) {
			NamingException ne = new NamingException("getObjectInstance failed");
			ne.setRootCause(e);
			throw ne;
		}
	} else {
		if (!(inter instanceof Context))
			throw new NotContextException(atom + " does not name a context");

		return ((Context) inter).lookup(nm.getSuffix(1));
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:28,代碼來源:LocalContext.java

示例10: rename

import javax.naming.Name; //導入依賴的package包/類
@Override
public void rename(Name oldname, Name newname) throws NamingException {
	if (oldname.isEmpty() || newname.isEmpty())
		throw new InvalidNameException("Cannot rename empty name");

	Name oldnm = getMyComponents(oldname);
	Name newnm = getMyComponents(newname);

	if (oldnm.size() != newnm.size())
		throw new OperationNotSupportedException("Do not support rename across different contexts");

	String oldatom = oldnm.get(0);
	String newatom = newnm.get(0);

	if (oldnm.size() == 1) {
		if (iBindings.get(newatom) != null)
			throw new NameAlreadyBoundException(newname.toString() + " is already bound");

		Object oldBinding = iBindings.remove(oldatom);
		if (oldBinding == null)
			throw new NameNotFoundException(oldname.toString() + " not bound");

		iBindings.put(newatom, oldBinding);
	} else {
		if (!oldatom.equals(newatom))
			throw new OperationNotSupportedException("Do not support rename across different contexts");

		Object inter = iBindings.get(oldatom);
		
		if (!(inter instanceof Context))
			throw new NotContextException(oldatom + " does not name a context");

		((Context) inter).rename(oldnm.getSuffix(1), newnm.getSuffix(1));
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:36,代碼來源:LocalContext.java

示例11: lookup

import javax.naming.Name; //導入依賴的package包/類
/**
 * Retrieves the named object. If name is empty, returns a new instance 
 * of this context (which represents the same naming context as this 
 * context, but its environment may be modified independently and it may 
 * be accessed concurrently).
 * 
 * @param name the name of the object to look up
 * @return the object bound to name
 * @exception NamingException if a naming exception is encountered
 */
public Object lookup(Name name)
    throws NamingException {
    if (name.isEmpty())
        return this;
    Entry entry = treeLookup(name);
    if (entry == null)
        throw new NamingException
            (sm.getString("resources.notFound", name));
    ZipEntry zipEntry = entry.getEntry();
    if (zipEntry.isDirectory())
        return new WARDirContext(base, entry);
    else
        return new WARResource(entry.getEntry());
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:WARDirContext.java

示例12: list

import javax.naming.Name; //導入依賴的package包/類
@Override
public NamingEnumeration list(Name name) throws NamingException {
	if (name.isEmpty())
		return new ListOfNames(iBindings.keys());

	Object target = lookup(name);
	if (target instanceof Context)
		return ((Context) target).list("");


	throw new NotContextException(name + " cannot be listed");
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:13,代碼來源:LocalContext.java

示例13: listBindings

import javax.naming.Name; //導入依賴的package包/類
@Override
public NamingEnumeration listBindings(Name name) throws NamingException {
	if (name.isEmpty())
		return new ListOfBindings(iBindings.keys());

	Object target = lookup(name);
	if (target instanceof Context)
		return ((Context) target).listBindings("");

	throw new NotContextException(name + " cannot be listed");
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:12,代碼來源:LocalContext.java

示例14: treeLookup

import javax.naming.Name; //導入依賴的package包/類
/**
 * Entry tree lookup.
 */
protected Entry treeLookup(Name name) {
    if (name.isEmpty())
        return entries;
    Entry currentEntry = entries;
    for (int i = 0; i < name.size(); i++) {
        if (name.get(i).length() == 0)
            continue;
        currentEntry = currentEntry.getChild(name.get(i));
        if (currentEntry == null)
            return null;
    }
    return currentEntry;
}
 
開發者ID:c-rainstorm,項目名稱:jerrydog,代碼行數:17,代碼來源:WARDirContext.java

示例15: treeLookup

import javax.naming.Name; //導入依賴的package包/類
/**
 * Entry tree lookup.
 */
protected Entry treeLookup(Name name) {
	if (name.isEmpty() || entries == null)
		return entries;
	Entry currentEntry = entries;
	for (int i = 0; i < name.size(); i++) {
		if (name.get(i).length() == 0)
			continue;
		currentEntry = currentEntry.getChild(name.get(i));
		if (currentEntry == null)
			return null;
	}
	return currentEntry;
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:17,代碼來源:WARDirContext.java


注:本文中的javax.naming.Name類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。