I have a Spring bean which is declared like this:
<osgi:reference id="basicAuthSecurityHandler" interface="com.groupgti.handler.authentication.basic.Handler"/>
<bean id="securityHandler" factory-bean="basicAuthSecurityHandler" factory-method="getSecurityHandler"/>
My getSecurityHandler method looks like this:
public ConstraintSecurityHandler getSecurityHandler(String realm) {
ConstraintSecurityHandler handler =(ConstraintSecurityHandler) factory.getBean("securityHandler");
handler.setRealmName(realm);
return handler;
}
This securityHandler bean is in scope prototype. I need to pass the parameter into getSecurityHandler method when it it constructed with spring. Is this even possible? I can’t find any documentation about it.
The only way I got it working is this:
I had to use
MethodInvokingFactoryBean. I have tried to useconstructor-arg, but then I got the exception that there is no such constructor. UsingMethodInvokingFactoryBeaneverything works fine.