Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse of <jee:environment /> [SPR-4196] #8874

Closed
spring-projects-issues opened this issue Nov 29, 2007 · 1 comment
Closed

Reuse of <jee:environment /> [SPR-4196] #8874

spring-projects-issues opened this issue Nov 29, 2007 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Ezequiel Chávez opened SPR-4196 and commented

The new "jee schema" have util tags like jee:jndi-lookup/ and jee:remote-slsb/; since this tags depends of jndiEnvironment property, the current solution it's limited for me; since i have more than one ejb bean definition, i can't reuse jee:environment y have to copy-paste for every single jee:remote-slsb, example:

<jee:remote-slsb id="myEjbOne" jndi-name="${myEjbOne.jndiName}" business-interface="${myEjbOne.interface}">
jee:environment
java.naming.factory.initial=${java.naming.factory.initial}
java.naming.provider.url=${java.naming.provider.url}
</jee:environment>
</jee:remote-slsb>

<jee:remote-slsb id="myEjbTwo" jndi-name="${myEjbTwo.jndiName}" business-interface="${myEjbTwo.interface}">
jee:environment
java.naming.factory.initial=${java.naming.factory.initial}
java.naming.provider.url=${java.naming.provider.url}
</jee:environment>
</jee:remote-slsb>

Possible solutions
#1
can define a jee:environment/ with attribute "id" for reuse.

<jee:remote-slsb id="myEjbOne" jndi-name="${myEjbOne.jndiName}" business-interface="${myEjbOne.interface}">
<jee:environment ref="jndiProperties" />

<!----alternative
<jee:environment><ref local="jndiProperties"/></jee:environment>
-->

</jee:remote-slsb>

<jee:remote-slsb id="myEjbTwo" jndi-name="${myEjbTwo.jndiName}" business-interface="${myEjbTwo.interface}">
<jee:environment ref="jndiProperties" />
</jee:remote-slsb>

<jee:environment id="jndiProperties">
java.naming.factory.initial=${java.naming.factory.initial}
java.naming.provider.url=${java.naming.provider.url}
</jee:environment>

#2
can use the tag <property /> nested of </jee:remote-slsb>, or an attribute "jndi-environment"
<jee:remote-slsb id="myEjbOne" jndi-name="${myEjbOne.jndiName}" business-interface="${myEjbOne.interface}">
<property name="jndiEnvironment" ref="jndiProperties" />
</jee:remote-slsb>

<jee:remote-slsb id="myEjbTwo" jndi-environment="jndiProperties" jndi-name="${myEjbTwo.jndiName}" business-interface="${myEjbTwo.interface}" />

<bean id="jndiProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
<prop key="java.naming.factory.initial">${java.naming.factory.initial}</prop>
<prop key="java.naming.provider.url">${java.naming.provider.url}</prop>
</props>
</property>
</bean>


Affects: 2.5 final

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

This has already been introduced in Spring 2.0.3: Check out the "environment-ref" attribute, which points to a shared Properties instance (e.g. defined with util:properties).

Juergen

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 2.0.3 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants