org.jboss.util.naming.Util类的使用及代码示例

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

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

Util介绍

[英]A static utility class for common JNDI operations.
[中]用于常见JNDI操作的静态实用程序类。

代码示例

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

  1. public void stop() throws Exception
  2. {
  3. Util.unbind(ctx, jndiName);
  4. }
  5. }

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

  1. /**
  2. * Binds the {@link TimerService} to {@link #jndiName} under {@link #context}
  3. *
  4. * @throws NamingException If there is any exception during the bind operation
  5. */
  6. public void start() throws NamingException
  7. {
  8. Reference ref = new Reference(TimerService.class.getName(), TimerServiceObjectFactory.class.getName(), null);
  9. Util.bind(this.context, jndiName, ref);
  10. }

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

  1. public void inject(InjectionContainer container)
  2. {
  3. try
  4. {
  5. Util.rebind(container.getEnc(), encName, obj);
  6. }
  7. catch (NamingException e)
  8. {
  9. throw new RuntimeException(new StringBuilder().append("could not bind enc name '").append(encName).append("' for ").append(error).append(" for container ").append(container.getIdentifier()).append(e.getMessage()).toString());
  10. }
  11. }
  12. }

代码示例来源: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.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.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. * Get the jms provider
  3. *
  4. * @throws Exception for any error
  5. */
  6. protected void setupJMSProviderAdapter() throws Exception
  7. {
  8. String providerAdapterJNDI = spec.getProviderAdapterJNDI();
  9. if (providerAdapterJNDI.startsWith("java:") == false)
  10. providerAdapterJNDI = "java:" + providerAdapterJNDI;
  11. log.debug("Retrieving the jms provider adapter " + providerAdapterJNDI + " for " + this);
  12. adapter = (JMSProviderAdapter) Util.lookup(providerAdapterJNDI, JMSProviderAdapter.class);
  13. log.debug("Using jms provider adapter " + adapter + " for " + this);
  14. }

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

  1. Util.bind(ctx, jndiName, psProxy);
  2. log.debug("Bound ProfileService proxy under: "+jndiName);
  3. if(mgtViewJndiName != null && mgtViewJndiName.length() > 0)
  4. Util.bind(ctx, mgtViewJndiName, mgtViewProxy);
  5. log.debug("Bound ManagementView proxy under: "+mgtViewJndiName);
  6. if(deployMgrJndiName != null && deployMgrJndiName.length() > 0)
  7. Util.bind(ctx, deployMgrJndiName, deployMgrProxy);
  8. log.debug("Bound DeploymentManager proxy under: "+deployMgrJndiName);
  9. Util.createLinkRef("SecureProfileService/remote", this.jndiName);
  10. Util.createLinkRef("SecureManagementView/remote", mgtViewJndiName);
  11. Util.createLinkRef("SecureDeploymentManager/remote", deployMgrJndiName);
  12. log.debug("Bound links back to secure ejb names");

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

  1. /**
  2. * Create a link
  3. *
  4. * @param fromName the from name
  5. * @param toName the to name
  6. * @throws NamingException for any error
  7. */
  8. public static void createLinkRef(String fromName, String toName) throws NamingException
  9. {
  10. InitialContext ctx = new InitialContext();
  11. createLinkRef(ctx, fromName, toName);
  12. }

代码示例来源: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.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.snowdrop/snowdrop-deployers-core

  1. /**
  2. * Do a jndi lookup for bean factory.
  3. *
  4. * @param name the jndi name
  5. * @return bean factory instance
  6. * @throws Exception for any exception
  7. */
  8. protected T lookup(String name) throws Exception {
  9. Class<T> beanFactoryClass = getExactBeanFactoryClass();
  10. T beanFactory = beanFactoryClass.cast(Util.lookup(name, beanFactoryClass));
  11. if (log.isTraceEnabled()) {
  12. log.trace("Found Spring bean factory [" + name + "]: " + beanFactory);
  13. }
  14. return beanFactory;
  15. }

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

  1. /**
  2. * Unbinds {@link TimerService} from {@link #jndiName} under {@link #context}
  3. * @throws NamingException If there is any exception during the bind operation
  4. */
  5. public void stop() throws NamingException
  6. {
  7. Util.unbind(this.context, jndiName);
  8. }
  9. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public void set(final Context context, final V value)
  5. {
  6. try
  7. {
  8. log.debugf("Binding [%s] at [%s] in context [%s]", value.toString().replace('\n', ' '), jndiName, context);
  9. Util.rebind(context, jndiName, value);
  10. }
  11. catch(NamingException e)
  12. {
  13. throw new RuntimeException("Failed to bind value [" + value + "] into context [" + context + "] with jndi name [" + jndiName + "]", e);
  14. }
  15. }

代码示例来源: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.jboss.ejb3.jndi/jboss-ejb3-jndi-binder

  1. @SuppressWarnings({"deprecation"})
  2. protected void bind(Context ctx, String name, Object obj) throws NamingException
  3. {
  4. if(log.isDebugEnabled())
  5. log.debug("Binding " + obj + " at " + name + " under " + ctx);
  6. Util.bind(ctx, name, obj);
  7. }

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

  1. /**
  2. * Lookup an object in the default initial context
  3. *
  4. * @param name the name to lookup
  5. * @param clazz the expected type
  6. * @return the object
  7. * @throws Exception for any error
  8. */
  9. public static Object lookup(String name, Class<?> clazz) throws Exception
  10. {
  11. InitialContext ctx = new InitialContext();
  12. try
  13. {
  14. return lookup(ctx, name, clazz);
  15. }
  16. finally
  17. {
  18. ctx.close();
  19. }
  20. }

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

  1. @Override
  2. public void stop() throws Exception
  3. {
  4. Util.unbind(parentContext, name);
  5. context = null;
  6. parentContext = null;
  7. }

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

  1. public void inject(InjectionContainer container)
  2. {
  3. try
  4. {
  5. Util.rebind(container.getEnc(), encName, new LinkRef(jndiName));
  6. }
  7. catch (NamingException e)
  8. {
  9. throw new RuntimeException(new StringBuilder().append("could not bind enc name '").append(encName).append("' for ").append(error).append(" for container ").append(container.getIdentifier()).append(e.getMessage()).toString());
  10. }
  11. }
  12. }

代码示例来源: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. }

相关文章