Leo:
Thoughts concerning the current code:
/**
* Handles singleton A4 components. Right now, we only
* support the LogEnabled and Serviceable interfaces.
*/
public class Avalon4ComponentHandler implements
Handler, LogEnabled, LifecycleInterceptable, Serviceable {Two things based on dealing with similar stuff:
* separate lifestyle concerns from new instance stuff
Basically a lifestyle handler encapsulates the decision concerning when a new instance is required. In the activation package you will find a LifestyleManager interface, a set of implementations, and a LifestyleManager factory. The factory is supplied with a ComponentFactory which deals with the setup and tearddown of components. What I think you describing in Avalon4ComponentHandler looks to me like an implementation of a component factory.
Second point - I think its a bad ide to use interface such as Serviceable etc. to provide a ServiceManager to a factory when in fact the factory isn't using the manager to resolve a dependency - but is instead using the object as an argument in subsequent operations. This get back to the subject of context. My suggest for the moment is to supply this stuff under the constructor directly and eliminate the usage of Lifecycle style interface on handlers.
Definely feel free to ignore all of the above - your in experimental mode and I'm just tossing in thoughts as they occur.
Cheers, Steve.
Leo Sutic wrote:
From: Hamilton Verissimo de Oliveira (Engenharia - SPO)
-----Mensagem original----- De: Leo Sutic [mailto:[EMAIL PROTECTED]
The handlers then allow for extensions to plug in where appropriate *for the component type*.
How's that? Tell me about it.
I'm a little confused by your question - do you want to know what I mean by "where appropriate" or how the extension is plugged in?
This is how it is plugged in:
You have this interface:
interface LifecycleInterceptor { public Object interceptCreation (Object instance); public Object interceptAccess (String accessor, Object instance); }
Each method can do either or both of:
+ Proxy the instance, return the proxy.
+ Call some method in the instance.
For example, you'd implement Initializable like this:
public Object interceptCreation (Object instance) { if (instance instanceof Initializable) { ((Initializable) instance).initialize (); } return instance; }
If you wanted to proxy the object, you'd do:
public Object interceptCreation (Object instance) { Object proxy = createProxy (instance); return proxy; }
Now, the question is, *when* do you apply the creation intercepts?
+ For an Avalon 4 component, it should be before Initialize.
+ For a Pico component, it should be after construction.
You have Handlers that manage component instances, so it is there that these LifecycleInterceptors are called:
http://cvs.apache.org/viewcvs.cgi/avalon-sandbox/aspect/src/java/org/apa che/avalon/aspect/Avalon4ComponentHandler.java?rev=1.1&view=markup
And this is how an Aspect provides the interceptor:
http://cvs.apache.org/viewcvs.cgi/avalon-sandbox/aspect/src/java/org/apa che/avalon/aspect/SecurityAspect.java?rev=1.1&view=markup
/LS
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--
|------------------------------------------------| | Magic by Merlin | | Production by Avalon | | | | http://avalon.apache.org/merlin | | http://dpml.net/merlin/distributions/latest | |------------------------------------------------|
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
