Richard I have taken you suggestion. My code looks much cleaner. thanks!
On 8/30/07, Richard Bronkhorst <[EMAIL PROTECTED]> wrote: > Hi tom > > I am not familiar with spring, but I think that to do this you need a > pointer to your ServerServlet in your application. I think you could > override the createApplication function in ServerServlet where you > first call super.createApplication and set some variable of the > Application (which you probably subclassed) to the ServerServlet > object. That way, the ServerServlet and the component can be accessed > from the application. > > Probably my proposal can be seen as a dirty hack, because the > application is supposed to be separated from the component it runs in. > I see no other way to do it though... > > Richard > > On 8/30/07, Tom McGee <[EMAIL PROTECTED]> wrote: > > Richard- > > Thanks for the suggestion. My ultimate goal is to be able to configure > > the logService, as well as a lot of other stuff with a Spring > > configuation. > > > > On 8/30/07, Richard Bronkhorst <[EMAIL PROTECTED]> wrote: > > > Hi tom, > > > > > > I had this same problem. I subclassed ServerServlet and used the new > > > class in my web.xml. > > > Then i overrided init: > > > public void init() throws ServletException { > > > super.init(); > > > this.getComponent().getClients().add(new > > > Client(Protocol.FILE)); > > > this.getComponent().setLogService(new LogService(false)); > > > } > > > > > > Hope this helps > > > > > > Richard > > > > > > On 8/29/07, Tom McGee <[EMAIL PROTECTED]> wrote: > > > > To access and/or replace the logService. > > > > > > > > On 8/29/07, Thierry Boileau <[EMAIL PROTECTED]> wrote: > > > > > Hi Tom, > > > > > > > > > > could tell us why you need to get the inner component? > > > > > > > > > > best regards, > > > > > Thierry Boileau > > > > > > I need to get the Component from an Application created by > > > > > > ServerServlet. I'm currently using this code: > > > > > > > > > > > > > > > > > > > > > > > > public abstract class AbstractSpringRestletApplication extends > > > > > > Application { > > > > > > > > > > > > … > > > > > > > > > > > > public ServletContext getServletContext(){ > > > > > > > > > > > > ServletContext result = null; > > > > > > > > > > > > if ((this.getContext()!=null)&&(this.getContext() > > > > > > instanceof > > > > > > > > > > > > ServletContextAdapter)) { > > > > > > > > > > > > result = > > > > > > > > > > > > > > > > > > ((ServletContextAdapter)this.getContext()).getServletContext(); > > > > > > > > > > > > } > > > > > > > > > > > > return result; > > > > > > > > > > > > } > > > > > > > > > > > > … > > > > > > > > > > > > private Component component; > > > > > > > > > > > > > > > > > > > > > > > > private void setComponent(Component c){ > > > > > > > > > > > > this.component = c; > > > > > > > > > > > > } > > > > > > > > > > > > … > > > > > > > > > > > > if(this.getServletContext() != null){ > > > > > > > > > > > > > > > > > > setComponent((Component)this.getServletContext().getAttribute("com.noelios.restlet.ext.servlet.ServerServlet.component")); > > > > > > > > > > > > } > > > > > > > > > > > > … > > > > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > Is there a better way of doing this? > > > > > > If not could you make this in ServerServlet public: > > > > > > private static final String NAME_COMPONENT_ATTRIBUTE_DEFAULT = > > > > > > "com.noelios.restlet.ext.servlet.ServerServlet.component"; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > Richard Bronkhorst > > > Software Developer > > > > > > Noterik BV > > > P.O. Box 15189 > > > 1001 MD Amsterdam > > > The Netherlands > > > > > > T: +31 (0)20 5929 966 > > > F: +31 (0)20 5929 969 > > > > > > www.noterik.com / www.noterik.nl / www.streamedit.com > > > > > > > > -- > Richard Bronkhorst > Software Developer > > Noterik BV > P.O. Box 15189 > 1001 MD Amsterdam > The Netherlands > > T: +31 (0)20 5929 966 > F: +31 (0)20 5929 969 > > www.noterik.com / www.noterik.nl / www.streamedit.com >