I have a client aplication in swing that uses spring. It also uses EJB3 services deployed in an EAR in an application server.
Full application is build using maven 2. My application is called demo. With maven, the EAR is named demo-<version>. For example for the first release of the demo application ear will be demo-1.0.0.ear.
With ejb3, jndi name for services is <ear>/<serviceName>/remote. Consequently I have an application context define as follow:
My problem is that the jndiName of the service contains the ear version. When I will upgrade my application I will have to update each jndiName. For example for ear release 2.0.0, jndi name for my service will be demo-ear-2.0.0/ShoppingCartBean/remote.Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> <!-- ============================================================= --> <!-- =====================Naming service definition========== --> <!-- ============================================================= --> <bean id="jndi" class="org.springframework.jndi.JndiTemplate"> <!-- JNDI definitions --> <property name="environment"> <util:properties id="propsJNDI" location="classpath:/jndi.properties" /> </property> </bean> <!-- ============================================================= --> <!-- =====================Application service definition========== --> <!-- ============================================================= --> <!-- Interface Service will be used using the logical name Simple. Service is deployed on the network by a J2EE application server. Logical name used by the client application is not the jndi name--> <!-- There no defintion for a concrete class, it is J2EE applicaion server reponsability to deploy services. --> <bean id="ShoppingCart" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiTemplate" ref="jndi" /> <property name="jndiName" value="demo-ear-1.0.0/ShoppingCartBean/remote" /> </bean> </beans>
Consequently I'd like to externalize a part of the jndiName in order to write something like:
In another property file or hardcoded in the Main of the appli I'd like to be able to set the value for the demo-ear property.Code:<bean id="ShoppingCart" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiTemplate" ref="jndi" /> <property name="jndiName" value="${demo-ear}/ShoppingCartBean/remote" /> </bean>
I did not succeed to find a solution. Any suggestion are welcome !


Reply With Quote