Stephen, I appreciate that. I'm sure others would too. Thanks Sonu Vijay
--- Stephen McConnell <[EMAIL PROTECTED]> wrote: > > This is a little introduction to embedding Merlin. > The descriptions > starts off with an overview of the Avalon Repository > bootstrapping > system - which at the end of the day is the core > embedding technology > used within the merlin platform. > > Simple Embedding Example: > ------------------------- > > 1. creating an initial context > > File cache = new File( "my-cache" ); > InitialContext context = new > DefaultInitialContext( cache ); > > The above code defines a cache directory for the > repository > system to use when loading resources needed in > your embedded > application - and provides the directory as an > argument when > creating a new InitialContext object. The > InitialContext is > you hook into the repository system and the > embedding machinery. > > 2. declare what you want to embed > > String spec = > > "artifact:avalon-logging/avalon-logkit?version=1.0-SNAPSHOT" > Artifact artifact = > Artifact.createArtifact( spec ); > > An artifact is a logical reference to a jar file > (or other type > of resource) that the repository can access. The > avalon-repository > system uses artifact references as the key to > locating meta data > about embedded classloaders. The classloader > meta data is > maintained as a properties file with the .meta > extension. For > example the above artifact meta address > translates to: > > > [host]/avalon-logging/jars/avalon-logkit-impl-1.0-SNAPSHOT.jar.meta > > The content of the meta file is automatically > generated using the > avalon-plugin avalon:artifact goal. Two real > examples are attached > (the logkit factory and the merlin factory > meta). > > The contents of the meta file includes: > > * a ordered list of jar files that are > required to > construct a classloader for the embedded > application > > * the name of a factory class to be used as > the embedded > instance creator > > 3. create the factory > > Using the initial context and the artifact you > now have everything > you need to create you embedded instance. > > Builder builder = m_context.newBuilder( > artifact ); > Factory factory = builder.getFactory(); > > Behind the scenes the avalon-repository system > has gone off, pulled > down the meta data, downloaded and cached all of > the classloader > entries, constructed a new classloader, and > instantiated the > factory. > > 4. parameterizing the factory > > The factory object is the central entry point of > the embedded > application - it is responsible for > instantiation of the > embedded instance based on a supplied criteria. > The initial > criteria (the defaults) are established by the > factory in > response to the following operation: > > Map criteria = > factory.createDefaultCriteria(); > > Based on the documentation about the facility > your embedding > you can update the criteria using application > specific keys. All > of the Merlin related criteria instances use the > avalon-util > Criteria as the map implementation. This > provides support for > key and type validation under the put operations > and type > coercion on get operations. > > For example: > > String key = "avalon.logging.configuration"; > File file = new File( "logging.xml" ); > criteria.put( key, file ); > > Parameterization of the criteria is typically > different for > each embedding scenario. A CLI handler will for > example adapt > to the command line operations and set criteria > values accordingly. > A we application may set the criteria based on > parameters declared > in a web.xml file. Typically the embedding > class acts as the > adapter between the embedded context and the > factory. > > 4. embedded instance creation > > Creation of the embedded instance is now a > simple one line > operation: > > Object object = factory.create( criteria ); > > The object that is created is the embedded > application. In this > example its a logging manager that uses the > logkit implementation. > However, it could have been the Merlin kernel. > The only difference > between the Merlin scenario and the logging > manager scenario is > the initial artifact and the actions taken to > parameterize the > criteria. > > Examples of Embedding > --------------------- > > merlin/logging/logkit > > Package contains an example of a logging > manager > that is established as part of merlin > establishment. > Key classes include the DefaultLoggingCriteria > and > DefaultLoggingFactory - the test package > demonstrates the > complete deployment of the logging manager with > nothing more > than avalon-repository-main in the project.xml > dependencies. > > Usage of this factory can be seen in the > merlin/kernel/impl > package - DefaultFactory class under the > createLoggingManager > operation. > > merlin/kernel/impl > > The kernel/impl package defines the factory > that is used to > create a new Merlin Kernel. Examples of > embeddors that > use this factory include: > > * merlin/kernel/cli - Main class > * merlin/kernel/plugin - MerlinBean > * merlin/kernel/servlet - MerlinServlet > * merlin/kernel/unit - AbstractMerlinTestCase > > Please note that there are some small differences > between the 3.2 and > 3.3 versions of the APIs. The above description of > based on 3.3 (CVS HEAD). > > Cheers, Stephen. > > -- > > === message truncated ===> > # > # Meta classifier. > # > > meta.domain = avalon > meta.version = 1.0 > > # > # Artifact descriptor. > # > > avalon.artifact.group = avalon-logging > avalon.artifact.name = avalon-logkit-impl > avalon.artifact.version = 1.0-SNAPSHOT > avalon.artifact.signature = 20040125.130218 > > > # > # Implementation dependencies. > # > > avalon.artifact.dependency.0 = > avalon-repository:avalon-repository-main;1.3-SNAPSHOT > avalon.artifact.dependency.1 = > avalon-logging:avalon-logging-api;1.0-SNAPSHOT > avalon.artifact.dependency.2 = > avalon-logging:avalon-logkit-api;1.0-SNAPSHOT > avalon.artifact.dependency.3 = > avalon-framework:avalon-framework-api;4.1.5 > avalon.artifact.dependency.4 = > avalon-framework:avalon-framework-impl;4.1.5 > avalon.artifact.dependency.5 = > excalibur-i18n:excalibur-i18n;1.1 > avalon.artifact.dependency.6 = > excalibur-configuration:excalibur-configuration;1.1 > avalon.artifact.dependency.7 = logkit:logkit;1.2.2 > avalon.artifact.dependency.8 = > xml-apis:xml-apis;2.0.2 > avalon.artifact.dependency.9 = > xml-apis:xmlParserAPIs;2.0.2 > avalon.artifact.dependency.10 = xerces:xerces;2.4.0 > > # > # Factory. > # > > avalon.artifact.factory = > org.apache.avalon.logging.logkit.DefaultLoggingFactory > > # > # EOF > # > > > # > # Meta classifier. > # > > meta.domain = avalon > meta.version = 1.0 > > # > # Artifact descriptor. > # > > avalon.artifact.group = merlin > avalon.artifact.name = merlin-impl > avalon.artifact.version = 3.3-SNAPSHOT > avalon.artifact.signature = 20040125.130421 > > # > # API dependencies. > # > > avalon.artifact.dependency.api.0 = > avalon-extension:avalon-extension-spi;1.1 > avalon.artifact.dependency.api.1 = > avalon-framework:avalon-framework-api;4.1.5 > avalon.artifact.dependency.api.2 = > excalibur-lifecycle:excalibur-lifecycle-api;1.0 > avalon.artifact.dependency.api.3 = > xml-apis:xml-apis;2.0.2 > avalon.artifact.dependency.api.4 = > xml-apis:xmlParserAPIs;2.0.2 > > # > # SPI dependencies. > # > > avalon.artifact.dependency.spi.0 = > merlin:merlin-api;3.3-SNAPSHOT > avalon.artifact.dependency.spi.1 = > avalon-activation:avalon-activation-api;2.0-SNAPSHOT > avalon.artifact.dependency.spi.2 = > avalon-activation:avalon-activation-spi;2.0-SNAPSHOT > avalon.artifact.dependency.spi.3 = > avalon-repository:avalon-repository-api;1.3-SNAPSHOT > avalon.artifact.dependency.spi.4 = > avalon-repository:avalon-repository-spi;1.3-SNAPSHOT > avalon.artifact.dependency.spi.5 = > avalon-logging:avalon-logging-api;1.0-SNAPSHOT > avalon.artifact.dependency.spi.6 = > avalon-composition:avalon-composition-api;2.0-SNAPSHOT > avalon.artifact.dependency.spi.7 = > avalon-composition:avalon-composition-spi;2.0-SNAPSHOT > avalon.artifact.dependency.spi.8 = > avalon-meta:avalon-meta-api;1.3 > avalon.artifact.dependency.spi.9 = > avalon-meta:avalon-meta-spi;1.3 > > # > # Implementation dependencies. > # > > avalon.artifact.dependency.0 = > avalon-activation:avalon-activation-impl;2.0-SNAPSHOT > avalon.artifact.dependency.1 = > avalon-composition:avalon-composition-impl;2.0-SNAPSHOT > avalon.artifact.dependency.2 = > avalon-meta:avalon-meta-impl;1.3.1 > avalon.artifact.dependency.3 = > avalon-extension:avalon-extension-impl;1.1 > avalon.artifact.dependency.4 = > avalon-framework:avalon-framework-impl;4.1.5 > avalon.artifact.dependency.5 = > avalon-util:avalon-util-defaults;1.2-SNAPSHOT > avalon.artifact.dependency.6 = > avalon-util:avalon-util-env;1.1-SNAPSHOT > avalon.artifact.dependency.7 = > avalon-util:avalon-util-exception;1.0 > avalon.artifact.dependency.8 = > avalon-util:avalon-util-criteria;1.1-SNAPSHOT > avalon.artifact.dependency.9 = > excalibur-i18n:excalibur-i18n;1.1 > avalon.artifact.dependency.10 = > excalibur-configuration:excalibur-configuration;1.1 > avalon.artifact.dependency.11 = xerces:xerces;2.4.0 > > # > # Factory. > # > > avalon.artifact.factory = > org.apache.avalon.merlin.impl.DefaultFactory > > # > # EOF > # > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]