Show Table of Contents
4.26. Instantiate an ArrayList Object Using a Static Factory Method
- Follow this example to instantiate an ArrayList object using a static factory method:
<jb:bean beanId="orders" class="java.util.List" factory="some.package.ListFactory#newList" createOnElement="orders" > <!-- ... bindings --> </jb:bean>Thesome.package.ListFactory#newListfactory definition establishes that thenewListmethod must be called on thesome.package.ListFactoryclass in order to create the bean. The class attributes define the bean as a List object. The specific kind of List object that it is (be it an ArrayList or a LinkedList), is decided by the ListFactory itself. - Observe this additional example:
<jb:bean beanId="orders" class="java.util.List" factory="some.package.ListFactory#getInstance.newList" createOnElement="orders" > <!-- ... bindings --> </jb:bean>This defines that an instance of the ListFactory needs to be retrieved using the static methodgetInstanceand then thenewListmethod needs to be called on the ListFactory object to create the List object. This construct lets you use singleton factories.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.