I have loaded "myspring.xml" in web.xml using context-param
in "myspring.xml" I have written bean to which I have passed arguments as constructor argument
<bean id="abc" class="com.Hello">
<constructor-arg ref="dataSource"/>
<constructor-arg value= “dummy data”/>
</bean>
in Hello bean I have initialized constructor as ,
public class Hello{
public Hello(datasource,dummydata){
}
public void methodFromHelloBean(){
// use here dummydata from constructor
}
}
Here , 'Hello' bean is getting initialized at server startup, as I defined in web.xml and it is working fine.
My question is -
I am working on exisitng applciation. I want to call methodFromHelloBean() inside my another class say MyService class. How I can call the method in MyService class.
One way i know is using applicationContext. But in my existing application I have not seen any bean loaded using application-context path.
what is other way , how I can initialize 'Hello' bean from 'MyService' class. Do I need to pass parameters to constructors while initializing & how.
Thanks in advance.