Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » PreDestroy not called
PreDestroy not called [message #1272155] Mon, 17 March 2014 03:49 Go to next message
Bastian Wagenfeld is currently offline Bastian Wagenfeld
Messages: 162
Registered: January 2013
Senior Member
Hi,

I've created a the following Xtend-class in my e4 application, that runs in compat mode:
@Creatable
class FileProvider {

	@Inject
	Logger logger

	@Inject
	new() {
	         // CALLED	
	}


	@PostConstruct
	def initialize() {
                // CALLED
	}

	@PreDestroy
	def cleanup() {
		// NOT CALLED
	}

}


I added it via ContextInjectionFactory.make(FileProvider.class, context);. The package javax.annotation (1.1.0) is also specified in the manifest.

Has anyone an idea what might cause this?

Best regards and thanks for any kind of help.
Bastian
Re: PreDestroy not called [message #1272298 is a reply to message #1272155] Mon, 17 March 2014 11:16 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5282
Registered: July 2009
Senior Member
did you dispose the context?

To

On 17.03.14 00:49, Bastian Wagenfeld wrote:
> Hi,
>
> I've created a the following Xtend-class in my e4 application, that runs
> in compat mode: @Creatable
> class FileProvider {
>
> @Inject
> Logger logger
>
> @Inject
> new() {
> // CALLED
> }
>
>
> @PostConstruct
> def initialize() {
> // CALLED
> }
>
> @PreDestroy
> def cleanup() {
> // NOT CALLED
> }
>
> }
>
> I added it via ContextInjectionFactory.make(FileProvider.class,
> context);. The package javax.annotation (1.1.0) is also specified in the
> manifest.
>
> Has anyone an idea what might cause this?
>
> Best regards and thanks for any kind of help.
> Bastian
>
Re: PreDestroy not called [message #1272538 is a reply to message #1272298] Tue, 18 March 2014 02:31 Go to previous messageGo to next message
Bastian Wagenfeld is currently offline Bastian Wagenfeld
Messages: 162
Registered: January 2013
Senior Member
Hi Thomas,

not that I'd know... If there isn't any other way to dispose it other than calling context.dispose(), I did not.

Best regards
Bastian
Re: PreDestroy not called [message #1272565 is a reply to message #1272538] Tue, 18 March 2014 04:10 Go to previous messageGo to next message
Jens Rabe is currently offline Jens Rabe
Messages: 53
Registered: September 2013
Member
I have a similar (the same?) problem. My PreDestroy is also not called. I annotated my class in a similar way and used the correct make() call. When calling context.dispose(), the disposal is triggered, but no PreDestroy is called.

Please shed some light in here because I want to use it "the correct way".

EDIT: Turned out that I forgot javax.annotation in the "Imported packages." It works now.

[Updated on: Tue, 18 March 2014 05:34]

Report message to a moderator

Re: PreDestroy not called [message #1272687 is a reply to message #1272565] Tue, 18 March 2014 09:57 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5282
Registered: July 2009
Senior Member
Can you show me your Bean? If you only use postconstruct and constructor
injection you might be running into
https://bugs.eclipse.org/bugs/show_bug.cgi?id=430041

Tom

On 18.03.14 01:10, Jens Rabe wrote:
> I have a similar (the same?) problem. My PreDestroy is also not called.
> I annotated my class in a similar way and used the correct make() call.
> When calling context.dispose(), the disposal is triggered, but no
> PreDestroy is called.
>
> I currently need to use a bad hack using restricted APIs where I cast my
> IEclipseContext do EclipseContext and attach an IContextDisposalListener
> via context.notifyOnDisposal().
>
> Please shed some light in here because I want to use it "the correct way".
Re: PreDestroy not called [message #1272692 is a reply to message #1272155] Tue, 18 March 2014 10:11 Go to previous message
Jens Rabe is currently offline Jens Rabe
Messages: 53
Registered: September 2013
Member
As I already stated, I forgot to include javax.annotation in the dependencies. I added this and it now works.
Previous Topic:org.eclipse.e4.ui.workbench.renderers.swt.cocoa.CocoaUIHandler
Next Topic:RCP issues (view titles, toolbar, quick access)
Goto Forum:
  


Current Time: Fri Aug 22 06:04:57 EDT 2014

Powered by FUDForum. Page generated in 0.03459 seconds