Class LocalServiceFactory

java.lang.Object
org.jolokia.server.core.util.LocalServiceFactory

public final class LocalServiceFactory extends Object
A simple factory for creating services with no-arg constructors from a textual descriptor. This descriptor, which must be a resource loadable by this class' classloader, is a plain text file which looks like
   org.jolokia.service.jmx.detector.TomcatDetector,50
   !org.jolokia.service.jmx.detector.JettyDetector
   org.jolokia.service.jmx.detector.JBossDetector
   org.jolokia.service.jmx.detector.WebsphereDetector,1500
 
If a line starts with ! it is removed if it has been added previously. The optional second numeric value is the order in which the services are returned. The services to create can have either a no-op constructor or one with an integer argument. If a constructor with an integer value exists than it is fed with the determined order. This feature is typically used in combination with Comparable to obtain a SortedSet which can merged with other sets and keeping the order intact.
Since:
05.11.10
Author:
roland
  • Method Details

    • createServices

      public static <T> List<T> createServices(ClassLoader pClassLoader, String... pDescriptorPaths)
      Create a list of services ordered according to the ordering given in the service descriptor files. Note, that the descriptor will be looked up in the whole classpath space, which can result in reading in multiple descriptors with a single path. Note, that the reading order for multiple resources with the same name is not defined.
      Type Parameters:
      T - type of the service objects to create
      Parameters:
      pClassLoader - classloader to use for looking up the services
      pDescriptorPaths - a list of resource paths which are handle in the given order. Normally, default service should be given as first parameter so that custom descriptors have a chance to remove a default service.
      Returns:
      a ordered list of created services or an empty list.
    • createServices

      public static <T> List<T> createServices(String... pDescriptorPaths)
      Create a list of services ordered according to the ordering given in the service descriptor files. Note, that the descriptor will be looked up in the whole classpath space, which can result in reading in multiple descriptors with a single path. Note, that the reading order for multiple resources with the same name is not defined. The class loader of the current class is used for looking up the resources.
      Type Parameters:
      T - type of the service objects to create
      Parameters:
      pDescriptorPaths - a list of resource paths which are handle in the given order. Normally, default service should be given as first parameter so that custom descriptors have a chance to remove a default service.
      Returns:
      a ordered list of created services.