如何在SpringContext中加载Beans属性
我想根据作为输入接收的对象更新spring应用程序上下文中bean的属性如何在SpringContext中加载Beans属性,spring,Spring,我想根据作为输入接收的对象更新spring应用程序上下文中bean的属性 There are many other beans here only required beans. <bean id="getReportParameterWithDetailsBean" class="com.oracle.xmlns.oxp.service.publicreportservice.GetReportParameters"> <property name="reportReq
There are many other beans here only required beans.
<bean id="getReportParameterWithDetailsBean" class="com.oracle.xmlns.oxp.service.publicreportservice.GetReportParameters">
<property name="reportRequest" >
<ref bean="reportRequestWithDetails"/>
</property>
<property name="userID" value = "#{userDetails.userId}" />
<property name="password" value = "#{userDetails.password}" />
</bean>
<bean id ="userDetails" class="com.oracle.xmlns.oxp.service.DataObjects.UserDetails">
<property name="userId" value = <Get the values from Reciever BEan> />
<property name="password" value = <Get the values from Reciever BEan> />
Receiver类的runARG是从外部组件调用的,该组件为我提供UserDetails对象,我需要在上面显示的xml代码段中设置它。
请帮助我实现这一点。提前感谢您是否有要更新代码的设置器?bean是与Spring连接的常规Java类。您可以使用
setter
方法设置getReportParameterWithDetailsBean
bean的值。因为它是单例bean,所以当您再次请求它时,它的值将得到反映。请提供GetReportParameters
类的源代码和加载示例应用程序上下文和数据输入。问题很清楚,但不是你们到目前为止做了什么。
}
public PublicReportServiceClientReciever(UserDetails userDetails){
this.user=userDetails;
}
private UserDetails user;
public UserDetails getUser() {
return user;
}
public void setUser(UserDetails user) {
this.user = user;
}
public void runARG(UserDetails userDetails){
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
this.user = userDetails;
//GetReportParameters will intuen be used in this bean PublicServiceReportReadWithDetails
PublicServiceReportReadWithDetails reader = new PublicServiceReportReadWithDetails();
reader.readreports();
((ClassPathXmlApplicationContext) context).close();
}