开发者

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.


  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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜