On Thursday 21 October 2004 05:36, Harvinder Singh wrote: > Question : Does this mean then that "MyComponent" will get resolved only if > it has the same class name as the xinfo file name. > Infact I tried with a sample component having the classname different from > the xinfo file name, and it did not get reolved and gave me an error. Issue > here is what suppose if I want to use the same implementation for two > different components.( my components have very similar functionality and > thus I wud like to use the same implementation passing a flag each time > which component to use.) > I will define both the components in block.xml having the same class names > and also an attribute 'type' which would suggest which one to use. > But the way merlin is behaving, it will need 2 different classes and two > different xinfos. > Will something like this work in Merlin : > > MyComponent1.xinfo and MyComponent.class - resolves 1st component > MyComponent2.xinfo and MyComponent.class - resolves 2nd component
The .xinfo file defines the Type of the component. It does not define/declare an instance of the component. > If not then please let me know how to achieve that? MyComponent.class and MyComponent.xinfo belong together. Unless MyComponent is from a 3rdParty source, I strongly urge you to let Magic produce the .xinfo file automatically. In your block, you declare the component's usage, and for singleton lifestyle that directly translates to a component instance. (Please note, that under the Avalon concepts, more than one singleton instance of the same class can exist.) <block name="MyBlock" > <classloader> : </classloader> <component name="somename" class="com.me.MyComponent" /> <component name="anothername" class="com.me.MyComponent" /> </block> If you have other components that are depending on those and it is important which instance (for instance different config) is used, you need manual dependency resolution; http://avalon.apache.org/central/about/tutorials/basic/dependencies/manual.html (Also, I urge you to let Magic produce the block file, so that the classloader is properly established.) I hope this is enough for you to proceed. Cheers Niclas -- +------//-------------------+ / http://www.bali.ac / / http://niclas.hedhman.org / +------//-------------------+ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]