Announcement Announcement Module
Collapse
No announcement yet.
Ambiguity Factory method in Bean definition?????? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ambiguity Factory method in Bean definition??????

    What is ambigious when you have a factory method getInstance() taking 2 kinds of arguments one being java.util.Properties and the other being javax.mail.Authenticator? i.e.

    getInstance(Properties p, Authenticator auth)
    getInstance(Properties p).

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="locations">
    <value>classpath:org/nmdp/ipr/config/pop3mail.properties</value>
    </property>
    </bean>

    <bean id="mailReader" class="org.nmdp.ipr.mail.MailReader">
    <property name="protocol" value="pop3"/>
    <property name="mailSession" ref="session"/>
    </bean>
    <!-- call factory method getInstance with Properties -->
    <bean id="session" class="javax.mail.Session" factory-method="getInstance">
    <constructor-arg ref="myprops" index="0"></constructor-arg>
    </bean>

    <bean id="myprops" class="java.util.Properties">
    <constructor-arg >
    <props>
    <prop key="somekey">value</prop>
    </props>
    </constructor-arg>
    </bean>



    </beans>

    Am I missing something pretty obvious here?
Working...
X