|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Add a ConvertListener to XStreamHello Dev staff,
I am convicted by xstream. but I like to use it to replace the spring configuaration files. I found I suffered too much in Spring's long time booting because it always parsing and loading all beans, at least, all bean definitions. What I need in XStream to solve my problem, is, to recognize a <ref bean="xxx"/>, which can give me a chance to control how to find the reference bean.You already have a 'reference' syntax but it's for absolute or relative references in one xml, not in my favour. I tried to use a Converter to implement it, not so good. (I tried by best to understand your sample). Finally I extracted the source and did some change to some files to add a new ConvertListener method to give a chance to let the me to intercept the object to be marshaled and unmarshaled. in this way, every object can be listened. The listener can change the object passed to it if met some condition. My senario for that is : [1] to load a xml-bean, but if met <ref/> tag, let the listener to load another xml and replace <ref/> [2] two ways to save to xml: [2a] normal way, just same to the XSteam normal behavior, <ref/> is actually not in object tree(be replaced already while loading) [2b] reference way, to restore the bean who is a <ref/>loading bean to <ref/> format. In this situation, the listener can check if a object implements an IdAware interface, it will generate back to <ref bean="id"/> format. Explaination: Request [1] is to define a bean and loading from any sources (file or database records). Request [2a] is better if to transfer the object to remote. Request [2b] is suitable to format a bean to regular style espectially when customer can change it. I am just doing this and almost make it done. I am writing if you are interested to add this function to your future version. And I am also trying to let Annotation no need to define one by one, but automatically define it when be used. (If you just ignore the Class Alias settings). Regards, Jason Song --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Add a ConvertListener to XStreamHi Jason,
Song Jason wrote: > Hello Dev staff, > > I am convicted by xstream. but I like to use it to replace the spring > configuaration files. I found I suffered too much in Spring's long > time booting because it always parsing and loading all beans, at > least, all bean definitions. :) > What I need in XStream to solve my problem, is, to recognize a <ref > bean="xxx"/>, which can give me a chance to control how to find the > reference bean.You already have a 'reference' syntax but it's for > absolute or relative references in one xml, not in my favour. > > I tried to use a Converter to implement it, not so good. (I tried by > best to understand your sample). Well, the reference mechanism has nothing to do with the converters, it is realized with the different MarshallerStrategy implementations. By default XStream uses an XPathMarshallerStrategy. > Finally I extracted the source and > did some change to some files to add a new ConvertListener method to > give a chance to let the me to intercept the object to be marshaled > and unmarshaled. in this way, every object can be listened. The > listener can change the object passed to it if met some condition. > > My senario for that is : [1] to load a xml-bean, but if met <ref/> > tag, let the listener to load another xml and replace <ref/> [2] two > ways to save to xml: [2a] normal way, just same to the XSteam normal > behavior, <ref/> is actually not in object tree(be replaced already > while loading) [2b] reference way, to restore the bean who is a > <ref/>loading bean to <ref/> format. In this situation, the listener > can check if a object implements an IdAware interface, it will > generate back to <ref bean="id"/> format. > > Explaination: Request [1] is to define a bean and loading from any > sources (file or database records). Request [2a] is better if to > transfer the object to remote. Request [2b] is suitable to format a > bean to regular style espectially when customer can change it. > > I am just doing this and almost make it done. I am writing if you are > interested to add this function to your future version. IMHO all of this can be done by a different MarshallerStrategy implementation. So no direct change to XStream should be necessary. > And I am also > trying to let Annotation no need to define one by one, but > automatically define it when be used. (If you just ignore the Class > Alias settings). Already too late ;-) The annotation stuff was refactored heavily in the last week. It is not ready yet, but processing the annotations on the fly is not that easy, since you have to ensure, that you still can use the same XStream instance concurrently and that all necessary annotations have been processed in time for deserialization tasks only. - Jörg --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
| Free embeddable forum powered by Nabble | Forum Help |