本文整理汇总了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);
}