How to create a Spring bean from a static inner class constructor? How to create a Spring bean from a static inner class constructor? spring spring

How to create a Spring bean from a static inner class constructor?


I think the reason it is not working is because Spring is not able to understand it as a static inner class.Probably this can work:

<beans>   <bean class="java.util.concurrent.ThreadPoolExecutor$CallerRunsPolicy"/></beans>


Use the factory-method attribute:

The following bean definition specifies that the bean will be created by calling a factory-method. The definition does not specify the type (class) of the returned object, only the class containing the factory method. In this example, the createInstance() method must be a static method.

<bean id="clientService" class="examples.ClientService"  factory-method="createInstance"/>