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.
> 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
[quoted text clipped - 7 lines]
> 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.
Chris - 15 Mar 2007 19:42 GMT
>> 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
[quoted text clipped - 12 lines]
> 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.