2.0.1 spring config and scope

View: New views
3 Messages — Rating Filter:   Alert me  

2.0.1 spring config and scope

by mortenbk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,


When using spring container in mule 1.4.3, each mule config file had its own spring config file with its own scope..

Now, when I use the new spring config style in mule 2.0.1, it seams like all configuration files is loaded into the same scope.

This is causing problems when using property-placeholder.
It seams like only one of the property-placeholders is loaded.

Does anyone have any idea how to fix this?

Regards,
Morten Kjetland

Re: 2.0.1 spring config and scope

by Andrew Perepelytsya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

No, you got the wrong impression. Mule always had a single scope for config files. They could be split, however, but in runtime it's a single config domain.

What you are seeing, however, is a classic Spring's FAQ. There can be only 1 PropertyPlaceholderConfigurer for a spring application context. Just ensure it's declared once in some file and move all property file names into this declaration.

Andrew

Re: 2.0.1 spring config and scope

by mortenbk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You misunderstand me. I didn't mean that there where several mule config scopes, but several spring context scopes.

In mule 1.4.3 each mule-config file set up its own spring context like this:
<container-context name="one_spring_container" className='org.mule.extras.spring.SpringContainerContext'>
        <properties>
                <property name='configFile' value='applicationContextOne.xml'/>
        </properties>
</container-context>

I have three different apps which can either run in mule alone, or in the same mule instance together.
This means that each app is a seperate maven project and makes it difficult to store all the properties files in one property-placeholder-tag in a single config file.

If there is no perfect solution to this problem, I can thing of two solutions:

1)
I can set up a different placeholderPrefix for each PropertyPlaceholderConfigurer (http://static.springframework.org/spring/docs/2.5.x/api/index.html). Change the default prefix from "${" to "${one".
This way I can access the property-values from one file/project like this: ${one.propertyPath} and from another like this: ${two.propertyPath}

2)
A maybe better solution is to create some kind of MergedPropertyPlaceholderConfigurer  which manages to load property-files from all apps. It could work like this: Each time a new MergedPropertyPlaceholderConfigurer-bean is created, the specified property-files is loaded and stored into the single PropertyPlaceholderConfigurer-used to read the propertyvalues from.

Any thoughts on this?

Regards,
Morten Kjetland

Andrew Perepelytsya wrote:
No, you got the wrong impression. Mule always had a single scope for config
files. They could be split, however, but in runtime it's a single config
domain.

What you are seeing, however, is a classic Spring's FAQ. There can be only 1
PropertyPlaceholderConfigurer for a spring application context. Just ensure
it's declared once in some file and move all property file names into this
declaration.

Andrew