View Full Version : Is it possible so set jndiEnvironment at runtime ?
eboudrant
Aug 27th, 2004, 09:21 AM
Is it possible so set jndiEnvironment at runtime with for a org.springframework.ejb.access.SimpleRemoteStatele ssSessionProxyFactoryBean bean ?
Because we don't want to set URL, LOGIN and PASSWORD in our Spring context definitions.
Thx,
-emmanuel
ElPapa
Aug 27th, 2004, 08:55 PM
If I understood you correctly you should be able to do something like this..
<beans>
<bean id="myComponent"
lazy-init="true"
class="org.springframework.ejb.access.SimpleRemoteStatele ssSessionProxyFactoryBean">
<property name="jndiName">
<value>SimpleEJB</value>
</property>
<property name="jndiEnvironment">
<props>
<prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
<prop key="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces</prop>
<prop key="java.naming.provider.url">jnp://localhost:1099</prop>
</props>
</property>
<property name="businessInterface">
<value>com.codethought.springejb.services.MyComponent</value>
</property>
</bean>
</beans>
irbouho
Aug 27th, 2004, 09:08 PM
Emmanuel,
You can subclass java.util.Properties and use a constructor that fill in the parameters, then use this class to initialize your SimpleRemoteStatelessSessionProxyFactoryBean:
<property name="jndiEnvironment">
<bean class="myEnvironmentClass" />
</property>
If you need to define some properties outside of your class (java.naming.factory.initial...), you can use a setter method
public void setSomeProperties(Properties props) {
puttAll(props);
}
<property name="jndiEnvironment">
<bean class="myEnvironmentClass">
<props>
<prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
<prop key="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces</prop>
</props>
</bean>
</property>
Of course you will have to recompile your class whenever the user / password / url change. I hope you will consider a better alternative.
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.