Issue Details (XML | Word | Printable)

Key: PICO-200
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Assignee: Aslak Hellesoy
Reporter: Aslak Hellesoy
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
PicoContainer

LifecycleManager refactoring

Created: 23/Jul/04 05:08 PM   Updated: 31/Aug/08 08:15 AM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.1

Time Tracking:
Not Specified

File Attachments: 1. Java Source File DefaultLifecycleManager.java (3 kB)
2. Java Source File DefaultLifecycleManagerFactory.java (0.5 kB)
3. Java Source File LifecycleManager.java (0.2 kB)
4. Text File LifecycleManager.patch (19 kB)
5. Java Source File LifecycleManagerFactory.java (0.3 kB)

Issue Links:
Duplicate
 


 Description  « Hide
This refactoring introduces two new classes: LifecycleManager and LifecycleManagerFactory.

The rationale behind this refactoring is to allow pluggable lifecycle mechanisms/strategies. The motivation for this is that users have different requirements for lifecycle algorithms.

Lifecycle management (LM) and dependency resolution (DR) are two separate concerns. This refactoring moves these separate concerns into different interfaces.

An instance of a LifecycleManagerFactory can now be passed to a DefaultPicoContainer's constructor. The other (old) constructors remain the same, calling the new constructor with a DefaultLifecycleManagerFactory. This factory creates DefaultLifecycleManager instances, which encapsulate the previous lifecycle algorithm that used to be in DefaultPicoContainer.

The lifecycle methods start(), stop() and dispose() remain on DefaultPicoContainer for backwards compatibility, but they have been deprecated in order to favour the new design.

If this refactoring is backed by a majority of the developers, the exixting code in NanoContainer should be refactored from pico.start() to pico.getLifecycleManager().start() etc. (Very simple).

Another nice effect from this refactoring is that we can now allow component developers to cherry-pick their own lifecycle methods, removing the requirement to implement the PicoContainer Startable and Disposable interfaces when lifecycle is needed. Additional LifecycleManager/LifecycleManagerFactory classes leveraging proxytoys multicast or other can now be used in conjunction with DefaultPicoContainer and everything in NanoContainer.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Paul Hammant added a comment - 24/Jul/04 04:07 AM
Neat. I particularly like the way that makeChildContainer() passes on the same LMF.

Methods start(), stop(), dispose() are still on PicoCOntainer. The new pluggable LM stuff is on MutablePicoContainer. Clearly at some point the were going to have to remove methods from PC.

We've added another (optional) ctor param to DPC. I've heard comment that we should not in respect of other things like a Monitor interface.


Paul Hammant added a comment - 24/Jul/04 04:13 AM
From MutablePicoContainer

+ Collection getChildContainers();

Ack. Should this expose impl ? Some vistor concept instead ? Just a thought.

+ List getComponentInstancesOfType(Class type) throws PicoException;

Should this not go to PC?

Also, perhaps the to-be-deprecated start() stop() dispose() methods on PC, should be added (non-deprecated) to MPC


Aslak Hellesoy added a comment - 24/Jul/04 11:21 AM
Applied. Introduced visitors and moved the getComponentInstancesOfType up to PicoContainer.

CVS was tagged with PRE_VISITOR_REFACTORING prior to committing this, so arollback is possible should this be necessary.

This issue is not closed yet - people can still comment on the current implementation.


Joerg Schaible added a comment - 19/Oct/04 05:15 PM
Forgotten to close.