Class ConfigHelper

java.lang.Object
org.apache.jackrabbit.vault.fs.config.ConfigHelper

public class ConfigHelper extends Object
ConfigHelper...
  • Constructor Details

    • ConfigHelper

      public ConfigHelper()
  • Method Details

    • getDefaultPackages

      public Map<String,String> getDefaultPackages()
    • getDefaultClasses

      public Map<String,String> getDefaultClasses()
    • getMappings

      protected Map<String,String> getMappings()
    • getDefaultPackage

      public String getDefaultPackage(String name)
    • getDefaultClass

      public String getDefaultClass(String name)
    • create

      public Object create(Element elem) throws ConfigurationException
      Throws:
      ConfigurationException
    • create

      public Object create(Element elem, Class<?> expectedType) throws ConfigurationException
      Creates an instance for the given config element, requiring the configured class to be of the given expected type. Configurations are frequently read from untrusted sources (e.g. META-INF/vault/config.xml inside a content package, parsed when the package is opened), so the class named by the class attribute must never be instantiated - and its static initializer therefore never triggered - unless it is of the type the caller will actually use. For the same reason the historic Class#FIELD static field access syntax is rejected: reading an arbitrary static field of an arbitrary class is not a configuration mechanism but a code-execution primitive.
      Parameters:
      elem - the config element
      expectedType - the type the configured class must be assignable to
      Returns:
      the new instance (or the element's text content if no class is configured)
      Throws:
      ConfigurationException - if the class cannot be resolved, is not assignable to expectedType, uses the rejected # field syntax, or cannot be instantiated
      Since:
      2.10.0 (Bundle version 4.3.0)
    • getMethodName

      public static String getMethodName(String prefix, String name)
    • getMethod

      public static Method getMethod(Object obj, String name, Class<?>... params)
    • hasSetter

      public static boolean hasSetter(Object obj, String name) throws ConfigurationException
      Throws:
      ConfigurationException
    • setField

      public static boolean setField(Object obj, String name, Object value) throws ConfigurationException
      Throws:
      ConfigurationException
    • invokeGetter

      public static <T> T invokeGetter(Object obj, String name, Class<T> T) throws ConfigurationException
      Throws:
      ConfigurationException