calling an arbitrary method via Spring ?

Marvin S. Addison marvin.addison at gmail.com
Wed May 1 11:41:48 EDT 2013


> It seems that the BeanPostProcessor is not being called when using
> jetty-spring. I looked at the jetty-spring code briefly, and I am not
> surprised

Actually, I'm fairly surprised. The context lifecycle hooks are a fairly 
important feature of Spring and not calling them as in a normal context 
environment seems odd.

Here's another approach I know will work: create a factory bean that 
takes the lifecycle listeners as a parameter and returns a configured 
server that sets the listeners internally before returning the instance. 
Here's the spring wiring for that as a sketch:

<!-- the factory bean, which contains a method called createInstance() -->
<bean id="serverFactory" class="ServerFactory">
   <property name="lifeCycleListeners">
     <list>
       <bean 
class="org.eclipse.jetty.util.component.FileNoticeLifeCycleListener">
         <constructor-arg value="${jetty.state#./jetty.state}" />
       </bean>
     </list>
   </property>
</bean>

<!-- the bean to be created via the factory bean -->
<bean id="jetty"
       factory-bean="serverFactory"
       factory-method="createInstance"/>

> it makes me not sure that configuring jetty via spring
> is a good idea.

You can probably find workarounds for any deficiencies, but at some 
point it may look like a hack.

M


More information about the dev mailing list