Lima-Loa

org.limaloa
Class AdapterFactory

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

public class AdapterFactory
extends java.lang.Object

Factory class that allows controlled creation of adapter instances.

Author:
Chris Nappin

Method Summary
 java.lang.Object createAdapter(java.lang.Class sourceInterface, java.lang.Object target, java.util.Map 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 mappingFiles)
          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 and 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.

Returns:
The factory instance

getInstance

public static AdapterFactory getInstance(java.util.List mappingFiles)
Initialise everything and get a new factory instance. This is an expensive operation and 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
Returns:
The factory instance

createAdapter

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

Parameters:
sourceInterface - The fully qualified interface type name that the adapter will implement
target - The target object to map calls to
methodMappings - A Map of target method names, keyed by source method name.
Returns:
A Proxy instance that maps calls.
Throws:
AdapterCreationException - Error creating the adapter

Lima-Loa