Hi Andreas,

I was more looking for something like this :

<bean id="myFactory" class="SomeClass" scope="prototype"/>

<bean class="TestClass"/>
            <argument ?ref?="myFactory"/>
</bean>

With TestClass as:
public final class TestClass {
            private final ?class? factory;

            public TestClass(final ?class? factory) {
                        this.factory= factory;
            }

            public void test() {
                        final SomeClass instance= factory.?method?();

                        ...
            }
}

Where ?ref? would be the way to inject the bean itself (manager) and not the 
result of the bean creation, ?class? the injected bean manager and ?method? the 
manager method to create the TestClass bean on demand.

Is there any way to do so?

Cheers,
Jean-Philippe

[@@ OPEN @@]

De : Andreas Pieber [mailto:[email protected]]
Envoyé : mercredi 12 juin 2013 07:42
À : Apache Karaf
Objet : Re: Blueprint scope and reference-list

I'm not sure if I understand your question. Yes it is
<!-- Simply call the factory manually on each invocation -->
<bean id="bindHandler" class="TestClass" >
<argument ref="myFactory"/>
</bean>
<reference-list interface="SomeInterface"/>
<reference-listener ref="bindHandler" bind-method="bind"/>
</reference-list>
I hope this helps!

Kind regards,
Andreas
On Mon, Jun 3, 2013 at 11:54 AM, CLEMENT Jean-Philippe 
<[email protected]<mailto:[email protected]>>
 wrote:
Hi Andreas,

Is there a way to inject the factory (prototype bean) itself?

Cheers,
JP

[@@ OPEN @@]

De : Andreas Pieber [mailto:[email protected]<mailto:[email protected]>]
Envoyé : samedi 1 juin 2013 10:57
À : Apache Karaf
Objet : Re: Blueprint scope and reference-list

Hey,

I'm sorry, but there isn't any blueprint only method available for this. You'll 
need to create your object manually during the bind call if you like such a 
behavior.

Kind regards,
Andreas

On Fri, May 31, 2013 at 11:11 AM, CLEMENT Jean-Philippe 
<[email protected]<mailto:[email protected]>>
 wrote:
Dear Karaf Team,

I would like to build a bean each time a reference is matched.

I tried this:
<bean id="KindOfFactory" class="TestClass" scope="prototype"/>

<reference-list interface="SomeInterface"/>
<reference-listener ref="KindOfFactory" bind-method="bind"/>
</reference-list>

But prototype instantiation seems to be linked to the reference-list itself 
rather than the listener call.

Anyway, is there a way to instantiate a bean each time a kind of service is 
mapped in Karaf using only blueprint?

Kind regards,
Jean-Philippe

[@@ OPEN @@]


Reply via email to