Class ClassAsset

java.lang.Object
org.jboss.shrinkwrap.api.asset.ClassAsset
All Implemented Interfaces:
Asset

public class ClassAsset extends Object implements Asset
ClassAsset Implementation of a Asset backed by a loaded Class
  • Field Details

    • DELIMITER_RESOURCE_PATH

      private static final char DELIMITER_RESOURCE_PATH
      Delimiter for paths while looking for resources
      See Also:
    • DELIMITER_CLASS_NAME_PATH

      private static final char DELIMITER_CLASS_NAME_PATH
      Delimiter for paths in fully-qualified class names
      See Also:
    • EXTENSION_CLASS

      private static final String EXTENSION_CLASS
      The filename extension appended to classes
      See Also:
    • clazz

      private Class<?> clazz
  • Constructor Details

    • ClassAsset

      public ClassAsset(Class<?> clazz)
      Load any class as a resource.
      Parameters:
      clazz - The class to load
      Throws:
      IllegalArgumentException - Class can not be null
  • Method Details

    • openStream

      public InputStream openStream()
      Converts the Class name into a Resource URL and uses the ClassloaderResource for loading the Class.
      Specified by:
      openStream in interface Asset
      Returns:
      A new open InputStream for each call
    • getSource

      public Class<?> getSource()
      Returns the loaded class.
    • getResourceNameOfClass

      private String getResourceNameOfClass(Class<?> clazz) throws IllegalArgumentException
      Returns the name of the class such that it may be accessed via ClassLoader.getResource()
      Parameters:
      clazz - The class
      Throws:
      IllegalArgumentException - If the class was not specified