Multiple implementations of the same service interface

71 views
Skip to first unread message

Ben

unread,
Jan 6, 2012, 12:27:02 PM1/6/12
to jspf
I've been looking at your framework and need to make sure I am
understanding your concept of singleton correctly.

When you say a service is a singleton, you are stating that there can
only be one implementation of a service interface at any given time.

For example, if I have some service interface called RandomService in
one jar. Then I build another two jars, each with its own
implementation of RandomService (say RandomServiceImpl1 and
RandomServiceImpl2). I then load them into the framework by placing
them in a plugin directory that's registered with the PluginManager
and attempt to get an instance of them I will get access to only one
of them.

Is this right?

SOUMYA JAHAGIRDAR

unread,
Jan 11, 2012, 9:14:56 AM1/11/12
to jspf
I too am interested in the answer to this question. If I have multiple
implementations for an interface e.g. for an Interface called document
I may have implementations called pdfDoc,htmlDoc,odtDoc,wordDoc.
Am I restricted to loading documents of only one class?

Ralf

unread,
Jan 11, 2012, 12:32:40 PM1/11/12
to jspf

No, since that would mean that there could only be one implementation
of "Plugin". You can have as many implementations of an interface as
you like. Each implementation, however, exists only once.

A simple call to getPlugin(Interface.class) will return a random
implementation. See OptionCapabilities and PluginManagerUtil in the
API on how to acquire a specific implementation. .
Reply all
Reply to author
Forward
0 new messages