The Source for Java Technology Collaboration
User: Password:



Start New Message Delete Post a Reply

Article: 
 Breaking the Last Dependency
Subject:  Plugins with no configuration at all
Date:  2005-04-15 01:47:41
From:  chris_e_brown
Response to: I agree


Why even bother with configuration files?

If you really need extensibility, create a class to load plugins from one or more JAR of CLASS files. It would step through all entries in the JAR file using java.util.zip or java.util.jar APIs, can figure out class names from path names, and check for implementations of an interface, abstract class, or subclasses of a concrete class. Pass the file URLs to a URLClassLoader, check with Class.isAssignableFrom, and then your factory can use this information to find all types dynamically.

 Feed java.net RSS Feeds