Home » Eclipse Projects » Eclipse 4 » Hook in, after the MApplication context is filled by Services?
| | | | | | |
Re: Hook in, after the MApplication context is filled by Services? [message #989033 is a reply to message #989020] |
Tue, 04 December 2012 11:12 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Am 04.12.12 11:44, schrieb Alex Kipling:
> Thnx Dirk. I am fighting an additional problem, which I initiall was not
> aware of:
>
> The Context, which I get inside the LifeCycleManager is different, from
> the context, which I to get inside my Model-Parts.
>
Yes that is expected. Contexts are hiearchical, we create a context for
each element in the model which inherits from MContext (e.g.
MApplication,MWindow,MPerspective,MPart)
Tom
|
|
| | | | | | | |
Re: Hook in, after the MApplication context is filled by Services? [message #989260 is a reply to message #989105] |
Wed, 05 December 2012 11:47 |
Alex Kipling Messages: 260 Registered: July 2012 |
Senior Member |
|
|
What I did was:
Instantiating a creatable Class X Inside a Handler. The instantiateion was triggered inside a @PostConstruct method.
Handler{
..
@PostConstruct
OnPostConstruct(X myClassXObject){
}
@Creatable
X{
@Inject
EHandlerService handlerService;
@Inject
ECommandService commandService;
@Inject
MApplication app;
}
As seen the Class X required a pointer to the services, and the MApplication.
First I had to move the instantiation of X to a later time, by using IEventBroker.
Then I found out, that annotation the Handlers by @Optional makes the construct work.
The Handlers are not available at creation time of X,
but when X's methods are used - the Services are allready there.
Question:
Can seomone explain me, why the Injected Objects are empty on constuction, but non empty on method execution?
Does the System monitor @Optional Objects, where Injection failed and injects them later, as soon as a fitting Object becomes available?
Handler{
..
@PostConstruct
OnPostConstruct(X myClassXObject){
}
@Creatable
X{
@Optional
@Inject
EHandlerService handlerService;
@Optional
@Inject
ECommandService commandService;
@Optional
@Inject
MApplication app;
}
|
|
|
Re: Hook in, after the MApplication context is filled by Services? [message #989270 is a reply to message #989260] |
Wed, 05 December 2012 12:43 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
The question remains why are you creating this instance of X. Why can't
you do that when the handler is really executed? What does this X do
that it has to be created when the handler is created.
Even if this would work as I outlined before the context that creates
the handler is completely a different one than the context in which the
handler is executed (=context of the currently active MPart).
There is no guarantee that the EHandlerService and ECommandService are
not bound to the invoking context and only work there appropriately
(e.g. there are handlers available on different levels and it depends on
the current active area which one take precendence).
Tom
Am 05.12.12 12:47, schrieb Alex Kipling:
> What I did was:
> Instantiating a creatable Class X Inside a Handler. The instantiateion
> was triggered inside a @PostConstruct method.
>
> Handler{
> .
> @PostConstruct
> OnPostConstruct(X myClassXObject){
>
> }
>
> @Creatable
> X{
> @Inject
> EHandlerService handlerService;
>
> @Inject
> ECommandService commandService;
>
> @Inject
> MApplication app;
> }
>
>
> As seen the Class X required a pointer to the services, and the
> MApplication. First I had to move the instantiation of X to a later
> time, by using IEventBroker.
>
> Then I found out, that annotation the Handlers by @Optional makes the
> construct work.
> The Handlers are not available at creation time of X, but when X's
> methods are used - the Services are allready there.
>
> Question:
> Can seomone explain me, why the Injected Objects are empty on
> constuction, but non empty on method execution?
> Does the System monitor @Optional Objects, where Injection failed and
> injects them later, as soon as a fitting Object becomes available?
>
>
> Handler{
> .
> @PostConstruct
> OnPostConstruct(X myClassXObject){
>
> }
>
> @Creatable
> X{
> @Optional
> @Inject
> EHandlerService handlerService;
>
> @Optional
> @Inject
> ECommandService commandService;
>
> @Optional
> @Inject
> MApplication app;
> }
>
|
|
| | |
Goto Forum:
Current Time: Fri Sep 27 01:36:27 GMT 2024
Powered by FUDForum. Page generated in 0.06073 seconds
|