views:

40

answers:

1

Hi!

I have some Abstract Factory

public interface AbstractViewersFactory {
    IAbstractShapeViewer createRectangle(BaseOperationsListener<RectangleDTO> p);
    IAbstractShapeViewer createOval(BaseOperationsListener<OvalDTO> p);
    IAbstractShapeViewer createTriangle(BaseOperationsListener<TriangleDTO> p);
}

And Its implementation Draw2DViewersFactory. Now, I want create some class that will take responsibility for creating presenters/viewers by model and configurate it by Spring. So, I need describe in .xml configuration what method it should call. It can be something like this (pseudo config)

<bean creator>
<constructor-args>
<list>
    <bean describe-item> <constructor-args>model=Rectangle.class, method-for-viewer-create="createRectangle"</args>
    <bean describe-item> <constructor-args>model=Oval.class, method-for-viewer-create="createOval"</args>
<list>
</constructor-args>
</bean>

How I can do it?

Thanks.

+2  A: 

Hi! Even though your question is very unclear, I think I got what you wanted to know. You can define a spring bean as a factory instance and then set the factory method of this bean like this:

<bean id="myFactoryBean"
  class="AbstractViewersFactory">

  <bean id="exampleBean"
  factory-bean="myFactoryBean"
  factory-method="createRectangle"/>

Hope this helps. Google this for further information :p

greetings

chzbrgla
@chzbrgla: thanks. I think it's what i need.
Stas