Announcement Announcement Module
Collapse
No announcement yet.
Is it possible so set jndiEnvironment at runtime ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is it possible so set jndiEnvironment at runtime ?

    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

  • #2
    If I understood you correctly you should be able to do something like this..


    Code:
    <beans>
          <bean id="myComponent"
               lazy-init="true"
               class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean">
              <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&#58;org.jnp.interfaces</prop>
                  <prop key="java.naming.provider.url">jnp&#58;//localhost&#58;1099</prop>
                </props>
              </property>
              <property name="businessInterface">
                  <value>com.codethought.springejb.services.MyComponent</value>
              </property>
          </bean>
    </beans>

    Comment


    • #3
      Emmanuel,

      You can subclass java.util.Properties and use a constructor that fill in the parameters, then use this class to initialize your SimpleRemoteStatelessSessionProxyFactoryBean:
      Code:
        <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
      Code:
        public void setSomeProperties&#40;Properties props&#41; &#123;
          puttAll&#40;props&#41;;
        &#125;
      
        <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&#58;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.

      Comment

      Working...
      X