Class Components

java.lang.Object
com.zfabrik.components.Components

public class Components extends Object
Convenience wrapper around IComponentsLookup and IComponentsManager This class provides static access methods to most used methods in IComponentsLookup and IComponentsManager.
  • Constructor Details

    • Components

      public Components()
  • Method Details

    • getComponentAs

      public static <T> T getComponentAs(String componentName, Class<T> clz, boolean required)
      Get a component facet by lookup through
      
       IComponentsLookup.INSTANCE.lookup(...)
       
      optionally requiring support of the facet.
      Type Parameters:
      T - Generic type of the facet
      Parameters:
      componentName - Name of the component
      clz - Class of the generic type
      required - if true the lookup must result in a non-null result or an IllegalStateException will be thrown
      Returns:
      The facet as implemented by the component
    • getComponentAs

      public static <T> T getComponentAs(String componentName, TypeRef<T> typeRef, boolean required)
      Get a component facet by lookup through
      
       IComponentsLookup.INSTANCE.lookup(...)
       
      optionally requiring support of the facet.
      Type Parameters:
      T - Generic type of the facet
      Parameters:
      componentName - Name of the component
      typeRef - TypeRef of the generic type
      required - if true the lookup must result in a non-null result or an IllegalStateException will be thrown
      Returns:
      The facet as implemented by the component
    • getComponentAs

      public static <T> T getComponentAs(String componentName, Class<T> clz)
      Get a component facet by lookup through
      
       getComponentAs(componentName, clz, false)
       
      i.e. with a non-required result.
      Type Parameters:
      T - Generic type of the facet
      Parameters:
      componentName - Name of the component
      clz - Class of the generic type
      Returns:
      The facet as implemented by the component
    • getComponentAs

      public static <T> T getComponentAs(String componentName, TypeRef<T> typeRef)
      Get a component facet by lookup through
      
       getComponentAs(componentName, clz, false)
       
      i.e. with a non-required result.
      Type Parameters:
      T - Generic type of the facet
      Parameters:
      componentName - Name of the component
      typeRef - TypeRef of the generic type
      Returns:
      The facet as implemented by the component
    • componentHandle

      public static IResourceHandle componentHandle(String componentName)
      Get the IResourceHandle facet of the named component. Note: This lookup is generically supported by the system and always returns a non-null result.
      Parameters:
      componentName - Name of the component
      Returns:
      The component's resource handle
    • getDependencyComponentAs

      public static <T> T getDependencyComponentAs(IResourceHandle dependant, String name, Class<T> clz, boolean required)
      Add a dependency by component name and retrieve a facet of the dependency.
      Type Parameters:
      T - Generic type of the facet
      Parameters:
      dependant - Handle of the component that will receive the dependency
      name - Name of the dependency component that will be added as a dependency
      clz - Class of the generic type
      required - if true the lookup via the dependency must result in a non-null result or an IllegalStateException will be thrown
      Returns:
      The facet as implemented by the dependency component
    • getDependencyComponentAs

      public static <T> T getDependencyComponentAs(IResourceHandle dependant, String name, TypeRef<T> typeRef, boolean required)
      Add a dependency by component name and retrieve a facet of the dependency.
      Type Parameters:
      T - Generic type of the facet
      Parameters:
      dependant - Handle of the component that will receive the dependency
      name - Name of the dependency component that will be added as a dependency
      typeRef - TypeRef of the generic type
      required - if true the lookup via the dependency must result in a non-null result or an IllegalStateException will be thrown
      Returns:
      The facet as implemented by the dependency component
    • getComponentProperties

      public static Properties getComponentProperties(IResourceHandle component)
      Get the component descriptor properties for the component supplied by IResourceHandle.
      Parameters:
      component - Resource handle of the component to retrieve properties for
      Returns:
      Properties of the supplied component
    • getComponentProperties

      public static Properties getComponentProperties(String componentName)
      Get the component descriptor properties for the component supplied by name.
      Parameters:
      componentName - Name of the component to retrieve properties for
      Returns:
      Properties of the supplied component
    • retrieve

      public static File retrieve(String componentName) throws IOException
      Get the resource folder of a component, if any. See also IComponentsRepository.retrieve(String)
      Parameters:
      componentName - Name of the component
      Returns:
      Resource folder as File, or null, if the component has no resource folder
      Throws:
      IOException
    • findComponents

      public static Collection<String> findComponents(X propertyExpression) throws IOException
      Find all components by query expression on their properties.
      Parameters:
      propertyExpression - Search query for components. See IComponentsRepository.findComponents(X)
      Returns:
      Query result
      Throws:
      IOException