Showing posts with label spring. Show all posts
Showing posts with label spring. Show all posts

Thursday, 22 April 2010

spring with a list in the constructor

How to pass a list into a Spring bean constructor
SnapshotTheWorld class expects a List as its only constructor parameter

Sample:

<bean id="snaptheWorld" class="mypackage.SnapshotTheWorld">

<constructor-arg>

   <list>

    <ref bean="myBean" />

    <ref bean="myOtherBean" />

  </list>

</constructor-arg>

</bean>

Wednesday, 21 April 2010

Using Spring with a static method

Here an instance of MyClass has the result of the static method 'getPlatformMBeanServer()' passed in to it's constructor.

Sample code:


<bean id="registry" class="com.mypackage.MyClass">

  <constructor-arg>

    <bean factory-method="getPlatformMBeanServer" class="java.lang.management.ManagementFactory" />

  </constructor-arg>

</bean>

Monday, 1 February 2010

Using spring to launch jetty

Spring can launch a webserver:
http://roopindersingh.com/2008/12/10/spring-and-jetty-integration/

edit this line and point at your own servlet:
<bean class="org.mortbay.jetty.servlet.DefaultServlet"/>