| Summary: | Improve AggregateLifeCycle handling of shared lifecycles | ||
|---|---|---|---|
| Product: | [RT] Jetty | Reporter: | Greg Wilkins <gregw> |
| Component: | other | Assignee: | Project Inbox <jetty-inbox> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | ||
| Version: | 7.6.0.RC3 | ||
| Target Milestone: | 7.5.x | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Greg Wilkins
The terminology I've used is the concept of "joined", ie if you want to stop with a thread, you join with it. In this context if a bean is joined, then it's lifecycle is linked. If it is disjoint, then it's lifecycle is not linked. So the normal addBean(Object) method remains, and it assumed any lifecycle bean that is already started is not joined. If you want to explicitly control joined status, you can use methods addBean(Object, boolean) join(Object) disjoin(Object) isJoint(Object) These are all thread safe, so can be done at anytime. So if you want to share a thread pool, you can do something like: ThreadPool t = new ThreadPool(); t.start(); AggregateLifeCycle a0 = new AggregateLifeCycle(); a0.addBean(t); a0.start(); AggregateLifeCycle a1 = new AggregateLifeCycle(); a1.addBean(t); a1.start(); a0.stop(); assert t.isStarted(); a1.stop(); assert t.isStarted(); t.start(); Now the catch is, that HttpClient and the Connectors are currently not AggregateLifeCycles... because they extend HttpBuffers instead! Doh! Well I think the IS-A relationship holds better to the AggregateLifeCycle than it does to HttpBuffers... so I think we can work around this by: + make HttpBuffers an interface + HttpClient and AbstraceConnectors will implement HttpBuffers + create a HttpBuffersImpl class + HttpClient and AbstraceConnectors will contain a HttpBuffersImpl and delegate methods to it + HttpClient and AbstraceConnectors will extend AggregateLifeCycle and the threadpool will be added as a dependent bean (join or not depending). changed names from join/disjoin to manage/unmanage |