On Mon, 2004-03-01 at 07:13, Niclas Hedhman wrote:
> On Monday 01 March 2004 22:59, Cameron Fieber wrote:
> > On Mon, 2004-03-01 at 06:07, Stephen McConnell wrote:
> > > Have not looked at the code yet - but basically a facility would
> do
> > > the
> > > following:
> > >
> > >    (a) on deployment, do scan of the model to locate component
> models
> > >        its is interested in, and secondly, register a composition
> > > event
> > >        listener to capture info about model structural changes
> > >
> > >    (b) on a composition event - just check the model that is added
> > >        (or handle updating is something is removed) - no need to
> > > rescan
> > >
> > > Stephen.
> >
> > That is what I am doing - I borrowed heavily from the
> > DefaultModelListener in the http facility code.
> 
> Without trying to be 'obstinate', you call processModel() on every
> event 
> containing a ContainmentModel, which traverse the whole model.
> 
> 
>     public void modelAdded( CompositionEvent compositionEvent )
>     {
>         DeploymentModel model = compositionEvent.getChild();
>         processModel( model, true );
>     }
> 
>     private void processModel( DeploymentModel model, boolean flag )
>     {
>         if ( model instanceof ContainmentModel )
>         {
>             ContainmentModel containment = ( ContainmentModel ) model;
>             if ( flag )
>             {
>                 containment.addCompositionListener( this );
>             }
>             else
>             {
>                 containment.removeCompositionListener( this );
>             }
>             DeploymentModel[] models = containment.getModels();
>             for ( int i = 0; i < models.length; i++ )
>             {
>                 processModel( models[i], flag );
>             }
>         }
> 
> But this is nit-picking :o)

Nit picking is fine! :-)  My understanding of the event model is
somewhat limited but as I understand it: a modelAdded containing a
ContainmentModel as the child would mean that a new sub-container was
just added?  In that case I call processModel on the DeploymentModel
contained in the event to register as a listener to that sub-container,
and process the models that it contains.  If there's a better way to do
it, I'm all for it - I'm mainly just trying to figure this stuff out as
I go.

> 
> Stephen's idea of LifeCycle extension is worth-while considering, but
> I wonder 
> if the ComponentManagementCompositionListener will be instantiated
> early 
> enough. Stephen ?

My first attempt used a LifecycleExtension, and it had the necessary
level of access to the component to export the management interfaces.

In looking through the ContainmentModel and ComponentModel I don't
immediately see a way to stuff support for a new StageModel in to a
Component - other than maybe removing the ComponentModel from the
ContainmentModel, wrapping it in something that returned true for
isaCandidate and returned the StageModel in getStageModel - but that
seems much more complicated than I'm sure it really is. :-)

-Cameron






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to