当前位置: 首页>>代码示例>>Java>>正文


Java NameParser.parse方法代码示例

本文整理汇总了Java中javax.naming.NameParser.parse方法的典型用法代码示例。如果您正苦于以下问题:Java NameParser.parse方法的具体用法?Java NameParser.parse怎么用?Java NameParser.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.naming.NameParser的用法示例。


在下文中一共展示了NameParser.parse方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例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:hinsenchan,项目名称:fil_project_mgmt_app_v2,代码行数:35,代码来源:DataSourceTest.java

示例7: getPaths

import javax.naming.NameParser; //导入方法依赖的package包/类
/**
 * Liefert zum Pfadlevel pathLength alle Knoten, die auf die LDAP-Suchanfrage
 * filter passen
 * 
 * @throws TimeoutException
 *           falls die Suche nicht vor endTime beendet werden konnte.
 * @author Max Meier (D-III-ITD 5.1)
 */
private RelativePaths getPaths(String filter, int pathLength, long endTime)
    throws TimeoutException
{

  Vector<Name> paths;

  long timeout = endTime - System.currentTimeMillis();
  if (timeout <= 0) throw new TimeoutException();
  if (timeout > Integer.MAX_VALUE) timeout = Integer.MAX_VALUE;

  try
  {
    setTimeout(properties, timeout);
    Logger.debug2("new InitialLdapContext(properties, null)");
    DirContext ctx = new InitialLdapContext(properties, null);

    Logger.debug2("ctx.getNameParser(\"\")");
    NameParser np = ctx.getNameParser("");
    int rootSize = np.parse(baseDN).size();
    SearchControls sc = new SearchControls();
    sc.setSearchScope(SearchControls.SUBTREE_SCOPE);

    sc.setTimeLimit((int) timeout);

    Logger.debug2("ctx.search(" + baseDN + "," + filter + ",sc) mit Zeitlimit "
      + sc.getTimeLimit());
    NamingEnumeration<SearchResult> enumer = ctx.search(baseDN, filter, sc);
    Logger.debug2("ctx.search() abgeschlossen");

    paths = new Vector<Name>();

    while (enumer.hasMoreElements())
    {
      if (System.currentTimeMillis() > endTime) throw new TimeoutException();
      SearchResult result = enumer.nextElement();
      String path = preparePath(result.getNameInNamespace());
      Name pathName = np.parse(path);
      /*
       * ACHTUNG: hier kann NICHT (pathLength < 0 && (pathName.size()+rootLength >
       * abs(pathLength))) getestet werden, denn Minus-Bedingungen betreffen die
       * Nachfahren, hier muesste also die Tiefe des tiefsten Nachfahrens
       * ausgewertet werden, die wir nicht kennen.
       */
      if (pathName.size() + rootSize == pathLength || pathLength < 0)
        paths.add(pathName);
    }

  }
  catch (NamingException e)
  {
    throw new TimeoutException(L.m("Internal error in LDAP."), e);
  }

  return new RelativePaths(pathLength, paths);

}
 
开发者ID:WollMux,项目名称:WollMux,代码行数:65,代码来源:LDAPDatasource.java

示例8: extractSlice

import javax.naming.NameParser; //导入方法依赖的package包/类
/**
 * Extracts a slice from an LDAP name.
 *
 * @param nameAsString
 *          LDAP name as string.
 * @param nameParser
 *          the LDAP JNDI name parser.
 * @param startIndex
 *          start index.
 * @param endIndex
 *          end index.
 * @return the LDAP name slice.
 * @throws NamingException whenever a naming exception occurs.
 */
protected String extractSlice(String nameAsString, NameParser nameParser,
    int startIndex, int endIndex) throws NamingException {
  int startI = startIndex;
  int endI = endIndex;
  Name name = nameParser.parse(nameAsString);
  if (startI < 0) {
    startI = name.size() + startI;
  }
  if (endI < 0) {
    endI = name.size() + endI;
  }
  return name.getPrefix(endI).getSuffix(startI).toString();
}
 
开发者ID:jspresso,项目名称:jspresso-ce,代码行数:28,代码来源:LdapLoginModule.java


注:本文中的javax.naming.NameParser.parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。