net.sf.farrago.fennel
Class FennelDbHandleImpl

java.lang.Object
  extended by net.sf.farrago.fennel.FennelDbHandleImpl
All Implemented Interfaces:
FennelDbHandle, FarragoAllocation, ClosableAllocation

public class FennelDbHandleImpl
extends Object
implements FennelDbHandle

FennelDbHandle is a public wrapper for FennelStorage, and represents a handle to a loaded Fennel database.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/fennel/FennelDbHandleImpl.java#8 $
Author:
John V. Sichi

Field Summary
private  FennelCmdExecutor cmdExecutor
           
private  long dbHandle
           
private  Map<RefPackage,Collection<RefBaseObject>> handleAssociationsMap
           
private static Logger jhTracer
           
private  FarragoMetadataFactory metadataFactory
           
private static Logger tracer
           
 
Constructor Summary
FennelDbHandleImpl(FarragoMetadataFactory metadataFactory, FarragoAllocationOwner owner, FennelCmdExecutor cmdExecutor, FemCmdOpenDatabase cmd)
          Opens a Fennel database.
 
Method Summary
 FennelJavaHandle allocateNewObjectHandle(FarragoAllocationOwner owner, Object obj)
          Creates a native handle for a Java object for reference by XML commands.
 void closeAllocation()
          Closes this object.
 long executeCmd(FemCmd cmd)
          Executes a FemCmd object.
 long executeCmd(FemCmd cmd, FennelExecutionHandle execHandle)
          Executes a FemCmd object, associating an optional execution handle with the command.
 String getAccessorXmiForTupleDescriptorTraced(FemTupleDescriptor tupleDesc)
          Constructs a FemTupleAccessor for a FemTupleDescriptor.
 FemDbHandle getFemDbHandle(FarragoMetadataFactory callerFactory)
           
private  Collection getHandleAssociations(RefPackage fennelPackage)
           
 FarragoMetadataFactory getMetadataFactory()
           
 EigenbaseException handleNativeException(SQLException ex)
           
 void setObjectHandle(long handle, Object obj)
          Changes the object referenced by a handle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tracer

private static final Logger tracer

jhTracer

private static final Logger jhTracer

metadataFactory

private final FarragoMetadataFactory metadataFactory

cmdExecutor

private final FennelCmdExecutor cmdExecutor

handleAssociationsMap

private Map<RefPackage,Collection<RefBaseObject>> handleAssociationsMap

dbHandle

private long dbHandle
Constructor Detail

FennelDbHandleImpl

public FennelDbHandleImpl(FarragoMetadataFactory metadataFactory,
                          FarragoAllocationOwner owner,
                          FennelCmdExecutor cmdExecutor,
                          FemCmdOpenDatabase cmd)
Opens a Fennel database.

Parameters:
metadataFactory - FarragoMetadataFactory for creating Fem instances
owner - the object which will be made responsible for this database's allocation
cmdExecutor - FennelCmdExecutor to use for executing all commands on this database
cmd - instance of FemCmdOpenDatabase with all parameters set
Method Detail

getMetadataFactory

public FarragoMetadataFactory getMetadataFactory()
Specified by:
getMetadataFactory in interface FennelDbHandle

getHandleAssociations

private Collection getHandleAssociations(RefPackage fennelPackage)

getFemDbHandle

public FemDbHandle getFemDbHandle(FarragoMetadataFactory callerFactory)
Specified by:
getFemDbHandle in interface FennelDbHandle
Parameters:
callerFactory - override for metadataFactory
Returns:
FemDbHandle for this database

getAccessorXmiForTupleDescriptorTraced

public String getAccessorXmiForTupleDescriptorTraced(FemTupleDescriptor tupleDesc)
Constructs a FemTupleAccessor for a FemTupleDescriptor. This shouldn't be called directly except from FennelRelUtil.

Specified by:
getAccessorXmiForTupleDescriptorTraced in interface FennelDbHandle
Parameters:
tupleDesc - source FemTupleDescriptor
Returns:
XMI string representation of FemTupleAccessor

executeCmd

public long executeCmd(FemCmd cmd)
Executes a FemCmd object. If the command produces a resultHandle, it will be set after successful execution.

Specified by:
executeCmd in interface FennelDbHandle
Parameters:
cmd - instance of FemCmd with all parameters set
Returns:
return handle as primitive

executeCmd

public long executeCmd(FemCmd cmd,
                       FennelExecutionHandle execHandle)
Executes a FemCmd object, associating an optional execution handle with the command. If the command produces a resultHandle, it will be set after successful execution.

Specified by:
executeCmd in interface FennelDbHandle
Parameters:
cmd - instance of FemCmd with all parameters set
execHandle - the execution handle associated with the command; null if there is no associated execution handle
Returns:
return handle as primitive

allocateNewObjectHandle

public FennelJavaHandle allocateNewObjectHandle(FarragoAllocationOwner owner,
                                                Object obj)
Creates a native handle for a Java object for reference by XML commands. After this, the Java object cannot be garbage collected until its owner explicitly calls closeAllocation.

Specified by:
allocateNewObjectHandle in interface FennelDbHandle
Parameters:
owner - the object which will be made responsible for the handle's allocation as a result of this call
obj - object for which to create a handle, or null to create a placeholder handle
Returns:
native handle

setObjectHandle

public void setObjectHandle(long handle,
                            Object obj)
Changes the object referenced by a handle.

Specified by:
setObjectHandle in interface FennelDbHandle
Parameters:
handle - the handle to change
obj - new object

closeAllocation

public void closeAllocation()
Description copied from interface: ClosableAllocation
Closes this object.

Specified by:
closeAllocation in interface FennelDbHandle
Specified by:
closeAllocation in interface ClosableAllocation

handleNativeException

public EigenbaseException handleNativeException(SQLException ex)
Specified by:
handleNativeException in interface FennelDbHandle