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


Java InitialContext.rebind方法代码示例

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


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

示例1: bind

import javax.naming.InitialContext; //导入方法依赖的package包/类
/**
 * Registers a new service in JNDI. The service is bound to the name define by the service interface's
 * {@link io.bdj.service.ServiceAddress} annotation.
 *
 * @param service
 *         the service instance to be registered. The service must implement an interface that is annotated with
 *         {@link io.bdj.service.ServiceAddress} that defines the service address.
 */
public static <S, I extends S> void bind(Class<S> serviceClass, I service) {

    ServiceAddress addr = getServiceAddress(serviceClass);
    try {
        InitialContext ic = new InitialContext();
        ic.rebind(addr.value(), service);
    } catch (NamingException e) {
        throw new ServiceRuntimeException("Could not bind service " + serviceClass);
    }
}
 
开发者ID:gmuecke,项目名称:boutique-de-jus,代码行数:19,代码来源:Services.java

示例2: bind

import javax.naming.InitialContext; //导入方法依赖的package包/类
/**
 * Bind a stub to a registry.
 * @param jndiUrl URL of the stub in the registry, extracted
 *        from the <code>JMXServiceURL</code>.
 * @param attributes A Hashtable containing environment parameters,
 *        built from the Map specified at this object creation.
 * @param rmiServer The object to bind in the registry
 * @param rebind true if the object must be rebound.
 **/
void bind(String jndiUrl, Hashtable<?, ?> attributes,
          RMIServer rmiServer, boolean rebind)
    throws NamingException, MalformedURLException {
    // if jndiURL is not null, we nust bind the stub to a
    // directory.
    InitialContext ctx =
        new InitialContext(attributes);

    if (rebind)
        ctx.rebind(jndiUrl, rmiServer);
    else
        ctx.bind(jndiUrl, rmiServer);
    ctx.close();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:RMIConnectorServer.java


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