Announcement Announcement Module
Collapse
No announcement yet.
Ref to jndi environment with jee schema Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ref to jndi environment with jee schema

    Hi,
    I used spring old style configuration for my JNDI lookup:

    <bean id="jndi" class="org.springframework.jndi.JndiTemplate">
    <property name="environment">
    <utilroperties location="classpath:spring/jndi.properties" />
    </property>
    </bean>
    <bean id="tut" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiTemplate" ref="jndi" />
    <property name="jndiName" value="ShoppingCartBean/remote" />
    </bean>


    In my app, I may have several jndi.properties. I do not want to repeat every time the properties in the bean defintion. That's why I use a ref on JndiTemplate.

    I try to use spring 2.0 style with jee schema. Unfortuantely I do not find a solution. To specify the environment I need to duplicate the env.
    <jee:jndi-lookup id="tut4" jndi-name="ShoppingCartBean/remote"/>
    <jee:environment>
    java.naming.provider.ur=localhost:1099
    <jee:environment>
    </jee:jndi-lookup>


    Is it possible to add a ref to specify only once the jee;environment ? Is there another solution ?

  • #2
    Originally posted by jc7442 View Post
    Hi,
    I used spring old style configuration for my JNDI lookup:

    <bean id="jndi" class="org.springframework.jndi.JndiTemplate">
    <property name="environment">
    <utilroperties location="classpath:spring/jndi.properties" />
    </property>
    </bean>
    <bean id="tut" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiTemplate" ref="jndi" />
    <property name="jndiName" value="ShoppingCartBean/remote" />
    </bean>


    In my app, I may have several jndi.properties. I do not want to repeat every time the properties in the bean defintion. That's why I use a ref on JndiTemplate.

    I try to use spring 2.0 style with jee schema. Unfortuantely I do not find a solution. To specify the environment I need to duplicate the env.
    <jee:jndi-lookup id="tut4" jndi-name="ShoppingCartBean/remote"/>
    <jee:environment>
    java.naming.provider.ur=localhost:1099
    <jee:environment>
    </jee:jndi-lookup>


    Is it possible to add a ref to specify only once the jee;environment ? Is there another solution ?
    No answer for this? Do I need to copy the same environment tag content for each EJB looked up?

    Comment


    • #3
      Hello,

      since spring 2.0.3 you can use the enviroment-ref attribut inside your jee tag.

      See release notes on this

      Code:
      * all "jee:*" tags support an "environment-ref" attribute, pointing to a shared bean of type "java.util.Properties"
      Regards
      lyserg

      Comment


      • #4
        Is there an example of how to use the environment-ref attribute? I have not been able to find one in any of the spring documentation.

        Thanks

        Comment


        • #5
          Hello,

          sure, have a look here

          http://static.springframework.org/sp...nment-multiple

          You can reuss your enviroment setting. Like this

          Code:
          <jee:jndi-lookup id="simple" jndi-name="jdbc/MyDataSource" environment-ref="myProperties">
          </jee:jndi-lookup>
          
          <util:properties id="myProperties" location="classpath:com/foo/production.properties"/>
          regards
          agim

          Comment

          Working...
          X