Skip to main content



      Home
Home » Eclipse Projects » Eclipse 4 » Manually triggering a class with injections?(How to manually trigger a classes method, which uses injections.)
Manually triggering a class with injections? [message #955072] Tue, 23 October 2012 09:38 Go to next message
Eclipse UserFriend
I have a class, which get a MApplication injected. It is a Handler. I want to trigger the Handler's methods manually.

Problem:
When I instantiate the Handler manually from another class - the MApplication is null. The class which I trigger the Handler from allready has an MApplication injected, so it is not a lifecycle problem.

Question:
How can I trigger a method in a class, which has @Inject annotated methods?


Re: Manually triggering a class with injections? [message #955081 is a reply to message #955072] Tue, 23 October 2012 09:45 Go to previous messageGo to next message
Eclipse UserFriend
Have a look at org.eclipse.e4.core.contexts.ContextInjectionFactory
Re: Manually triggering a class with injections? [message #955109 is a reply to message #955081] Tue, 23 October 2012 10:18 Go to previous messageGo to next message
Eclipse UserFriend
Thnx, the following Injected everything from the current iEclipseContext into the new Object.

		ManipulateModelhandler man = new ManipulateModelhandler();
		
		//inject the context into an object
		//IEclipseContext iEclipseContext was injected into this class
		ContextInjectionFactory.inject(man,iEclipseContext);
		
		man.execute();

Re: Manually triggering a class with injections? [message #955571 is a reply to message #955109] Tue, 23 October 2012 18:30 Go to previous messageGo to next message
Eclipse UserFriend
I think you should invoke ContextInjectFactory.invoke method with @Execute as parameter
Re: Manually triggering a class with injections? [message #960843 is a reply to message #955072] Sat, 27 October 2012 17:28 Go to previous message
Eclipse UserFriend
Even though I'm not aware of what you are trying to achieve, creating handlers manually and calling @inject methods with CIF does not sound the right approach except in some really advanced cases IMHO.

Anyway, getting to your question the CIF.invoke will invoke annotated methods for you.
Previous Topic:Tootip for a TreeViewer
Next Topic:Does e4 support opening a view in a dialog shell?!
Goto Forum:
  


Current Time: Sat Jul 12 18:42:51 EDT 2025

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

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

Back to the top