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


Java NameParser類代碼示例

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


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

示例1: getNameParser

import javax.naming.NameParser; //導入依賴的package包/類
/**
 * Retrieves the parser associated with the named context. In a 
 * federation of namespaces, different naming systems will parse names 
 * differently. This method allows an application to get a parser for 
 * parsing names into their atomic components using the naming convention 
 * of a particular naming system. Within any single naming system, 
 * NameParser objects returned by this method must be equal (using the 
 * equals() test).
 * 
 * @param name the name of the context from which to get the parser
 * @return a name parser that can parse compound names into their atomic 
 * components
 * @exception NamingException if a naming exception is encountered
 */
@Override
public NameParser getNameParser(Name name)
    throws NamingException {

    while ((!name.isEmpty()) && (name.get(0).length() == 0))
        name = name.getSuffix(1);
    if (name.isEmpty())
        return nameParser;

    if (name.size() > 1) {
        Object obj = bindings.get(name.get(0));
        if (obj instanceof Context) {
            return ((Context) obj).getNameParser(name.getSuffix(1));
        } else {
            throw new NotContextException
                (sm.getString("namingContext.contextExpected"));
        }
    }

    return nameParser;

}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:37,代碼來源:NamingContext.java

示例2: getNameParser

import javax.naming.NameParser; //導入依賴的package包/類
/**
 * Retrieves the parser associated with the named context. In a 
 * federation of namespaces, different naming systems will parse names 
 * differently. This method allows an application to get a parser for 
 * parsing names into their atomic components using the naming convention 
 * of a particular naming system. Within any single naming system, 
 * NameParser objects returned by this method must be equal (using the 
 * equals() test).
 * 
 * @param name the name of the context from which to get the parser
 * @return a name parser that can parse compound names into their atomic 
 * components
 * @exception NamingException if a naming exception is encountered
 */
public NameParser getNameParser(Name name)
    throws NamingException {

    while ((!name.isEmpty()) && (name.get(0).length() == 0))
        name = name.getSuffix(1);
    if (name.isEmpty())
        return nameParser;

    if (name.size() > 1) {
        Object obj = bindings.get(name.get(0));
        if (obj instanceof Context) {
            return ((Context) obj).getNameParser(name.getSuffix(1));
        } else {
            throw new NotContextException
                (sm.getString("namingContext.contextExpected"));
        }
    }

    return nameParser;

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:36,代碼來源:NamingContext.java

示例3: getNameParser

import javax.naming.NameParser; //導入依賴的package包/類
/**
    * Retrieves the parser associated with the named context. In a 
    * federation of namespaces, different naming systems will parse names 
    * differently. This method allows an application to get a parser for 
    * parsing names into their atomic components using the naming convention 
    * of a particular naming system. Within any single naming system, 
    * NameParser objects returned by this method must be equal (using the 
    * equals() test).
    * 
    * @param name the name of the context from which to get the parser
    * @return a name parser that can parse compound names into their atomic 
    * components
    * @exception NamingException if a naming exception is encountered
    */
   public NameParser getNameParser(Name name)
       throws NamingException {

while ((!name.isEmpty()) && (name.get(0).length() == 0))
    name = name.getSuffix(1);
       if (name.isEmpty())
           return nameParser;

       if (name.size() > 1) {
           Object obj = bindings.get(name.get(0));
           if (obj instanceof Context) {
               return ((Context) obj).getNameParser(name.getSuffix(1));
           } else {
               throw new NotContextException
                   (sm.getString("namingContext.contextExpected"));
           }
       }

       return nameParser;

   }
 
開發者ID:c-rainstorm,項目名稱:jerrydog,代碼行數:36,代碼來源:NamingContext.java

示例4: getNameParser

import javax.naming.NameParser; //導入依賴的package包/類
/**
 * Retrieves the parser associated with the named context. In a federation
 * of namespaces, different naming systems will parse names differently.
 * This method allows an application to get a parser for parsing names into
 * their atomic components using the naming convention of a particular
 * naming system. Within any single naming system, NameParser objects
 * returned by this method must be equal (using the equals() test).
 * 
 * @param name
 *            the name of the context from which to get the parser
 * @return a name parser that can parse compound names into their atomic
 *         components
 * @exception NamingException
 *                if a naming exception is encountered
 */
@Override
public NameParser getNameParser(Name name) throws NamingException {

	while ((!name.isEmpty()) && (name.get(0).length() == 0))
		name = name.getSuffix(1);
	if (name.isEmpty())
		return nameParser;

	if (name.size() > 1) {
		Object obj = bindings.get(name.get(0));
		if (obj instanceof Context) {
			return ((Context) obj).getNameParser(name.getSuffix(1));
		} else {
			throw new NotContextException(sm.getString("namingContext.contextExpected"));
		}
	}

	return nameParser;

}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:36,代碼來源:NamingContext.java

示例5: getNameParser

import javax.naming.NameParser; //導入依賴的package包/類
/**
 * Retrieves the parser associated with the named context. In a
 * federation of namespaces, different jndi systems will parse names
 * differently. This method allows an application to get a parser for
 * parsing names into their atomic components using the jndi convention
 * of a particular jndi system. Within any single jndi system,
 * NameParser objects returned by this method must be equal (using the
 * equals() test).
 *
 * @param name the name of the context from which to get the parser
 * @return a name parser that can parse compound names into their atomic
 * components
 * @throws NamingException if a jndi exception is encountered
 */
@Override
public NameParser getNameParser(Name name) throws NamingException {

    while ((!name.isEmpty()) && (name.get(0).length() == 0)) {
        name = name.getSuffix(1);
    }

    if (name.isEmpty()) {
        return NAME_PARSER;
    }

    if (name.size() > 1) {
        Object obj = bindings.get(name.get(0));
        if (obj instanceof Context) {
            return ((Context) obj).getNameParser(name.getSuffix(1));
        } else {
            throw new NotContextException(SM.getString("namingContext.contextExpected"));
        }
    }

    return NAME_PARSER;

}
 
開發者ID:wso2,項目名稱:carbon-jndi,代碼行數:38,代碼來源:NamingContext.java

示例6: testDataSource

import javax.naming.NameParser; //導入依賴的package包/類
/**
 * Tests that we can get a connection from the DataSource bound in JNDI
 * during test setup
 * 
 * @throws Exception
 *             if an error occurs
 */
public void testDataSource() throws Exception {
    NameParser nameParser = this.ctx.getNameParser("");
    Name datasourceName = nameParser.parse("_test");
    Object obj = this.ctx.lookup(datasourceName);
    DataSource boundDs = null;

    if (obj instanceof DataSource) {
        boundDs = (DataSource) obj;
    } else if (obj instanceof Reference) {
        //
        // For some reason, this comes back as a Reference instance under CruiseControl !?
        //
        Reference objAsRef = (Reference) obj;
        ObjectFactory factory = (ObjectFactory) Class.forName(objAsRef.getFactoryClassName()).newInstance();
        boundDs = (DataSource) factory.getObjectInstance(objAsRef, datasourceName, this.ctx, new Hashtable<Object, Object>());
    }

    assertTrue("Datasource not bound", boundDs != null);

    Connection con = boundDs.getConnection();
    con.close();
    assertTrue("Connection can not be obtained from data source", con != null);
}
 
開發者ID:KillianMeersman,項目名稱:Geometry-wars,代碼行數:31,代碼來源:DataSourceTest.java

示例7: lookupDatasourceInJNDI

import javax.naming.NameParser; //導入依賴的package包/類
private DataSource lookupDatasourceInJNDI(String jndiName) throws Exception {
    NameParser nameParser = this.ctx.getNameParser("");
    Name datasourceName = nameParser.parse(this.tempDir.getAbsolutePath() + jndiName);
    Object obj = this.ctx.lookup(datasourceName);
    DataSource boundDs = null;

    if (obj instanceof DataSource) {
        boundDs = (DataSource) obj;
    } else if (obj instanceof Reference) {
        //
        // For some reason, this comes back as a Reference instance under CruiseControl !?
        //
        Reference objAsRef = (Reference) obj;
        ObjectFactory factory = (ObjectFactory) Class.forName(objAsRef.getFactoryClassName()).newInstance();
        boundDs = (DataSource) factory.getObjectInstance(objAsRef, datasourceName, this.ctx, new Hashtable<Object, Object>());
    }

    return boundDs;
}
 
開發者ID:KillianMeersman,項目名稱:Geometry-wars,代碼行數:20,代碼來源:DataSourceRegressionTest.java

示例8: lookupDatasourceInJNDI

import javax.naming.NameParser; //導入依賴的package包/類
private DataSource lookupDatasourceInJNDI(String jndiName) throws Exception {
	NameParser nameParser = this.ctx.getNameParser("");
	Name datasourceName = nameParser.parse(this.tempDir.getAbsolutePath()
			+ jndiName);
	Object obj = this.ctx.lookup(datasourceName);
	DataSource boundDs = null;

	if (obj instanceof DataSource) {
		boundDs = (DataSource) obj;
	} else if (obj instanceof Reference) {
		//
		// For some reason, this comes back as a Reference
		// instance under CruiseControl !?
		//
		Reference objAsRef = (Reference) obj;
		ObjectFactory factory = (ObjectFactory) Class.forName(
				objAsRef.getFactoryClassName()).newInstance();
		boundDs = (DataSource) factory.getObjectInstance(objAsRef,
				datasourceName, this.ctx, new Hashtable<Object, Object>());
	}

	return boundDs;
}
 
開發者ID:hinsenchan,項目名稱:fil_project_mgmt_app_v2,代碼行數:24,代碼來源:DataSourceRegressionTest.java

示例9: getNameParser

import javax.naming.NameParser; //導入依賴的package包/類
/**
 * Tries to look for the context associated with the given name and returns
 * the appropriate name parser. For <code>DNSContext</code> this method
 * will return an instance of <code>DNSNameParser</code> class.
 * 
 * @param a
 *            name to return a name parser for
 * @return a name parser for the naming system the found context is
 *         associated with
 * @throws NotContextException
 *             if found object is not a context so we cannot obtain a name
 *             parser from it
 * @throws NamingException
 *             if such exception was encountered during lookup
 * @see Context#getNameParser(Name)
 */
public NameParser getNameParser(Name name) throws NamingException {
    Object obj;

    if (name == null) {
        // jndi.2E=The name is null
        throw new NullPointerException(Messages.getString("jndi.2E")); //$NON-NLS-1$
    }
    obj = lookup(name);
    if (obj instanceof DNSContext) {
        return nameParser;
    } else if (obj instanceof Context) {
        return ((Context) obj).getNameParser(""); //$NON-NLS-1$
    }
    // jndi.4E=found object is not a Context
    throw new NotContextException(Messages.getString("jndi.4E")); //$NON-NLS-1$
}
 
開發者ID:nextopio,項目名稱:nextop-client,代碼行數:33,代碼來源:DNSContext.java

示例10: getNameParser

import javax.naming.NameParser; //導入依賴的package包/類
/**
 * Returns the name parser for given name.
 * 
 * @param name
 *            a name in the string form to return a name parser for
 * @return the name parser found
 * @throws NotContextException
 *             if found object is not a context
 * @throws NamingException
 *             if such exception was encountered during lookup
 * @see DNSContext#getNameParser(Name) for details
 * @see javax.naming.Context#getNameParser(java.lang.String)
 */
public NameParser getNameParser(String name) throws NamingException {
    Object obj;

    if (name == null) {
        // jndi.2E=The name is null
        throw new NullPointerException(Messages.getString("jndi.2E")); //$NON-NLS-1$
    }
    obj = lookup(name);
    if (obj instanceof DNSContext) {
        return nameParser;
    } else if (obj instanceof Context) {
        return ((Context) obj).getNameParser(""); //$NON-NLS-1$
    }
    // jndi.4E=found object is not a Context
    throw new NotContextException(Messages.getString("jndi.4E")); //$NON-NLS-1$
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:30,代碼來源:DNSContext.java

示例11: getNameParser

import javax.naming.NameParser; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
public NameParser getNameParser(Name name) throws NamingException {
    if (!(name instanceof CompositeName)) {
        // jndi.26=URL context can't accept non-composite name: {0}
        throw new InvalidNameException(Messages.getString("jndi.26", name)); //$NON-NLS-1$
    }

    if (name.size() == 1) {
        return getNameParser(name.get(0));
    }
    Context context = getContinuationContext(name);
    try {
        return context.getNameParser(name.getSuffix(1));
    } finally {
        context.close();
    }
}
 
開發者ID:nextopio,項目名稱:nextop-client,代碼行數:20,代碼來源:GenericURLContext.java

示例12: getLDAPGroupNames

import javax.naming.NameParser; //導入依賴的package包/類
private Collection<Name> getLDAPGroupNames(DirContext ctx, Attributes useratt)
{
	Set<Name> foundGroups = new HashSet<Name>();
	if( !Check.isEmpty(memberOfField) )
	{
		Attribute attribute = useratt.get(memberOfField);
		try
		{
			NameParser parser = ctx.getNameParser(""); //$NON-NLS-1$
			if( attribute != null )
			{
				NamingEnumeration<?> enumeration = attribute.getAll();
				while( enumeration != null && enumeration.hasMore() )
				{
					String role = (String) enumeration.next();
					Name compound = parser.parse(role);
					foundGroups.add(compound);
				}
			}
		}
		catch( NamingException e )
		{
			throw new RuntimeException("Couldn't get memberField", e);
		}
	}
	return foundGroups;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:28,代碼來源:MemberOfGroupSearch.java

示例13: getDistinguishedName

import javax.naming.NameParser; //導入依賴的package包/類
/**
 * Returns the distinguished name of a search result.
 *
 * @param context Our DirContext
 * @param base The base DN
 * @param result The search result
 * @return String containing the distinguished name
 */
protected String getDistinguishedName(DirContext context, String base, SearchResult result)
    throws NamingException {
    // Get the entry's distinguished name
    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();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:JNDIRealm.java

示例14: getNameParser

import javax.naming.NameParser; //導入依賴的package包/類
@Override
public NameParser getNameParser(Name name) throws NamingException {
	Object obj = lookup(name);
	
	if (obj instanceof Context)
		((Context) obj).close();

	return this;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:10,代碼來源:LocalContext.java

示例15: getNameParser

import javax.naming.NameParser; //導入依賴的package包/類
@Override
public NameParser getNameParser(final Name name) throws NamingException {
	// Do lookup to verify name exists
	final Object obj = lookup(name);
	if (obj instanceof Context) {
		((Context) obj).close();
	}
	return NamingContext.nameParser;
}
 
開發者ID:geronimo-iia,項目名稱:winstone,代碼行數:10,代碼來源:NamingContext.java


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