On Monday 25 October 2004 23:02, Harvinder Singh wrote:
> Is there any way I can read the xinfos and come up with
> a configuration object for each component.
> I am doing all this stuff since I do not want to change the component
> implmentation at all.
I suggest that you;
1. Use Metro, or
2. Use Fortress
In Metro, you will have a fairly precise access to the entire deployment
model, and the embedding bootstrapper looks something like this;
public static void main( String[] args ) throws Exception
{
//
// Create the initial context factory. This establishes
// the initial bootstrap properties, cache and repository
// access point.
//
File cache =
new File( System.getProperty( "project.cache" ) );
InitialContextFactory factory = new InitialContextFactory();
factory.setCacheDirectory( cache );
InitialContext context = factory.createInitialContext();
Repository repo = new StandardLoader( context );
//
// create the system context which provides access to a fully
// functional repository, logging system, and working context
//
Artifact transit =
Artifact.createArtifact( "dpml/transit/dpml-transit-impl#1.0.0" );
ClassLoader classloader = Main.class.getClassLoader();
Factory systemfactory =
(Factory) repo.getPlugin( classloader, transit, new Object[0] );
SystemContext system = (SystemContext) systemfactory.create();
Repository repository = system.getRepository();
//
// load metro's composition model factory and get a criteria instance
// so we can parameterize things before creating the root model
//
Artifact composition = Artifact.createArtifact(
"dpml/composition/dpml-composition-impl#1.0.0" );
ClassLoader loader = SystemContext.class.getClassLoader();
Object[] params = new Object[]{ system };
CompositionFactory compositionFactory = (CompositionFactory)
system.getRepository().getPlugin( classloader, composition, params );
//
// setup the criteria
//
CompositionCriteria criteria =
compositionFactory.createCompositionCriteria();
criteria.setAuditMode( true );
criteria.setDeploymentPath(
new String[]{ "somedir/myapp.block" } );
//
// create the root model
//
ContainmentModel model =
compositionFactory.createContainmentModel( criteria );
//
// do stuff
//
model.commission();
}
After the ContainmentModel has been created, you can traverse the entire set
of components in their blocks, and investigate their types, as well as set
the Configuration for each of them, among many things.
Check the org.apache.avalon.composition.model.ComponentModel and
org.apache.avalon.composition.model.ContainmentModel in
runtime/composition/api/src/main/ for the full API.
The reason for not using Merlin, is that Merlin is being shut down at Apache,
and the migration path is to use Metro instead (see
http://marc.theaimsgroup.com/?l=avalon-users&m=109782104930454&w=2 ),
and Metro provides full Merlin compatibility for component authors, but since
we can not keep the org.apache package names, and hence must introduce
incompatibility for embedded applications, we also took this opportunity to
make some additional, very wanted changes to the bootstrapping code, to make
it much more generic and a solution for other applications that are not
interested in the full Metro platform.
I suggest that if you decide to fly with Metro, that you bring any further
questions to the support-dpml@ mailing list.
Fortress is more similar to Excalibur Component Manager, and is less robust in
its composition, and requires more containment management from the developer,
i.e. in your case more control over what to do.
Fortress now lives in http://excalibur.apache.org and if you decide to use you
will need to bring your questions there.
Cheers
Niclas
--
+------//-------------------+
/ http://www.bali.ac /
/ http://niclas.hedhman.org /
+------//-------------------+
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]