You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Stephen McConnell <mc...@apache.org> on 2002/08/13 18:45:54 UTC

lifecycle extension proposal

Currently we have two different lifecycle extension interface (Fortress 
style and Merlin style). This email processes a common single approach.  
The current interfaces in Merlin and Fortress are detailed below 
together with a summary of the differences and the issue I have with 
both approaches.  I've summarized the objectives relative to a common 
model, and detailed a two interfaces that could be used as a common 
solution for both Merlin and Fortress.  I have also included an example 
of the extension related meta-info that would be required.

Current Fortress extension interface:
-------------------------------------

     public interface LifecycleExtension
     {
         void create( Object object, Context context );
         void destroy( Object object, Context context );
         void access( Object object, Context context );
         void release( Object object, Context context );
     }

Current Merlin extension interface
---------------------------------

     public interface Extension
     {
         void extend( int stage, Object object, Context context )
            throws Exception;
     }

Differences
-----------

In the Merlin model an extension implementation declares the stages it 
supports (create, destroy, access and release) and the Merlin framework 
only calls the extension for those stages.  In Fortress the stage is 
called irrespective of the extension's requirement to handle the stage.  
Another difference is the declaration of "throws Exception" that is 
included in the Merlin case but not in the Fortress case.

Issues
------

In both solutions there is a context argument supplied for every stage.  
In Fortress a general context object is passed in by the container.  In 
Merlin the context object is built based on the implementations 
declaration of the context information it needs.  In both cases this 
seems problematic. In the Fortress case its not clear what the context 
contains and what context values an extension implementation can depend 
on.  In Merlin its possible to declare the context constraints and 
establishment criteria in the x-files, however, the supply of context 
under the destroy, access and release stages seems questionable - I 
believe we should only be supplying context during the create stage.  An 
implementation is free to hold a reference to the supplied context if it 
needs this information in subsequent stages.

Another issue raises was the simplicity factory.  The Fortress model is 
generally considered to be easier to understand (due to explicit methods 
for each stage as opposed to the enumeration approach in Merlin).

Objective
---------

Establish a common interface or set of interfaces that are shared by 
Merlin and Fortress for extension management, meeting the following 
criteria:

  1. readily understandable method signatures
  2. separation of individual stages (i.e. an extension does not
     need to support all stages)
  3. type validation - ability to inspect an handler implementation
     to see if it implements a lifecycle stage and ability to inspect
     the target component to see if it implements the extension stage
     interface
  4. context validation - ability to know what context information a
     stage requires prior to lifecycle stage invocation
  5. exception support - provide ability for an extension to throw an
     exception in creation and access stages

Interface Proposal
------------------

The following two interfaces are proposed as a common replacement of the 
Merlin Extension interface and Fortress LifecycleExtension interface.

    interface Creator
    {
         void create( Object object, Context context ) throws Exception;
         void destroy( Object );
    }

    interface Accessor
    {
         void access( Object object ) throws Exception;
         void release( Object object );
    }

The Fortress LifecycleExtension could be redefined as:

    public interface LifecycleExtension extends Creator, Accessor {}

The Merlin Extension interface would be replaced by direct use of 
Creator and Accessor.


Meta-Info Proposal
------------------

Meta-Info declaration (i.e. type level information included in an .xinfo 
file) in an extension hamdler.  This is basically the same as the 
existing Merlin meta info declaration for an extension - the only change 
is that the extension does not declare which lifecycle stages it 
supports (because we can get this info from the class if we use the 
above interfaces).

    <type>

      <!-- component, dependency, service declarations, etc. -->
      <extensions>
        
        <!-- a type may provide implementation of multiple extensions -->
        <extension>

           <!-- extension stage name and interface reference -->
           <name>exploitable</name>
           <reference type="Demonstratable" />

           <!-- optional extension attributes -->
           <attributes>
             <attribute key="status" value="experimental"/>
           </attributes>     

           <!-- declaration of the context values required by the 
extension -->
           <context>
              <entry key="home" type="java.io.File"/>
           </context>

        </extension>
      </extensions>    
    </type>

If this all sounds reasonable I'll go ahead and put it in place in Merlin.

Cheers, Steve,

-- 

Stephen J. McConnell

OSM SARL
digital products for a global economy
mailto:mcconnell@osm.net
http://www.osm.net



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: lifecycle extension proposal

Posted by Berin Loritsch <bl...@apache.org>.
> From: Stephen McConnell [mailto:mcconnell@apache.org] 
> 
> Berin Loritsch wrote:
> 
> >What help do you need?
> >
> 
> What I would like to do is to put in place a pooled and per-thread 
> handler.  I've got the framework in place but I really don't know 
> anything about the mpool stuff.  What would be perfect is someone who 
> knows mpool and Fortress inside out, and is keen to learn about the 
> Merlin meta API, and wants to volunteer to put something in 
> place (hint, 
> hint) ;-).  I've done transient and singleton as examples of 
> using the 
> lifestyle manager and abstract lifestyle handler.  In 
> addition I've put 
> in place a framework which will allow replacement of the lifestyle 
> manager at a per-container level which means potential 
> assignment of a 
> Fortress manager to a container and from there a specialized 
> container 
> (e.g. Fortress can do whatever it wants inside Merlin) 
> running parrallel 
> with Merlin containers.

:)

I'll see what I can do.  I may be able to look at it later tonight
or later today.  I'm not sure--but I have to do the work I'm almost
paid for...


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: lifecycle extension proposal

Posted by Stephen McConnell <mc...@apache.org>.

Berin Loritsch wrote:

>>From: Stephen McConnell [mailto:mcconnell@apache.org] 
>>
>>Marcus Crafter wrote:
>>
>>    
>>
>>>Hi Stephen,
>>>
>>>	Sorry, I'm coming into the thread a little late - I'll 
>>>      
>>>
>>have a look at
>>    
>>
>>>	what you've done in Merlin below and send in some comments soon.
>>>	
>>>
>>>      
>>>
>>Great!
>>I'm looking forward to ticking that one off the list,
>>    
>>
>
>
>Me too!
>
>  
>
>>>	Are you in the process of splitting up the jar files now ?
>>>
>>>      
>>>
>>If you happy with the org.apache.ezcalibur.container.lifecycle stuff 
>>(inside the excalibur/assembly CVS), I'll package it up into 
>>a seperate 
>>jar file ASAP.  
>>    
>>
>
>I am happy with it.
>
>
>  
>
>>>	Assuming the extension models are now consolidated - 
>>>      
>>>
>>the next thing in
>>    
>>
>>>	the lifecycle extension world to look at was the 
>>>      
>>>
>>session proposal
>>    
>>
>>>	from Berin, archived under 
>>>	
>>>      
>>>
>>http://marc.theaimsgroup.com/?l=avalon-dev&m=102742811501755&w=2.
>>    
>>
>>>	
>>>	Have you investigated this one already ?
>>>	
>>>
>>>      
>>>
>>Nope - I actually want to finalize the lifestyle content 
>>first (any help 
>>from Fortress people appraciated).
>>    
>>
>
>That's cool.  I want a common model as well.
>
>  
>
>> Basically singleton and transient 
>>are in place.  Getting in mpool based pooled policy and 
>>per-thread would 
>>wrap that item up nicely.  Fro there I would like to do a 
>>review of the 
>>meta model package - make sure all the doc is ok, check 
>>consistency in 
>>method naming, class naming etc. then push this into a 
>>seperate project. 
>> After that, update Merlin 2.0 to use the "common" meta-model 
>>and get an 
>>alpha release out the door.
>>    
>>
>
>What help do you need?
>

What I would like to do is to put in place a pooled and per-thread 
handler.  I've got the framework in place but I really don't know 
anything about the mpool stuff.  What would be perfect is someone who 
knows mpool and Fortress inside out, and is keen to learn about the 
Merlin meta API, and wants to volunteer to put something in place (hint, 
hint) ;-).  I've done transient and singleton as examples of using the 
lifestyle manager and abstract lifestyle handler.  In addition I've put 
in place a framework which will allow replacement of the lifestyle 
manager at a per-container level which means potential assignment of a 
Fortress manager to a container and from there a specialized container 
(e.g. Fortress can do whatever it wants inside Merlin) running parrallel 
with Merlin containers.

Cheers, Steve.


>
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>  
>

-- 

Stephen J. McConnell

OSM SARL
digital products for a global economy
mailto:mcconnell@osm.net
http://www.osm.net




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: lifecycle extension proposal

Posted by Berin Loritsch <bl...@apache.org>.
> From: Stephen McConnell [mailto:mcconnell@apache.org] 
> 
> Marcus Crafter wrote:
> 
> >Hi Stephen,
> >
> >	Sorry, I'm coming into the thread a little late - I'll 
> have a look at
> >	what you've done in Merlin below and send in some comments soon.
> >	
> >
> 
> Great!
> I'm looking forward to ticking that one off the list,


Me too!

> >	Are you in the process of splitting up the jar files now ?
> >
> 
> If you happy with the org.apache.ezcalibur.container.lifecycle stuff 
> (inside the excalibur/assembly CVS), I'll package it up into 
> a seperate 
> jar file ASAP.  

I am happy with it.


> >	Assuming the extension models are now consolidated - 
> the next thing in
> >	the lifecycle extension world to look at was the 
> session proposal
> >	from Berin, archived under 
> >	
> http://marc.theaimsgroup.com/?l=avalon-dev&m=102742811501755&w=2.
> >	
> >	Have you investigated this one already ?
> >	
> >
> 
> Nope - I actually want to finalize the lifestyle content 
> first (any help 
> from Fortress people appraciated).

That's cool.  I want a common model as well.

>  Basically singleton and transient 
> are in place.  Getting in mpool based pooled policy and 
> per-thread would 
> wrap that item up nicely.  Fro there I would like to do a 
> review of the 
> meta model package - make sure all the doc is ok, check 
> consistency in 
> method naming, class naming etc. then push this into a 
> seperate project. 
>  After that, update Merlin 2.0 to use the "common" meta-model 
> and get an 
> alpha release out the door.

What help do you need?



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: lifecycle extension proposal

Posted by Stephen McConnell <mc...@apache.org>.

Marcus Crafter wrote:

>Hi Stephen,
>
>	Sorry, I'm coming into the thread a little late - I'll have a look at
>	what you've done in Merlin below and send in some comments soon.
>	
>

Great!
I'm looking forward to ticking that one off the list,

>	Are you in the process of splitting up the jar files now ?
>

If you happy with the org.apache.ezcalibur.container.lifecycle stuff 
(inside the excalibur/assembly CVS), I'll package it up into a seperate 
jar file ASAP.  

>	
>	Assuming the extension models are now consolidated - the next thing in
>	the lifecycle extension world to look at was the session proposal
>	from Berin, archived under 
>	http://marc.theaimsgroup.com/?l=avalon-dev&m=102742811501755&w=2.
>	
>	Have you investigated this one already ?
>	
>

Nope - I actually want to finalize the lifestyle content first (any help 
from Fortress people appraciated).  Basically singleton and transient 
are in place.  Getting in mpool based pooled policy and per-thread would 
wrap that item up nicely.  Fro there I would like to do a review of the 
meta model package - make sure all the doc is ok, check consistency in 
method naming, class naming etc. then push this into a seperate project. 
 After that, update Merlin 2.0 to use the "common" meta-model and get an 
alpha release out the door.

Cheers, Steve.


>	Cheers,
>	
>	Marcus
>	
>On Wed, Aug 14, 2002 at 01:00:48PM +0200, Stephen McConnell wrote:
>  
>
>>    
>>
>>>OK
>>>
>>>After seperation of profile deployment from instance instantiation I can
>>>now provide context to all stages.
>>>
>>>I'll go ahead and update Merlin's extension framework to the following:
>>>
>>> interface Creator
>>> {
>>>      void create( Object object, Context context ) throws Exception;
>>>      void destroy( Object object, Context context );
>>> }
>>>
>>> interface Accessor
>>> {
>>>      void access( Object object, Context context ) throws Exception;
>>>      void release( Object object, Context context );
>>> }
>>>
>>>Cheers, Steve.
>>>      
>>>
>>DONE.
>>
>>Merlin now provides full support for lifestyle extension based on the 
>>above interfaces.  I've include the Creator and Accessor interfaces and 
>>container independent abstract classes in the package 
>>org.apache.excalibur.container.lifecycle.* For the moment these are 
>>included in the merlin jar file but I'll come up with a seperate 
>>excalibur-container jar in the near future that can be used indepedently 
>>of Merlin.
>>
>>Cheers, Steve.
>>
>>-- 
>>
>>Stephen J. McConnell
>>
>>OSM SARL
>>digital products for a global economy
>>mailto:mcconnell@osm.net
>>http://www.osm.net
>>
>>
>>
>>
>>--
>>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>>For additional commands, e-mail: <ma...@jakarta.apache.org>
>>
>>    
>>
>
>  
>

-- 

Stephen J. McConnell

OSM SARL
digital products for a global economy
mailto:mcconnell@osm.net
http://www.osm.net




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: lifecycle extension proposal

Posted by Marcus Crafter <cr...@fztig938.bank.dresdner.net>.
Hi Stephen,

	Sorry, I'm coming into the thread a little late - I'll have a look at
	what you've done in Merlin below and send in some comments soon.
	
	Are you in the process of splitting up the jar files now ?
	
	Assuming the extension models are now consolidated - the next thing in
	the lifecycle extension world to look at was the session proposal
	from Berin, archived under 
	http://marc.theaimsgroup.com/?l=avalon-dev&m=102742811501755&w=2.
	
	Have you investigated this one already ?
	
	Cheers,
	
	Marcus
	
On Wed, Aug 14, 2002 at 01:00:48PM +0200, Stephen McConnell wrote:
> 
> 
> >
> >OK
> >
> >After seperation of profile deployment from instance instantiation I can
> >now provide context to all stages.
> >
> >I'll go ahead and update Merlin's extension framework to the following:
> >
> >  interface Creator
> >  {
> >       void create( Object object, Context context ) throws Exception;
> >       void destroy( Object object, Context context );
> >  }
> >
> >  interface Accessor
> >  {
> >       void access( Object object, Context context ) throws Exception;
> >       void release( Object object, Context context );
> >  }
> >
> >Cheers, Steve.
> 
> 
> DONE.
> 
> Merlin now provides full support for lifestyle extension based on the 
> above interfaces.  I've include the Creator and Accessor interfaces and 
> container independent abstract classes in the package 
> org.apache.excalibur.container.lifecycle.* For the moment these are 
> included in the merlin jar file but I'll come up with a seperate 
> excalibur-container jar in the near future that can be used indepedently 
> of Merlin.
> 
> Cheers, Steve.
> 
> -- 
> 
> Stephen J. McConnell
> 
> OSM SARL
> digital products for a global economy
> mailto:mcconnell@osm.net
> http://www.osm.net
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 

-- 
        .....
     ,,$$$$$$$$$,      Marcus Crafter
    ;$'      '$$$$:    Computer Systems Engineer
    $:         $$$$:   ManageSoft GmbH
     $       o_)$$$:   82-84 Mainzer Landstrasse
     ;$,    _/\ &&:'   60327 Frankfurt Germany
       '     /( &&&
           \_&&&&'
          &&&&.
    &&&&&&&:

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: lifecycle extension proposal

Posted by Stephen McConnell <mc...@apache.org>.

>
> OK
>
> After seperation of profile deployment from instance instantiation I can
> now provide context to all stages.
>
> I'll go ahead and update Merlin's extension framework to the following:
>
>   interface Creator
>   {
>        void create( Object object, Context context ) throws Exception;
>        void destroy( Object object, Context context );
>   }
>
>   interface Accessor
>   {
>        void access( Object object, Context context ) throws Exception;
>        void release( Object object, Context context );
>   }
>
> Cheers, Steve.


DONE.

Merlin now provides full support for lifestyle extension based on the 
above interfaces.  I've include the Creator and Accessor interfaces and 
container independent abstract classes in the package 
org.apache.excalibur.container.lifecycle.* For the moment these are 
included in the merlin jar file but I'll come up with a seperate 
excalibur-container jar in the near future that can be used indepedently 
of Merlin.

Cheers, Steve.

-- 

Stephen J. McConnell

OSM SARL
digital products for a global economy
mailto:mcconnell@osm.net
http://www.osm.net




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: lifecycle extension proposal

Posted by Stephen McConnell <mc...@apache.org>.

Stephen McConnell wrote:

>
>
>>>> Interface Proposal
>>>> ------------------
>>>>
>>>> The following two interfaces are proposed as a common replacement 
>>>> of the Merlin Extension interface and Fortress LifecycleExtension 
>>>> interface.
>>>>
>>>>    interface Creator
>>>>    {
>>>>         void create( Object object, Context context )           
>>>> throws Exception;
>>>>         void destroy( Object );
>>>>    }
>>>>
>>>>    interface Accessor
>>>>    {
>>>>         void access( Object object ) throws Exception;
>>>>         void release( Object object );
>>>>    }
>>>>   
>>>
>>>
>>>
>>> :/
>>>
>>> I would add the Context to each of the methods, but your exception
>>> handling is correct.  See above for examples that require the existence
>>> of the Context obejct.
>>>
>>
>> I'm still maintaining my position that this is not needed, but in the 
>> meantime, some questions - Is it correct to asume that the context 
>> instance is the same imutable instance for each invocation?  If this 
>> isn not true, a lot more complexity is needed in the meta-info and 
>> meta-data model (a.k.a. lets' not go in that direction).  Secondly, 
>> assuming it's the same instances, then if the container has to cache 
>> this value (as opposed to the extension) - (which is what your 
>> suggesting), then basically your saying that for every component 
>> instance, the container must maintain the context state for all of 
>> the extensions the component is dependent on (eeek).  I'm reasonably 
>> confident that you don't want to imply that, but as far as I can see 
>> - that's the implication. Can you enlighten me? 
>
>
>
> If the context is imutable for the lifetime of the profile (as opposed 
> to an instance of the type), then maintaining the set of context vales 
> under a map keyed by extension stage may be possible within the scope 
> of the AbstractLifestyleHandler - I'm looking into it further - inital 
> thoughts are that this may not be as problamatic as I'm suggesting above. 


OK

After seperation of profile deployment from instance instantiation I can
now provide context to all stages.

I'll go ahead and update Merlin's extension framework to the following:

   interface Creator
   {
        void create( Object object, Context context )
           throws Exception;
        void destroy( Object object, Context context );
   }

   interface Accessor
   {
        void access( Object object, Context context ) throws Exception;
        void release( Object object, Context context );
   }

Cheers, Steve.


-- 

Stephen J. McConnell

OSM SARL
digital products for a global economy
mailto:mcconnell@osm.net
http://www.osm.net




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: lifecycle extension proposal

Posted by Stephen McConnell <mc...@apache.org>.

>>> Interface Proposal
>>> ------------------
>>>
>>> The following two interfaces are proposed as a common replacement of 
>>> the Merlin Extension interface and Fortress LifecycleExtension 
>>> interface.
>>>
>>>    interface Creator
>>>    {
>>>         void create( Object object, Context context )           
>>> throws Exception;
>>>         void destroy( Object );
>>>    }
>>>
>>>    interface Accessor
>>>    {
>>>         void access( Object object ) throws Exception;
>>>         void release( Object object );
>>>    }
>>>   
>>
>>
>> :/
>>
>> I would add the Context to each of the methods, but your exception
>> handling is correct.  See above for examples that require the existence
>> of the Context obejct.
>>
>
> I'm still maintaining my position that this is not needed, but in the 
> meantime, some questions - Is it correct to asume that the context 
> instance is the same imutable instance for each invocation?  If this 
> isn not true, a lot more complexity is needed in the meta-info and 
> meta-data model (a.k.a. lets' not go in that direction).  Secondly, 
> assuming it's the same instances, then if the container has to cache 
> this value (as opposed to the extension) - (which is what your 
> suggesting), then basically your saying that for every component 
> instance, the container must maintain the context state for all of the 
> extensions the component is dependent on (eeek).  I'm reasonably 
> confident that you don't want to imply that, but as far as I can see - 
> that's the implication. 
> Can you enlighten me? 


If the context is imutable for the lifetime of the profile (as opposed 
to an instance of the type), then maintaining the set of context vales 
under a map keyed by extension stage may be possible within the scope of 
the AbstractLifestyleHandler - I'm looking into it further - inital 
thoughts are that this may not be as problamatic as I'm suggesting above.

Cheers, Steve.


-- 

Stephen J. McConnell

OSM SARL
digital products for a global economy
mailto:mcconnell@osm.net
http://www.osm.net




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: lifecycle extension proposal

Posted by Stephen McConnell <mc...@apache.org>.
Berin:

Thanks for the feedback.  After ready you reply I think we are down to 
the single issue of context management during the access, release and 
destroy stages (which is also related to the meta-info context 
information). 

Firstly the context separation issue
------------------------------------

The problem I have (from the point of view of a container) is that I am 
dealing with a number of seperate constructed context instances:

  (A) the context to provide to a target component under the
      contextualize stage that is built based on the context criteria
      declared in the component profile (this is the classic component
      context)

  (B) the context to provide to an extension under its contextualixe
      stage (keep in mind that in Merlin an extension is no different
      for a regular component)

  (C) the context to supply to an extension when requesting stage
      execution (keeping in mind that the supplied context must be
      constructed by the container in accordance with type level
      context criteria and profile level context value creation
      directives)

In Fortress B doesn't exist because extensions are not components, 
context A is uses as the value in C, however, the implementation of A 
knows nothing about the context requirements of the extension - so 
Fortress is basically running on hope and luck that the context 
information needed during execution of a stage will be supplied by the 
container.  In the Merlin case the extension handler declares explicitly 
the context that it needs (independently of the context that the target 
component needs) and the directives for container creation of the 
context values.

This ensures that extension handler components can be built and used 
independently of the implementation of the target component.

To sumarise - the context values supplied to a lifecycle extension 
method must be declared. Given that they are declared, then the 
declaration must occur inside the type that is dependent on the value 
(i.e. the extension handler implementation, not the target component, 
and not the container).


On context arguments in access, release and destroy stage invocations
---------------------------------------------------------------------

In Merlin the create stage context value for an extension is produced by 
the class ResourceProvider through the method createContext( 
ExtensionDescriptor descriptor, Context context).  This is invoked by 
the stateless class LifecycleHelper.  The ResourceProvider class is also 
state independent of the object being managed.  If context state needs 
to be maintained across lifecycle stages for a given extension (e.g. 
extension X needs context during create and destroy) then extension X 
should maintain the refernece to the context supplied during create.  In 
the examples provided, all of these appear to use the same context 
instance across the different stages - as such, I don't see a problem 
with pushing the obligation onto the extension handler for maintaining 
the reference to the context instance over its lifetime.

If (and this is a big if) - an extension needs to be suppplied with 
different context information at different stages, then a lot more 
detail will be needed in the meta-info and meta-data models then we have 
at the moment.  This is also something I would *really* not like to support.

 .... more notes in-line

Berin Loritsch wrote:

>>From: Stephen McConnell [mailto:mcconnell@apache.org] 
>>
>>Currently we have two different lifecycle extension interface 
>>(Fortress style and Merlin style). This email processes a 
>>common single approach.  
>>The current interfaces in Merlin and Fortress are detailed below 
>>together with a summary of the differences and the issue I have 
>>with both approaches.  I've summarized the objectives relative 
>>to a common model, and detailed a two interfaces that could be 
>>used as a common solution for both Merlin and Fortress.  I have 
>>also included an example of the extension related meta-info that 
>>would be required.
>>    
>>
>
>A smile comes across my face :)
>
>
><snip/>
>
>  
>
>>Differences
>>-----------
>>
>>In the Merlin model an extension implementation declares the 
>>stages it supports (create, destroy, access and release) and 
>>the Merlin framework only calls the extension for those stages.  
>>In Fortress the stage is called irrespective of the extension's 
>>requirement to handle the stage.  
>>Another difference is the declaration of "throws Exception" that 
>>is included in the Merlin case but not in the Fortress case.
>>    
>>
>
>A minor omission.  It can be remedied, but lets get the merger of 
>code done first.
>
>
>  
>
>>Issues
>>------
>>
>>In both solutions there is a context argument supplied for 
>>every stage.  
>>In Fortress a general context object is passed in by the 
>>container.  In Merlin the context object is built based on 
>>the implementations declaration of the context information 
>>it needs.  In both cases this seems problematic. In the 
>>Fortress case its not clear what the context contains and 
>>what context values an extension implementation can depend 
>>on.  In Merlin its possible to declare the context 
>>constraints and establishment criteria in the x-files, 
>>however, the supply of context under the destroy, access and 
>>release stages seems questionable - I believe we should only 
>>be supplying context during the create stage.  An 
>>implementation is free to hold a reference to the supplied 
>>context if it needs this information in subsequent stages.
>>    
>>
>
>Bear in mind that something along the lines of a persistence 
>mechanism or a session management mechanism needs to pass in 
>values so that the extended lifecycles can use them.  For 
>instance, consider a configuration manager that is central to 
>Avalon.  The configuration is stored by the ConfigManager, and 
>retrieved from it as well.
>
>Something like this:
>
>interface PersistentConfigurable extends Configurable
>{
>    Configuration saveConfiguration();
>}
>
>The lifecycle extention handler would have to access the 
>ConfigManager somehow--most likely by the Context.
>
>This would be a DISPOSE time requirement for Context.
>

In Merlin, the peristence extension is required to declare the
context values that it requires.  It may also declare directives
through which a container can create these context values. The
extension could also declare dependecies on other components as
part of its process of establishing the state it needs to fullfill
the extension stage execution.  I.e. the container responsibility
is limited to handling context construction and component assembly.
Anything else is extension resposibility.

In this example, a ConfigManager has to be created.  A ConfigManager
is unknow to Merlin.  A ConfigManager could be created by Merlin
using context directives, or, the extension could create a manager
itself, or aquire a manager via a service dependency.  Bottom line
is that the extension is resoposible for establishment of the
ContextManager instance in which case it can also hold a reference
to that instance when handling subsequent stages.

>
>Also session management requires both REQUEST and RELEASE access to the
>Context.
>
>interface SessionEnabled
>{
>    setSession(Session session);
>    unsetSession(Session session);
>}
>
>On REQUEST, setSession() is called and the component can obtain all the
>values it needs to continue processing for its client.  On RELEASE,
>unsetSession() is called and the component can save all the values it
>will need the next time it is requested.
>
>These are very real requirements that support the requirement of having
>Context accessible to all lifecycle methods.
>

Having context accessible is different to passing it across an interface.  
In the above example, a context value can be supplied by the container on
creation, the extension can hold a reference to this for use during the
access and release stages.

>>Another issue raises was the simplicity factory.  The 
>>Fortress model is generally considered to be easier to understand 
>>(due to explicit methods for each stage as opposed to the enumeration 
>>approach in Merlin).
>>    
>>
>
>True.
>
>
>  
>
>>Objective
>>---------
>>
>>Establish a common interface or set of interfaces that are shared by 
>>Merlin and Fortress for extension management, meeting the following 
>>criteria:
>>
>>  1. readily understandable method signatures
>>  2. separation of individual stages (i.e. an extension does not
>>     need to support all stages)
>>  3. type validation - ability to inspect an handler implementation
>>     to see if it implements a lifecycle stage and ability to inspect
>>     the target component to see if it implements the extension stage
>>     interface
>>  4. context validation - ability to know what context information a
>>     stage requires prior to lifecycle stage invocation
>>  5. exception support - provide ability for an extension to throw an
>>     exception in creation and access stages
>>    
>>
>
>Keep in mind that Fortress did provide an Abstract implementation that
>provided null implementations for all the unneeded lifecycle methods.
>That left the implementor to only implement what they need.  However
>since the Fortress model does not support requirements 3-5, we need to 
>work harder.
>
>
>  
>
>>Interface Proposal
>>------------------
>>
>>The following two interfaces are proposed as a common 
>>replacement of the Merlin Extension interface and Fortress 
>>LifecycleExtension interface.
>>
>>    interface Creator
>>    {
>>         void create( Object object, Context context ) 
>>           throws Exception;
>>         void destroy( Object );
>>    }
>>
>>    interface Accessor
>>    {
>>         void access( Object object ) throws Exception;
>>         void release( Object object );
>>    }
>>    
>>
>
>:/
>
>I would add the Context to each of the methods, but your exception
>handling is correct.  See above for examples that require the existence
>of the Context obejct.
>

I'm still maintaining my position that this is not needed, but in the 
meantime, some questions - Is it correct to asume that the context 
instance is the same imutable instance for each invocation?  If this isn 
not true, a lot more complexity is needed in the meta-info and meta-data 
model (a.k.a. lets' not go in that direction).  Secondly, assuming it's 
the same instances, then if the container has to cache this value (as 
opposed to the extension) - (which is what your suggesting), then 
basically your saying that for every component instance, the container 
must maintain the context state for all of the extensions the component 
is dependent on (eeek).  I'm reasonably confident that you don't want to 
imply that, but as far as I can see - that's the implication.  

Can you enlighten me?


>
>
>  
>
>>The Fortress LifecycleExtension could be redefined as:
>>
>>    public interface LifecycleExtension extends Creator, Accessor {}
>>    
>>
>
>:)  Or we can just use the Creator/Accessor like everyone else.
>
>
>  
>
>>The Merlin Extension interface would be replaced by direct use of 
>>Creator and Accessor.
>>    
>>
>
>Right.
>
>  
>
>>Meta-Info Proposal
>>------------------
>>
>>Meta-Info declaration (i.e. type level information included 
>>in an .xinfo file) in an extension hamdler.  This is basically 
>>the same as the existing Merlin meta info declaration for an 
>>extension - the only change is that the extension does not 
>>declare which lifecycle stages it supports (because we can get 
>>this info from the class if we use the above interfaces).
>>
>>    <type>
>>
>>      <!-- component, dependency, service declarations, etc. -->
>>      <extensions>
>>        
>>        <!-- a type may provide implementation of multiple 
>>extensions -->
>>        <extension>
>>
>>           <!-- extension stage name and interface reference -->
>>           <name>exploitable</name>
>>           <reference type="Demonstratable" />
>>
>>           <!-- optional extension attributes -->
>>           <attributes>
>>             <attribute key="status" value="experimental"/>
>>           </attributes>     
>>
>>           <!-- declaration of the context values required by the 
>>extension -->
>>           <context>
>>              <entry key="home" type="java.io.File"/>
>>           </context>
>>
>>        </extension>
>>      </extensions>    
>>    </type>
>>
>>If this all sounds reasonable I'll go ahead and put it in 
>>place in Merlin.
>>    
>>
>
>It looks good to me with the one exception I already noted (existence of
>Context).
>

Where else would you define the context?  The context criteria is 
totally independent of the object that the extension is servicing, its 
independent of the serviced objects context, and its not the smae as the 
context supplied to an extension in its role of component.  To put it 
anywhere else would be a SOC violation - see comments on this at 
beginning on the email.

Cheers, Steve.


-- 

Stephen J. McConnell

OSM SARL
digital products for a global economy
mailto:mcconnell@osm.net
http://www.osm.net




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: lifecycle extension proposal

Posted by Berin Loritsch <bl...@apache.org>.
> From: Stephen McConnell [mailto:mcconnell@apache.org] 
> 
> Currently we have two different lifecycle extension interface 
> (Fortress 
> style and Merlin style). This email processes a common single 
> approach.  
> The current interfaces in Merlin and Fortress are detailed below 
> together with a summary of the differences and the issue I have with 
> both approaches.  I've summarized the objectives relative to a common 
> model, and detailed a two interfaces that could be used as a common 
> solution for both Merlin and Fortress.  I have also included 
> an example 
> of the extension related meta-info that would be required.

A smile comes across my face :)


<snip/>

> Differences
> -----------
> 
> In the Merlin model an extension implementation declares the 
> stages it 
> supports (create, destroy, access and release) and the Merlin 
> framework 
> only calls the extension for those stages.  In Fortress the stage is 
> called irrespective of the extension's requirement to handle 
> the stage.  
> Another difference is the declaration of "throws Exception" that is 
> included in the Merlin case but not in the Fortress case.

A minor omission.  It can be remedied, but lets get the merger of code
done first.


> Issues
> ------
> 
> In both solutions there is a context argument supplied for 
> every stage.  
> In Fortress a general context object is passed in by the 
> container.  In 
> Merlin the context object is built based on the implementations 
> declaration of the context information it needs.  In both cases this 
> seems problematic. In the Fortress case its not clear what 
> the context 
> contains and what context values an extension implementation 
> can depend 
> on.  In Merlin its possible to declare the context constraints and 
> establishment criteria in the x-files, however, the supply of context 
> under the destroy, access and release stages seems questionable - I 
> believe we should only be supplying context during the create 
> stage.  An 
> implementation is free to hold a reference to the supplied 
> context if it 
> needs this information in subsequent stages.

Bear in mind that something along the lines of a persistence mechanism
or a session management mechanism needs to pass in values so that the
extended lifecycles can use them.  For instance, consider a
configuration
manager that is central to Avalon.  The configuration is stored by
the ConfigManager, and retrieved from it as well.

Something like this:

interface PersistentConfigurable extends Configurable
{
    Configuration saveConfiguration();
}

The lifecycle extention handler would have to access the ConfigManager
somehow--most likely by the Context.

This would be a DISPOSE time requirement for Context.

Also session management requires both REQUEST and RELEASE access to the
Context.

interface SessionEnabled
{
    setSession(Session session);
    unsetSession(Session session);
}

On REQUEST, setSession() is called and the component can obtain all the
values it needs to continue processing for its client.  On RELEASE,
unsetSession() is called and the component can save all the values it
will need the next time it is requested.

These are very real requirements that support the requirement of having
Context accessible to all lifecycle methods.


> Another issue raises was the simplicity factory.  The 
> Fortress model is 
> generally considered to be easier to understand (due to 
> explicit methods 
> for each stage as opposed to the enumeration approach in Merlin).

True.


> Objective
> ---------
> 
> Establish a common interface or set of interfaces that are shared by 
> Merlin and Fortress for extension management, meeting the following 
> criteria:
> 
>   1. readily understandable method signatures
>   2. separation of individual stages (i.e. an extension does not
>      need to support all stages)
>   3. type validation - ability to inspect an handler implementation
>      to see if it implements a lifecycle stage and ability to inspect
>      the target component to see if it implements the extension stage
>      interface
>   4. context validation - ability to know what context information a
>      stage requires prior to lifecycle stage invocation
>   5. exception support - provide ability for an extension to throw an
>      exception in creation and access stages

Keep in mind that Fortress did provide an Abstract implementation that
provided null implementations for all the unneeded lifecycle methods.
That left the implementor to only implement what they need.  However
since
the Fortress model does not support requirements 3-5, we need to work
harder.


> Interface Proposal
> ------------------
> 
> The following two interfaces are proposed as a common 
> replacement of the 
> Merlin Extension interface and Fortress LifecycleExtension interface.
> 
>     interface Creator
>     {
>          void create( Object object, Context context ) throws 
> Exception;
>          void destroy( Object );
>     }
> 
>     interface Accessor
>     {
>          void access( Object object ) throws Exception;
>          void release( Object object );
>     }

:/

I would add the Context to each of the methods, but your exception
handling is correct.  See above for examples that require the existence
of the Context obejct.


> The Fortress LifecycleExtension could be redefined as:
> 
>     public interface LifecycleExtension extends Creator, Accessor {}

:)  Or we can just use the Creator/Accessor like everyone else.


> The Merlin Extension interface would be replaced by direct use of 
> Creator and Accessor.

Right.

> Meta-Info Proposal
> ------------------
> 
> Meta-Info declaration (i.e. type level information included 
> in an .xinfo 
> file) in an extension hamdler.  This is basically the same as the 
> existing Merlin meta info declaration for an extension - the 
> only change 
> is that the extension does not declare which lifecycle stages it 
> supports (because we can get this info from the class if we use the 
> above interfaces).
> 
>     <type>
> 
>       <!-- component, dependency, service declarations, etc. -->
>       <extensions>
>         
>         <!-- a type may provide implementation of multiple 
> extensions -->
>         <extension>
> 
>            <!-- extension stage name and interface reference -->
>            <name>exploitable</name>
>            <reference type="Demonstratable" />
> 
>            <!-- optional extension attributes -->
>            <attributes>
>              <attribute key="status" value="experimental"/>
>            </attributes>     
> 
>            <!-- declaration of the context values required by the 
> extension -->
>            <context>
>               <entry key="home" type="java.io.File"/>
>            </context>
> 
>         </extension>
>       </extensions>    
>     </type>
> 
> If this all sounds reasonable I'll go ahead and put it in 
> place in Merlin.

It looks good to me with the one exception I already noted (existence of
Context).


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>