Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Remove service registration from EventBroker when the service's context is getting disposed
Remove service registration from EventBroker when the service's context is getting disposed [message #1081641] Wed, 07 August 2013 13:49 Go to next message
Peter Ambrus is currently offline Peter AmbrusFriend
Messages: 3
Registered: August 2013
Junior Member
I have a service which contains some event handling method declared with the @UIEventTopic annotation. This service is instantiated through a context function when a part is instantiated (the user opens the part). So the service will be in the part's context.
After the instantiation the user uses the part, the service handles the events correctly, everything is fine.
When the user gets bored of the part he closes it. In this moment the part will be disposed and the context of the part will be disposed as well, so I expect that my service won't handle the events any more as it's context is already disposed. Unfortunately I experienced that the service won't be removed from the EventBroker when the context is disposed, so its handling method will be called when the appropriate event is fired. Actually as much as I could debug the only thing is happening with the service is the processing of its @PreDestroy method.

My question is whether it is a normal behavior or the service should be removed from the EventBroker when the context is disposed? In case this is the normal behavior how can I deregister my service from the EventBroker?
Re: Remove service registration from EventBroker when the service's context is getting disposed [message #1081660 is a reply to message #1081641] Wed, 07 August 2013 14:10 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
How do you construct the service instance in the context function? The
deregistration is done when the context used to create the instance is
disposed (e.g. the one from a part is disposed when it is closed).

Tom

On 07.08.13 15:54, Peter Ambrus wrote:
> I have a service which contains some event handling method declared with
> the @UIEventTopic annotation. This service is instantiated through a
> context function when a part is instantiated (the user opens the part).
> So the service will be in the part's context.
> After the instantiation the user uses the part, the service handles the
> events correctly, everything is fine.
> When the user gets bored of the part he closes it. In this moment the
> part will be disposed and the context of the part will be disposed as
> well, so I expect that my service won't handle the events any more as
> it's context is already disposed. Unfortunately I experienced that the
> service won't be removed from the EventBroker when the context is
> disposed, so its handling method will be called when the appropriate
> event is fired. Actually as much as I could debug the only thing is
> happening with the service is the processing of its @PreDestroy method.
>
> My question is whether it is a normal behavior or the service should be
> removed from the EventBroker when the context is disposed? In case this
> is the normal behavior how can I deregister my service from the
> EventBroker?
Re: Remove service registration from EventBroker when the service's context is getting disposed [message #1081663 is a reply to message #1081660] Wed, 07 August 2013 14:19 Go to previous message
Peter Ambrus is currently offline Peter AmbrusFriend
Messages: 3
Registered: August 2013
Junior Member
Hi Tom,

The context function doesn't contain any special:
public class PositionPresenterFactory extends ContextFunction {

    @Override
    public Object compute(IEclipseContext context, String contextKey) {
        return ContextInjectionFactory.make(PositionPresenterImpl.class, context);
    }
}


It is called when the @PostConstract method of the part is called as it gets a PositionPresenter object. So I assume the context in the context function is the same as in the part.
Previous Topic:application doesn't start anymore
Next Topic:Unchecking "Enable Animations" doesn't disable animations
Goto Forum:
  


Current Time: Thu Apr 18 10:43:55 GMT 2024

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

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

Back to the top