aokell.lib.control.binding
Class AbstractBindingControllerImpl

java.lang.Object
  extended by aokell.lib.control.binding.AbstractBindingControllerImpl
All Implemented Interfaces:
BindingControllerItf, Controller, BindingController
Direct Known Subclasses:
FlatBindingControllerImpl, PrimitiveBindingControllerImpl

public abstract class AbstractBindingControllerImpl
extends Object
implements BindingControllerItf, Controller

Root class for binding controllers implementations.

Author:
Lionel Seinturier

Field Summary
protected  Component compctrl
           
 Map reverseBindings
          Store backward links to interfaces bound to the interfaces of the component managed by this binding controller.
 
Fields inherited from interface aokell.lib.control.binding.BindingControllerItf
NAME, TYPE
 
Constructor Summary
AbstractBindingControllerImpl()
           
 
Method Summary
 void addFcCollectionInterfaceNames(List cltItfNames)
          Add the names of currently bound interfaces to the given list.
 void bindFc(String arg0, Object arg1)
          Binds the client interface whose name is given to a server interface.
protected  void bindFcContent(String arg0, Object arg1)
          If the content and the component parts are separated, and if the content part implements the BindingController interface, invoke it.
 void cloneFcCtrl(Component dst, Object hints)
          Clone the controller state from the current component to another one.
protected  Object getFcClientItf(String itfName)
          Return the interface whose name is given.
protected  List getFcSingletonClientItfs()
          Return the list of client interfaces for the component attached to this controller.
 void initFcCtrl()
          Initialize the controller.
 boolean isFcBound()
           
 boolean isFcReverseBound()
           
 String[] listFc()
          Returns the names of the client interfaces of the component to which this interface belongs.
 Object lookupFc(String arg0)
          Returns the interface to which the given client interface is bound.
 void reverseBindFc(String dstItfName, Object src)
          Record a reverse binding.
 Object reverseLookupFc(String dstItfName)
          Lookup a reverse binding.
 void reverseUnbindFc(String dstItfName)
          Remove a reverse binding.
 void setFcCompCtrl(Component compctrl)
          Set the reference towards the component controller associated to this controller.
protected  void testLegalBinding(String arg0, InterfaceType it, Object arg1)
          Test whether the a client interface implementing the specified InterfaceType can be bound to arg1.
protected  void testLifeCyleBeforeUnbinding(Component arg0)
           
 void unbindFc(String arg0)
          Unbinds the given client interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reverseBindings

public Map reverseBindings
Store backward links to interfaces bound to the interfaces of the component managed by this binding controller.


compctrl

protected Component compctrl
Constructor Detail

AbstractBindingControllerImpl

public AbstractBindingControllerImpl()
Method Detail

listFc

public String[] listFc()
Returns the names of the client interfaces of the component to which this interface belongs.

Specified by:
listFc in interface BindingController
Returns:
the names of the client interfaces of the component to which this interface belongs.

lookupFc

public Object lookupFc(String arg0)
                throws NoSuchInterfaceException
Returns the interface to which the given client interface is bound. More precisely, returns the server interface to which the client interface whose name is given is bound. This server interface is necessarily in the same address space as the client interface.

Specified by:
lookupFc in interface BindingController
Parameters:
arg0 - the name of a client interface of the component to which this interface belongs.
Returns:
the server interface to which the given interface is bound, or null if it is not bound.
Throws:
NoSuchInterfaceException - if the component to which this interface belongs does not have a client interface whose name is equal to the given name.

bindFc

public void bindFc(String arg0,
                   Object arg1)
            throws NoSuchInterfaceException,
                   IllegalBindingException,
                   IllegalLifeCycleException
Binds the client interface whose name is given to a server interface. More precisely, binds the client interface of the component to which this interface belongs, and whose name is equal to the given name, to the given server interface. The given server interface must be in the same address space as the client interface.

Specified by:
bindFc in interface BindingController
Parameters:
arg0 - the name of a client interface of the component to which this interface belongs.
arg1 - a server interface.
Throws:
NoSuchInterfaceException - if there is no such client interface.
IllegalBindingException - if the binding cannot be created.
IllegalLifeCycleException - if this component has a LifeCycleController interface, but it is not in an appropriate state to perform this operation.

bindFcContent

protected void bindFcContent(String arg0,
                             Object arg1)
If the content and the component parts are separated, and if the content part implements the BindingController interface, invoke it. Discard the result.


unbindFc

public void unbindFc(String arg0)
              throws NoSuchInterfaceException,
                     IllegalBindingException,
                     IllegalLifeCycleException
Unbinds the given client interface. More precisely, unbinds the client interface of the component to which this interface belongs, and whose name is equal to the given name.

Specified by:
unbindFc in interface BindingController
Parameters:
arg0 - the name of a client interface of the component to which this interface belongs.
Throws:
NoSuchInterfaceException - if there is no such client interface.
IllegalBindingException - if the binding cannot be removed.
IllegalLifeCycleException - if this component has a LifeCycleController interface, but it is not in an appropriate state to perform this operation.

reverseBindFc

public void reverseBindFc(String dstItfName,
                          Object src)
Record a reverse binding. When a source interface is bound to a target one, the reverse link (target -> source) is also recorded in the target binding controller. This reverse mappings is primarily used to prevent content controllers from performing remove operations that would create invalid bindings.

Specified by:
reverseBindFc in interface BindingControllerItf
Parameters:
dstItfName - the target interface name for the binding
src - the source interface for the binding

reverseLookupFc

public Object reverseLookupFc(String dstItfName)
Lookup a reverse binding. See reverseBindFc(String,Object) for the rationale behind reverse bindings.

Specified by:
reverseLookupFc in interface BindingControllerItf
Parameters:
dstItfName - the target interface name to be looked up
Returns:
the corresponding source interface or null

reverseUnbindFc

public void reverseUnbindFc(String dstItfName)
Remove a reverse binding. See reverseBindFc(String,Object) for the rationale behind reverse bindings.

Specified by:
reverseUnbindFc in interface BindingControllerItf
Parameters:
dstItfName - the target interface name to be removed

isFcBound

public boolean isFcBound()
Specified by:
isFcBound in interface BindingControllerItf
Returns:
true if the given component contains at least one binding (excluding the binding with the component interface).

isFcReverseBound

public boolean isFcReverseBound()
Specified by:
isFcReverseBound in interface BindingControllerItf
Returns:
true if the given component contains at least one reverse binding

addFcCollectionInterfaceNames

public void addFcCollectionInterfaceNames(List cltItfNames)
Add the names of currently bound interfaces to the given list.

Specified by:
addFcCollectionInterfaceNames in interface BindingControllerItf

testLifeCyleBeforeUnbinding

protected void testLifeCyleBeforeUnbinding(Component arg0)
                                    throws IllegalLifeCycleException
Throws:
IllegalLifeCycleException

getFcClientItf

protected Object getFcClientItf(String itfName)
                         throws NoSuchInterfaceException
Return the interface whose name is given.

Throws:
NoSuchInterfaceException

getFcSingletonClientItfs

protected List getFcSingletonClientItfs()
Return the list of client interfaces for the component attached to this controller.


testLegalBinding

protected void testLegalBinding(String arg0,
                                InterfaceType it,
                                Object arg1)
                         throws IllegalBindingException,
                                NoSuchInterfaceException
Test whether the a client interface implementing the specified InterfaceType can be bound to arg1.

Throws:
IllegalBindingException - if the binding is illegal
NoSuchInterfaceException

setFcCompCtrl

public void setFcCompCtrl(Component compctrl)
Set the reference towards the component controller associated to this controller.

Specified by:
setFcCompCtrl in interface Controller

initFcCtrl

public void initFcCtrl()
Initialize the controller.

Specified by:
initFcCtrl in interface Controller

cloneFcCtrl

public void cloneFcCtrl(Component dst,
                        Object hints)
                 throws CloneCtrlException
Clone the controller state from the current component to another one. This method may receive some hints on how to do this, or provide some hints on how this has been done. For instance, the hints may be a map that is read and/or written by the controller. The raison d'etre of these hints is that when its state is cloned, a controller may produce results that are needed by other controllers.

Specified by:
cloneFcCtrl in interface Controller
Parameters:
dst - the destination component
hints - hints for performing the operation
Throws:
CloneCtrlException