本文整理匯總了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();
}
示例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();
}
示例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
}
}
示例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();
}
示例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);
}
}
}
示例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);
}
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}