Interface Marshalable<T>

  • Type Parameters:
    T - The type of the instances being served by the factory.
    All Known Subinterfaces:
    MediaTypeFactory
    All Known Implementing Classes:
    FormMediaTypeFactory, JsonMediaTypeFactory, TextMediaTypeFactory, XmlMediaTypeFactory, YamlMediaTypeFactory
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.


    @FunctionalInterface
    public interface Marshalable<T>
    The Marshalable defines the functionality which must be provided in order to represent a factory for object creation depending on some provided context and of a predefined type specified with a generic argument (in contrast to the BeanLookupFactory , which creates instances of an expected type). Many alternative implementations of a Marshalable may may exist which construct the instances their way.

    Having factories that generic as we define it here, we are able to decouple our business logic from any specific framework: Your business logic must not know anything about how the instances are generated. It mainly just needs to know how to use the Marshalable. It is up to the application "end point", i.e. a command line tool with a main-method or a web-application to finally decide which factory to use.

    Depending on the implementation used or configuration provided, the Marshalable may return singletons or dedicated separate instances when queried for instances.

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      <SRC> T toMarshaled​(SRC aContext)
      This method creates / retrieves an instance of the given type with the given identifier (name) constructed as defined in one to many configuration files.
      default <SRC> T toMarshaled​(SRC aContext, java.util.Map<java.lang.String,java.lang.String> aProperties)
      This method creates / retrieves an instance of the given type with the given identifier (name) constructed as defined in one to many configuration files.
    • Method Detail

      • toMarshaled

        <SRC> T toMarshaled​(SRC aContext)
                     throws org.refcodes.exception.MarshalException
        This method creates / retrieves an instance of the given type with the given identifier (name) constructed as defined in one to many configuration files. How the instance is configured, created or retrieved is up to the nature (implementation) of the according factory.
        Type Parameters:
        SRC - The context which may influence the object being created by this factory.
        Parameters:
        aContext - The context which may influence the object being created by this factory.
        Returns:
        The instance being fabricated by this factory.
        Throws:
        org.refcodes.exception.MarshalException - Thrown when marshaling / serializing an object fails.
      • toMarshaled

        default <SRC> T toMarshaled​(SRC aContext,
                                    java.util.Map<java.lang.String,java.lang.String> aProperties)
                             throws org.refcodes.exception.MarshalException
        This method creates / retrieves an instance of the given type with the given identifier (name) constructed as defined in one to many configuration files. How the instance is configured, created or retrieved is up to the nature (implementation) of the according factory.
        Type Parameters:
        SRC - The context which may influence the object being created by this factory.
        Parameters:
        aContext - The context which may influence the object being created by this factory.
        aProperties - The dynamic properties which are used to configure the desired bean.
        Returns:
        The instance being fabricated by this factory.
        Throws:
        org.refcodes.exception.MarshalException - Thrown when marshaling / serializing an object fails.