You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Dennis Kieselhorst <de...@apache.org> on 2016/03/31 14:27:10 UTC

[configuration] use commons configuration 2 as PropertySource in Spring

Hi,

great to see that Commons Configuration 2.0 is out.

There is one question that appeared during the migration in one of my
projects. With Commons Configuration 1.0 a Spring modules factory bean
(org.springmodules.commons.configuration.CommonsConfigurationFactoryBean) was
used to directly use Commons Configuration with Spring's
PropertyPlaceholderConfigurer. As this is no longer maintained, the
question is how to do this with Commons Configuration 2.0.

Of course it should be possible to copy the existing Spring modules
source code to the project and migrate it to 2.0. Is there some better
way to do this? I know Spring offers YAML, but it should be still
Commons Configuration (the existing XML configuration files should not
be affected).

Cheers
Dennis

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [configuration] use commons configuration 2 as PropertySource in Spring

Posted by Oliver Heger <ol...@oliver-heger.de>.
Hi Dennis,

Am 19.04.2016 um 22:05 schrieb Dennis Kieselhorst:
> Hi Gary,
> 
> I'm Apache committer and like to contribute but do you think it makes
> sense to have a Spring dependency in Commons Configuration? Maybe as
> optional?

obviously, there is no better active project where this Spring-related
code could live. So I guess, an optional dependency would probably be okay.

On the dependencies page all optional dependencies are listed and also
for which use cases they are required. So this information would need to
be updated, too.

Thanks
Oliver

> 
> Regards
> Dennis
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [configuration] use commons configuration 2 as PropertySource in Spring

Posted by Dennis Kieselhorst <de...@apache.org>.
Hi Gary,

I'm Apache committer and like to contribute but do you think it makes
sense to have a Spring dependency in Commons Configuration? Maybe as
optional?

Regards
Dennis

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [configuration] use commons configuration 2 as PropertySource in Spring

Posted by Gary Gregory <ga...@gmail.com>.
Hi Dennis,

Patches welcome, or at least our own JIRA ticket.

Actually, if you are already an Apache committer, you can commit to Apache
Commons.

Gary

On Tue, Apr 19, 2016 at 5:24 AM, Dennis Kieselhorst <de...@apache.org> wrote:

> Hi Ron!
>
> > We are just now starting to assess Config 2, but I would assume these
> approaches would still work.
>
> You are right, just replace the imports and it works. Thanks for the
> hint. Btw the code would be simpler if this issue is fixed:
> https://jira.spring.io/browse/SPR-9631
>
> Cheers
> Dennis
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: [configuration] use commons configuration 2 as PropertySource in Spring

Posted by Dennis Kieselhorst <de...@apache.org>.
Hi Ron!

> We are just now starting to assess Config 2, but I would assume these
approaches would still work.

You are right, just replace the imports and it works. Thanks for the
hint. Btw the code would be simpler if this issue is fixed:
https://jira.spring.io/browse/SPR-9631

Cheers
Dennis

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [configuration] use commons configuration 2 as PropertySource in Spring

Posted by "DiFrango, Ronald" <Ro...@capitalone.com>.
Dennis,

For Commons 1.x, my team followed this example to create a bridge:

	https://gist.github.com/danieldbower/2702482


Then, we created an extension of Spring's PropertySourceLoader that instantiates this class, therefore we can use commons config with @Value.  This was all bridged using Spring Initializer approach.

The other alternative we used was to create a static bean in our config class that looks something like:

	@Bean
	public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer(ConfigurableEnvironment env) {
		PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
		MutablePropertySources sources = new MutablePropertySources();
		sources.addLast(new ApacheCommonsConfigPropertySource(<your loaded commons config class>));
		configurer.setPropertySources(sources);
		configurer.setEnvironment(env);
		return configurer;
	}



We are just now starting to assess Config 2, but I would assume these approaches would still work.

Thanks,

Ron DiFrango






On 3/31/16, 8:27 AM, "Dennis Kieselhorst" <de...@apache.org> wrote:

>Hi,
>
>great to see that Commons Configuration 2.0 is out.
>
>There is one question that appeared during the migration in one of my
>projects. With Commons Configuration 1.0 a Spring modules factory bean
>(org.springmodules.commons.configuration.CommonsConfigurationFactoryBean) was
>used to directly use Commons Configuration with Spring's
>PropertyPlaceholderConfigurer. As this is no longer maintained, the
>question is how to do this with Commons Configuration 2.0.
>
>Of course it should be possible to copy the existing Spring modules
>source code to the project and migrate it to 2.0. Is there some better
>way to do this? I know Spring offers YAML, but it should be still
>Commons Configuration (the existing XML configuration files should not
>be affected).
>
>Cheers
>Dennis
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>For additional commands, e-mail: user-help@commons.apache.org
>
>
________________________________________________________

The information contained in this e-mail is confidential and/or proprietary to Capital One and/or its affiliates and may only be used solely in performance of work or services for Capital One. The information transmitted herewith is intended only for use by the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.

Re: [configuration] use commons configuration 2 as PropertySource in Spring

Posted by Oliver Heger <ol...@oliver-heger.de>.
Hi Dennis,

Am 31.03.2016 um 14:27 schrieb Dennis Kieselhorst:
> Hi,
> 
> great to see that Commons Configuration 2.0 is out.
> 
> There is one question that appeared during the migration in one of my
> projects. With Commons Configuration 1.0 a Spring modules factory bean
> (org.springmodules.commons.configuration.CommonsConfigurationFactoryBean) was
> used to directly use Commons Configuration with Spring's
> PropertyPlaceholderConfigurer. As this is no longer maintained, the
> question is how to do this with Commons Configuration 2.0.
> 
> Of course it should be possible to copy the existing Spring modules
> source code to the project and migrate it to 2.0. Is there some better
> way to do this? I know Spring offers YAML, but it should be still
> Commons Configuration (the existing XML configuration files should not
> be affected).

I never used CommonsConfigurationFactoryBean myself. It is unfortunate
that the Spring Modules project is no longer active; the best solution
would probably be to update the factory bean on Spring side.

I am not sure how to proceed in this question. I am reluctant to adding
a corresponding integration to Commons Configuration itself because this
would require adding all those Spring dependencies and seems to be a bit
out of scope.

Oliver

> 
> Cheers
> Dennis
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org