Re: [Simple-support] Framework limitation? Session map, template system and the "class" attribute o
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2008-04-16 18:42:41
|
Hi Timo,
No this is not a limitation, it is a feature. This is
because the "class" attribute is added on top of the
class schema attributes and elements. These attributes
are added via Strategy objects, which is given the
NodeMap for the XML element. The straegy adds the
following.
NodeMap.add("class", object.getClass().getName());
This allows you to implement your own strategy to
modify these attributes as they may not suit all
purposes. For example, take a C++, PHP or C#
application that wants to read XML generated from your
Java app. The "class" annotations are not very useful
here. You'll want something like.
type="name"
instead of
class="com.domain.framework.NameObject"
The Strategy object allows you to perform these
manipulations. Take a look at the CycleStrategy which
allows you to keep track of even the most complext of
object graphs, ensuring the cycles are tracked with
"id" attributes. Currently there is not many
implementations, but its easy to write your own
Strategy to automatically generate and replace "class"
attributes.
Hope this helps,
Niall
--- Timo Rumland <cr...@ol...> wrote:
> Hello,
>
> I have a question regarding the persister callback
> session map and the
> template system (appropriate documentation section
> is "Maintaining
> state between persister callbacks").
>
> I have a XML file, which looks like this:
>
> -------------
> <MyObjects>
> <MyInterface
>
class="net.test.lib.concurrent.theme.InterfaceImpl1"/>
> <MyInterface
>
class="net.test.lib.concurrent.theme.InterfaceImpl2"/>
> <MyInterface
>
class="net.test.lib.concurrent.theme.InterfaceImpl3"/>
> </MyObjects>
> -------------
>
> The XML above is of course only a simplification of
> the real
> structure. There are a lot of entries for
> "<MyInterface...", and every
> entry has the same packge but a different class (it
> is always
> "net.test.lib.concurrent.theme.").
>
> Now it would be really nice to replace those package
> declarations with
> a template variable, so the XML looks like this:
>
> -------------
> <MyObjects>
> <property name="package"
> value="net.test.lib.concurrent.theme"/>
>
> <MyInterface class="${package}.InterfaceImpl1"/>
> <MyInterface class="${package}.InterfaceImpl2"/>
> <MyInterface class="${package}.InterfaceImpl3"/>
> </MyObjects>
> -------------
>
> That way I could easily change the package name and
> must not touch
> every "<MyInterface..." line. In the documentation
> you write "The
> templating engine has access to all details placed
> into the session
> map object.", but this seems only to be true for
> other "normal"
> elements, not the "class" attribute of an element.
>
> Is this a real limitation, or even a bug?
>
> (The framework just does not substitute ${package},
> so it tries to
> load the class "${package}.InterfaceImpl1" instead
> of
> "net.test.lib.concurrent.theme.InterfaceImpl1").
>
> I'm using the XML file to configure a rather complex
> system (like a
> build system) and this feature would be extremely
> useful in many
> cases for me (and for others, too, for sure).
>
> If this is a limitation, may you think about
> implementing this feature
> so the template system also works for those "class"
> attributes in the
> XML elements? That would be great!
>
>
> Best regards,
> Timo
>
>
>
-------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008
> JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still
> time to save $100.
> Use priority code J8TL2D2.
>
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
>
https://lists.sourceforge.net/lists/listinfo/simple-support
>
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
|