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


Java Binding類代碼示例

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


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

示例1: configFromJndiConf

import javax.naming.Binding; //導入依賴的package包/類
private void configFromJndiConf(Object rootContextName) {
    if (rootContextName instanceof String) {
        String name = (String) rootContextName;
        name = name.substring(0, name.lastIndexOf('/')) + "/conf" + name.substring(name.lastIndexOf('/'));
        try {
            InitialContext ctx = new InitialContext();
            NamingEnumeration<Binding> bindings = ctx.listBindings(name);

            while (bindings.hasMore()) {
                Binding bd = bindings.next();
                IntrospectionSupport.setProperty(this, bd.getName(), bd.getObject());
            }

        } catch (Exception ignored) {
            if (LOG.isTraceEnabled()) {
                LOG.trace("exception on config from jndi: " + name, ignored);
            }
        }
    }
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:21,代碼來源:JmsPoolXAConnectionFactory.java

示例2: 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());
    }

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

示例3: listBindings

import javax.naming.Binding; //導入依賴的package包/類
/**
 * Enumerates the names bound in the named context, along with the 
 * objects bound to them. The contents of any subcontexts are not 
 * included.
 * <p>
 * If a binding is added to or removed from this context, its effect on 
 * an enumeration previously returned is undefined.
 * 
 * @param name the name of the context to list
 * @return an enumeration of the bindings in this context. 
 * Each element of the enumeration is of type Binding.
 * @exception NamingException if a naming exception is encountered
 */
@Override
public NamingEnumeration<Binding> listBindings(Name name)
    throws NamingException {
    // Removing empty parts
    while ((!name.isEmpty()) && (name.get(0).length() == 0))
        name = name.getSuffix(1);
    if (name.isEmpty()) {
        return new NamingContextBindingsEnumeration(bindings.values().iterator(), this);
    }
    
    NamingEntry entry = bindings.get(name.get(0));
    
    if (entry == null) {
        throw new NameNotFoundException
            (sm.getString("namingContext.nameNotBound", name, name.get(0)));
    }
    
    if (entry.type != NamingEntry.CONTEXT) {
        throw new NamingException
            (sm.getString("namingContext.contextExpected"));
    }
    return ((Context) entry.value).listBindings(name.getSuffix(1));
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:37,代碼來源:NamingContext.java

示例4: doGet

import javax.naming.Binding; //導入依賴的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

示例5: 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());
    }

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:ApplicationContext.java

示例6: 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);
        }
    }

}
 
開發者ID:c-rainstorm,項目名稱:jerrydog,代碼行數:21,代碼來源:ApplicationContext.java

示例7: 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());
	}

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

示例8: listBindings

import javax.naming.Binding; //導入依賴的package包/類
/**
 * Enumerates the names bound in the named context, along with the objects
 * bound to them. The contents of any subcontexts are not included.
 * <p>
 * If a binding is added to or removed from this context, its effect on an
 * enumeration previously returned is undefined.
 * 
 * @param name
 *            the name of the context to list
 * @return an enumeration of the bindings in this context. Each element of
 *         the enumeration is of type Binding.
 * @exception NamingException
 *                if a naming exception is encountered
 */
@Override
public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
	// Removing empty parts
	while ((!name.isEmpty()) && (name.get(0).length() == 0))
		name = name.getSuffix(1);
	if (name.isEmpty()) {
		return new NamingContextBindingsEnumeration(bindings.values().iterator(), this);
	}

	NamingEntry entry = bindings.get(name.get(0));

	if (entry == null) {
		throw new NameNotFoundException(sm.getString("namingContext.nameNotBound", name, name.get(0)));
	}

	if (entry.type != NamingEntry.CONTEXT) {
		throw new NamingException(sm.getString("namingContext.contextExpected"));
	}
	return ((Context) entry.value).listBindings(name.getSuffix(1));
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:35,代碼來源:NamingContext.java

示例9: init

import javax.naming.Binding; //導入依賴的package包/類
public void init() throws ServletException {
    super.init();
    // Nombre del layout por defecto
    defaultLayoutName = getServletConfig().getInitParameter("defaultLayoutName");

    try {
        Context context = new InitialContext();
        // Bajo JNDI habr� todos los pares: nombre, path que metemos en el Map
        NamingEnumeration namingEnum = context.listBindings("java:comp/env/layout");
        while (namingEnum.hasMore()) {
            Binding binding = (Binding) namingEnum.next();
            layoutPathMap.put(binding.getName(), binding.getObject());
        }
    } catch (NamingException e) {
        log.error("Error accediendo a JNDI", e);
    }

    // El layout por defecto debe estar en el Map!
    if (!layoutPathMap.containsKey(defaultLayoutName)) {
        log.error("El layout por defecto \"" + defaultLayoutName + "\" no est� definido bajo java:comp/env/layout");
        throw new UnavailableException("Error de configuraci�n");
    }
}
 
開發者ID:GovernIB,項目名稱:sistra,代碼行數:24,代碼來源:LayoutServlet.java

示例10: listServices

import javax.naming.Binding; //導入依賴的package包/類
private void listServices(BundleContext bundleContext, Context context) throws NamingException {
    Dictionary<String, Object> propertyMap = new Hashtable<>();
    propertyMap.put("osgi.jndi.service.name", "foo/myService");

    FooService fooService = new FooServiceImpl();
    ServiceRegistration<FooService> fooServiceRegistration = bundleContext.registerService(
            FooService.class, fooService, propertyMap);

    NamingEnumeration<Binding> listBindings =
            context.listBindings("osgi:service/foo/myService");

    Binding binding = listBindings.nextElement();

    logger.info("First service retrieved from the listBinding has the class : " + binding.getClassName());
    listBindings.close();  //call the close() method so that it will unget all the gotten services.
    fooServiceRegistration.unregister();
}
 
開發者ID:wso2,項目名稱:carbon-jndi,代碼行數:18,代碼來源:OSGiURLExecutor.java

示例11: listBindings

import javax.naming.Binding; //導入依賴的package包/類
/**
 * Enumerates the names bound in the named context, along with the
 * objects bound to them. The contents of any subcontexts are not
 * included.
 * <p>
 * If a binding is added to or removed from this context, its effect on
 * an enumeration previously returned is undefined.
 *
 * @param name the name of the context to list
 * @return an enumeration of the bindings in this context.
 * Each element of the enumeration is of type Binding.
 * @throws NamingException if a jndi exception is encountered
 */
@Override
public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {

    // Removing empty parts
    while ((!name.isEmpty()) && (name.get(0).length() == 0)) {
        name = name.getSuffix(1);
    }

    if (name.isEmpty()) {
        return new NamingContextBindingsEnumeration(new ArrayList<>(bindings.values()), this);
    }

    NamingEntry entry = bindings.get(name.get(0));

    if (entry == null) {
        throw new NameNotFoundException(SM.getString("namingContext.nameNotBound", name, name.get(0)));
    }

    if (entry.type != NamingEntry.CONTEXT) {
        throw new NamingException(SM.getString("namingContext.contextExpected"));
    }
    return ((Context) entry.value).listBindings(name.getSuffix(1));
}
 
開發者ID:wso2,項目名稱:carbon-jndi,代碼行數:37,代碼來源:NamingContext.java

示例12: 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);
   }
}
 
開發者ID:Wolfgang-Winter,項目名稱:cibet,代碼行數:21,代碼來源:EESchedulerTask.java

示例13: changePassord

import javax.naming.Binding; //導入依賴的package包/類
public void changePassord(ServiceContext serviceContext, User user, String password) throws Exception{
	long companyId = serviceContext.getCompanyId();
	Properties userMappings = getUserMappings(serviceContext.getCompanyId());
	Binding binding = getUser(companyId, user.getScreenName());
	System.out.println("bingging " + binding);
	System.out.println("Pass " + user.getPassword());
    String name = StringPool.BLANK;
	StringBuilder sb = new StringBuilder();
	LdapContext ctx = getContext(serviceContext.getCompanyId());
       sb = new StringBuilder();
	sb.append(userMappings.getProperty("screenName"));
	sb.append(StringPool.EQUAL);
	sb.append(user.getScreenName());
	sb.append(StringPool.COMMA);
	sb.append(getUsersDN(companyId));
	name = sb.toString();
	Modifications mods = Modifications.getInstance();  
	
	mods.addItem(userMappings.getProperty(UserConverterKeys.PASSWORD),password);
	ModificationItem[] modItems = mods.getItems();
	if (binding != null) {
		ctx.modifyAttributes(name, modItems);
	}
	
}
 
開發者ID:openegovplatform,項目名稱:OEPv2,代碼行數:26,代碼來源:ManagerLdap.java

示例14: getNameInNamespace

import javax.naming.Binding; //導入依賴的package包/類
public String getNameInNamespace(long companyId, Binding binding)
		throws Exception {

	String baseDN = PrefsPropsUtil.getString(companyId,
			PropsKeys.LDAP_BASE_DN);

	if (Validator.isNull(baseDN)) {
		return binding.getName();
	} else {
		StringBuilder sb = new StringBuilder();

		sb.append(binding.getName());
		sb.append(StringPool.COMMA);
		sb.append(baseDN);

		return sb.toString();
	}
}
 
開發者ID:openegovplatform,項目名稱:OEPv2,代碼行數:19,代碼來源:ManagerLdap.java

示例15: next

import javax.naming.Binding; //導入依賴的package包/類
@Override
public Binding next() throws NamingException {
	if (hasMore()) {
		final Entry<String, Object> entry = iterator.next();

		final String name = entry.getKey();
		Object value = entry.getValue();
		try {
			value = NamingManager.getObjectInstance(value, new CompositeName().add(name), context, environnement);
		} catch (final Throwable err) {
			final NamingException errNaming = new NamingException("Failed To Get Instance ");
			errNaming.setRootCause(err);
			throw errNaming;
		}
		return new Binding(name, value);
	}
	throw new NoSuchElementException();
}
 
開發者ID:geronimo-iia,項目名稱:winstone,代碼行數:19,代碼來源:Bindings.java


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