You should be able to inject a service into itself. It's a proxy that
gets injected. Make sure  there weren't any errors in the console.


On Sat, 5 Feb 2005 18:35:32 +0100, Olivier Bourgeois <[EMAIL PROTECTED]> wrote:
> Hello all,
> 
>         I'm playing with hivemind 1.1-alpha AdapterRegistry and now that I got
> some simple example working, I'm asking myself a question I can't find
> an answer :)
>         Is there a way to do- kind of - recursion with the AdaptaterRegistry? 
> I
> explain myself: suppose I want to create an XmlAdapter service with this
> interface :
> 
> public interface XmlAdapter {
>         toXml (Object o);
> }
> 
> I could define then :
> 
> public class StringAdapter {
>         public String toXml (Object o) {
>                 String value = (String) o;
>                 return value.trim();
>         }
> }
> 
> This works fine for "converting" a String to XML.
> But now suppose I got this object to adapt :
> 
> public class Name {
>         private String firstName;
>         private String lastName;
>         // + getters & setters
> }
> 
> A great trick would be to be able to do something like this :
> 
> public class NameAdapter {
>         public String toXml (Object o) {
>                 Name value = (Name) o;
>                 String ret = new String("<Name><FirstName>");
> 
>                 // Here do some trick to get a StringAdapter from the registry
> 
>                 ret.append(stringAdapter.toXml(value.getFirstName()));
>                 ret.append("</FirstName><LastName>");
>                 ret.append(stringAdapter.toXml(value.getLastName()));
>                 ret.append("</LastName></Name>");
>                 return ret;
>         }
> }
> 
> Of course I tried to inject the service in
> itself but this leads only to nullpointerexception ( well, I expected
> something like this anyway...).
> 
> So, is there a way to do this ? Or should I try another way ? ( with
> the new Chain service maybe ? )
> 
> thanks in advance for any help/pointers,
> 
> Olivier.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to