I have 2 different packages, called parent and child. child has dependency on parent.
parent has a cron functionality (like initiating separate thread for property refresh using timer).
parent
package parent;
public class ParentExmaple {
// a separate thread calls updateProperty1, resides in parent.
public void updateProperty1() {
// code
}
}
child
package child;
import parent.ParentExample;
public class ChildExample {
public void updateProperty2() {
// code
}
}
Now I need to add a functionality from child to that cron in parent. This may be ridiculous. Is there any way to implement it?
like, I need to call ChildExample.updateProperty2 inside the ParentExample.updateProperty1 method.
Thanks in advance!
Is the cron functionality core to the behaviour of the parent? If so, override it in the child. If not, extract the cron functionality into an external class and use composition to provide the functionality to the parent and child, then modify it as required in the child.
Bit difficult to give a more concrete answer without a concrete example.