Class RegistryBinder


  • class RegistryBinder
    extends java.lang.Object
    The RegistryBinder object is used acquire converters using a binding between a type and its converter. All converters instantiated are cached internally to ensure that the overhead of acquiring a converter is reduced. Converters are created on demand to ensure they are instantiated only if required.
    See Also:
    Registry
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Cache<java.lang.Class> cache
      This is used to cache bindings between types and converters.
      private ConverterFactory factory
      This is used to instantiate and cache the converter objects.
    • Constructor Summary

      Constructors 
      Constructor Description
      RegistryBinder()
      Constructor for the RegistryBinder object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void bind​(java.lang.Class type, java.lang.Class converter)
      This is used to register a binding between a type and the converter used to serialize and deserialize it.
      private Converter create​(java.lang.Class type)
      This is used to acquire a Converter instance from this binder.
      Converter lookup​(java.lang.Class type)
      This is used to acquire a Converter instance from this binder.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • factory

        private final ConverterFactory factory
        This is used to instantiate and cache the converter objects.
      • cache

        private final Cache<java.lang.Class> cache
        This is used to cache bindings between types and converters.
    • Constructor Detail

      • RegistryBinder

        public RegistryBinder()
        Constructor for the RegistryBinder object. This is used to create bindings between classes and the converters that should be used to serialize and deserialize the instances. All converters are instantiated once and cached for reuse.
    • Method Detail

      • lookup

        public Converter lookup​(java.lang.Class type)
                         throws java.lang.Exception
        This is used to acquire a Converter instance from this binder. All instances are cached to reduce the overhead of lookups during the serialization process. Converters are lazily instantiated and so are only created if demanded.
        Parameters:
        type - this is the type to find the converter for
        Returns:
        this returns the converter instance for the type
        Throws:
        java.lang.Exception
      • create

        private Converter create​(java.lang.Class type)
                          throws java.lang.Exception
        This is used to acquire a Converter instance from this binder. All instances are cached to reduce the overhead of lookups during the serialization process. Converters are lazily instantiated and so are only created if demanded.
        Parameters:
        type - this is the type to find the converter for
        Returns:
        this returns the converter instance for the type
        Throws:
        java.lang.Exception
      • bind

        public void bind​(java.lang.Class type,
                         java.lang.Class converter)
                  throws java.lang.Exception
        This is used to register a binding between a type and the converter used to serialize and deserialize it. During the serialization process the converters are retrieved and used to convert the object properties to XML.
        Parameters:
        type - this is the object type to bind to a converter
        converter - this is the converter class to be used
        Throws:
        java.lang.Exception