Search This Blog

Java: Add Service Provider at runtime


Is it possible to add service providers at runtime?


Yes. In JDK versions up to 1.4.2, the classpath is scanned for providers each time they need to be queried. In 1.5.0, providers are cached with a timeout of 60 seconds. So adding a service provider to the classpath will have an immediate effect or after 1 minute, respectively. Adding a provider to the classpath at runtime can be done in several ways:

  • Change the classpath to include additional .jar files or directories by setting the system property java.class.path using System.setProperty().

  • Write a .jar file into one of the extension directories.

  • Write the class files and configuration files of a provider to a directory that is already in the class path.

  • Modify a .jar file that is already in the path.


No comments:

Post a Comment