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


Java NameClassPair.getName方法代碼示例

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


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

示例1: contextDump

import javax.naming.NameClassPair; //導入方法依賴的package包/類
private static String contextDump(Context ctx, String root, boolean recurse, int level) 
{
	StringBuilder sb = new StringBuilder();
	try
	{
		for( NamingEnumeration<NameClassPair> list = ctx.list(root); list.hasMore(); ) 
		{
		    NameClassPair nc = list.next();
		    for(int t=0; t<level; ++t)
		    	sb.append('\t');
		    sb.append(nc);
	    	sb.append("line.separator");
	    	if(recurse)
	    	{
	    		String childPath = root.length() > 0 ? root + "/" + nc.getName() : nc.getName();
	    		contextDump(ctx, childPath, recurse, level+1);
	    	}
		}
	}
	catch(NamingException nX)
	{
		sb.append(nX.getMessage());
	}
	
	return sb.toString();
}
 
開發者ID:VHAINNOVATIONS,項目名稱:Telepathology,代碼行數:27,代碼來源:JndiUtility.java

示例2: list

import javax.naming.NameClassPair; //導入方法依賴的package包/類
/**
 * List children of this collection. The names given are relative to this
 * URI's path. The full uri of the children is then : path + "/" + name.
 */
public Enumeration<String> list()
    throws IOException {

    if (!connected) {
        connect();
    }

    if ((resource == null) && (collection == null)) {
        throw new FileNotFoundException(
                getURL() == null ? "null" : getURL().toString());
    }

    Vector<String> result = new Vector<String>();

    if (collection != null) {
        try {
            NamingEnumeration<NameClassPair> enumeration =
                collection.list("/");
            UEncoder urlEncoder = new UEncoder(UEncoder.SafeCharsSet.WITH_SLASH);
            while (enumeration.hasMoreElements()) {
                NameClassPair ncp = enumeration.nextElement();
                String s = ncp.getName();
                result.addElement(
                        urlEncoder.encodeURL(s, 0, s.length()).toString());
            }
        } catch (NamingException e) {
            // Unexpected exception
            throw new FileNotFoundException(
                    getURL() == null ? "null" : getURL().toString());
        }
    }

    return result.elements();

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

示例3: tldScanResourcePathsWebInf

import javax.naming.NameClassPair; //導入方法依賴的package包/類
private void tldScanResourcePathsWebInf(DirContext resources,
                                        String rootPath,
                                        Set tldPaths) 
        throws IOException {

    if (log.isTraceEnabled()) {
        log.trace("  Scanning TLDs in " + rootPath + " subdirectory");
    }

    try {
        NamingEnumeration items = resources.list(rootPath);
        while (items.hasMoreElements()) {
            NameClassPair item = (NameClassPair) items.nextElement();
            String resourcePath = rootPath + "/" + item.getName();
            if (!resourcePath.endsWith(".tld")
                    && (resourcePath.startsWith("/WEB-INF/classes")
                        || resourcePath.startsWith("/WEB-INF/lib"))) {
                continue;
            }
            if (resourcePath.endsWith(".tld")) {
                if (log.isTraceEnabled()) {
                    log.trace("   Adding path '" + resourcePath + "'");
                }
                tldPaths.add(resourcePath);
            } else {
                tldScanResourcePathsWebInf(resources, resourcePath,
                                           tldPaths);
            }
        }
    } catch (NamingException e) {
        ; // Silent catch: it's valid that no /WEB-INF directory exists
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:34,代碼來源:TldConfig.java

示例4: list

import javax.naming.NameClassPair; //導入方法依賴的package包/類
/**
 * List children of this collection. The names given are relative to this
 * URI's path. The full uri of the children is then : path + "/" + name.
 */
public Enumeration<String> list() throws IOException {

	if (!connected) {
		connect();
	}

	if ((resource == null) && (collection == null)) {
		throw new FileNotFoundException(getURL() == null ? "null" : getURL().toString());
	}

	Vector<String> result = new Vector<String>();

	if (collection != null) {
		try {
			NamingEnumeration<NameClassPair> enumeration = collection.list("/");
			UEncoder urlEncoder = new UEncoder(UEncoder.SafeCharsSet.WITH_SLASH);
			while (enumeration.hasMoreElements()) {
				NameClassPair ncp = enumeration.nextElement();
				String s = ncp.getName();
				result.addElement(urlEncoder.encodeURL(s, 0, s.length()).toString());
			}
		} catch (NamingException e) {
			// Unexpected exception
			throw new FileNotFoundException(getURL() == null ? "null" : getURL().toString());
		}
	}

	return result.elements();

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

示例5: doList

import javax.naming.NameClassPair; //導入方法依賴的package包/類
private static void doList(int level, InitialContext context, String name) throws NamingException {

      for (NamingEnumeration ne = context.list(name); ne.hasMore();) {
         NameClassPair ncp = (NameClassPair) ne.next();
         String objectName = ncp.getName();
         String className = ncp.getClassName();
         String classText = " :" + className;
         if (isContext(className)) {
            log.debug(getPad(level) + "+" + objectName + classText);
            doList(level + 1, context, name + "/" + objectName);
         } else {
            log.debug(getPad(level) + "-" + objectName + classText);
         }
      }
   }
 
開發者ID:Wolfgang-Winter,項目名稱:cibet,代碼行數:16,代碼來源:EjbLookup.java

示例6: walk

import javax.naming.NameClassPair; //導入方法依賴的package包/類
private void walk(Context ctx, String name) {
    NamingEnumeration<NameClassPair> list = null;
    try {
        list = ctx.list("java:comp/" + name);
        while (list.hasMore()) {
            NameClassPair pair = list.next();
            if(!pair.getName().equals("__")){
                String cname = name + "/" + pair.getName();
                walk(ctx, cname);
            }
        }
    } catch (NamingException e) {
        logger.info("java:comp/" + name);
    }
}
 
開發者ID:phuihock,項目名稱:birtconn,代碼行數:16,代碼來源:Application.java

示例7: getJndiDataSourcesAt

import javax.naming.NameClassPair; //導入方法依賴的package包/類
private static Map<String, DataSource> getJndiDataSourcesAt(String jndiPrefix)
		throws NamingException {
	final InitialContext initialContext = new InitialContext();
	final Map<String, DataSource> dataSources = new LinkedHashMap<String, DataSource>(2);
	try {
		for (final NameClassPair nameClassPair : Collections
				.list(initialContext.list(jndiPrefix))) {
			// note: il ne suffit pas de tester
			// (DataSource.class.isAssignableFrom(Class.forName(nameClassPair.getClassName())))
			// car nameClassPair.getClassName() vaut "javax.naming.LinkRef" sous jboss 5.1.0.GA
			// par exemple, donc on fait le lookup pour voir
			final String jndiName;
			if (nameClassPair.getName().startsWith("java:")) {
				// pour glassfish v3
				jndiName = nameClassPair.getName();
			} else {
				jndiName = jndiPrefix + '/' + nameClassPair.getName();
			}
			final Object value = initialContext.lookup(jndiName);
			if (value instanceof DataSource) {
				dataSources.put(jndiName, (DataSource) value);
			}
		}
	} catch (final NamingException e) {
		// le préfixe ("comp/env/jdbc", "/jdbc" ou "java:global/jdbc", etc) n'existe pas dans jndi,
		// (dans glassfish 3.0.1, c'est une NamingException et non une NameNotFoundException)
		return dataSources;
	}
	initialContext.close();
	return dataSources;
}
 
開發者ID:javamelody,項目名稱:javamelody,代碼行數:32,代碼來源:JdbcWrapperHelper.java

示例8: list

import javax.naming.NameClassPair; //導入方法依賴的package包/類
/**
 * List children of this collection. The names given are relative to this
 * URI's path. The full uri of the children is then : path + "/" + name.
 */
public Enumeration<String> list()
    throws IOException {

    if (!connected) {
        connect();
    }

    if ((resource == null) && (collection == null)) {
        throw new FileNotFoundException(
                getURL() == null ? "null" : getURL().toString());
    }

    Vector<String> result = new Vector<String>();

    if (collection != null) {
        try {
            NamingEnumeration<NameClassPair> enumeration =
                collection.list("/");
            while (enumeration.hasMoreElements()) {
                NameClassPair ncp = enumeration.nextElement();
                String s = ncp.getName();
                result.addElement(
                        URL_ENCODER.encodeURL(s, 0, s.length()).toString());
            }
        } catch (NamingException e) {
            // Unexpected exception
            throw new FileNotFoundException(
                    getURL() == null ? "null" : getURL().toString());
        }
    }

    return result.elements();

}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:39,代碼來源:DirContextURLConnection.java

示例9: logNameClassPair

import javax.naming.NameClassPair; //導入方法依賴的package包/類
public static void logNameClassPair(NameClassPair ncp) {

        String s = "name: ";
        s += ncp.getName();

        s += ", class name: ";
        s += ncp.getClassName();

        s += ", name in namespace: ";

        try {

            s += ncp.getNameInNamespace();
        }
        catch(UnsupportedOperationException e) {

            s += "UNSUPPORTED";

        }

        s += ", ";
        s += (ncp.isRelative() ? "relative" : "NOT relative");

        log.info(s);
    }
 
開發者ID:NovaOrdis,項目名稱:playground,代碼行數:26,代碼來源:Util.java

示例10: next

import javax.naming.NameClassPair; //導入方法依賴的package包/類
@Override
public Binding next() throws NamingException {
    NameClassPair pair = entries.next();
    return new Binding(pair.getName(), pair.getClassName(), null);
}
 
開發者ID:huihoo,項目名稱:olat,代碼行數:6,代碼來源:VFSDirContext.java


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