Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Locating all classes implementing a given interface?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Bas  
View profile  
 More options Dec 2 2007, 2:57 pm
Newsgroups: comp.lang.java.programmer
From: Bas <basschu...@gmail.com>
Date: Sun, 2 Dec 2007 11:57:09 -0800 (PST)
Local: Sun, Dec 2 2007 2:57 pm
Subject: Locating all classes implementing a given interface?
Hi,

my app allows third party code as plugins for certain behaviour. The
actual implementation to use can be specified using a string that
contains the classname. This works great.

However, I'd like the user to be able to specify the class name to use
using a popup menu.

The plugin is contained in a jar that is visible in the classpath.

Is it possible for my code to find all classes implementing my plugin
interface that are available at runtime? Iterating over a directory,
locate the jars and check those is not really what I want. Is this
sort of information dynamically available from the jre?

Thanks,

bas.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Thornton  
View profile  
 More options Dec 2 2007, 3:12 pm
Newsgroups: comp.lang.java.programmer
From: Mark Thornton <mark.p.thorn...@ntl-spam-world.com>
Date: Sun, 02 Dec 2007 20:12:50 GMT
Local: Sun, Dec 2 2007 3:12 pm
Subject: Re: Locating all classes implementing a given interface?

The correct way to implement this type of feature is using
java.util.ServiceLoader (since Java 6). This has been the recommended
approach since at least Java 1.4, but ServiceLoader was added to make it
easier.

Mark Thornton


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
keke  
View profile  
 More options Dec 3 2007, 5:02 am
Newsgroups: comp.lang.java.programmer
From: keke <iamk...@gmail.com>
Date: Mon, 3 Dec 2007 02:02:07 -0800 (PST)
Local: Mon, Dec 3 2007 5:02 am
Subject: Re: Locating all classes implementing a given interface?
On Dec 3, 3:57 am, Bas <basschu...@gmail.com> wrote:
> Hi,

> my app allows third party code as plugins for certain behaviour. The
> actual implementation to use can be specified using a string that
> contains the classname. This works great.

I think there are two approaches:

1/ manually scan all classes available in your jar file
2/ specify your implementation somewhere, for example in your
manifest.mf file.

Cheers
K


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »