Vikas Phonsa wrote:

Guys,
Pls tell me what's going on here. When you run the merlin tutorial examples
using the Merlin CLI for the first time lots of jars are downloaded to the
local repository from dpml ( or whatever ) and ibiblio.

What is there in the CLI code that is doing that. What step does that.

There are two steps which trigger jar downloading. The first step concerns the creation of an InitialContext. The InitialContext is supplied with a directory pointing to the merlin system repository (this is the merlin/system directory). The initial context implementation uses this to load up a repository implementation. If you look inside the merlin-cli jar file you will find a properties file called avalon.properties. This contains the following line:


  avalon.repository.implementation =
    avalon-repository:avalon-repository-impl;1.2

This is reference to artifact in merlin/system. Basically the above spec translates to avalon-repository/jars/avalon-repository-1.2.jar. Before loading in this file, the initial context will look for [filename].meta. The contents of the .meta file is a description of the structural dependencies - or more simply the jars needed to construct a classloader and the class that is a factory to loaded by the initial context to establish a repository management system.

Here is the content of the .meta file:

http://www.dpml.net/avalon-repository/jars/avalon-repository-impl-1.2.jar.meta

The initial context builds the classloader and instantiates a repository implementation. This brings us to the next step in the merlin establishment process. In the Merlin 3.2.5 CLI sources you will see something like the following:

   Builder builder = new DefaultBuilder( context, artifact );
   ClassLoader classloader = builder.getClassLoader();
   Factory factory = builder.getFactory();
   Map criteria = factory.createDefaultCriteria();
   handleCommandLine( criteria, line );
   m_kernel = factory.create( criteria );

The artifact argument is the repository reference to the merlin implementation - e.g. artifact:merlin/merlin-impl#3.2.4. The DefaultBuilder goes through approximately the same process we used to establish the repository implementation - it looks for a .meta file - in this case is this file:

http://www.dpml.net/merlin/jars/merlin-impl-3.2.4.jar.meta

The builder constructs a classloader chain (api, spi, impl) and creates a factory using that classloader. The CLI code then gets the default factory criteria, modifies this based on command line arguments, and then finally - creates the merlin kernel.

I have seen such downloads while using maven.

But I copied the MerlinTestCase code into my IDE and loaded a component
there. Didn't use any maven, don't have any project.xml.

This ran fine but all those jars where downloaded. So what step in CLI or
TestCase is doing that.

Test case and CLI are doing the same thing - creating a builder (which triggers dependent resource loading), instantiating a factory, customizing criteria, then instantiating a new kernel using the criteria.


Hope this helps.

Cheers, Stephen.

Vikas

---------------------------------------------------------------------
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]



Reply via email to