org.objectweb.jorm.genclass.lib
Class GenClassBinding

java.lang.Object
  |
  +--org.objectweb.jorm.genclass.lib.GenClassBinding
All Implemented Interfaces:
PBinding, PBindingCtrl
Direct Known Subclasses:
FosGenClassBinding, RdbGenClassBinding

public abstract class GenClassBinding
extends java.lang.Object
implements PBindingCtrl

This abstract class provides all the generic code for PBinding associated with JORM generic classes. It implements all methods except "exist", "read", and "write" (indeed, all I/O methods are DS-specific).

Author:
P. Dechamboux

Field Summary
protected  GenClassMapping genClassMapping
          The PClassMapping that manages this GenClass PBinding.
protected  java.util.ArrayList indexes
          This fields
protected  PName pName
          The PName of this PBinding object, which gives access to the relevant DSI.
protected  byte status
          The current state of this PBinding object.
 
Fields inherited from interface org.objectweb.jorm.api.PBinding
ACTION_BIND, ACTION_EXIST, ACTION_EXPORT, ACTION_READ, ACTION_UNBIND, ACTION_UNEXPORT, ACTION_WRITE, LIFECYCLE_ACTIVEFORIO, LIFECYCLE_DELTOWRITE, LIFECYCLE_ERROR, LIFECYCLE_NEWTOWRITE, LIFECYCLE_NOTBOUND
 
Constructor Summary
GenClassBinding()
          It contructs
GenClassBinding(GenClassMapping mapping)
          It contructs
 
Method Summary
 void bind(PName pn)
          It assigns a DSI represented by the PName passed as a parameter to this PBinding.
 PName export(java.lang.Object conn)
          It creates a new PName for this binding, the binding state is normally changed to LIFECYCLE_NEWTOWRITE, and the link to a data store instance if it existed is removed.
 PName export(java.lang.Object conn, java.lang.Object hints)
          It creates a new PName for this binding, the binding state is normally changed to LIFECYCLE_NEWTOWRITE, and the link to a data store instance if it existed is removed.
 PClassMapping getPClassMapping()
          It gives access to the PClassMapping which manages this binding.
 PName getPName()
          It gives access to the PName, which designate a particular DSI, associated to this binding.
 byte getStatus()
          It yields the current status associated with this PBinding.
 void init(PClassMapping pcm)
          It initialises a PBinding.
 void read(java.lang.Object conn, PAccessor pa, java.lang.Object txctx)
          It reads the data store instance designated by the PName of this binding and transfers each attribute value to the accessor object.
 void setPName(PName pn)
          It assigns the current PName associated with this PBinding.
 void setStatus(byte s)
          It assigns the current status associated with this PBinding.
 void unbind()
          It remove the association between a PName and a PBinding.
 void unexport(java.lang.Object conn)
          It prepares this PBinding to remove the data store instance from the data store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.jorm.api.PBinding
exist, read, write
 

Field Detail

status

protected byte status
The current state of this PBinding object.


genClassMapping

protected GenClassMapping genClassMapping
The PClassMapping that manages this GenClass PBinding.


pName

protected PName pName
The PName of this PBinding object, which gives access to the relevant DSI. This should always have a value (never null) and it should have a "null" PName value when unbound.


indexes

protected java.util.ArrayList indexes
This fields

Constructor Detail

GenClassBinding

public GenClassBinding()
It contructs


GenClassBinding

public GenClassBinding(GenClassMapping mapping)
                throws PExceptionProtocol
It contructs

Method Detail

bind

public void bind(PName pn)
          throws PException
It assigns a DSI represented by the PName passed as a parameter to this PBinding. This thus changes the link to the data store instance if one has been already assigned. The state either changed to LIFECYCLE_NOACCESSOR and LIFECYCLE_ACTIVEFORIO.

Specified by:
bind in interface PBinding
Parameters:
pn - The new PName to associate to this binding. This name must belong to the binder associated to this binding.
Throws:
PExceptionNaming - It is raised when there is a problem for the associated binder to manage this PName.
PException

export

public PName export(java.lang.Object conn)
             throws PException
It creates a new PName for this binding, the binding state is normally changed to LIFECYCLE_NEWTOWRITE, and the link to a data store instance if it existed is removed.

Specified by:
export in interface PBinding
Parameters:
conn - The connection that can be used to refer to the DS.
Returns:
The new PName assigned to this binding.
Throws:
PExceptionIO - It is raised when a problem occured while accessing to the DS.
PExceptionNaming - It is raised when the associated binder does not manage to create a new name.
PExceptionProtocol - It is raised when it is called with a state different from the following ones: LIFECYCLE_ACTIVEFORIO LIFECYCLE_DELTOWRITE LIFECYCLE_NEWTOWRITE LIFECYCLE_NOACC
PException

export

public PName export(java.lang.Object conn,
                    java.lang.Object hints)
             throws PException
Description copied from interface: PBinding
It creates a new PName for this binding, the binding state is normally changed to LIFECYCLE_NEWTOWRITE, and the link to a data store instance if it existed is removed.

Specified by:
export in interface PBinding
Parameters:
conn - The connection that can be used to refer to the DS.
hints - Any information relevant for name creation.
Returns:
The new PName assigned to this binding.
PException

getPClassMapping

public PClassMapping getPClassMapping()
It gives access to the PClassMapping which manages this binding.

Specified by:
getPClassMapping in interface PBinding
Returns:
The PClassMapping which creates this binding.

getPName

public PName getPName()
It gives access to the PName, which designate a particular DSI, associated to this binding. It returns null if the binding has not been given a PName using a bind or export method.

Specified by:
getPName in interface PBinding
Returns:
The PName associated to this binding.

getStatus

public byte getStatus()
It yields the current status associated with this PBinding.

Specified by:
getStatus in interface PBinding
Returns:
The corresponding status.

init

public void init(PClassMapping pcm)
          throws PExceptionProtocol
It initialises a PBinding.

Specified by:
init in interface PBinding
Parameters:
pcm - The PBinding to initialise.
Throws:
PExceptionProtocol - This PBinding cannot be managed by this PClassMapping.

unbind

public void unbind()
            throws PException
It remove the association between a PName and a PBinding. No more PName is associated with this binding (it has no more link with a DSI).

Specified by:
unbind in interface PBinding
Throws:
PExceptionNaming - It is raised when there is a problem for the associated binder to manage this PName.
PException

unexport

public void unexport(java.lang.Object conn)
              throws PException
It prepares this PBinding to remove the data store instance from the data store. In order to actually remove this DSI, a call to write must follow.

Specified by:
unexport in interface PBinding
Parameters:
conn - The connection that can be used to refer to the DS.
Throws:
PExceptionNaming - It is raised when there is a problem for the associated binder to manage this PName.
PExceptionProtocol - It is raised when it is called with a state different from the following ones: LIFECYCLE_ACTIVEFORIO LIFECYCLE_DELTOWRITE LIFECYCLE_NEWTOWRITE
PException

read

public void read(java.lang.Object conn,
                 PAccessor pa,
                 java.lang.Object txctx)
          throws PException
It reads the data store instance designated by the PName of this binding and transfers each attribute value to the accessor object. This read method should be used when prefetching is requested.

Specified by:
read in interface PBinding
Parameters:
conn - The connection that can be used to refer to the DS.
pa - The PAccessor used to access memory variables.
txctx - The transaction context that can be used in case of prefetching.
Throws:
PExceptionIO - It is raised when a problem occured while accessing to the DS.
PExceptionNaming - It is raised when there is a problem for the associated binder to manage this PName.
PExceptionProtocol - It is raised when it is called with a state different from the following ones: LIFECYCLE_ACTIVEFORIO
PException

setPName

public void setPName(PName pn)
It assigns the current PName associated with this PBinding.

Specified by:
setPName in interface PBindingCtrl

setStatus

public void setStatus(byte s)
It assigns the current status associated with this PBinding.

Specified by:
setStatus in interface PBindingCtrl