本文整理匯總了Java中javax.naming.Binding.getObject方法的典型用法代碼示例。如果您正苦於以下問題:Java Binding.getObject方法的具體用法?Java Binding.getObject怎麽用?Java Binding.getObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.naming.Binding
的用法示例。
在下文中一共展示了Binding.getObject方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: listCollectionPaths
import javax.naming.Binding; //導入方法依賴的package包/類
/**
* List resource paths (recursively), and store all of them in the given
* Set.
*/
private static void listCollectionPaths(Set<String> set,
DirContext resources, String path) throws NamingException {
Enumeration<Binding> childPaths = resources.listBindings(path);
while (childPaths.hasMoreElements()) {
Binding binding = childPaths.nextElement();
String name = binding.getName();
StringBuilder childPath = new StringBuilder(path);
if (!"/".equals(path) && !path.endsWith("/"))
childPath.append("/");
childPath.append(name);
Object object = binding.getObject();
if (object instanceof DirContext) {
childPath.append("/");
}
set.add(childPath.toString());
}
}
示例2: while
import javax.naming.Binding; //導入方法依賴的package包/類
/**
* List resource paths (recursively), and store all of them in the given
* Set.
*/
private static void listCollectionPaths
(Set set, DirContext resources, String path)
throws NamingException {
Enumeration childPaths = resources.listBindings(path);
while (childPaths.hasMoreElements()) {
Binding binding = (Binding) childPaths.nextElement();
String name = binding.getName();
StringBuffer childPath = new StringBuffer(path);
if (!"/".equals(path) && !path.endsWith("/"))
childPath.append("/");
childPath.append(name);
Object object = binding.getObject();
if (object instanceof DirContext) {
childPath.append("/");
}
set.add(childPath.toString());
}
}
示例3: listPaths
import javax.naming.Binding; //導入方法依賴的package包/類
/**
* List resource paths (recursively), and store all of them in the given
* Set.
*/
private static void listPaths(Set set, DirContext resources, String path)
throws NamingException {
Enumeration childPaths = resources.listBindings(path);
while (childPaths.hasMoreElements()) {
Binding binding = (Binding) childPaths.nextElement();
String name = binding.getName();
String childPath = path + "/" + name;
set.add(childPath);
Object object = binding.getObject();
if (object instanceof DirContext) {
listPaths(set, resources, childPath);
}
}
}
示例4: listCollectionPaths
import javax.naming.Binding; //導入方法依賴的package包/類
/**
* List resource paths (recursively), and store all of them in the given
* Set.
*/
private static void listCollectionPaths(Set<String> set, DirContext resources, String path) throws NamingException {
Enumeration<Binding> childPaths = resources.listBindings(path);
while (childPaths.hasMoreElements()) {
Binding binding = childPaths.nextElement();
String name = binding.getName();
StringBuilder childPath = new StringBuilder(path);
if (!"/".equals(path) && !path.endsWith("/"))
childPath.append("/");
childPath.append(name);
Object object = binding.getObject();
if (object instanceof DirContext) {
childPath.append("/");
}
set.add(childPath.toString());
}
}
示例5: listContext
import javax.naming.Binding; //導入方法依賴的package包/類
/**
* Recursively exhaust the JNDI tree
*/
private static final void listContext(javax.naming.Context ctx, String indent) {
try {
NamingEnumeration<Binding> list = ctx.listBindings("");
while (list.hasMore()) {
Binding item = (Binding) list.next();
String className = item.getClassName();
String name = item.getName();
log.info(indent + className + " | " + name);
Object o = item.getObject();
if (o instanceof javax.naming.Context) {
listContext((javax.naming.Context) o, indent + " ");
}
}
} catch (NamingException ex) {
log.warn("JNDI failure: ", ex);
}
}
示例6: createJndiBinding
import javax.naming.Binding; //導入方法依賴的package包/類
private static JndiBinding createJndiBinding(String path, Binding binding) {
final String name = getBindingName(path, binding);
final String className = binding.getClassName();
final Object object = binding.getObject();
final String contextPath;
final String value;
if (object instanceof Context
// "javax.naming.Context".equals(className) nécessaire pour le path "comp" dans JBoss 6.0
|| "javax.naming.Context".equals(className)
// pour jetty :
|| object instanceof Reference
&& "javax.naming.Context".equals(((Reference) object).getClassName())) {
if (!path.isEmpty()) {
contextPath = path + '/' + name;
} else {
// nécessaire pour jonas 5.1.0
contextPath = name;
}
value = null;
} else {
contextPath = null;
value = formatValue(object);
}
return new JndiBinding(name, className, contextPath, value);
}
示例7: dumpBindings
import javax.naming.Binding; //導入方法依賴的package包/類
private static void dumpBindings(Context ctx, int indent) {
try {
NamingEnumeration<Binding> bindings = ctx.listBindings("");
while (bindings.hasMore()) {
Binding binding = bindings.next();
StringBuffer blanks = new StringBuffer();
for (int i = 0; i < indent; i++) {
blanks.append(" ");
}
System.out.println(String.format("%s%s (%s)", blanks, binding.getName(), binding.getClassName()));
Object boundObj = binding.getObject();
if (boundObj instanceof Context) {
dumpBindings((Context) boundObj, indent + 3);
}
}
} catch (NamingException e) {
System.out.println(e);
}
}
示例8: printResources
import javax.naming.Binding; //導入方法依賴的package包/類
/**
* List the resources of the given context.
*/
protected void printResources(PrintWriter writer, String prefix,
javax.naming.Context namingContext,
String type, Class<?> clazz,
StringManager smClient) {
try {
NamingEnumeration<Binding> items = namingContext.listBindings("");
while (items.hasMore()) {
Binding item = items.next();
if (item.getObject() instanceof javax.naming.Context) {
printResources
(writer, prefix + item.getName() + "/",
(javax.naming.Context) item.getObject(), type, clazz,
smClient);
} else {
if ((clazz != null) &&
(!(clazz.isInstance(item.getObject())))) {
continue;
}
writer.print(prefix + item.getName());
writer.print(':');
writer.print(item.getClassName());
// Do we want a description if available?
writer.println();
}
}
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
log("ManagerServlet.resources[" + type + "]", t);
writer.println(smClient.getString("managerServlet.exception",
t.toString()));
}
}
示例9: printResources
import javax.naming.Binding; //導入方法依賴的package包/類
/**
* List the resources of the given context.
*/
protected void printResources(PrintWriter writer, String prefix,
javax.naming.Context namingContext,
String type, Class clazz) {
try {
NamingEnumeration items = namingContext.listBindings("");
while (items.hasMore()) {
Binding item = (Binding) items.next();
if (item.getObject() instanceof javax.naming.Context) {
printResources
(writer, prefix + item.getName() + "/",
(javax.naming.Context) item.getObject(), type, clazz);
} else {
if ((clazz != null) &&
(!(clazz.isInstance(item.getObject())))) {
continue;
}
writer.print(prefix + item.getName());
writer.print(':');
writer.print(item.getClassName());
// Do we want a description if available?
writer.println();
}
}
} catch (Throwable t) {
log("ManagerServlet.resources[" + type + "]", t);
writer.println(sm.getString("managerServlet.exception",
t.toString()));
}
}
示例10: clearContext
import javax.naming.Binding; //導入方法依賴的package包/類
/**
* Removes all entries from the specified context, including subcontexts.
*
* @param context context to clear
*/
private void clearContext(Context context) throws NamingException {
for (NamingEnumeration e = context.listBindings(""); e.hasMoreElements();) {
Binding binding = (Binding) e.nextElement();
if (binding.getObject() instanceof Context) {
clearContext((Context) binding.getObject());
}
context.unbind(binding.getName());
}
}
示例11: verifyListBindings
import javax.naming.Binding; //導入方法依賴的package包/類
private void verifyListBindings(Context c, String name, Object obj1, Object obj2)
throws NamingException {
boolean datasourceFoundFlg = false;
boolean o2FoundFlg = false;
boolean datasourceO1FoundFlg = false;
boolean datasourceNullFoundFlg = false;
// List bindings for the specified context
for (NamingEnumeration en = c.listBindings(name); en.hasMore();) {
Binding b = (Binding) en.next();
if (b.getName().equals("datasource")) {
assertEquals(b.getObject(), dataSourceContext);
datasourceFoundFlg = true;
Context nextCon = (Context) b.getObject();
for (NamingEnumeration en1 = nextCon.listBindings(""); en1.hasMore();) {
Binding b1 = (Binding) en1.next();
if (b1.getName().equals("sub41")) {
assertEquals(b1.getObject(), obj1);
datasourceO1FoundFlg = true;
} else if (b1.getName().equals("sub43")) {
// check for null object
assertNull(b1.getObject());
datasourceNullFoundFlg = true;
}
}
} else if (b.getName().equals("sub42")) {
assertEquals(b.getObject(), obj2);
o2FoundFlg = true;
}
}
if (!(datasourceFoundFlg && o2FoundFlg && datasourceO1FoundFlg && datasourceNullFoundFlg)) {
fail();
}
}
示例12: printResources
import javax.naming.Binding; //導入方法依賴的package包/類
/**
* List the resources of the given context.
*/
protected void printResources(final PrintWriter writer, final String prefix,
final javax.naming.Context namingContext,
final String type, final Class clazz) {
try {
final NamingEnumeration items = namingContext.listBindings("");
while (items.hasMore()) {
final Binding item = (Binding) items.next();
if (item.getObject() instanceof javax.naming.Context) {
printResources
(writer, prefix + item.getName() + '/',
(javax.naming.Context) item.getObject(), type, clazz);
} else {
if (clazz != null &&
!clazz.isInstance(item.getObject())) {
continue;
}
writer.print(prefix + item.getName());
writer.print(':');
writer.print(item.getClassName());
// Do we want a description if available?
writer.println();
}
}
} catch (Throwable t) {
log("ManagerServlet.resources[" + type + ']', t);
writer.println(sm.getString("managerServlet.exception",
t.toString()));
}
}
示例13: printResources
import javax.naming.Binding; //導入方法依賴的package包/類
/**
* List the resources of the given context.
*/
protected void printResources(PrintWriter writer, String prefix, javax.naming.Context namingContext, String type,
Class<?> clazz, StringManager smClient) {
try {
NamingEnumeration<Binding> items = namingContext.listBindings("");
while (items.hasMore()) {
Binding item = items.next();
if (item.getObject() instanceof javax.naming.Context) {
printResources(writer, prefix + item.getName() + "/", (javax.naming.Context) item.getObject(), type,
clazz, smClient);
} else {
if ((clazz != null) && (!(clazz.isInstance(item.getObject())))) {
continue;
}
writer.print(prefix + item.getName());
writer.print(':');
writer.print(item.getClassName());
// Do we want a description if available?
writer.println();
}
}
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
log("ManagerServlet.resources[" + type + "]", t);
writer.println(smClient.getString("managerServlet.exception", t.toString()));
}
}
示例14: clearContext
import javax.naming.Binding; //導入方法依賴的package包/類
/**
* Removes all entries from the specified context, including subcontexts.
*
* @param context context ot clear
*/
private void clearContext(Context context)
throws NamingException {
for (NamingEnumeration e = context.listBindings(""); e
.hasMoreElements();) {
Binding binding = (Binding) e.nextElement();
if (binding.getObject() instanceof Context) {
clearContext((Context) binding.getObject());
}
context.unbind(binding.getName());
}
}
示例15: assertBinding
import javax.naming.Binding; //導入方法依賴的package包/類
protected void assertBinding(Binding binding) throws NamingException {
Object object = binding.getObject();
assertTrue("Should have got a child context but got: " + object, object instanceof Context);
Context childContext = (Context) object;
NamingEnumeration<Binding> iter = childContext.listBindings("");
while (iter.hasMore()) {
Binding destinationBinding = iter.next();
LOG.info("Found destination: " + destinationBinding.getName());
Object destination = destinationBinding.getObject();
assertTrue("Should have a Destination but got: " + destination, destination instanceof Destination);
}
}