btw: actually I often tend to make the static method a member of the object that my plugin is initialising, - but only do that if the object is already 'servlet aware'. otoh if the object isnt supposed to know about servlets and such like (or its a third party thing) then you dont want to introduce a dependency on servlet.jar so just do it like I said below.
-----Original Message----- From: Andrew Hill [mailto:[EMAIL PROTECTED] Sent: Wednesday, 31 March 2004 23:08 To: Struts Users Mailing List Subject: RE: Struts and plugin question <snip> But, fact is that when I want to get my component from servletcontext I have to cast it to my proper type. Is there a way to avoid that? </snip> Not really, but you could create a static (or non static if you like) helper method somewhere to take care of both remembering the key and casting: public class MyComponentFinder { public static final MyComponent getMyComponent(ServletContext sc) { return (MyComponent)sc.getATtribute(MY_COMPONENT_KEY); } } -----Original Message----- From: Marco Mistroni [mailto:[EMAIL PROTECTED] Sent: Wednesday, 31 March 2004 23:02 To: 'Struts Users Mailing List' Subject: Struts and plugin question Hi all, I was wondering something about plugIns. Let's say, I want to create an object that has application context. So I create a plugIn to initialize it and store it in ServletContext. But, fact is that when I want to get my component from servletcontext I have to cast it to my proper type. Is there a way to avoid that? Just for some brainstorming.... Thanx in advance to all the replies Regards marco --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]