Hi Stephen, Thanks for the input but I think the question was not very clear. I have created a stand alone class and I dont want to make it as a Merlin component. but I want to access an existing Merlin component from it. How do I do that ? Or let's say how can I access a merlin component from a simple jsp file ?
Regards, Harvinder -----Original Message----- From: Stephen McConnell [mailto:[EMAIL PROTECTED] Sent: Monday, August 23, 2004 7:54 PM To: 'Avalon framework users'; [EMAIL PROTECTED] Subject: RE: Instantiating a component from a stand alone class? > -----Original Message----- > From: Harvinder Singh [mailto:[EMAIL PROTECTED] > Sent: 24 August 2004 02:15 > To: Avalon framework users > Subject: Instantiating a component from a stand alone class? > > All, > > I want to know whether one can instantiate a Merlin component from a stand > alone java class? > Whether it is possible or not? Yes - you do this by embedded merlin within your java class. > I am able to lookup one component from another by defining the > dependencies. > Since, the Service Manager class is used to lookup for components, I used > it > in my stand alone java class to lookup for the component. > But how do I get the instantiated ServiceManager now (in the stand alone > class)since it is giving me nullpointer exception. The role of the Merlin system is basically to take care of the deployment of components by combining information from the component type (typically the declaration of dependencies, declaration of capabilities, etc.) with directives that tell Merlin what to do (directives are the things declared within a block). Based on this information, Merlin takes care of the creation and supply of everything a component needs (such as the preparation of the ServiceManager, Context, etc.). > I tried implementing the Servicable interface and defining the service() > method but it does not get invoked at all. Is it that the service method > is > invoked only if the class is a component and implements Serviceable > interface? In order for a component to be recognized as such, it *must* declare itself using the @avalon.component tag. For example: /** * A sample component. * * @avalon.component * version="1.0" * name="hello" * lifestyle="singleton" */ This information (together with other tags) is used by the meta plugin to generate a XML descriptor of the component. For example - the above declaration will result in the generation of the following xml in a file named [component-class-name].xinfo. <type> <info> <name>hello</name> <version>1.0.0</version> <lifestyle>singleton</lifestyle> <collection>hard</collection> </info> </type> The class together with the xinfo file are included in a jar file. At runtime Merlin loads blocks (files containing <container> directives) and during the loading process it scans you jar file for .xinfo declarations and for each xinfo, it registers this information as an available component type. Once Merlin has completed the process of loading jar files, the assembly phase kicks-in. During assembly Merlin prepares a list of requested component deployment targets (the <component> declarations in you block), and for all of these components Merlin will attempt to resolve consumer to provider associations (i.e. wiring models of components together). Once Merlin has established a viable assembly the deployment process continues with the commissioning of all of the components. It's during the commissioning stage that Merlin actually instantiates component instances and does stuff like supplying a completely customized service manager, context, etc. If your planning on embedding Merlin is another class, basically you have the possibility to take control over the deployment process. For example, the embedding class can instruct Merlin to load different blocks - perhaps modify configurations, deploy components, undeploy, change things around, redeploy, etc. > Any help on this would be great. You will normally find some of the Avalon committers hanging out on the #merlin channel at irc.freenode.net - feel free to roll up and fire away with questions. Cheers, Steve. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]