Discovering subclasses or implementations of an interface

Discussion in 'Java' started by Chris, Mar 15, 2007.

  1. Chris

    Chris Guest

    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.
     
    Chris, Mar 15, 2007
    #1
    1. Advertising

  2. 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.
     
    Joshua Cranmer, Mar 15, 2007
    #2
    1. Advertising

  3. Chris

    Chris Guest

    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/enicholas/archive/2006/04/creating_a_serv.html

    Looks like there's enough here to get started.
     
    Chris, Mar 15, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff 'Jones' Putz
    Replies:
    1
    Views:
    345
    John Saunders
    Nov 25, 2003
  2. Marcus Crafter
    Replies:
    1
    Views:
    355
    Mike Schilling
    Feb 19, 2004
  3. Sparko

    Interface implementations

    Sparko, Mar 2, 2004, in forum: Java
    Replies:
    4
    Views:
    359
    Christophe Vanfleteren
    Mar 2, 2004
  4. z-man
    Replies:
    15
    Views:
    614
    Chris Uppal
    Oct 11, 2006
  5. Replies:
    11
    Views:
    533
Loading...

Share This Page