org.compass.gps.device.ojb
Class OjbGpsDevice

java.lang.Object
  extended by org.compass.gps.device.AbstractGpsDevice
      extended by org.compass.gps.device.ojb.OjbGpsDevice
All Implemented Interfaces:
CompassGpsDevice, MirrorDataChangesGpsDevice, PassiveMirrorGpsDevice
Direct Known Subclasses:
SpringOjbGpsDevice

public class OjbGpsDevice
extends AbstractGpsDevice
implements PassiveMirrorGpsDevice

An ObJectRelationalBridge (OJB) device, provides support for using ojb and ojb mapping files to index a database. The path can be views as: Database <-> OJB <-> Objects <-> Compass::Gps <-> Compass::Core (Search Engine). What it means is that for every object that has both ojb and compass mappings, you will be able to index it's data, as well as real time mirroring of data changes.

Indexing the data (using the index() operation) requires the batchPersistentBroker property to be set, before the index() operation is called.

Real-time mirroring of data changes requires to use the attachLifecycleListeners(PersistenceBroker) to let the device listen for any data changes, and removeLifecycleListeners(PersistenceBroker) to remove the listener. Since the lifecycle listener can only be set on the instance level, and not the factory level (why would you do that, ojb developers?), attach and remove must be called every time a PersistentBroker is instantiated. You can use the OjbGpsDeviceUtils.attachPersistenceBrokerForIndex(org.compass.gps.CompassGpsDevice, org.apache.ojb.broker.PersistenceBroker) and OjbGpsDeviceUtils.removePersistenceBrokerForMirror(org.compass.gps.CompassGpsDevice, org.apache.ojb.broker.PersistenceBroker) as helper methods if attache to a generic device is required (which must be the OjbGpsDevice).

Since the real time mirroring and the event listener registration sounds like an aspect for Ojb aware classes/methods, Compass::Spring utilizes spring support for OJB and aspects for a much simpler event registration, please see Compass::Spring for more documentation.

Author:
kimchy

Field Summary
protected static org.apache.commons.logging.Log log
           
 
Fields inherited from class org.compass.gps.device.AbstractGpsDevice
compassGps
 
Constructor Summary
OjbGpsDevice()
           
OjbGpsDevice(String name, org.apache.ojb.broker.PersistenceBroker indexPersistenceBroker)
           
 
Method Summary
 void attachLifecycleListeners(org.apache.ojb.broker.PersistenceBroker pb)
          Attached the OjbGpsDevice lifecycle listener to the instance of the persistence broker.
protected  org.apache.ojb.broker.PersistenceBroker doGetIndexPersistentBroker()
          A method which can be used by derived classes to supply the persistent broker by a means of a centrelized registry (for example).
protected  void doIndex(CompassSession session, IndexPlan indexPlan)
          Derived devices must implement the method to perform the actual indexing operation.
protected  void doStart()
          Derived devices can implement it in case of start event notification.
protected  void doStop()
          Derived devices can implement it in case of stop event notification.
 org.apache.ojb.broker.PersistenceBroker getIndexPersistenceBroker()
          Returns the batch persistence broker used for indexing.
 boolean isMirrorDataChanges()
          Should the device perform real time data mirroring.
 void removeLifecycleListeners(org.apache.ojb.broker.PersistenceBroker pb)
          Removed the OjbGpsDevice lifecycle listener from the instance of the persistence broker.
 void setIndexPersistenceBroker(org.apache.ojb.broker.PersistenceBroker indexPersistenceBroker)
          Sets the batch persistence broker used for indexing.
 void setMirrorDataChanges(boolean mirrorDataChanges)
          Sets if the device will perform real time data changes mirroring.
 
Methods inherited from class org.compass.gps.device.AbstractGpsDevice
buildMessage, getGps, getName, index, injectGps, isFilteredForIndex, isPerformingIndexOperation, isRunning, setFilteredEntitiesForIndex, setName, shouldMirrorDataChanges, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.compass.gps.CompassGpsDevice
getGps, getName, index, injectGps, isPerformingIndexOperation, isRunning, setName, shouldMirrorDataChanges, start, stop
 

Field Detail

log

protected static org.apache.commons.logging.Log log
Constructor Detail

OjbGpsDevice

public OjbGpsDevice()

OjbGpsDevice

public OjbGpsDevice(String name,
                    org.apache.ojb.broker.PersistenceBroker indexPersistenceBroker)
Method Detail

doIndex

protected void doIndex(CompassSession session,
                       IndexPlan indexPlan)
                throws CompassGpsException
Description copied from class: AbstractGpsDevice
Derived devices must implement the method to perform the actual indexing operation.

Specified by:
doIndex in class AbstractGpsDevice
Throws:
CompassGpsException

doGetIndexPersistentBroker

protected org.apache.ojb.broker.PersistenceBroker doGetIndexPersistentBroker()
                                                                      throws CompassGpsException
A method which can be used by derived classes to supply the persistent broker by a means of a centrelized registry (for example).

Throws:
CompassGpsException

doStart

protected void doStart()
                throws CompassGpsException
Description copied from class: AbstractGpsDevice
Derived devices can implement it in case of start event notification.

Overrides:
doStart in class AbstractGpsDevice
Throws:
CompassGpsException

doStop

protected void doStop()
               throws CompassGpsException
Description copied from class: AbstractGpsDevice
Derived devices can implement it in case of stop event notification.

Overrides:
doStop in class AbstractGpsDevice
Throws:
CompassGpsException

attachLifecycleListeners

public void attachLifecycleListeners(org.apache.ojb.broker.PersistenceBroker pb)
Attached the OjbGpsDevice lifecycle listener to the instance of the persistence broker.

Parameters:
pb - The persistence broker

removeLifecycleListeners

public void removeLifecycleListeners(org.apache.ojb.broker.PersistenceBroker pb)
Removed the OjbGpsDevice lifecycle listener from the instance of the persistence broker.

Parameters:
pb - The persistence broker

getIndexPersistenceBroker

public org.apache.ojb.broker.PersistenceBroker getIndexPersistenceBroker()
Returns the batch persistence broker used for indexing.


setIndexPersistenceBroker

public void setIndexPersistenceBroker(org.apache.ojb.broker.PersistenceBroker indexPersistenceBroker)
Sets the batch persistence broker used for indexing.


isMirrorDataChanges

public boolean isMirrorDataChanges()
Description copied from interface: MirrorDataChangesGpsDevice
Should the device perform real time data mirroring.

Specified by:
isMirrorDataChanges in interface MirrorDataChangesGpsDevice
Returns:
true if the device mirror data changes

setMirrorDataChanges

public void setMirrorDataChanges(boolean mirrorDataChanges)
Description copied from interface: MirrorDataChangesGpsDevice
Sets if the device will perform real time data changes mirroring.

Specified by:
setMirrorDataChanges in interface MirrorDataChangesGpsDevice
Parameters:
mirrorDataChanges - Should the device mirror data changes


Copyright (c) 2004-2008 The Compass Project.