Results 1 to 3 of 3

Thread: Is it possible so set jndiEnvironment at runtime ?

  1. #1

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Tacoma, WA USA
    Posts
    49

    Default

    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>
    ElPapa

    The delusion that people care about what I think:
    http://www.codethought.com/blog

  3. #3
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    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.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

Similar Threads

  1. Replies: 9
    Last Post: Oct 14th, 2005, 09:38 AM
  2. Injecting runtime constructor-arg properties
    By james.estes in forum Container
    Replies: 4
    Last Post: Oct 5th, 2005, 07:37 AM
  3. Replies: 3
    Last Post: Sep 16th, 2005, 11:44 AM
  4. Replies: 3
    Last Post: Aug 17th, 2005, 05:44 AM
  5. Replies: 13
    Last Post: Jun 14th, 2005, 06:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •