Re: [Simple-support] Dynamic object type determination
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2011-06-04 04:51:20
|
Hi,
I am sure you could use a strategy here and write your own way of determining the type. The persister will simply ask the strategy, what is the type for this XML element. The strategy then provides an object with the details. There should be some examples in the test cases of this.
You should then be able to do.
MyStrategy x = ...
Persister p = new Persister(x);
Object o = p.read(Object.class, xml);
Niall
--- On Fri, 3/6/11, Lumsdon, Hugo <Hug...@bl...> wrote:
> From: Lumsdon, Hugo <Hug...@bl...>
> Subject: [Simple-support] Dynamic object type determination
> To: sim...@li...
> Received: Friday, 3 June, 2011, 10:39 AM
> Hi,
>
> Very new to the Simple framework, but curious as to whether
> there is an
> easy way to dynamically determine the object type that
> we're
> de-serializing from the XML file itself without having to
> specify it in
> advance as an argument to the
> Serializer. i.e. the object type would
> be determined from the top-level XML element name.
>
> Basically in many cases we're not expecting to have to
> manipulate
> objects within our Java code - but purely pass them to a
> view (e.g.
> Freemarker) so it can pull back specific bean properties
> using
> introspection as normal. We're using
> Spring MVC - and it just means we
> can use a generic controller in many circumtances to read
> in the
> relevant content XML object and just hand off to the
> required view.
>
> I guess this is a bit like the functionality the @Union
> annotation
> provides, but that's obviously a level down so we'd have to
> wrap
> everything. Maybe that is the best solution here, but
> just exploring
> options.
>
> Thanks.
>
>
>
>
>
>
>
>
> THIS MESSAGE AND ANY ATTACHMENTS ARE CONFIDENTIAL,
> PROPRIETARY, AND MAY BE PRIVILEGED. If this message
> was misdirected, BlackRock, Inc. and its subsidiaries,
> ("BlackRock") does not waive any confidentiality or
> privilege. If you are not the intended recipient,
> please notify us immediately and destroy the message without
> disclosing its contents to anyone. Any distribution,
> use or copying of this e-mail or the information it contains
> by other than an intended recipient is unauthorized.
> The views and opinions expressed in this e-mail message are
> the author's own and may not reflect the views and opinions
> of BlackRock, unless the author is authorized by BlackRock
> to express such views or opinions on its behalf. All
> email sent to or from this address is subject to electronic
> storage and review by BlackRock. Although BlackRock
> operates anti-virus programs, it does not accept
> responsibility for any damage whatsoever caused by viruses
> being passed.
>
>
>
> --
> BlackRock Advisors (UK) Limited is authorized and regulated
> by The Financial Services Authority. Registered in England.
> Registered No:796793. Registered Office: 33 King William
> Street, London EC4R 9AS.
>
> ------------------------------------------------------------------------------
> Simplify data backup and recovery for your virtual
> environment with vRanger.
> Installation's a snap, and flexible recovery options mean
> your data is safe,
> secure and there when you need it. Discover what all the
> cheering's about.
> Get your free trial download today.
> http://p.sf.net/sfu/quest-dev2dev2
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
|