How can i represent the following code snippet in java, my project is using Spring4 and i need to convert the same. Any help would be much appreciated. Thanks in advance!
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
<prop key="java.naming.provider.url">t3://localhost:7001</prop>
</props>
</property>
Here's the equivalent Java config. Add it to your @Configuration
class:
@Bean
public JndiTemplate jndiTemplate() {
Properties props = new Properties();
props.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
props.setProperty(InitialContext.PROVIDER_URL, "t3://localhost:7001");
return new JndiTemplate(props);
}