Skip to main content



      Home
Home » Eclipse Projects » Equinox » Singletons and Extension Points
Singletons and Extension Points [message #44890] Thu, 22 July 2004 12:30 Go to next message
Eclipse UserFriend
Hello,

Is it possible to cleanly define a singleton instance of a
class that is specified in an extension point?

My question is based upon the following observations:

1. when using
IConfigurationElement.createExecutableExtension the default
(no-args) constructor is called.

2. if a class is referenced in two extension points, then
it's default constructor will be called twice, breaking the
concept of the singleton.

:-/

The best solution I can think of is to use the extension
point to get access to a non-singleton factory, which then
provides an accessor to a singleton which implements the
interface we're really interested in.

This seems a bit of an indirect, so I'm wondering if there's
a better or a standard solution.

cheers
_______________________________________________
rich rdfx.org
Re: Singletons and Extension Points [message #44989 is a reply to message #44890] Thu, 22 July 2004 16:25 Go to previous message
Eclipse UserFriend
Originally posted by: chaves.nospam.inf.ufsc.br.ok

An instance of the class specified in an extension point will be created
every time someone calls IConfigurationElement#createExecutableExtension.

Using a dummy proxy class that delegates to the singleton object is the
way to go.

Rafael

rich boakes wrote:

> Hello,

> Is it possible to cleanly define a singleton instance of a
> class that is specified in an extension point?

> My question is based upon the following observations:

> 1. when using
> IConfigurationElement.createExecutableExtension the default
> (no-args) constructor is called.

> 2. if a class is referenced in two extension points, then
> it's default constructor will be called twice, breaking the
> concept of the singleton.

> :-/

> The best solution I can think of is to use the extension
> point to get access to a non-singleton factory, which then
> provides an accessor to a singleton which implements the
> interface we're really interested in.

> This seems a bit of an indirect, so I'm wondering if there's
> a better or a standard solution.

> cheers
> _______________________________________________
> rich rdfx.org
Previous Topic:Is there an extension point for forcing a plug-in to unload last?
Next Topic:SWT/Plugin Book
Goto Forum:
  


Current Time: Mon Jul 14 09:31:24 EDT 2025

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

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

Back to the top