I have another problem relating to dynamic update in iPOJO:
1. Problem:
//
@Component(name="C", immediate=true)
@Instantiate
public class C_impl {
@Requires
A_Service service;
}
//
2. Requirement:
Question:
How can I develop AN INDEPENDENT COMPONENT to reconfigure (control) component implementation? I read (http://felix.apache.org/site/dive-into-the-ipojo-manipulation-depths.html) but I don’t understand well. Thanks in advance for your reply
Well, you want to change the component class of a component ? This will not really work.
The only way would be to have the two implementation available without instance declared (no @instantiate) and create a component that required both Factories (org.apache.felix.ipojo.Factory service) and create the instances when needed. Obviously, if you need replacement, you would also need to dispose the first created instance when creating the second one.
So, it would need a component like this (this is pseudo code):
@Component(immediate=true)
@Instantiate
public class Controller {
@Requires(filter="(factory.name=A)")
Factory factoryOfA;
@Requires(filter="(factory.name=B)")
Factory factoryOfB;
ComponentInstance instance;
@Validate
public void createA() throws Exception {
instance = factoryOfA.createInstance(null);
}
public void switchToB() throws Exception {
instance.dispose();
instance = factoryOfB.createInstance(null);
}
}