On Oct 10, 2011, at 5:34 PM, Thiago H. de Paula Figueiredo wrote: > On Mon, 10 Oct 2011 18:14:01 -0300, Tony Nelson <tnel...@starpoint.com> wrote: > >> >> On Oct 10, 2011, at 4:58 PM, Thiago H. de Paula Figueiredo wrote: >> >>> On Mon, 10 Oct 2011 17:18:59 -0300, Tony Nelson <tnel...@starpoint.com> >>> wrote: >>> >>>> How is it possible to access a service registered in AppModule#bind from >>>> an object created outside of Tapestry's control? >>> >>> You can get the Registry from >>> servletContext.getAttribute(TapestryFilter.REGISTRY_CONTEXT_NAME) and then >>> use one of the getService() methods. >>> >> >> Forgive my ignorance, but in an object that was created either via "new" or >> someClass.newInstance() how would I have access to the servletContext? > > In this scenario, are you in a web app or not? >
I am in a web app, however, I have a service that I need to start as a runnable. The services is registered with bind, and started with @Startup in AppModule. When the service handles an event it creates objects to service specific events. These objects that get created need access to other services that are registered via bind. That's where I'm getting stuck. Posting the code isn't really possible, there is just too much. But a simple example would be something like: A user submits a form, that causes a DB update, and an e-mail to be sent. E-Mail messages aren't sent directly, rather they are written to a table and a handler process is woken up to deal with the new data in the table. This handler process reads the "send email event" from the table, and creates objects as necessary to handle the event. These are the objects need access to other services that are already registered. Yes, it's rather convoluted and the e-mail example is just a simple example. We have many other events that get queued and serviced later so that users using the web application don't have to wait for things that can be processed in the background. Thanks in advance for any help. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org