You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Leo Simons <le...@apache.org> on 2003/04/11 22:44:31 UTC

[merlin] merlin.engine.lifecycle & friends

well, I'm gonna be looking at merlin in the next few weeks...started 
with "removing the yellow" on some packages (most commits didn't make it 
due to size I think).

---

About lifecycle....why is this package as complex as it is? What 
possible purpose is there to using half a dozen services to do something 
as simple as starting up the lifecycle? It must be terrible overhead...

Actually, I can't see why 80% of the code in this package is neccessary. 
Why is it there? Phoenix does the same basic thing in one or two methods 
(DefaultApplication.doStartup() or something like that).

Also, why is composition and contextualization merged? These are 
seperate concerns in my book. I see that in several places. What's the 
idea here?

---

bargimg on, I found some awkward code....stuff like

         String key = "urn:assembly:lifecycle.logging";
         if( m_context.hasEntry( key ) )
         {
             m_logging = (LoggingService) m_context.get( key );
         } else
         {
             m_logging = makeLoggingService();
         }

         key = "urn:assembly:lifecycle.context";
         if( m_context.hasEntry( key ) )
         {
             m_contextualization = (ContextualizationService) 
m_context.get( key );
         } else
         {
             m_contextualization = makeContextualizationService();
         }

services from a context? I think use of SM is a better idea.

Also, the goal with keys is to make them well-known, so I think a better 
pattern in general is

         if( m_context.hasEntry( LoggingService.ROLE ) )
         {
             m_logging = (LoggingService) m_context.get(
                   LoggingService.ROLE );
         } else
         {
             m_logging = makeLoggingService();
         }

         if( m_context.hasEntry( ContextualizationService.ROLE ) )
         {
             m_contextualization = (ContextualizationService)
                   m_context.get( ContextualizationService.ROLE );
         } else
         {
             m_contextualization = makeContextualizationService();
         }

furthermore, makeBlah() again looks like flexibility syndrome and 
subversion of control. IoC says that the container should provide what 
the component needs. These aren't actually optional dependencies. 
Seperation of concern dictates the component does not handle creation of 
its own dependencies. More generally, always completely decouple 
implementations from each other when you decouple.

finally, IoC should also make sure a component gets everything it needs. 
The whole idea is that you can make assumptions about that in your 
components, so you don't have to do this defensive programming cruft in 
your components wrt the lifecycle. So the snippet IMO should simplify to

             m_logging = (LoggingService)m_serviceManager.get(
                   LoggingService.ROLE );
             m_contextualization = (ContextualizationService)
                   m_serviceManager.get( ContextualizationService.ROLE );

Next up in the bad practices visor comes even more redundant defensive 
programming, stuff like

         if( appliance == null )
         {
             throw new NullPointerException( "appliance" );
         }

appearing everywhere. Even lifecycle stages implemented just for the 
sake of redundant checks like this. Anyone object if I blaze through the 
merlin code and change stuff like that all around? It's going to make 
things a lot easier to read.

Also, I plan to bring down the vocabulary (made some changes already as 
an example) to the level normal humans can read. Now's the time to 
object before I throw half of it out :D

---

spi --> Service Provider Interface. Where does that term come from? What 
exactly does it mean? Can we change that to "api"?

---

Lastly (for today), where exactly are what xdoc sources for 
avalon.apache.org/sandbox/assembly and /sandbox/merlin? How is the site 
generated nowadays?

I'm writing some minimal ant scripts to get merlin into gump again 
tomorrow (though no promise).

cheers,

- LSD



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: [merlin] merlin.engine.lifecycle & friends

Posted by Peter Royal <pr...@apache.org>.
On Friday, April 11, 2003, at 07:39  PM, Stephen McConnell wrote:
> Leo Simons wrote:
>
>> well, I'm gonna be looking at merlin in the next few weeks...started 
>> with "removing the yellow" on some packages (most commits didn't make 
>> it due to size I think).
>
>
> What does "removing the yellow" mean?
> I just did a clean ckeckout and build and everything seems fine to me.

My guess is he's using IDEA, <http://intellij.com>, (best ide in the 
world), and it has a red/yellow/green display to indicate if a class 
has any errors, unused fields, etc.
-pete


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: [merlin] merlin.engine.lifecycle & friends

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

Leo Simons wrote:

> well, I'm gonna be looking at merlin in the next few weeks...started 
> with "removing the yellow" on some packages (most commits didn't make 
> it due to size I think). 


What does "removing the yellow" mean?
I just did a clean ckeckout and build and everything seems fine to me.

>
>
> ---
>
> About lifecycle....why is this package as complex as it is? What 
> possible purpose is there to using half a dozen services to do 
> something as simple as starting up the lifecycle? It must be terrible 
> overhead... 


There is scope for optimization in that package.  The reason for the 
complexity is that I need/want pluggable strategies.  As example of a 
strategy is Avalon 4.  Another strategy is A5.  In putting the package 
together I had to take care of (a) bootstrap concerns, versus (b) 
handling alternative strategy.  At the end of the day I was able to 
factor this down to one replaceble lifestyle phase.  With that resolved 
the rest remaining lifestyle handlers can be significantly optimised.

>
> Actually, I can't see why 80% of the code in this package is 
> neccessary. Why is it there? Phoenix does the same basic thing in one 
> or two methods (DefaultApplication.doStartup() or something like that). 


The objective is to be able to handle multiple component models within a 
single JVM. For example, I want to be able to deploy components that are 
classic A4 concurrently with A5 or some custom component model.  That 
adds complexity.  Secondly, Merlin provides a much higher degreee of 
flexibility concerning the way in which depedencies are managed - this 
includes handling context entries as real dependencies.

>
>
> Also, why is composition and contextualization merged? These are 
> seperate concerns in my book. I see that in several places. What's the 
> idea here?


The merge is a result of thinking about this for about 6 months.  My 
conclusion was that seperation of contextualization and servicing in A4 
was an artifical notion when looking at the problem from the point of 
view of a container architecture.  Rather than dealing with two 
dependency problems, I abstracted this down to one - and the Avalon 
strategy reflects the seperation of this concern into two phases.

Logically I consider this to be one problem.

>
> ---
>
> bargimg on, I found some awkward code....stuff like
>
>         String key = "urn:assembly:lifecycle.logging";
>         if( m_context.hasEntry( key ) )
>         {
>             m_logging = (LoggingService) m_context.get( key );
>         } else
>         {
>             m_logging = makeLoggingService();
>         }
>
>         key = "urn:assembly:lifecycle.context";
>         if( m_context.hasEntry( key ) )
>         {
>             m_contextualization = (ContextualizationService) 
> m_context.get( key );
>         } else
>         {
>             m_contextualization = makeContextualizationService();
>         }
>
> services from a context? I think use of SM is a better idea. 


The context you are referring to is not an Avalon context.  It is a 
context class from the Assembly/context package that represents an 
abstraction of the A4 context + service notions.  At the end of the day 
an entry if an entry in context can be declarative - then there is no 
tangible difference between it and an entry in a service manager.

>
>
> Also, the goal with keys is to make them well-known, so I think a 
> better pattern in general is
>
>         if( m_context.hasEntry( LoggingService.ROLE ) )
>         {
>             m_logging = (LoggingService) m_context.get(
>                   LoggingService.ROLE );
>         } else
>         {
>             m_logging = makeLoggingService();
>         }
>
>         if( m_context.hasEntry( ContextualizationService.ROLE ) )
>         {
>             m_contextualization = (ContextualizationService)
>                   m_context.get( ContextualizationService.ROLE );
>         } else
>         {
>             m_contextualization = makeContextualizationService();
>         }


Yep.
Agreed.

>
> furthermore, makeBlah() again looks like flexibility syndrome and 
> subversion of control. 


Guilty as accused on flexibility syndrome.  As noted above - there is 
room for consilidation here.


> IoC says that the container should provide what the component needs. 
> These aren't actually optional dependencies.


The conflicting interests are related to using the API without having to 
declare everything. What is happening in the code you are referrring to 
is that if the dependecy is not being supplied, then the internal 
component is building it.  The up side is that the developer using the 
API does not need to worry about everything.  The downside is what you 
pointed out.  To be frank - I'm floating between both extremes (hense 
the compromise).

> Seperation of concern dictates the component does not handle creation 
> of its own dependencies. More generally, always completely decouple 
> implementations from each other when you decouple.


I agree - but I also want to make the API easy to use.
Anyway - I'm open to suggestions.

>
> finally, IoC should also make sure a component gets everything it 
> needs. The whole idea is that you can make assumptions about that in 
> your components, so you don't have to do this defensive programming 
> cruft in your components wrt the lifecycle. So the snippet IMO should 
> simplify to
>
>             m_logging = (LoggingService)m_serviceManager.get(
>                   LoggingService.ROLE );
>             m_contextualization = (ContextualizationService)
>                   m_serviceManager.get( ContextualizationService.ROLE );
>
> Next up in the bad practices visor comes even more redundant defensive 
> programming, stuff like
>
>         if( appliance == null )
>         {
>             throw new NullPointerException( "appliance" );
>         }


The package was written with the assumption that these API would be 
usable in other applications - hense the seperation of meta - assembly - 
and merlin.  I don't think you can make the assumption that defensive 
programming is not required what an operation is public.

>
> appearing everywhere. Even lifecycle stages implemented just for the 
> sake of redundant checks like this. Anyone object if I blaze through 
> the merlin code and change stuff like that all around? It's going to 
> make things a lot easier to read. 


I have reservations about the if( xxx  == null ) unless it is real clear 
that the API is not exposed.  Aside from that go fo it.

> Also, I plan to bring down the vocabulary (made some changes already 
> as an example) to the level normal humans can read. 


ROTFL

> Now's the time to object before I throw half of it out :D


No objection what so every.
:-)

> -- 
>
> spi --> Service Provider Interface. 


Yep.

> Where does that term come from? 


Hrom this alian mind!

> What exactly does it mean? 


Service Provider Interface.
a.k.a. an interface implemented by a provider.

> Can we change that to "api"?


Anything can changed - personally SPI means more to me than API. An API 
means the programming interface which in my mind is different to the SPI 
- the SPI is the contractual stuff.

>
> ---
>
> Lastly (for today), where exactly are what xdoc sources for 
> avalon.apache.org/sandbox/assembly and /sandbox/merlin? How is the 
> site generated nowadays? 


I really want to use that expression here - RTFRM
(I'm laughing - seriously - the site build instructions are in the top 
level README.txt file).

$ maven merlin-site

> I'm writing some minimal ant scripts to get merlin into gump again 
> tomorrow (though no promise). 


Cool.

Cheers, Steve.

>
> cheers,
>
> - LSD
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
> For additional commands, e-mail: dev-help@avalon.apache.org
>
>
>

-- 

Stephen J. McConnell
mailto:mcconnell@apache.org
http://www.osm.net

Sent via James running under Merlin as an NT service.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org