velapanur
velapanur

Reputation: 335

Multiple Implementations passed in a list

I am New to Spring.I have this question which has been bothering me for a while now. Any help would be appreciated.

There is an Interface which calls a getter method.

interface MessageHandler{

    public List GetMessageCheckerList();

}

There is another Interface called MessageChecker which has multiple Implementations. Say MessageChecker1, TestChecker, etc. (lets assume 2 for now )

Now how do i define this in the configuration xml file.

I actually have the bean created ,

here is the rest of the code

<bean id="checkerList" class="java.util.ArrayList">
    <constructor-arg>
        <list>
            <ref bean="HL7Checker"/>
        </list>
    </constructor-arg>
</bean>


<bean id="HL7Checker" class="com.kahootz.messagereceiver.HL7CheckerImpl">
    <property name="messageExecutor" ref="Executor"/>
</bean>

Please Advice

When I actually run the program using a main method, I get the handle of one of the beans, The HL7Checker should be passed in a list to the Bean with ID=messageHandler. But when i print out the list. It is empty.

Without using spring and only using getter and setter methods , i am able "set" a list and retrieve it using Get.

Upvotes: 0

Views: 153

Answers (1)

Roland Illig
Roland Illig

Reputation: 41686

  1. Almost all of your names do not conform to the Java Naming Conventions. That makes it hard for others to understand your code.
  2. The <ref> tag expects the name of an object, not the name of a class. So you need to define a <bean id="testChecker" class="com.test.TestChecker" /> before you can reference it.
  3. Don't use the package name com.Test. First, it should contain only lowercase letters. Second, you should be the owner of that name.

Upvotes: 2

Related Questions