Results 1 to 5 of 5

Thread: Ref to jndi environment with jee schema

  1. #1
    Join Date
    Jul 2006
    Posts
    12

    Default 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">
    <util:properties 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. #2
    Join Date
    May 2005
    Posts
    13

    Default

    Quote 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?

  3. #3
    Join Date
    Nov 2006
    Location
    Germany
    Posts
    452

    Default

    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

  4. #4
    Join Date
    May 2007
    Posts
    5

    Default

    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

  5. #5
    Join Date
    Nov 2006
    Location
    Germany
    Posts
    452

    Default

    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

Posting Permissions

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