Hello,
Anonymous has commented on
http://tapestry.apache.org/defining-tapestry-ioc-services.html.
You can find the comment here:
http://tapestry.apache.org/defining-tapestry-ioc-services.html#comment_2240
Please note that if the comment contains a hyperlink, it must be approved
before it is shown on the site.
Below is the reply that was posted:
~~~~
Building services in Tapestry is easy. I'm glad that you can choose the
approach that works best for your application's needs. However, there is one
thing seems to be missing. Since services that are created once per thread are
disposed after each request, there should be a intuitive way to add cleanup
logic to your code. The only way I know of to do this is by adding a cleanup
listener to the PerthreadManager service. It works, but only for perthread
scoped services. What if a developer created a custom scope for other
developers to use?
Other IoC containers like CDI and Spring support lifecycle callbacks to add
custom logic to initialize and dispose of objects. Tapestry supports
initialization with the PostInjection annotation, but I see no corresponding
support for object disposal. So I propose a couple of things. First, there
could be a disposer method in the module class. It could be recognized by a
naming convention or annotation as with other module methods. For example:
class AppModule {
public static buildMyService() {
return new MyServiceImpl();
}
public static dispose(MyService service) {
service.close();
}
}
As you can see, the service to dispose is recognized by the method signature.
Marker annotations can be applied, and other parameters may be passed as needed.
The other approach is to create a annotation that identifies a disposer method
on the service itself. For example:
class MyServiceImpl {
@PostInjection
public init() {
}
@PreDisposal
public destroy() {
close();
}
}
~~~~
With regards,
The Apache Tapestry Project.
You are receiving this email because you have subscribed to changes for the
tapestry site.
To stop receiving these emails, unsubscribe from the mailing list that is
providing these notifications.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]