Re: Classpath error when embedding merlin into a commandline application

Niclas Hedhman <[email protected]>
Newsgroups gmane.comp.jakarta.avalon.user
Organization Private
Message-ID <[email protected]>
On Friday 10 September 2004 18:07, Stephen McConnell wrote:
> > -----Original Message-----
> > From: Rajamani Saravanan [mailto:[email protected]]
> > It will be really simple if I can do this without embedding Merlin
> > into my application and instead asking it to simply launch all blocks
> > found in a folder - BUT AFTER login is through...
>
> No problem - to do this what you want is a "facility".  Instead of
> embedding Merlin (and worrying about all of that stuff) just create a
> component that request the containing component model via context. For
> example - you facility would be the only component within the initial
> block but with a reference to the enclosing containment model you can
> dynamically populate your container with anything you want based on
> whatever logic you want.

> With a reference to the containment model - you're in business.
Except he might not know what the business is...

What Steve is trying to say; :o)

1.  Get the reference to the <container> where the "start" component is 
located by,
/** @avalon.entry key="urn:composition:containment.model"
 *    type="org.apache.avalon.composition.model.ContainmentModel"
 */
public void contextualize( Context ctx )
{
    m_Model = (ContainmentModel) 
        ctx.get( "urn:composition:containment.model" );
}
Technically (probably considered bad practice) you can also retrieve any 
container within the application, by getModel(), for instance getModel( "/" 
), returns the root container (although it might be the root application 
container in the future).

2. Any point later in time, you can "load" another container/block dynamically 
by doing;
   m_Model.addContainmentModel( blockUrl );
or
   m_Model.addContainmentModel( blockUrl, configUrl );
This will behave as if those blocks were "launched" at Merlin startup.

3. And you can equally do the opposite, remove the block later.


Cheers
Niclas
-- 
   +------//-------------------+
  / http://www.bali.ac        /
 / http://niclas.hedhman.org / 
+------//-------------------+
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.