Lima-Loa

org.limaloa
Class AdapterFactory

java.lang.Object
  extended by org.limaloa.AdapterFactory

public final class AdapterFactory
extends java.lang.Object

Factory class that allows controlled creation of adapter instances.

Author:
Chris Nappin

Method Summary
<T> T
createAdapter(java.lang.Class<T> sourceInterface, java.lang.Object target, java.util.List<MethodMapping> methodMappings)
          Creates a new adapter instance, which maps calls to it's methods to the appropriate method on the target object.
static AdapterFactory getInstance()
          Initialise everything and get a new factory instance.
static AdapterFactory getInstance(java.util.List<java.lang.String> mappingFiles, boolean useDozer)
          Initialise everything and get a new factory instance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static AdapterFactory getInstance()
Initialise everything and get a new factory instance. This is an expensive operation, therefore this should only be called once and the factory re-used (e.g. as a singleton) to create all adapter instances. This version of the method uses default settings, which is to disable any use of Dozer and only allow internally handled object mappings.

Returns:
The factory instance

getInstance

public static AdapterFactory getInstance(java.util.List<java.lang.String> mappingFiles,
                                         boolean useDozer)
Initialise everything and get a new factory instance. This is an expensive operation and (if enabled) triggers Dozer to initialise itself, therefore this should only be called once and the factory re-used (e.g. as a singleton) to create all adapter instances. This version of the method takes a List of filenames, containing custom Dozer mapping definitions.

Parameters:
mappingFiles - A List of Dozer mapping filenames to use, or null if none
useDozer - Whether to use Dozer or not
Returns:
The factory instance

createAdapter

public <T> T createAdapter(java.lang.Class<T> sourceInterface,
                           java.lang.Object target,
                           java.util.List<MethodMapping> methodMappings)
                throws MappingCreationConfigurationException
Creates a new adapter instance, which maps calls to it's methods to the appropriate method on the target object.

Type Parameters:
T - The adapter interface type
Parameters:
sourceInterface - The interface type class that the adapter will implement
target - The target object to map calls to
methodMappings - A List of MethodMapping.
Returns:
A Proxy instance that maps calls.
Throws:
MappingCreationConfigurationException - Error creating the adapter

Lima-Loa