You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by MichaelAtSAG <me...@gmail.com> on 2011/12/15 20:21:19 UTC

Spring XML Context - two similar beans

I want two Spring beans defined:

<1> jmsEDA
<2> jmsEDAPE

The second bean jmsEDAPE has all the properties of the first bean, except
with a different bean id and an additional property.

How do I do this so that the second bean does not contain redundant
information with first bean?

Example showing the beans with undesired redundancy:

	
	<bean id="jmsEDA" class="org.apache.camel.component.jms.JmsComponent">
		<property name="connectionFactory">
			<bean class="org.apache.activemq.ActiveMQConnectionFactory">
				<property name="brokerURL"
value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false" />
			</bean>
		</property>
	</bean>

	
	<bean id="jmsEDAPE" class="org.apache.camel.component.jms.JmsComponent">
		<property name="connectionFactory">
			<bean class="org.apache.activemq.ActiveMQConnectionFactory">
				<property name="brokerURL"
value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false" />
				<property name="clientID" value="ProcessEngine" />
			</bean>
		</property>
	</bean>

--
View this message in context: http://camel.465427.n5.nabble.com/Spring-XML-Context-two-similar-beans-tp5078474p5078474.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Spring XML Context - two similar beans

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Besides bean inheritance, sometimes people use property placeholders
and externalize values into .properties files or the likes.
Spring support property placeholders in the <bean>'s. Then the copy
and paste is tolerable, as all you do is referring to the same
property key.

There is plenty of web pages and documentation on the web about using
spring property placeholders

But mind that Spring does not fully support placeholders in non-spring
namespaces, such as <camelContext>
http://camel.apache.org/how-do-i-use-spring-property-placeholder-with-camel-xml.html

And Camel also have property placeholder support which extended
abilities from Camel point of view
http://camel.apache.org/using-propertyplaceholder.html


On Thu, Dec 15, 2011 at 8:21 PM, MichaelAtSAG <me...@gmail.com> wrote:
> I want two Spring beans defined:
>
> <1> jmsEDA
> <2> jmsEDAPE
>
> The second bean jmsEDAPE has all the properties of the first bean, except
> with a different bean id and an additional property.
>
> How do I do this so that the second bean does not contain redundant
> information with first bean?
>
> Example showing the beans with undesired redundancy:
>
>
>        <bean id="jmsEDA" class="org.apache.camel.component.jms.JmsComponent">
>                <property name="connectionFactory">
>                        <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>                                <property name="brokerURL"
> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false" />
>                        </bean>
>                </property>
>        </bean>
>
>
>        <bean id="jmsEDAPE" class="org.apache.camel.component.jms.JmsComponent">
>                <property name="connectionFactory">
>                        <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>                                <property name="brokerURL"
> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false" />
>                                <property name="clientID" value="ProcessEngine" />
>                        </bean>
>                </property>
>        </bean>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Spring-XML-Context-two-similar-beans-tp5078474p5078474.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Spring XML Context - two similar beans

Posted by MichaelAtSAG <me...@gmail.com>.
Thanks Babak, and i understand the point you made. I am still learning the
relationship between Camel and Spring, and still learning the proper
terminology to use google to find answers. I did try to find the answer
before posting but I was not searching with the term inheritance.

--
View this message in context: http://camel.465427.n5.nabble.com/Spring-XML-Context-two-similar-beans-tp5078474p5078734.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Spring XML Context - two similar beans

Posted by bvahdat <ba...@swissonline.ch>.
Hi Michael,

Before asking any question in a user forum, I do personally always google a
bit beforehand for a possible (correct) answer. In your case using [1] like
many other hits on google I could easily find the answer to your question.

And IMHO your question has nothing to do with the Apache Camel.  

[1] http://www.mkyong.com/spring/spring-bean-configuration-inheritance/

Babak

--
View this message in context: http://camel.465427.n5.nabble.com/Spring-XML-Context-two-similar-beans-tp5078474p5078688.html
Sent from the Camel - Users mailing list archive at Nabble.com.