Class ResourcePathTypeResolver

java.lang.Object
org.citrusframework.spi.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. Note that, in order to reduce classpath scanning, the resolver caches the results of specific classpath scans.

A possible property file content that represents the resource in classpath could look like this:

 type=org.citrusframework.MySpecialPojo
 

Users can define custom property names to read instead of the default TypeResolver.DEFAULT_TYPE_PROPERTY.

Users can define custom property names to read instead of the default TypeResolver.DEFAULT_TYPE_PROPERTY.

Author:
Christoph Deppisch
  • Constructor Details

    • 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 Details

    • 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 path, 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:
    • instantiateType

      public <T> T instantiateType(String type, Object... initargs)
      Instantiate a type by its name.