Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to invoke a bean method in Apache Blueprint?

I have the following java classes

public class SecondClass
{
    //...
}

public class MyClass
{
    public void doSomething(SecondClass secondClass)
    {
        //...
    }
}

In blueprint I have something like the following

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">

    <bean id="secondClass" class="foo.bar.SecondClass" />

    <bean id="myClass" class="foo.bar.MyClass" />

    <!-- How do I invoke myClass.doSomething(secondClass) ??? -->

</blueprint>

Someone knows how to call myClass.doSomething(secondClass) from inside Blueprint?

like image 874
slux83 Avatar asked Jan 30 '26 01:01

slux83


1 Answers

If I understand correctly (not being very familiar with the MethodInvokingFactoryBean myself) what you need is a factory method, ie. something like the following:

   <bean id="myClass" class="foo.bar.MyClass" 
         factory-method="doSomething">   
       <argument ref="secondClass"/>    
   </bean>

You can find more details on how to use factories with blueprint in this guide (one of the most useful blueprint resources IMO)

like image 82
Christina Avatar answered Feb 01 '26 13:02

Christina



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!