Re: [Configuration] Is there any way to save my complex bean in XML resource and use it later ?

2011-02-18 Thread Mike Power



On 02/16/2011 02:32 AM, Jörg Schaible wrote:

Hi Moein,

Moein Enayati wrote:


Dear all
Hi


Till now ,whenever I want to use Apache.Commons.Configuration API with an
XML file , I’ve written down myBeans definition manually in XML resource.

But now I have a new demand to use complex beans with complex property
types and the ability to save them (their signature) automatically in the
XML resource.


I’ve just find apache.commons.betwixt. BeanWriter() having the ability ,
but it seems configuration-API has its own signature.


Is there any way in Apache.commons.configuration  to save my beans in an
xml file which is compatible with configuration ?

This is definitely out of scope for commons configuration. What you're
looking for is a persistence layer that can turn a Java object into XML and
restore it later. This is a classical task for JAXB or something like
XStream.

- Jörg
Just sharing an observation I have made while researching my 
configuration needs.  I ended up looking in commons configuration for a 
means of loading a configuration from XML into a Configuration object 
and then loading from that Configuration into a bean.  I still wanted 
interpolation and combined configuration.  I did not find that in 
Configuration so I decided that I would still use Configuration and not 
design and implement that particular solution.


My use case, I am writing an application, maven plugin, ant plugin, all 
of which basically does the same thing.  Both ant and maven have a a 
configuration api that represents a bean as XML.  So that covered both 
ant and maven, but I still needed a way to configure the application.  I 
thought it would be nice to leverage the same concept that I used for 
maven and ant.  The idea being that maven, ant, and the application 
would load their configuration into the same bean object.  The XML 
between the three may not be syntactically the same, but it would be 
familiar.


I find the configuration api to be useful as it is, and I am perfectly 
happy adding an additional library for functionality when it is out of 
scope for configuration.


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



Re: [Configuration] Is there any way to save my complex bean in XML resource and use it later ?

2011-02-16 Thread Jörg Schaible
Hi Moein,

Moein Enayati wrote:

 Dear all
 Hi
 
 
 Till now ,whenever I want to use Apache.Commons.Configuration API with an
 XML file , I’ve written down myBeans definition manually in XML resource.
 
 But now I have a new demand to use complex beans with complex property
 types and the ability to save them (their signature) automatically in the
 XML resource.
 
 
 I’ve just find apache.commons.betwixt. BeanWriter() having the ability ,
 but it seems configuration-API has its own signature.
 
 
 Is there any way in Apache.commons.configuration  to save my beans in an
 xml file which is compatible with configuration ?

This is definitely out of scope for commons configuration. What you're 
looking for is a persistence layer that can turn a Java object into XML and 
restore it later. This is a classical task for JAXB or something like 
XStream.

- Jörg


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



Re: [Configuration] Is there any way to save my complex bean in XML resource and use it later ?

2011-02-16 Thread Moein Enayati
Dear Jörg

You're ok!

But have a look at this part of code :

 *BeanDeclaration bDecl = new XMLBeanDeclaration(xmlConfig,
myBeanNameRootAddress);*

*MyBean  myBean = (MyBean ) BeanHelper.createBean(bDecl);*


Here we have the ability to load a predefined bean out of an XML file. So I
thought it must be a simple way to save that bean into the same file !


You know , I’m worry about using another library to save myBean into the
file and I can’t load its XMLDeclaration later on.



Am I right?




On Wed, Feb 16, 2011 at 2:02 PM, Jörg Schaible
joerg.schai...@scalaris.comwrote:

 Hi Moein,
 *
 Moein Enayati wrote:
 ..*

 This is definitely out of scope for commons configuration. What you're
 looking for is a persistence layer that can turn a Java object into XML and
 restore it later. This is a classical task for JAXB or something like
 XStream.

 - Jörg


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




Re: [Configuration] Is there any way to save my complex bean in XML resource and use it later ?

2011-02-16 Thread Oliver Heger

Am 16.02.2011 11:50, schrieb Moein Enayati:

Dear Jörg

You're ok!

But have a look at this part of code :

  *BeanDeclaration bDecl = new XMLBeanDeclaration(xmlConfig,
myBeanNameRootAddress);*

*MyBean  myBean = (MyBean ) BeanHelper.createBean(bDecl);*


Here we have the ability to load a predefined bean out of an XML file. So I
thought it must be a simple way to save that bean into the same file !


You know , I’m worry about using another library to save myBean into the
file and I can’t load its XMLDeclaration later on.



Am I right?


This support for loading beans in Commons Configuration is more like in 
the Spring framework (but in a very limited form). There you also define 
beans in configuration files which you can load at runtime, but you do 
not have the possibility to store beans and update your configuration files.


As Jörg pointed out, you are really after a XML bean mapper. Commons 
Configuration does not support this use case, at least not in a 
convenient way.


Sorry
Oliver




On Wed, Feb 16, 2011 at 2:02 PM, Jörg Schaible
joerg.schai...@scalaris.comwrote:


Hi Moein,
*
Moein Enayati wrote:
..*

This is definitely out of scope for commons configuration. What you're
looking for is a persistence layer that can turn a Java object into XML and
restore it later. This is a classical task for JAXB or something like
XStream.

- Jörg


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







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