Leo Sutic wrote: > > > > Would work, but if that's the case, I have to implement a > > "factory", the parser itself (including the "factory" > > interface, the parser interface) etc. and I don't see the > > great advantage in using a component framework anymore as I > > code most part myself. > > > > Am I wrong? > > Carsten, > > you got it right. Those are exactly the implications of the > proposal. > > Now for the good parts: The factory can be generic. > So I code up a PooledFactory that takes your component class > as a parameter, and bam there we go. > Thanks for your quick answer, Leo! This sounds good, but... (more below)
> The only change is that you'll have to grab the factories > out of the ComponentManager in the compose() method: > > <component role="org.ziegeler.CarstensComponent" > class="Avalon4Factory" > avalon-4-class="org.ziegeler.CarstensA4Component" > pool-min="2" > pool-max="4"/> > > ... > > public class CarstensComposer { > > A4Factory carstenFactory; > > public void compose (ComponentManager manager) { > carstenFactory = (A4Factory) manager.lookup > (org.ziegeler.CarstensComponent.ROLE); > } > > public void doStuff () { > CarstensComponent comp = (CarstensComponent) > carstenFactory.getInstance (); > try { > comp.doStuff (); > } finally { > carstenFactory.release (comp); > } > } > } > > Look at the configuration snippet, and replace "class" with > "handler-class" and "avalon-4-class" with "class" and you get > the idea. > > ..or am I trying to do the impossible here? Yes, this should work, but I don't see the real advantage of it. Now, a component framework should make working with components very easy. As a client (or Composer) I personally don't want to care about ThreadSafe or not (that is in my eyes one of the big advantages of the current 4.x implementation, although there are some other problems...). Now, if I want to lookup a component, I have to know if it is ThreadSafe or not. If it is ThreadSafe I directly get the component on lookup - if not, I get a "factory" and need a second method call on this factory to get the real component. And I believe that the client a) should not care about this implementation detail and b) in some cases even might not know about it. Carsten -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>