Hi Sean,
I understand your concerns. Here is an alternative, from your Resource, to
retrieve the parent application:
MyApplication app =
(MyApplication)getContext().getAttributes().get("org.restlet.application");
BTW, I've just added a new constant KEY to Application in SVN to simplify
to:
MyApplication app =
(MyApplication)getContext().getAttributes().get(Application.KEY);
Then, once you have your parent application, you can access to all your
custom properties, in a type safe way. I hope this looks better to you than
using attributes to store your shared state.
Best regards,
Jerome
> -----Message d'origine-----
> De : news [mailto:[EMAIL PROTECTED] De la part de Sean Landis
> Envoyé : jeudi 25 janvier 2007 20:59
> À : [email protected]
> Objet : Re: Newbie question on the Resource changes in RC3
>
> Hi Jerome,
>
> Jerome Louvel <contact <at> noelios.com> writes:
>
> > Thanks for detailing your requirements with concrete code.
> I think you can
> > already cover your need for application level state (shared
> by all Resources
> > and Restlets) by leveraging Context's attributes:
>
> I considered that and looked for a better way. Passing
> application data
> via context is a dangerous practice:
> - Namespace collisions
> - Tight coupling through convention
> - Not type safe
> - Difficult to maintain
> - Difficult to debug
> This is one of the reasons we don't use JSP. Restlet is a
> strong project that
> promotes good practices. I think it would be wise to continue
> that in all
> respects. Promoting the use of contexts for data passing is
> counter to that.
> That's not to say there isn't utility in contexts. I just think
> Restlet application developers should be discouraged from
> using contexts
> and, whenever possible, be provided with a safe alternative.
>
> Sean
>