Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Re-injection of a Java collection
Re-injection of a Java collection [message #1695648] Mon, 18 May 2015 11:41 Go to next message
Piero Campalani is currently offline Piero CampalaniFriend
Messages: 114
Registered: January 2015
Senior Member

Dear experts,

I have a registry (a Java Collection) of objects which I'd like to inject to a GUI method in order to synchronize the graphical representation of this registry.

package foo.model
public class MyRegistry extends ArrayList<MyRecord> {}

package foo.ui
public class RegistryView {
    @PostConstruct postConstruct(Composite parent) { ... }

    @Inject
    public void updateRegsitry(MyRegistry registry) {
        // update the GUI
       ...
    }
}


Currently, I have a component in OSGI-INF/ that declares the context function to provide and persist the registry in the application context.

My method is called and everything is OK, but it seems here that re-injection does not happen when I add new elements nor when the content/status of an existing element changes.

Can you confirm that this is the expected behaviour?
Where could I find detailed information about Eclipse DI re-injection?

Would you suggest a different IoC design here?

Thanks as always for any suggestion.
-Piero
Re: Re-injection of a Java collection [message #1695682 is a reply to message #1695648] Mon, 18 May 2015 13:00 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
So, you expect the DI engine to be able to know when to re-inject "when you add new elements or when the content/status of an existing element changes"?

You should be using databinding to bind your model elements to the UI components (tree/table/...), that is not the responsibility of the DI engine.

BTW, have a look at this:
http://en.wikipedia.org/wiki/Composition_over_inheritance

Piero Campalani wrote on Mon, 18 May 2015 13:41
Dear experts,
My method is called and everything is OK, but it seems here that re-injection does not happen when I add new elements nor when the content/status of an existing element changes.

Re: Re-injection of a Java collection [message #1695691 is a reply to message #1695648] Mon, 18 May 2015 13:27 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
On 18.05.15 13:41, Piero Campalani wrote:
> Dear experts,
>
> I have a registry (a Java Collection) of objects which I'd like to
> inject to a GUI method in order to synchronize the graphical
> representation of this registry.
>
>
> package foo.model
> public class MyRegistry extends ArrayList<MyRecord> {}
>
> package foo.ui
> public class RegistryView {
> @PostConstruct postConstruct(Composite parent) { ... }
>
> @Inject
> public void updateRegsitry(MyRegistry registry) {
> // update the GUI
> ...
> }
> }
>
>
> Currently, I have a component in OSGI-INF/ that declares the context
> function to provide and persist the registry in the application context.
>
> My method is called and everything is OK, but it seems here that
> re-injection does not happen when I add new elements nor when the
> content/status of an existing element changes.
>

Yes we are not tracking the content of objects no matter if it is a
collection, ... .

You better inject an Observable-Collection another but IHMO no really
suitable approach is to invent your own annotation like efxclipse did it
for OSGi-Services
(https://wiki.eclipse.org/Efxclipse/Runtime/Recipes#Injection_of_OSGi-Services)

Tom
Re: Re-injection of a Java collection [message #1695699 is a reply to message #1695682] Mon, 18 May 2015 13:37 Go to previous messageGo to next message
Piero Campalani is currently offline Piero CampalaniFriend
Messages: 114
Registered: January 2015
Senior Member

Dear Erdal,
thanks for little arrogant, partial but still very useful response. Smile
I misunderstood DI re-injection then, but it's fine.

I found out about the official Vogella's note now:
http://www.vogella.com/tutorials/EclipseRCP/article.html#dependencyinjection_reinject
Re: Re-injection of a Java collection [message #1695700 is a reply to message #1695691] Mon, 18 May 2015 13:38 Go to previous messageGo to next message
Piero Campalani is currently offline Piero CampalaniFriend
Messages: 114
Registered: January 2015
Senior Member

Thank you Tom,
that's cool actually, I might give it a try. !
Re: Re-injection of a Java collection [message #1695705 is a reply to message #1695699] Mon, 18 May 2015 13:47 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Oh, what makes you think my response was arrogant?

Piero Campalani wrote on Mon, 18 May 2015 15:37
Dear Erdal,
thanks for little arrogant, partial but still very useful response. Smile
I misunderstood DI re-injection then, but it's fine.

I found out about the official Vogella's note now:
http://www.vogella.com/tutorials/EclipseRCP/article.html#dependencyinjection_reinject

Re: Re-injection of a Java collection [message #1695831 is a reply to message #1695705] Tue, 19 May 2015 15:27 Go to previous message
Piero Campalani is currently offline Piero CampalaniFriend
Messages: 114
Registered: January 2015
Senior Member

Nevermind U_U
Previous Topic:Share Objects with MApplication.getContext()
Next Topic:Access objects from multiple parts of an Eclipse RCP Application
Goto Forum:
  


Current Time: Tue Mar 19 03:45:40 GMT 2024

Powered by FUDForum. Page generated in 0.02638 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top