private PropertyProvider getDelegate(MetricDefinition definition) {
    try {
      Class<?> clz = Class.forName(definition.getType());

      // singleton/factory
      try {
        Method m = clz.getMethod("getInstance", Map.class, Map.class);
        Object o = m.invoke(null, definition.getProperties(), definition.getMetrics());
        return PropertyProvider.class.cast(o);
      } catch (Exception e) {
        LOG.info("Could not load singleton or factory method for type '" +
            definition.getType());
      }

      // try maps constructor
      try {
        Constructor<?> ct = clz.getConstructor(Map.class, Map.class);
        Object o = ct.newInstance(definition.getProperties(), definition.getMetrics());
        return PropertyProvider.class.cast(o);
      } catch (Exception e) {
        LOG.info("Could not find contructor for type '" +
            definition.getType());
      }

      // just new instance
      return PropertyProvider.class.cast(clz.newInstance());

    } catch (Exception e) {
      LOG.error("Could not load class " + definition.getType());
      return null;
    }
  }
@param definition metric definition for a component and resource type combination
@return the custom property provider
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java