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


Java Context.listBindings方法代码示例

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


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

示例1: doGet

import javax.naming.Context; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    resp.setContentType("text/plain;UTF-8");
    PrintWriter out = resp.getWriter();

    try {
        Context ctx = new InitialContext();
        NamingEnumeration<Binding> enm =
            ctx.listBindings("java:comp/env/list");
        while (enm.hasMore()) {
            Binding b = enm.next();
            out.print(b.getObject().getClass().getName());
        }
    } catch (NamingException ne) {
        ne.printStackTrace(out);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:20,代码来源:TestNamingContext.java

示例2: createMBeans

import javax.naming.Context; //导入方法依赖的package包/类
/**
 * Create the MBeans for the interesting global JNDI resources in
 * the specified naming context.
 *
 * @param prefix Prefix for complete object name paths
 * @param context Context to be scanned
 *
 * @exception NamingException if a JNDI exception occurs
 */
protected void createMBeans(String prefix, Context context)
    throws NamingException {

    if (debug >= 1) {
        log("Creating MBeans for Global JNDI Resources in Context '" +
            prefix + "'");
    }

    NamingEnumeration bindings = context.listBindings("");
    while (bindings.hasMore()) {
        Binding binding = (Binding) bindings.next();
        String name = prefix + binding.getName();
        Object value = context.lookup(binding.getName());
        if (debug >= 2) {
            log("Checking resource " + name);
        }
        if (value instanceof Context) {
            createMBeans(name + "/", (Context) value);
        } else if (value instanceof UserDatabase) {
            try {
                createMBeans(name, (UserDatabase) value);
            } catch (Exception e) {
                log("Exception creating UserDatabase MBeans for " + name,
                    e);
            }
        }
    }

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:39,代码来源:GlobalResourcesLifecycleListener.java

示例3: clearContext

import javax.naming.Context; //导入方法依赖的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());
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:15,代码来源:ContextJUnitTest.java

示例4: verifyListBindings

import javax.naming.Context; //导入方法依赖的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();
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:36,代码来源:ContextJUnitTest.java


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