Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Discovering subclasses or implementations of an interface

Reply
Thread Tools

Discovering subclasses or implementations of an interface

 
 
Chris
Guest
Posts: n/a
 
      03-15-2007
We've got an app that has connectors to external systems. We allow our
customers to subclass our main Connector class to implement their own
connector. If a customer puts a Connector implementation on the
classpath, is it possible for our app to discover it automatically?

What I want to do is show the full list of all available connectors in
the user interface of our app, without forcing the customer to manually
add the connector. I'd like to avoid adding yet another configuration file.

It's possible for us to have the customer implement an interface rather
than subclass a main class, if necessary.
 
Reply With Quote
 
 
 
 
Joshua Cranmer
Guest
Posts: n/a
 
      03-15-2007
Chris wrote:
> We've got an app that has connectors to external systems. We allow our
> customers to subclass our main Connector class to implement their own
> connector. If a customer puts a Connector implementation on the
> classpath, is it possible for our app to discover it automatically?
>
> What I want to do is show the full list of all available connectors in
> the user interface of our app, without forcing the customer to manually
> add the connector. I'd like to avoid adding yet another configuration file.
>
> It's possible for us to have the customer implement an interface rather
> than subclass a main class, if necessary.


java.util.ServiceProvider sounds like what you want. If not, you'll have
to do some ugly messing around with class loaders to detect classes that
subclass Connector.
 
Reply With Quote
 
 
 
 
Chris
Guest
Posts: n/a
 
      03-15-2007
Joshua Cranmer wrote:
> Chris wrote:
>> We've got an app that has connectors to external systems. We allow our
>> customers to subclass our main Connector class to implement their own
>> connector. If a customer puts a Connector implementation on the
>> classpath, is it possible for our app to discover it automatically?
>>
>> What I want to do is show the full list of all available connectors in
>> the user interface of our app, without forcing the customer to
>> manually add the connector. I'd like to avoid adding yet another
>> configuration file.
>>
>> It's possible for us to have the customer implement an interface
>> rather than subclass a main class, if necessary.

>
> java.util.ServiceProvider sounds like what you want. If not, you'll have
> to do some ugly messing around with class loaders to detect classes that
> subclass Connector.


I did not find that class, but I did find this:

http://weblogs.java.net/blog/enichol...ng_a_serv.html

Looks like there's enough here to get started.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hierarchy of interface/implementations. horos11@gmail.com Java 11 03-25-2009 05:57 PM
Reflection: discovering the implementations of an interface z-man Java 15 10-11-2006 09:16 AM
Discovering Management IP Address for Cisco 1900 Switch Walbert Cisco 1 01-05-2005 08:35 AM
Interface implementations Sparko Java 4 03-02-2004 04:04 PM
Determining interface implementations during runtime ? Marcus Crafter Java 1 02-19-2004 11:31 PM



Advertisments