org.persvr.datasource
Class LocalJsonFileSource

java.lang.Object
  extended by org.persvr.remote.JsonReceiver
      extended by org.persvr.datasource.AbstractJsonSource
          extended by org.persvr.datasource.LocalJsonFileSource
All Implemented Interfaces:
ChangeableData, DataSource, ListDataSource, WritableDataSource, PersevereFilter.LocalDataSource

public class LocalJsonFileSource
extends AbstractJsonSource
implements PersevereFilter.LocalDataSource, WritableDataSource, ChangeableData


Nested Class Summary
 
Nested classes/interfaces inherited from class org.persvr.datasource.AbstractJsonSource
AbstractJsonSource.RootAndResolved
 
Nested classes/interfaces inherited from class org.persvr.remote.JsonReceiver
JsonReceiver.UpdateInfo
 
Field Summary
static java.lang.String LOCAL_JSPON_RELATIVE_PATH
           
protected  java.lang.String localPath
           
static java.lang.String pathSeparator
           
 
Fields inherited from class org.persvr.datasource.AbstractJsonSource
defaultCacheLength
 
Fields inherited from class org.persvr.remote.JsonReceiver
FUNCTION_CODE_KEY, NOT_READY_FIELD, path
 
Constructor Summary
LocalJsonFileSource()
           
 
Method Summary
 boolean doesObjectNeedUpdating(java.lang.String objectId)
          This indicates how long an object can be accessed by id before an id request should go back to the data source for an update.
 java.lang.Object getFieldValue(LazyPropertyId valueId)
          This is called when a field value contains an unfulfilled value (ValueId)
protected  java.lang.Object getJson(java.lang.String resourceName)
          Gets the JSON string for a particular object id.
 java.lang.String getPathSeparator()
           
protected  ObjectId idFromJSPONObject(java.util.Map object, ObjectId defaultId)
           
 void initParameters(java.util.Map<java.lang.String,java.lang.Object> parameters)
          This is called on initialization and provides access to the data source configuration parameters
protected  void mapJson(PersistableInitializer initializer, java.lang.Object object, java.lang.String objectId)
           
 java.util.Iterator mapQuery(Query query)
          This is called when an object is being activated to retrieve the persisted data for a given object with a filter
protected  void newJson(java.lang.String json)
           
 boolean passThrough()
           
 void recordDelete(java.lang.String objectId)
          This is called when an object should be deleted
 NewObjectPersister recordNewObject(Persistable object)
          This is called when a new object is persisted
protected  void setJson(java.lang.String resourceName, java.lang.String json)
           
static void setLocalJsonPath(java.lang.String localJsonPath)
           
 
Methods inherited from class org.persvr.datasource.AbstractJsonSource
abortTransaction, commitTransaction, convertJsonToJavaScript, getId, getMap, getResourceAsString, handleNewObject, hiddenId, makeDirty, mapObject, mapSchema, recordList, recordPropertyAddition, recordPropertyChange, recordPropertyRemoval, serialize, setId, startTransaction
 
Methods inherited from class org.persvr.remote.JsonReceiver
convertJsponStringToObject, convertParsedToObject, createInitialObject, getPath, handleRPC, idOrValueFromJSON, listFromJSPONArray, parseJsponString, replaceList, setPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.persvr.datasource.WritableDataSource
abortTransaction, commitTransaction, recordPropertyAddition, recordPropertyChange, recordPropertyRemoval, startTransaction
 
Methods inherited from interface org.persvr.datasource.DataSource
getId, hiddenId, mapObject, setId
 

Field Detail

LOCAL_JSPON_RELATIVE_PATH

public static final java.lang.String LOCAL_JSPON_RELATIVE_PATH
See Also:
Constant Field Values

localPath

protected java.lang.String localPath

pathSeparator

public static final java.lang.String pathSeparator
See Also:
Constant Field Values
Constructor Detail

LocalJsonFileSource

public LocalJsonFileSource()
Method Detail

doesObjectNeedUpdating

public boolean doesObjectNeedUpdating(java.lang.String objectId)
Description copied from interface: ChangeableData
This indicates how long an object can be accessed by id before an id request should go back to the data source for an update.

Specified by:
doesObjectNeedUpdating in interface ChangeableData
Returns:

recordDelete

public void recordDelete(java.lang.String objectId)
                  throws java.lang.Exception
Description copied from interface: WritableDataSource
This is called when an object should be deleted

Specified by:
recordDelete in interface WritableDataSource
Throws:
java.lang.Exception

recordNewObject

public NewObjectPersister recordNewObject(Persistable object)
                                   throws java.lang.Exception
Description copied from interface: WritableDataSource
This is called when a new object is persisted

Specified by:
recordNewObject in interface WritableDataSource
Overrides:
recordNewObject in class AbstractJsonSource
Returns:
persister
Throws:
java.lang.Exception

setLocalJsonPath

public static void setLocalJsonPath(java.lang.String localJsonPath)

getJson

protected java.lang.Object getJson(java.lang.String resourceName)
                            throws java.lang.Exception
Description copied from class: AbstractJsonSource
Gets the JSON string for a particular object id. This is called when an object needs to be initialized, and this AbstractJsonSource/JsonReceiver will handle the conversion of the JSON string to an object

Specified by:
getJson in class AbstractJsonSource
Returns:
the JSON string
Throws:
java.lang.Exception

setJson

protected void setJson(java.lang.String resourceName,
                       java.lang.String json)
                throws java.lang.Exception
Specified by:
setJson in class AbstractJsonSource
Throws:
java.lang.Exception

getPathSeparator

public java.lang.String getPathSeparator()
Overrides:
getPathSeparator in class AbstractJsonSource

mapJson

protected void mapJson(PersistableInitializer initializer,
                       java.lang.Object object,
                       java.lang.String objectId)
Overrides:
mapJson in class AbstractJsonSource

idFromJSPONObject

protected ObjectId idFromJSPONObject(java.util.Map object,
                                     ObjectId defaultId)
Specified by:
idFromJSPONObject in class JsonReceiver

getFieldValue

public java.lang.Object getFieldValue(LazyPropertyId valueId)
                               throws java.lang.Exception
Description copied from interface: DataSource
This is called when a field value contains an unfulfilled value (ValueId)

Specified by:
getFieldValue in interface DataSource
Returns:
the real value referred to by valueId
Throws:
java.lang.Exception

initParameters

public void initParameters(java.util.Map<java.lang.String,java.lang.Object> parameters)
Description copied from interface: DataSource
This is called on initialization and provides access to the data source configuration parameters

Specified by:
initParameters in interface DataSource

passThrough

public boolean passThrough()
Specified by:
passThrough in interface PersevereFilter.LocalDataSource

mapQuery

public java.util.Iterator mapQuery(Query query)
                            throws java.lang.Exception
Description copied from interface: DataSource
This is called when an object is being activated to retrieve the persisted data for a given object with a filter

Specified by:
mapQuery in interface DataSource
Returns:
Throws:
java.lang.Exception

newJson

protected void newJson(java.lang.String json)
                throws java.lang.Exception
Specified by:
newJson in class AbstractJsonSource
Throws:
java.lang.Exception