Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Something like a Singleton with injection
Something like a Singleton with injection [message #899576] Wed, 01 August 2012 13:48 Go to next message
Tommaso De Sica is currently offline Tommaso De SicaFriend
Messages: 131
Registered: March 2012
Location: Italy
Senior Member

Goodmorning all,

I'm going to realize something like a Singleton object in Eclipse 4.
I've got a class (MyLogger) and other classes should share an istance of it.
This idea can be realized through injection? I tried to use @Singleton annotation, but I did not understand how it works.

Very thank you.
Re: Something like a Singleton with injection [message #899580 is a reply to message #899576] Wed, 01 August 2012 14:00 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Well I'm not sure about the @Singleton contract either, the easiest way
although to inject the same instance into all your POJOs is to put the
MyLogger-Instance in the IEclipseContext of the MApplication.

Tom

Am 01.08.12 15:48, schrieb Tommaso De Sica:
> Goodmorning all,
>
> I'm going to realize something like a Singleton object in Eclipse 4.
> I've got a class (MyLogger) and other classes should share an istance of
> it.
> This idea can be realized through injection? I tried to use @Singleton
> annotation, but I did not understand how it works.
>
> Very thank you.
Re: Something like a Singleton with injection [message #906353 is a reply to message #899580] Sat, 01 September 2012 07:49 Go to previous messageGo to next message
Tommaso De Sica is currently offline Tommaso De SicaFriend
Messages: 131
Registered: March 2012
Location: Italy
Senior Member

I've realized my purprose with use of
@Creatable
@Singleton
public class MyClass{...}


Thanks Thomas Smile
Re: Something like a Singleton with injection [message #910841 is a reply to message #906353] Mon, 10 September 2012 13:31 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Did that really create only one MyClass? Or will it instantiate multiple instances of it?

PW


Previous Topic:Migrate XText based RCP to Eclipse 4.2
Next Topic:org.eclipse.core.runtime.AssertionFailedException
Goto Forum:
  


Current Time: Thu Apr 25 09:40:18 GMT 2024

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

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

Back to the top