congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
JndiLocatorDelegate
Code IndexAdd Tabnine to your IDE (free)

How to use
JndiLocatorDelegate
in
org.springframework.jndi

Best Java code snippets using org.springframework.jndi.JndiLocatorDelegate (Showing top 20 results out of 315)

origin: spring-projects/spring-framework

  public <T> T lookup(String jndiName, Class<T> requiredType) throws Exception {
    JndiLocatorDelegate locator = new JndiLocatorDelegate();
    if (jndiEnvironment instanceof JndiTemplate) {
      locator.setJndiTemplate((JndiTemplate) jndiEnvironment);
    }
    else if (jndiEnvironment instanceof Properties) {
      locator.setJndiEnvironment((Properties) jndiEnvironment);
    }
    else if (jndiEnvironment != null) {
      throw new IllegalStateException("Illegal 'jndiEnvironment' type: " + jndiEnvironment.getClass());
    }
    locator.setResourceRef(resourceRef);
    return locator.lookup(jndiName, requiredType);
  }
}
origin: spring-projects/spring-framework

/**
 * Create a new {@code JndiPropertySource} with the given name
 * and a {@link JndiLocatorDelegate} configured to prefix any names with
 * "java:comp/env/".
 */
public JndiPropertySource(String name) {
  this(name, JndiLocatorDelegate.createDefaultResourceRefLocator());
}
origin: spring-projects/spring-framework

/**
 * Configure a {@code JndiLocatorDelegate} with its "resourceRef" property set to
 * {@code true}, meaning that all names will be prefixed with "java:comp/env/".
 * @see #setResourceRef
 */
public static JndiLocatorDelegate createDefaultResourceRefLocator() {
  JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate();
  jndiLocator.setResourceRef(true);
  return jndiLocator;
}
origin: spring-projects/spring-framework

  @Override
  public MBeanServer getMBeanServer() {
    try {
      return new JndiLocatorDelegate().lookup("java:comp/env/jmx/runtime", MBeanServer.class);
    }
    catch (NamingException ex) {
      throw new MBeanServerNotFoundException("Failed to retrieve WebLogic MBeanServer from JNDI", ex);
    }
  }
},
origin: spring-projects/spring-framework

@Test
public void nameBoundWithPrefix() {
  final SimpleNamingContext context = new SimpleNamingContext();
  context.bind("java:comp/env/p1", "v1");
  JndiTemplate jndiTemplate = new JndiTemplate() {
    @Override
    protected Context createInitialContext() throws NamingException {
      return context;
    }
  };
  JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate();
  jndiLocator.setResourceRef(true);
  jndiLocator.setJndiTemplate(jndiTemplate);
  JndiPropertySource ps = new JndiPropertySource("jndiProperties", jndiLocator);
  assertThat(ps.getProperty("p1"), equalTo("v1"));
}
origin: spring-projects/spring-framework

/**
 * Set whether the lookup occurs in a Java EE container, i.e. if the prefix
 * "java:comp/env/" needs to be added if the JNDI name doesn't already
 * contain it. PersistenceAnnotationBeanPostProcessor's default is "true".
 * @see org.springframework.jndi.JndiLocatorSupport#setResourceRef
 */
public void setResourceRef(boolean resourceRef) {
  this.jndiLocator.setResourceRef(resourceRef);
}
origin: spring-projects/spring-framework

@Override
public void afterPropertiesSet() throws NamingException {
  if (this.jndiName != null) {
    try {
      this.threadFactory = this.jndiLocator.lookup(this.jndiName, ThreadFactory.class);
    }
    catch (NamingException ex) {
      if (logger.isTraceEnabled()) {
        logger.trace("Failed to retrieve [" + this.jndiName + "] from JNDI", ex);
      }
      logger.info("Could not find default managed thread factory in JNDI - " +
          "proceeding with default local thread factory");
    }
  }
}
origin: spring-projects/spring-framework

/**
 * Set the JNDI template to use for JNDI lookups.
 * @see org.springframework.jndi.JndiAccessor#setJndiTemplate
 */
public void setJndiTemplate(JndiTemplate jndiTemplate) {
  this.jndiLocator.setJndiTemplate(jndiTemplate);
}
origin: spring-projects/spring-framework

/**
 * Set the JNDI environment to use for JNDI lookups.
 * @see org.springframework.jndi.JndiAccessor#setJndiEnvironment
 */
public void setJndiEnvironment(Properties jndiEnvironment) {
  this.jndiLocator.setJndiEnvironment(jndiEnvironment);
}
origin: spring-projects/spring-framework

@Nullable
public Object getProperty(String name) {
  if (getSource().isResourceRef() && name.indexOf(':') != -1) {
    Object value = this.source.lookup(name);
    if (logger.isDebugEnabled()) {
      logger.debug("JNDI lookup for name [" + name + "] returned: [" + value + "]");
origin: spring-projects/spring-framework

@Test
public void isDefaultJndiEnvironmentAvailableFalse() throws Exception {
  Field builderField = NamingManager.class.getDeclaredField("initctx_factory_builder");
  builderField.setAccessible(true);
  Object oldBuilder = builderField.get(null);
  builderField.set(null, null);
  try {
    assertThat(JndiLocatorDelegate.isDefaultJndiEnvironmentAvailable(), equalTo(false));
  }
  finally {
    builderField.set(null, oldBuilder);
  }
}
origin: spring-projects/spring-framework

@Test
public void nameBoundWithoutPrefix() {
  final SimpleNamingContext context = new SimpleNamingContext();
  context.bind("p1", "v1");
  JndiTemplate jndiTemplate = new JndiTemplate() {
    @Override
    protected Context createInitialContext() throws NamingException {
      return context;
    }
  };
  JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate();
  jndiLocator.setResourceRef(true);
  jndiLocator.setJndiTemplate(jndiTemplate);
  JndiPropertySource ps = new JndiPropertySource("jndiProperties", jndiLocator);
  assertThat(ps.getProperty("p1"), equalTo("v1"));
}
origin: org.springframework/spring-context

  @Override
  public MBeanServer getMBeanServer() {
    try {
      return new JndiLocatorDelegate().lookup("java:comp/env/jmx/runtime", MBeanServer.class);
    }
    catch (NamingException ex) {
      throw new MBeanServerNotFoundException("Failed to retrieve WebLogic MBeanServer from JNDI", ex);
    }
  }
},
origin: org.springframework/spring-context

/**
 * Configure a {@code JndiLocatorDelegate} with its "resourceRef" property set to
 * {@code true}, meaning that all names will be prefixed with "java:comp/env/".
 * @see #setResourceRef
 */
public static JndiLocatorDelegate createDefaultResourceRefLocator() {
  JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate();
  jndiLocator.setResourceRef(true);
  return jndiLocator;
}
origin: spring-projects/spring-framework

/**
 * Set whether the lookup occurs in a Java EE container, i.e. if the prefix
 * "java:comp/env/" needs to be added if the JNDI name doesn't already
 * contain it. PersistenceAnnotationBeanPostProcessor's default is "true".
 * @see org.springframework.jndi.JndiLocatorSupport#setResourceRef
 */
public void setResourceRef(boolean resourceRef) {
  this.jndiLocator.setResourceRef(resourceRef);
}
origin: spring-projects/spring-framework

@Override
public void afterPropertiesSet() throws NamingException {
  if (this.jndiName != null) {
    setConcurrentExecutor(this.jndiLocator.lookup(this.jndiName, Executor.class));
  }
}
origin: spring-projects/spring-framework

/**
 * Set the JNDI template to use for JNDI lookups.
 * @see org.springframework.jndi.JndiAccessor#setJndiTemplate
 */
public void setJndiTemplate(JndiTemplate jndiTemplate) {
  this.jndiLocator.setJndiTemplate(jndiTemplate);
}
origin: spring-projects/spring-framework

/**
 * Set the JNDI environment to use for JNDI lookups.
 * @see org.springframework.jndi.JndiAccessor#setJndiEnvironment
 */
public void setJndiEnvironment(Properties jndiEnvironment) {
  this.jndiLocator.setJndiEnvironment(jndiEnvironment);
}
origin: org.springframework/spring-context

@Nullable
public Object getProperty(String name) {
  if (getSource().isResourceRef() && name.indexOf(':') != -1) {
    Object value = this.source.lookup(name);
    if (logger.isDebugEnabled()) {
      logger.debug("JNDI lookup for name [" + name + "] returned: [" + value + "]");
origin: spring-projects/spring-framework

propertySources.addLast(new StubPropertySource(SERVLET_CONFIG_PROPERTY_SOURCE_NAME));
propertySources.addLast(new StubPropertySource(SERVLET_CONTEXT_PROPERTY_SOURCE_NAME));
if (JndiLocatorDelegate.isDefaultJndiEnvironmentAvailable()) {
  propertySources.addLast(new JndiPropertySource(JNDI_PROPERTY_SOURCE_NAME));
org.springframework.jndiJndiLocatorDelegate

Javadoc

JndiLocatorSupport subclass with public lookup methods, for convenient use as a delegate.

Most used methods

  • <init>
  • lookup
  • setJndiTemplate
  • setResourceRef
  • isDefaultJndiEnvironmentAvailable
    Check whether a default JNDI environment, as in a Java EE environment, is available on this JVM.
  • setJndiEnvironment
  • createDefaultResourceRefLocator
    Configure a JndiLocatorDelegate with its "resourceRef" property set to true, meaning that all names
  • isResourceRef

Popular in Java

  • Parsing JSON documents to java classes using gson
  • scheduleAtFixedRate (Timer)
  • compareTo (BigDecimal)
  • onRequestPermissionsResult (Fragment)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Top 12 Jupyter Notebook Extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now