E4 Injection/Event System [message #1692371] |
Wed, 15 April 2015 07:31  |
Eclipse User |
|
|
|
Hi,
short description: I need to keep three objects in sync.
So, whenever A changes I need to first update B and then update C.
All objects are in the eclipse context.
I came up with the following way, but am unsure if it is unsafe or bad style.
Let's say, we start by injecting object A into the eclipse context:
In order to get object B in sync, I was thinking about implementing the following code to a manager class which is always present in the context:
@Inject
@Optional
public void doProcessing(A a) {
B b = new B(a));
context.set(B.class, b);
}
Within class C which is created at program startup, I would do the following:
@Inject
@Optional
private A a;
@Inject
@Optional
public void doProcessing(B b) {
//do something with a and b!
}
What do you think about this? Would you rather use the event system?
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.13844 seconds