Class ResourcePathTypeResolver

  • All Implemented Interfaces:
    TypeResolver

    public class ResourcePathTypeResolver
    extends Object
    implements TypeResolver
    Type resolver resolves references via resource path lookup. Provided resource paths should point to a resource in classpath (e.g. META-INF/my/resource/path/file-name). The resolver will try to locate the resource as classpath resource and read the file as property file. By default the resolver reads the default type resolver property TypeResolver.DEFAULT_TYPE_PROPERTY and instantiates a new instance for the given type information. A possible property file content that represents the resource in classpath could look like this: type=com.consol.citrus.MySpecialPojo Users can define custom property names to read instead of the default TypeResolver.DEFAULT_TYPE_PROPERTY.
    Author:
    Christoph Deppisch
    • Constructor Detail

      • ResourcePathTypeResolver

        public ResourcePathTypeResolver()
        Default constructor using META-INF resource base path.
      • ResourcePathTypeResolver

        public ResourcePathTypeResolver​(String resourceBasePath)
        Default constructor initializes with given resource path.
        Parameters:
        resourceBasePath -
    • Method Detail

      • resolveProperty

        public String resolveProperty​(String resourcePath,
                                      String property)
        Description copied from interface: TypeResolver
        Resolve resource path property file with given name and load given property.
        Specified by:
        resolveProperty in interface TypeResolver
        Returns:
      • resolve

        public <T> T resolve​(String resourcePath,
                             String property,
                             Object... initargs)
        Description copied from interface: TypeResolver
        Load given property from given resource path property file and create new instance of given type. The type information is read by the given property in the resource file.
        Specified by:
        resolve in interface TypeResolver
        Returns:
      • resolveAll

        public <T> Map<String,​T> resolveAll​(String resourcePath,
                                                  String property,
                                                  String keyProperty)
        Description copied from interface: TypeResolver
        Load all resources in given resource path and create new instance of given type. The type information is read by the given property in the resource file.
        Specified by:
        resolveAll in interface TypeResolver
        Returns: