JMMF API
pre-release v0.7

fr.umlv.jmmf.adapter
Class AdapterFactory

java.lang.Object
  |
  +--fr.umlv.jmmf.adapter.AdapterFactory

public class AdapterFactory
extends java.lang.Object

a factory for a generated specialized adapter. There 3 parts in the factory interface :

All adapter created by this factory implements the Adapter interface.
code code code
TO DO: cache generated classes. must improve object allocations.

Version:
0.6.2
Author:
Remi Forax
See Also:
Adapter

Field Summary
static java.lang.Object SEND_ADAPTEE
          send the adaptee as first parameter of the multi-method during its invocation.
static java.lang.Object SEND_ADAPTER
          send the adapter as first parameter of the multi-method during its invocation.
static java.lang.Object SEND_NONE
          send no additionnal parameter to the multi-method during its invocation.
 
Constructor Summary
AdapterFactory()
          construct a default adapter factory.
AdapterFactory(java.lang.Class type)
          construct an adapter factory where all generated adapters implements the class take as argument.
 
Method Summary
 void addInterface(java.lang.Class interfaze)
          add an interface for all generated adapter.
 void addInterface(java.lang.Class adapteeClass, java.lang.Class interfaze)
          add an interface for all adapter for which the adaptee implements adapteeClass.
 void addInterface(java.lang.Class adapteeClass, java.lang.Class interfaze, boolean wrappable)
          add an interface for all adapter for which the adaptee implements adapteeClass.
 void addMultiMethod(java.lang.Object target, MultiMethod mm)
          add multimethod as an implementation of all adapter.
 void addMultiMethod(java.lang.Object target, MultiMethod mm, java.lang.Object invocationOption)
          add multimethod for an adaptee class.
 java.lang.Object create(java.lang.Object adaptee)
          generate a specialized adapter.
protected  java.lang.Object defaultTraversal(AdapterMessage message)
          called if no method matching.
 AdapterHook getHook()
          get the hook for all adapters.
protected  java.lang.Class[] getInterfaces(java.lang.Class adapteeClass)
           
 boolean isKeepAdapteeInterfaces()
          get the keepAdapteeInterfaces flag. if this flag is true, the interfaces of the adaptee is implemented by the generic adapter.
 boolean isWrappable(java.lang.Class clazz)
          return true if the class object is register as wrappable.
protected  boolean isWrappable(java.lang.Object object)
           
 void setAdapteeMultiFactory(MultiFactory factory)
          set the multi-method factory for adaptee.
 void setHook(AdapterHook hook)
          set the hook for all adapters.
 void setKeepAdapteeInterfaces(boolean keepAdapteeInterfaces)
          set the keepAdapteeInterfaces flag. if this flag is true, the interfaces of the adaptee is implemented by the generic adapter.
 void setWrappable(java.lang.Class aClass, boolean wrappable)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEND_NONE

public static final java.lang.Object SEND_NONE
send no additionnal parameter to the multi-method during its invocation.

SEND_ADAPTER

public static final java.lang.Object SEND_ADAPTER
send the adapter as first parameter of the multi-method during its invocation.

SEND_ADAPTEE

public static final java.lang.Object SEND_ADAPTEE
send the adaptee as first parameter of the multi-method during its invocation.
Constructor Detail

AdapterFactory

public AdapterFactory()
construct a default adapter factory.

AdapterFactory

public AdapterFactory(java.lang.Class type)
construct an adapter factory where all generated adapters implements the class take as argument.
Parameters:
type - must be an interface.
Method Detail

setHook

public void setHook(AdapterHook hook)
set the hook for all adapters.
Throws:
java.lang.IllegalArgumentException - if hook is null.

getHook

public AdapterHook getHook()
get the hook for all adapters.

setAdapteeMultiFactory

public void setAdapteeMultiFactory(MultiFactory factory)
set the multi-method factory for adaptee.

setKeepAdapteeInterfaces

public void setKeepAdapteeInterfaces(boolean keepAdapteeInterfaces)
set the keepAdapteeInterfaces flag. if this flag is true, the interfaces of the adaptee is implemented by the generic adapter.
Parameters:
keepAdapteeInterfaces - the new value of the flag.

isKeepAdapteeInterfaces

public boolean isKeepAdapteeInterfaces()
get the keepAdapteeInterfaces flag. if this flag is true, the interfaces of the adaptee is implemented by the generic adapter.
Returns:
the value of the keepAdapteeInterfaces flag.

setWrappable

public void setWrappable(java.lang.Class aClass,
                         boolean wrappable)

addInterface

public void addInterface(java.lang.Class interfaze)
add an interface for all generated adapter.
Parameters:
interfaze - interface that all generated adapter must implements.

addInterface

public void addInterface(java.lang.Class adapteeClass,
                         java.lang.Class interfaze)
add an interface for all adapter for which the adaptee implements adapteeClass.
Parameters:
adapteeClass - class of one adaptee.
interfaze - all generated adapter that wrapped an adaptee that implements the adapteeClass must implements this interface.

addInterface

public void addInterface(java.lang.Class adapteeClass,
                         java.lang.Class interfaze,
                         boolean wrappable)
add an interface for all adapter for which the adaptee implements adapteeClass.
Parameters:
adapteeClass - class of one adaptee.
interfaze - all generated adapter that wrapped an adaptee that implements the adapteeClass must implements this interface.
wrappable - a flag that
See Also:
setWrappable(Class,boolean)

addMultiMethod

public void addMultiMethod(java.lang.Object target,
                           MultiMethod mm)
add multimethod as an implementation of all adapter.
Parameters:
target - target of the multi-method, the target may be null.
mm - multi-method.

addMultiMethod

public void addMultiMethod(java.lang.Object target,
                           MultiMethod mm,
                           java.lang.Object invocationOption)
add multimethod for an adaptee class.
Parameters:
target - target of the multi-method, the target may be null.
mm - multi-method.
invocationOption - which first parameter is send to the multi-method.
This flag could contains three differents values :
SEND_NONE
if there no new first parameter.
SEND_ADAPTEE
if the adaptee is send as first parameter.
SEND_ADAPTER
if the adapter is send as first parameter.
WARNING: this method suppose that the hook is the DefaultAdapterHook.

create

public java.lang.Object create(java.lang.Object adaptee)
generate a specialized adapter.
Parameters:
adaptee - object wrapped in the adapter.
Returns:
a specialized adapter that implements all interfaces.

isWrappable

protected boolean isWrappable(java.lang.Object object)

isWrappable

public boolean isWrappable(java.lang.Class clazz)
return true if the class object is register as wrappable.
See Also:
setWrappable(Class,boolean)

getInterfaces

protected java.lang.Class[] getInterfaces(java.lang.Class adapteeClass)

defaultTraversal

protected java.lang.Object defaultTraversal(AdapterMessage message)
called if no method matching. Default implementation throw a NoMatchingMethodException.
Throws:
NoMatchingMethodException - always thrown.

JMMF API
pre-release v0.7

Rémi Forax 1999,2000 Université de Marne la Vallée