/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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; }
/** * 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; }
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); } }
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); } }
@Test public void propertyWithDefaultClauseInResourceRefMode() { JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate() { @Override public Object lookup(String jndiName) throws NamingException { throw new IllegalStateException("Should not get called"); } }; jndiLocator.setResourceRef(true); JndiPropertySource ps = new JndiPropertySource("jndiProperties", jndiLocator); assertThat(ps.getProperty("propertyKey:defaultValue"), nullValue()); }
@Test public void propertyWithColonInNonResourceRefMode() { JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate() { @Override public Object lookup(String jndiName) throws NamingException { assertEquals("my:key", jndiName); return "my:value"; } }; jndiLocator.setResourceRef(false); JndiPropertySource ps = new JndiPropertySource("jndiProperties", jndiLocator); assertThat(ps.getProperty("my:key"), equalTo("my:value")); }
@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")); }
@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")); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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; }
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); } }