如何在Spring Context中加载Beans属性

时间:2014-11-05 14:19:58

标签: spring

我想在Spring应用程序上下文中基于我收到的对象更新bean的属性.Below是我的代码片段。

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> />

     

用户详细信息是我在接收器类中作为输入接收的bean,我希望这些值在bean“getReportParameterWithDetailsBean”中可用。

getReportParameterWithDetailsBean有各自的setter和getter,它是一个生成的Stub,因此太大了。

以下是Reciever类的代码,该类具有“UserDetails”作为其属性。     public class PublicReportServiceClientReciever {     public PublicReportServiceClientReciever(){

}

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();
}

接收器类'runARG是从外部组件调用的,它为我提供了UserDetails对象,我需要在上面显示的xml代码段中设置它。 请帮助我实现这一点。谢谢你提前

0 个答案:

没有答案