Interface Resource

All Superinterfaces:
Serializable

public interface Resource extends Serializable

Generic interface to provide a Reader or InputStream for the underlying IO resource.

  • Method Details

    • getInputStream

      InputStream getInputStream() throws IOException
      Open an InputStream to the resource, the user must close this when finished.
      Returns:
      InputStream to the resource
      Throws:
      IOException
    • getReader

      Reader getReader() throws IOException
      Opens a Reader to the resource, the user must close this when finished.
      Returns:
      Reader to the resource
      Throws:
      IOException
    • getSourcePath

      String getSourcePath()
      Returns:
      source path of the resource, if one is available.
    • getTargetPath

      String getTargetPath()
      Returns:
      the target path that should be used when writing this resource down to KieFileSystem.
    • getResourceType

      ResourceType getResourceType()
      Returns the type of the resource if one could be inferred by the extension of the resource or if it was explicitly set.
      Returns:
      typo of the resource
    • getConfiguration

      ResourceConfiguration getConfiguration()
      Returns:
      the configuration for the resource if one is available.
    • setSourcePath

      Resource setSourcePath(String path)
      Sets this resource name. Some services require a resource to be named and it is not always possible to infer a name automatically. For instance, a file resource automatically infers its name from the file and path, but a byte array resource has to be given a name.
      Parameters:
      path - the path of the resource
      Returns:
      the resource itself in order to use it as a fluent API
    • setTargetPath

      Resource setTargetPath(String path)
      In case this resource should be written to a different path when writing it down to the KieFileSystem, this property allows the application to set such path.
      Parameters:
      path - the path of the resource
      Returns:
      the resource itself in order to use it as a fluent API
    • setResourceType

      Resource setResourceType(ResourceType type)
      Sets the resource type. For some resources it is possible to infer the type by the file name extension for instance. When it is not possible to infer it automatically, the user is expected to set it.
      Parameters:
      type - the resource type
      Returns:
      the resource itself in order to use it as a fluent API
    • setConfiguration

      Resource setConfiguration(ResourceConfiguration conf)
      Sets the resource configuration in case it is necessary.
      Parameters:
      conf - the resource configuration
      Returns:
      the resource itself in order to use it as a fluent API