i need to inject with @Autowired some variables in a class. This is my situation
class A {
private B b = new B();
... toDo ..
}
class B {
// Variables that i need to inject @Autowired
private int hour;
private int minutes;
private boolean allowSystemReboot;
// setter and getter method for the 3 var
public B() {
..toDo..
}
}
And this is my xml file
<beans>
<context:annotation-config />
<bean id="rpwTask" class="package.A" >
<property name="maxDelay" value="300" />
<property name="rate" value="60" />
</bean>
<bean id="repowerjournalpagetask" class="package.B" >
<property name="hour" value="4" />
<property name="minutes" value="15" />
<property name="allowSystemReboot" value="true" />
</bean>
</beans>
But if i log the variable hour minutes and allowSystemReboot the result are 0 0 false.
So, where do i fault?
Thanks
EDIT
i modify my classes adding another class and changing the .xml
class A {
private B b = new B();
// Variables that i need to inject @Autowired
private int hour;
private int minutes;
private boolean allowSystemReboot;
// setter and getter method for the 3 var
... toDo ..
public B createB() {
B b = new B(hour, minutes, allowSystemReboot);
}
}
class B {
private int hour;
private int minutes;
private boolean allowSystemReboot;
// setter and getter method for the 3 var
public B(int h, int m boolean asr) {
hour = h;
minutes = m;
allowSystemReboot = asr;
..toDo..
}
}
this is the new xml file
<beans>
<context:annotation-config />
<bean id="rpwTask" class="package.A" >
<property name="hour" value="4" />
<property name="minutes" value="15" />
<property name="allowSystemReboot" value="true" />
<property name="maxDelay" value="300" />
<property name="rate" value="60" />
</bean>
</beans>
But continuing to get false 0 and 0. arg!!!