Interface ComponentFactory

All Known Implementing Classes:
AbstractComponentFactory, AbstractComponentFactory

public interface ComponentFactory
A provider of component types registered into the system via ComponentFactoryProvider. The available components in the local system will be a combination of results from all registered component factories.

The default ComponentFactoryService or RootFactoryService will create instances of components or roots by calling the factory methods createComponent(org.praxislive.core.ComponentType) or

invalid reference
#createRootComponent(org.praxislive.core.ComponentType)
. As an alternative, redirects can be provided to other services that will be used to construct the requested type. The alternative service might use the factory methods, other data in the component data lookups, or its own registry to construct the component.

The data lookups can also be used to provide additional metadata related to each component type.

  • Method Details

    • componentTypes

      Stream<ComponentType> componentTypes()
      Component types provided by this factory.
      Returns:
      stream of component types
    • rootTypes

      Stream<ComponentType> rootTypes()
      Root types provided by this factory.
      Returns:
      stream of root types
    • componentData

      default Lookup componentData(ComponentType type)
      Query the data associated with this component type.
      Parameters:
      type - component type
      Returns:
      lookup of data
    • rootData

      default Lookup rootData(ComponentType type)
      Query the data associated with this root type.
      Parameters:
      type - root type
      Returns:
      lookup of data
    • createComponent

      default Component createComponent(ComponentType type) throws ComponentInstantiationException
      Create an instance of the component associated with this type. Component factories with a redirect may not support this method, and always throw an exception. The default implementation always throws an exception.
      Parameters:
      type - component type to create
      Returns:
      created component instance
      Throws:
      ComponentInstantiationException
    • createRoot

      default Root createRoot(ComponentType type) throws ComponentInstantiationException
      Create an instance of the root associated with this type. Component factories with a redirect may not support this method, and always throw an exception. The default implementation always throws an exception.
      Parameters:
      type - root type to create
      Returns:
      created root instance
      Throws:
      ComponentInstantiationException
    • componentRedirect

      default Optional<ComponentFactory.Redirect> componentRedirect()
      Optional service to redirect to for component instantiation. The control on the service should follow the same shape as the default ComponentFactoryService.NEW_INSTANCE_INFO, accepting a ComponentType and returning the component instance wrapped in a PReference.
      Returns:
      optional service redirect
    • rootRedirect

      default Optional<ComponentFactory.Redirect> rootRedirect()
      Optional service to redirect to for root instantiation. The control on the service should follow the same shape as the default RootFactoryService.NEW_ROOT_INSTANCE_INFO, accepting a ComponentType and returning the root instance wrapped in a PReference.
      Returns:
      optional service redirect