Neeme Praks wrote: > > I just committed an example where this would be useful: > org.apache.avalon.excalibur.i18n.test.DefaultBundleMatcherTestCase and the > corresponding .xtest file. > The issue here is that usually the lifecycle of BundleMatcher > inplementations would be managed by BundleSelector. However, in the test, I > don't want to go through BundleSelector, I want to bypass that and test only > BundleMatcher implementation, not BundleSelector.
If BundleMatcher (or implementation) is a Component, then you should be able to directly instantiate these. If you don't want to go through the Selector, then make the roles like this: BundleMatcher.ROLE + "/test1" BundleMatcher.ROLE + "/test2" etc. You can directly grab them from the the ComponentManager in the ExcaliburTestCase. > So, AFAISee, my testcase needs to manage the lifecycle and for that I need > some configuration data... > If this issue could be solved otherwise, I'm all ears. :-) If you need to manage your own lifecycle, then you shouldn't be using ExcaliburTestCase. It's not doing anything for you. Give each BundleMatcher component a unique role for your test--that will allow the ComponentManager to manage their lifecycle without having to go through a Selector layer. > On a similar note, I saw some object factory implementations in excalibur. > Are there any benefits in favor of using those instead of doing directly > classForName() in my code (as I'm doing right now in some places)? Would > they manage the lifecycle for me? The ComponentHolder class will read your Component class and give you the proper type of ComponentHolder to manage the lifecycle of your Components directly. > What will happen if I lookup a component through manager, would save it > somewhere and would look up another one. It would return the same instance, > as there is only one instance per component in manager, correct? That depends on the LifeStyle interface you implemented. If your class is ThreadSafe, the component instance is the same. If your class is Poolable, Recycleable, or SingleThreaded (the default), then chances are you will get a different instance each time you request. Please note that for Poolable and Recycleable, if you return the instance you looked up, that instance will be used again. > Willing to learn better ways of doing things, > Neeme Willing to teach better ways of doing things, Berin PS I am also willing to learn... -- "Those who would trade liberty for temporary security deserve neither" - Benjamin Franklin -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>