本文整理了Java中org.jboss.util.naming.Util.createSubcontext()
方法的一些代码示例,展示了Util.createSubcontext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.createSubcontext()
方法的具体详情如下:
包路径:org.jboss.util.naming.Util
类名称:Util
方法名:createSubcontext
[英]Create a subcontext including any intermediate contexts.
[中]创建包含任何中间上下文的子上下文。
代码示例来源:origin: org.mobicents.core/mobicents-core-jar
/**
* Register standard SLEE contexts in JNDI
*
* @throws Exception
*/
protected void initNamingContexts() throws Exception {
// Initialize the SLEE name space
/*
* The following code sets the global name for the Slee
*/
Context ctx = new InitialContext();
ctx = Util.createSubcontext(ctx, JVM_ENV + CTX_SLEE);
Util.createSubcontext(ctx, "resources");
Util.createSubcontext(ctx, "container");
Util.createSubcontext(ctx, "facilities");
Util.createSubcontext(ctx, "sbbs");
ctx = Util.createSubcontext(ctx, "nullactivity");
Util.createSubcontext(ctx, "factory");
Util.createSubcontext(ctx, "nullactivitycontextinterfacefactory");
}
代码示例来源:origin: org.jboss.reloaded/jboss-reloaded-naming-deployers
@Override
public void start() throws Exception
{
parentContext = (application != null ? application.getContext() : nameSpaces.getGlobalContext());
context = Util.createSubcontext(parentContext, name);
// JavaEE 6 5.15
context.bind("ModuleName", name);
log.debug("Installed context " + context + " for JavaEE module " + name + ", application = " + application + ", parentContext = " + parentContext);
}
代码示例来源:origin: org.jboss/jboss-common-core
/** Create a subcontext including any intermediate contexts.
@param ctx the parent JNDI Context under which value will be bound
@param name the name relative to ctx of the subcontext.
@return The new or existing JNDI subcontext
@throws javax.naming.NamingException on any JNDI failure
*/
public static Context createSubcontext(Context ctx, String name) throws NamingException
{
Name n = ctx.getNameParser("").parse(name);
return createSubcontext(ctx, n);
}
代码示例来源:origin: org.mobicents.core/mobicents-core-jar
/**
* Register a internal slee component with jndi.
*
*/
public static void registerWithJndi(String prefix, String name,
Object object) {
String fullName = JVM_ENV + prefix + "/" + name;
try {
Context ctx = new InitialContext();
try {
Util.createSubcontext(ctx, fullName);
} catch (NamingException e) {
logger.warn("Context, " + fullName + " might have been bound.");
logger.warn(e);
}
ctx = (Context) ctx.lookup(JVM_ENV + prefix);
// ctx.createSubcontext(name);
// ctx = (Context) ctx.lookup(name);
// Util.rebind(JVM_ENV + prefix + "/" + name, object);
NonSerializableFactory.rebind(fullName, object);
StringRefAddr addr = new StringRefAddr("nns", fullName);
Reference ref = new Reference(object.getClass().getName(), addr,
NonSerializableFactory.class.getName(), null);
Util.rebind(ctx, name, ref);
logger.debug("registered with jndi " + fullName);
} catch (Exception ex) {
logger.warn("registerWithJndi failed for " + fullName, ex);
}
}
代码示例来源:origin: org.jboss/jboss-common-core
/** Bind val to name in ctx, and make sure that all intermediate contexts exist
@param ctx the parent JNDI Context under which value will be bound
@param name the name relative to ctx where value will be bound
@param value the value to bind.
@throws NamingException for any error
*/
public static void bind(Context ctx, Name name, Object value) throws NamingException
{
int size = name.size();
String atom = name.get(size - 1);
Context parentCtx = createSubcontext(ctx, name.getPrefix(size - 1));
parentCtx.bind(atom, value);
}
代码示例来源:origin: org.jboss.ejb3/jboss-ejb3-core
public static void rebind(Context ctx, String strName, Object value) throws javax.naming.NamingException
{
Name name = ctx.getNameParser("").parse(strName);
int size = name.size();
String atom = name.get(size - 1);
Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1));
String key = parentCtx.getNameInNamespace() + "/" + atom;
wrapperMap.put(key, value);
String className = value.getClass().getName();
String factory = NonSerializableFactory.class.getName();
StringRefAddr addr = new StringRefAddr("nns", key);
Reference memoryRef = new Reference(className, addr, factory, null);
parentCtx.rebind(atom, memoryRef);
}
代码示例来源:origin: org.jboss/jboss-common-core
/** Rebind val to name in ctx, and make sure that all intermediate contexts exist
@param ctx the parent JNDI Context under which value will be bound
@param name the name relative to ctx where value will be bound
@param value the value to bind.
@throws NamingException for any error
*/
public static void rebind(Context ctx, Name name, Object value) throws NamingException
{
int size = name.size();
String atom = name.get(size - 1);
Context parentCtx = createSubcontext(ctx, name.getPrefix(size - 1));
parentCtx.rebind(atom, value);
}
代码示例来源:origin: org.mobicents.core/mobicents-core-jar
private void bindInJndi() {
Context ctx;
try {
ctx = new InitialContext();
ComponentKey key = resourceAdaptorId.getComponentKey();
Util.createSubcontext(ctx, CTX_JAVA_SLEE_RESOURCES + "/" + key.getName() + "/" + key.getVendor() + "/" + key.getVersion());
} catch (NamingException e) {
log.error("Failed binding RA in JNDI. RA ID: " + resourceAdaptorId, e);
}
}
代码示例来源:origin: org.jboss.ejb3/jboss-ejb3-core
public static void bind(Context ctx, String strName, Object value) throws javax.naming.NamingException
{
Name name = ctx.getNameParser("").parse(strName);
int size = name.size();
String atom = name.get(size - 1);
Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1));
String key = parentCtx.getNameInNamespace() + "/" + atom;
wrapperMap.put(key, value);
String className = value.getClass().getName();
String factory = NonSerializableFactory.class.getName();
StringRefAddr addr = new StringRefAddr("nns", key);
Reference memoryRef = new Reference(className, addr, factory, null);
parentCtx.bind(atom, memoryRef);
}
代码示例来源:origin: org.jboss/jboss-common-core
/**
* A convenience method that simplifies the process of rebinding a
* non-serializable object into a JNDI context. This version binds the
* target object into the default IntitialContext using name path.
*
* @param name the name to use as JNDI path name. The key into the
* NonSerializableFactory map is obtained from the toString() value of name.
* The name parameter cannot be a 0 length name.
* @param target the non-Serializable object to bind.
* @param createSubcontexts a flag indicating if subcontexts of name should
* be created if they do not already exist.
* @throws NamingException thrown on failure to rebind key into ctx.
* @author Matt Carter
**/
public static synchronized void rebind(Name name, Object target, boolean createSubcontexts) throws NamingException
{
String key = name.toString();
InitialContext ctx = new InitialContext();
if (createSubcontexts == true && name.size() > 1)
{
int size = name.size() - 1;
Util.createSubcontext(ctx, name.getPrefix(size));
}
rebind(ctx, key, target);
}
代码示例来源:origin: org.mobicents.servlet.sip.containers/sip-servlets-tomcat-jboss4
Context sipSubcontext = Util.createSubcontext(globalEnvCtx,SipNamingContextListener.SIP_SUBCONTEXT);
Context applicationNameSubcontext = Util.createSubcontext(sipSubcontext,applicationName);
NonSerializableFactory.rebind(applicationNameSubcontext,SipNamingContextListener.SIP_FACTORY_JNDI_NAME, sipFactoryFacade);
NonSerializableFactory.rebind(applicationNameSubcontext, SipNamingContextListener.SIP_SESSIONS_UTIL_JNDI_NAME, sipSessionsUtil);
Context envCtx = (Context) iniCtx.lookup("java:comp/env");
currentThread.setContextClassLoader(currentLoader);
sipSubcontext = Util.createSubcontext(envCtx,SipNamingContextListener.SIP_SUBCONTEXT);
applicationNameSubcontext = Util.createSubcontext(sipSubcontext,applicationName);
NonSerializableFactory.rebind(applicationNameSubcontext,SipNamingContextListener.SIP_FACTORY_JNDI_NAME, sipFactoryFacade);
NonSerializableFactory.rebind(applicationNameSubcontext, SipNamingContextListener.SIP_SESSIONS_UTIL_JNDI_NAME, sipSessionsUtil);
代码示例来源:origin: org.jboss.ejb3/jboss-ejb3-core
public void start() throws Exception
{
Context baseCtx = ctx;
Name name = baseCtx.getNameParser("").parse(jndiName);
baseCtx = Util.createSubcontext(baseCtx, name.getPrefix(name.size() - 1));
String atom = name.get(name.size() - 1);
RefAddr refAddr = new StringRefAddr(JndiSessionProxyObjectFactory.REF_ADDR_NAME_JNDI_BINDING_DELEGATE_PROXY_FACTORY, atom + PROXY_FACTORY_NAME);
Reference ref = new Reference("java.lang.Object", refAddr, JndiSessionProxyObjectFactory.class.getName(), null);
try
{
Util.rebind(baseCtx, atom, ref);
} catch (NamingException e)
{
NamingException namingException = new NamingException("Could not bind producer factory into JNDI under jndiName: " + baseCtx.getNameInNamespace() + "/" + atom);
namingException.setRootCause(e);
throw namingException;
}
}
代码示例来源:origin: org.jboss.ejb3/jboss-ejb3-core
public static void unbind(Context ctx, String strName) throws NamingException
{
Name name = ctx.getNameParser("").parse(strName);
int size = name.size();
String atom = name.get(size - 1);
Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1));
String key = parentCtx.getNameInNamespace() + "/" + atom;
wrapperMap.remove(key);
Util.unbind(ctx, strName);
}
代码示例来源:origin: org.jboss.jbossas/jboss-as-connector
/**
* Bind the connection factory into jndi
*/
protected void bindConnectionFactory() throws Exception
{
InitialContext ctx = initialContext;
try
{
Name name = ctx.getNameParser("").parse(jndiName);
String key = name.toString();
if( true == true && name.size() > 1 )
{
int size = name.size() - 1;
Util.createSubcontext(initialContext, name.getPrefix(size));
}
NonSerializableFactory.rebind(initialContext, key, datasource);
log.info("Bound datasource to JNDI name '" + jndiName + "'");
}
catch (NamingException ne)
{
throw new DeploymentException("Could not bind ConnectionFactory into jndi: " + jndiName, ne);
}
finally
{
ctx.close();
}
}
代码示例来源:origin: org.jboss/jboss-common-core
/** A convenience method that simplifies the process of rebinding a
non-serializable object into a JNDI context.
@param ctx the JNDI context to rebind to.
@param key the key to use in both the NonSerializableFactory map and JNDI. It
must be a valid name for use in ctx.bind().
@param target the non-Serializable object to bind.
@param createSubcontexts a flag indicating if subcontexts of name should
be created if they do not already exist.
@throws NamingException thrown on failure to rebind key into ctx.
*/
public static synchronized void rebind(Context ctx, String key,
Object target, boolean createSubcontexts) throws NamingException
{
Name name = ctx.getNameParser("").parse(key);
if( createSubcontexts == true && name.size() > 1 )
{
int size = name.size() - 1;
Util.createSubcontext(ctx, name.getPrefix(size));
}
rebind(ctx, key, target);
}
内容来源于网络,如有侵权,请联系作者删除!