Конфигурация Spring Bean Dependency Injection xml - Как передать динамические параметры в внедренный зависимый объект во время создания - PullRequest
0 голосов
/ 27 марта 2019

Я создаю класс обслуживания, используя applicationContext.getBean ("service", userDetail).userDetail специфичен для каждого запроса.Я хочу передать этот userDetail в dao, который вводится в службу через конфигурацию spring xml

public class MyServiceImpl {
   private MyDaoImpl dao;
   private UserDetail userDetail;
......
}

public class MyDaoImpl {
    private UserDetail userDetail;
......  
}
/***Main class getting bean reference from spring****/
ApplicationContext context = new ClassPathXmlApplicationContext("spring-context.xml");
MyServiceImpl service = (MyServiceImpl)context.getBean("service", userDetail);
/**userDetail is session specific attribute****/

Вопрос - как передать userDetail, который находится в служебном бине, вДао бин, который вводится

/***spring config where i am stuck*****/
<bean id="service" class = "MyServiceImpl" scope="prototype">
    <constructor-arg name="userDetail" value = ""/>
    <property name="dao" ref="mydao"/>
/**NOT SURE HOW TO PASS userDetail from service bean into myDao bean
either through constructor or property**/
</bean>
<bean id = "mydao" class="MyDaoImpl" scope="prototype">
    <constructor-arg name="userDetail" value = ""/>
</bean>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...