biz.hammurapi.persistence
Class ChunkingStringStorage

java.lang.Object
  extended by biz.hammurapi.config.ComponentBase
      extended by biz.hammurapi.persistence.ChunkingStringStorage
All Implemented Interfaces:
biz.hammurapi.config.Component, biz.hammurapi.config.Context, biz.hammurapi.metrics.MeasurementCollector, biz.hammurapi.metrics.MeasurementConsumer, StringStorage

public class ChunkingStringStorage
extends biz.hammurapi.config.ComponentBase
implements StringStorage

This class manages storage and retrieval of strings to and from relational database. Strings can be of arbitrary size, long strings are cut into chunks. Strings are keyed by integers. Often used strings are cached in memory using soft references.

Author:
Pavel Vlasov

Field Summary
 
Fields inherited from class biz.hammurapi.config.ComponentBase
owner
 
Constructor Summary
ChunkingStringStorage()
           
 
Method Summary
 java.lang.Integer addText(java.lang.String text)
          Returns key for given text.
protected  java.lang.Object getChild(java.lang.String name)
          Alternative way to access text entries.
 java.lang.String getText(java.lang.Integer key)
          Returns string by key.
 void setChunkSize(int chunkSize)
          Size of individual text chunk.
 void setDatasource(javax.sql.DataSource datasource)
          Data source
 void setIdentityManager(biz.hammurapi.sql.IdentityManager identityManager)
          Identity manager is used to generate/retrieve identity of newely inserted entries.
 void setTimer(java.util.Timer timer)
          Timer for cleaning up memory entries, can be null.
 void start()
          Starts timer and cache.
 void stop()
          Stops memory cache and times.
 
Methods inherited from class biz.hammurapi.config.ComponentBase
addMeasurement, get, getMeasurementConsumer, getOwner, getOwner, setMeasurementConsumer, setOwner
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChunkingStringStorage

public ChunkingStringStorage()
Method Detail

setTimer

public void setTimer(java.util.Timer timer)
Timer for cleaning up memory entries, can be null.

Parameters:
timer -

setDatasource

public void setDatasource(javax.sql.DataSource datasource)
Data source

Parameters:
datasource -

getText

public java.lang.String getText(java.lang.Integer key)
Description copied from interface: StringStorage
Returns string by key. Null key is always mapped to null value.

Specified by:
getText in interface StringStorage
Returns:

addText

public java.lang.Integer addText(java.lang.String text)
Description copied from interface: StringStorage
Returns key for given text. Adds text to the database if needed.

Specified by:
addText in interface StringStorage
Returns:

stop

public void stop()
Stops memory cache and times.

Specified by:
stop in interface biz.hammurapi.config.Component

setIdentityManager

public void setIdentityManager(biz.hammurapi.sql.IdentityManager identityManager)
Identity manager is used to generate/retrieve identity of newely inserted entries.

Parameters:
identityManager -

setChunkSize

public void setChunkSize(int chunkSize)
Size of individual text chunk.

Parameters:
chunkSize -

start

public void start()
           throws biz.hammurapi.config.ConfigurationException
Starts timer and cache.

Specified by:
start in interface biz.hammurapi.config.Component
Throws:
biz.hammurapi.config.ConfigurationException

getChild

protected java.lang.Object getChild(java.lang.String name)
Alternative way to access text entries.

Overrides:
getChild in class biz.hammurapi.config.ComponentBase


Copyright © 2006 Hammurapi Group. All Rights Reserved.