> -----Original Message-----
> From: Stephen McConnell [mailto:[EMAIL PROTECTED]
>
> I've just committed an example of embedding merlin so that you can get
> an idea of things (available in avalon/merlin/platform/tutorials/main).

I hope everyone has taken a look at this example:

http://cvs.apache.org/viewcvs.cgi/avalon/merlin/platform/tutorials/main/src/
java/tutorial/Main.java?rev=1.2&view=markup

Stephen shows a good example of just how simple it can be to start Merlin.
But, of course, that's not the *whole* story.  In fact, I've told Stephen
before that I consider that approach cheating. :-)  In this email I'm going
to try to give a better tour of the "magic" in merlin's startup process.


1. Several properties are set in the 'merlin.properties' file.  This 
   includes telling merlin which block to run.  To do this programmatically:

        Factory factory = builder.getFactory();
        Map criteria = factory.createDefaultCriteria();
        criteria.put( "merlin.deployment", "conf/demo.block" );
        factory.create( criteria );

   (this was in Stephen's original version)

2. I'm guessing on this, but if you want to access the kernel, all you need 
   to do is change the above to:

    Kernel merlin = (Kernel) factory.create(criteria);

   You can then go about the business of accessing components via the
kernel. 
   But that's for a different email.

3. The repository does all the magic.  Specifically, the repository gets all

    the info to launch the merlin kernel from a META file:

http://www.ibiblio.org/maven/merlin/jars/merlin-impl-3.3-SNAPSHOT.jar.meta

    This file accurately shows you what dependencies are required  (three
    classloaders and 22 jars).  It also reveals the next trick.


4. org.apache.avalon.merlin.impl.DefaultFactory does all the work.  
   If you want to *really* see how Merlin starts up, look at this class.


Now, I like the repository idea.  In fact, it's the primary reason I decided
to use Merlin in one of my latest apps.  However, there are other times when
I don't really want to use a repository.  In fact, sometimes I want to be
able to deliver a single large jar file that includes everything I need.

With that in mind, I decided to look at how I could start up Merlin
_without_ using the repository.  So I started with the DefaultKernel class
and started tracing back all the dependencies I would need.  I only
considered constructor dependencies, just the bare minimum I would need to
full fill the requirements of the DefaultKernel.

Result?  30+ classes required.  And you still need a Repository class.  A
simple list of the dependencies has been attached for those who are
interested.

I had done something similar with Merlin but that was before the whole
Repository package.  After reviewing it now I see that there isn't any easy
way to start up Merlin without a repository and without a bit of meta-info.
That's not necessarily a bad thing -- ECM and Fortress generally require
external configuration files and a few helper/factory classes.

So in the end, I'm not necessarily encouraged or discouraged.  I've been
thinking about a number of ways we could make Merlin simpler and give users
more options on how to start Merlin and load/deploy their components.  My
goal is to decrease the learning curve of Avalon so that a new user could
get the basics down within an hour.  That involves not only better
documentation but also a very simple way to work with the container.

Thoughts?

J. Aaron Farr
  SONY ELECTRONICS
  DDP-CIM
  (724) 696-7653


Kernel
  KernelContext
    Logger
    ContainmentModel
      ContaintmentContext
       Logger
       SystemContext
       ClassloaderModel
       ContainmentProfile

SystemContext
  LoggerManager
    LoggingDescriptor
      CategoryDirective
      TargetDescriptor
        FileTargetProvider
  Repository
    CacheManager
      ProxyContext
        
ClassLoaderModel
  ClassLoaderContext
    Logger
    Repository  (another)
    ClassLoaderDirective
        LibraryDirective
        ClasspathDirective
           FilesetDirective
           RepositoryDirective
             ResourceDirective

ContainmentPrifile
  ClassloaderDirective (another)
  ServiceDirective
    ServiceDescriptor
       ReferenceDescriptor
  CategoriesDirective
  Profile  (which one???)
    BlockCompositionProfile
      or
    DeploymentProfile
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to