org.jboss.util.naming.Util.createSubcontext()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(167)

本文整理了Java中org.jboss.util.naming.Util.createSubcontext()方法的一些代码示例,展示了Util.createSubcontext()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.createSubcontext()方法的具体详情如下:
包路径:org.jboss.util.naming.Util
类名称:Util
方法名:createSubcontext

Util.createSubcontext介绍

[英]Create a subcontext including any intermediate contexts.
[中]创建包含任何中间上下文的子上下文。

代码示例

代码示例来源:origin: org.mobicents.core/mobicents-core-jar

  1. /**
  2. * Register standard SLEE contexts in JNDI
  3. *
  4. * @throws Exception
  5. */
  6. protected void initNamingContexts() throws Exception {
  7. // Initialize the SLEE name space
  8. /*
  9. * The following code sets the global name for the Slee
  10. */
  11. Context ctx = new InitialContext();
  12. ctx = Util.createSubcontext(ctx, JVM_ENV + CTX_SLEE);
  13. Util.createSubcontext(ctx, "resources");
  14. Util.createSubcontext(ctx, "container");
  15. Util.createSubcontext(ctx, "facilities");
  16. Util.createSubcontext(ctx, "sbbs");
  17. ctx = Util.createSubcontext(ctx, "nullactivity");
  18. Util.createSubcontext(ctx, "factory");
  19. Util.createSubcontext(ctx, "nullactivitycontextinterfacefactory");
  20. }

代码示例来源:origin: org.jboss.reloaded/jboss-reloaded-naming-deployers

  1. @Override
  2. public void start() throws Exception
  3. {
  4. parentContext = (application != null ? application.getContext() : nameSpaces.getGlobalContext());
  5. context = Util.createSubcontext(parentContext, name);
  6. // JavaEE 6 5.15
  7. context.bind("ModuleName", name);
  8. log.debug("Installed context " + context + " for JavaEE module " + name + ", application = " + application + ", parentContext = " + parentContext);
  9. }

代码示例来源:origin: org.jboss/jboss-common-core

  1. /** Create a subcontext including any intermediate contexts.
  2. @param ctx the parent JNDI Context under which value will be bound
  3. @param name the name relative to ctx of the subcontext.
  4. @return The new or existing JNDI subcontext
  5. @throws javax.naming.NamingException on any JNDI failure
  6. */
  7. public static Context createSubcontext(Context ctx, String name) throws NamingException
  8. {
  9. Name n = ctx.getNameParser("").parse(name);
  10. return createSubcontext(ctx, n);
  11. }

代码示例来源:origin: org.mobicents.core/mobicents-core-jar

  1. /**
  2. * Register a internal slee component with jndi.
  3. *
  4. */
  5. public static void registerWithJndi(String prefix, String name,
  6. Object object) {
  7. String fullName = JVM_ENV + prefix + "/" + name;
  8. try {
  9. Context ctx = new InitialContext();
  10. try {
  11. Util.createSubcontext(ctx, fullName);
  12. } catch (NamingException e) {
  13. logger.warn("Context, " + fullName + " might have been bound.");
  14. logger.warn(e);
  15. }
  16. ctx = (Context) ctx.lookup(JVM_ENV + prefix);
  17. // ctx.createSubcontext(name);
  18. // ctx = (Context) ctx.lookup(name);
  19. // Util.rebind(JVM_ENV + prefix + "/" + name, object);
  20. NonSerializableFactory.rebind(fullName, object);
  21. StringRefAddr addr = new StringRefAddr("nns", fullName);
  22. Reference ref = new Reference(object.getClass().getName(), addr,
  23. NonSerializableFactory.class.getName(), null);
  24. Util.rebind(ctx, name, ref);
  25. logger.debug("registered with jndi " + fullName);
  26. } catch (Exception ex) {
  27. logger.warn("registerWithJndi failed for " + fullName, ex);
  28. }
  29. }

代码示例来源:origin: org.jboss/jboss-common-core

  1. /** Bind val to name in ctx, and make sure that all intermediate contexts exist
  2. @param ctx the parent JNDI Context under which value will be bound
  3. @param name the name relative to ctx where value will be bound
  4. @param value the value to bind.
  5. @throws NamingException for any error
  6. */
  7. public static void bind(Context ctx, Name name, Object value) throws NamingException
  8. {
  9. int size = name.size();
  10. String atom = name.get(size - 1);
  11. Context parentCtx = createSubcontext(ctx, name.getPrefix(size - 1));
  12. parentCtx.bind(atom, value);
  13. }

代码示例来源:origin: org.jboss.ejb3/jboss-ejb3-core

  1. public static void rebind(Context ctx, String strName, Object value) throws javax.naming.NamingException
  2. {
  3. Name name = ctx.getNameParser("").parse(strName);
  4. int size = name.size();
  5. String atom = name.get(size - 1);
  6. Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1));
  7. String key = parentCtx.getNameInNamespace() + "/" + atom;
  8. wrapperMap.put(key, value);
  9. String className = value.getClass().getName();
  10. String factory = NonSerializableFactory.class.getName();
  11. StringRefAddr addr = new StringRefAddr("nns", key);
  12. Reference memoryRef = new Reference(className, addr, factory, null);
  13. parentCtx.rebind(atom, memoryRef);
  14. }

代码示例来源:origin: org.jboss/jboss-common-core

  1. /** Rebind val to name in ctx, and make sure that all intermediate contexts exist
  2. @param ctx the parent JNDI Context under which value will be bound
  3. @param name the name relative to ctx where value will be bound
  4. @param value the value to bind.
  5. @throws NamingException for any error
  6. */
  7. public static void rebind(Context ctx, Name name, Object value) throws NamingException
  8. {
  9. int size = name.size();
  10. String atom = name.get(size - 1);
  11. Context parentCtx = createSubcontext(ctx, name.getPrefix(size - 1));
  12. parentCtx.rebind(atom, value);
  13. }

代码示例来源:origin: org.mobicents.core/mobicents-core-jar

  1. private void bindInJndi() {
  2. Context ctx;
  3. try {
  4. ctx = new InitialContext();
  5. ComponentKey key = resourceAdaptorId.getComponentKey();
  6. Util.createSubcontext(ctx, CTX_JAVA_SLEE_RESOURCES + "/" + key.getName() + "/" + key.getVendor() + "/" + key.getVersion());
  7. } catch (NamingException e) {
  8. log.error("Failed binding RA in JNDI. RA ID: " + resourceAdaptorId, e);
  9. }
  10. }

代码示例来源:origin: org.jboss.ejb3/jboss-ejb3-core

  1. public static void bind(Context ctx, String strName, Object value) throws javax.naming.NamingException
  2. {
  3. Name name = ctx.getNameParser("").parse(strName);
  4. int size = name.size();
  5. String atom = name.get(size - 1);
  6. Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1));
  7. String key = parentCtx.getNameInNamespace() + "/" + atom;
  8. wrapperMap.put(key, value);
  9. String className = value.getClass().getName();
  10. String factory = NonSerializableFactory.class.getName();
  11. StringRefAddr addr = new StringRefAddr("nns", key);
  12. Reference memoryRef = new Reference(className, addr, factory, null);
  13. parentCtx.bind(atom, memoryRef);
  14. }

代码示例来源:origin: org.jboss/jboss-common-core

  1. /**
  2. * A convenience method that simplifies the process of rebinding a
  3. * non-serializable object into a JNDI context. This version binds the
  4. * target object into the default IntitialContext using name path.
  5. *
  6. * @param name the name to use as JNDI path name. The key into the
  7. * NonSerializableFactory map is obtained from the toString() value of name.
  8. * The name parameter cannot be a 0 length name.
  9. * @param target the non-Serializable object to bind.
  10. * @param createSubcontexts a flag indicating if subcontexts of name should
  11. * be created if they do not already exist.
  12. * @throws NamingException thrown on failure to rebind key into ctx.
  13. * @author Matt Carter
  14. **/
  15. public static synchronized void rebind(Name name, Object target, boolean createSubcontexts) throws NamingException
  16. {
  17. String key = name.toString();
  18. InitialContext ctx = new InitialContext();
  19. if (createSubcontexts == true && name.size() > 1)
  20. {
  21. int size = name.size() - 1;
  22. Util.createSubcontext(ctx, name.getPrefix(size));
  23. }
  24. rebind(ctx, key, target);
  25. }

代码示例来源:origin: org.mobicents.servlet.sip.containers/sip-servlets-tomcat-jboss4

  1. Context sipSubcontext = Util.createSubcontext(globalEnvCtx,SipNamingContextListener.SIP_SUBCONTEXT);
  2. Context applicationNameSubcontext = Util.createSubcontext(sipSubcontext,applicationName);
  3. NonSerializableFactory.rebind(applicationNameSubcontext,SipNamingContextListener.SIP_FACTORY_JNDI_NAME, sipFactoryFacade);
  4. NonSerializableFactory.rebind(applicationNameSubcontext, SipNamingContextListener.SIP_SESSIONS_UTIL_JNDI_NAME, sipSessionsUtil);
  5. Context envCtx = (Context) iniCtx.lookup("java:comp/env");
  6. currentThread.setContextClassLoader(currentLoader);
  7. sipSubcontext = Util.createSubcontext(envCtx,SipNamingContextListener.SIP_SUBCONTEXT);
  8. applicationNameSubcontext = Util.createSubcontext(sipSubcontext,applicationName);
  9. NonSerializableFactory.rebind(applicationNameSubcontext,SipNamingContextListener.SIP_FACTORY_JNDI_NAME, sipFactoryFacade);
  10. NonSerializableFactory.rebind(applicationNameSubcontext, SipNamingContextListener.SIP_SESSIONS_UTIL_JNDI_NAME, sipSessionsUtil);

代码示例来源:origin: org.jboss.ejb3/jboss-ejb3-core

  1. public void start() throws Exception
  2. {
  3. Context baseCtx = ctx;
  4. Name name = baseCtx.getNameParser("").parse(jndiName);
  5. baseCtx = Util.createSubcontext(baseCtx, name.getPrefix(name.size() - 1));
  6. String atom = name.get(name.size() - 1);
  7. RefAddr refAddr = new StringRefAddr(JndiSessionProxyObjectFactory.REF_ADDR_NAME_JNDI_BINDING_DELEGATE_PROXY_FACTORY, atom + PROXY_FACTORY_NAME);
  8. Reference ref = new Reference("java.lang.Object", refAddr, JndiSessionProxyObjectFactory.class.getName(), null);
  9. try
  10. {
  11. Util.rebind(baseCtx, atom, ref);
  12. } catch (NamingException e)
  13. {
  14. NamingException namingException = new NamingException("Could not bind producer factory into JNDI under jndiName: " + baseCtx.getNameInNamespace() + "/" + atom);
  15. namingException.setRootCause(e);
  16. throw namingException;
  17. }
  18. }

代码示例来源:origin: org.jboss.ejb3/jboss-ejb3-core

  1. public static void unbind(Context ctx, String strName) throws NamingException
  2. {
  3. Name name = ctx.getNameParser("").parse(strName);
  4. int size = name.size();
  5. String atom = name.get(size - 1);
  6. Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1));
  7. String key = parentCtx.getNameInNamespace() + "/" + atom;
  8. wrapperMap.remove(key);
  9. Util.unbind(ctx, strName);
  10. }

代码示例来源:origin: org.jboss.jbossas/jboss-as-connector

  1. /**
  2. * Bind the connection factory into jndi
  3. */
  4. protected void bindConnectionFactory() throws Exception
  5. {
  6. InitialContext ctx = initialContext;
  7. try
  8. {
  9. Name name = ctx.getNameParser("").parse(jndiName);
  10. String key = name.toString();
  11. if( true == true && name.size() > 1 )
  12. {
  13. int size = name.size() - 1;
  14. Util.createSubcontext(initialContext, name.getPrefix(size));
  15. }
  16. NonSerializableFactory.rebind(initialContext, key, datasource);
  17. log.info("Bound datasource to JNDI name '" + jndiName + "'");
  18. }
  19. catch (NamingException ne)
  20. {
  21. throw new DeploymentException("Could not bind ConnectionFactory into jndi: " + jndiName, ne);
  22. }
  23. finally
  24. {
  25. ctx.close();
  26. }
  27. }

代码示例来源:origin: org.jboss/jboss-common-core

  1. /** A convenience method that simplifies the process of rebinding a
  2. non-serializable object into a JNDI context.
  3. @param ctx the JNDI context to rebind to.
  4. @param key the key to use in both the NonSerializableFactory map and JNDI. It
  5. must be a valid name for use in ctx.bind().
  6. @param target the non-Serializable object to bind.
  7. @param createSubcontexts a flag indicating if subcontexts of name should
  8. be created if they do not already exist.
  9. @throws NamingException thrown on failure to rebind key into ctx.
  10. */
  11. public static synchronized void rebind(Context ctx, String key,
  12. Object target, boolean createSubcontexts) throws NamingException
  13. {
  14. Name name = ctx.getNameParser("").parse(key);
  15. if( createSubcontexts == true && name.size() > 1 )
  16. {
  17. int size = name.size() - 1;
  18. Util.createSubcontext(ctx, name.getPrefix(size));
  19. }
  20. rebind(ctx, key, target);
  21. }

相关文章