net.methodyne.bellvue.store
Class DataLayer

java.lang.Object
  extended bynet.methodyne.bellvue.store.DataLayer

public class DataLayer
extends java.lang.Object

The datastore functions for inserting, update, delete and locking are accessible by this.

Version:
1.0
Date: 11.08.2003
Time: 15:54:20
copyright Methodyne GmbH, Zug - Switzerland.
Author:
Andreas Reiss

Field Summary
 net.methodyne.bellvue.store.MemStore memStore
           
 
Constructor Summary
DataLayer(java.lang.String dir)
          Creates and initialises a new in memory datastore
 
Method Summary
 void addAll(Sdata sd, java.util.Collection c, java.lang.String name)
           
 void delete(Sdata sd, java.lang.Object x)
          Delete
 Finder fetch(Finder x, Sdata sd)
          Retrieve data from the store via the given Finder
 long getObjectCount()
          Count all objects in the Store
 java.lang.Object getRefObjects(java.lang.Object x, Sdata sd)
          Used to restore the referenced objects in collections or references.
 void init()
          Initialise supporting Hashes
 int lockType(java.lang.Object y, Sdata sd)
          This attempts to put a lock for this object and returns the locktype
 boolean permitted(Sdata sd, java.lang.String name)
          Checks is the user in sd.user is allowed to access the Bclass given by name
 void repAll(Sdata sd, java.util.Collection c, java.lang.String name)
           
 java.lang.Object retrieve(Sdata sd, java.lang.String name, long reference)
          Retrieves an object and locks it.
 java.lang.Object retrieve(Sdata sd, java.lang.String name, long reference, boolean unlocked)
          Retrieves an object without locking it.
 java.lang.Object retrieveNext(Sdata sd, java.lang.Object x)
          To enable navigation from one object to the next in store.
 java.lang.Object retrievePrevious(Sdata sd, java.lang.Object x)
          To enable navigation from one object to the next in store.
 void store(Sdata sd, java.lang.Object x)
          Store an object and set the lock for the user in sd.user
 void store(Sdata sd, java.lang.Object x, boolean bulk)
          Used by the bulk object only - do not use this in your application!
 void storeUnlocked(Sdata sd, java.lang.Object x)
          Store an object without setting a lock.
 void takeState()
          Dumps the data from memory to disk.
 void unlock(java.lang.Object o, Sdata sd)
          Explicitly unlocks an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

memStore

public net.methodyne.bellvue.store.MemStore memStore
Constructor Detail

DataLayer

public DataLayer(java.lang.String dir)
Creates and initialises a new in memory datastore

Parameters:
dir - the directory to persist data on disk
Method Detail

init

public void init()
Initialise supporting Hashes


store

public void store(Sdata sd,
                  java.lang.Object x,
                  boolean bulk)
Used by the bulk object only - do not use this in your application!

Parameters:
sd -
x -
bulk -

storeUnlocked

public void storeUnlocked(Sdata sd,
                          java.lang.Object x)
Store an object without setting a lock.

Parameters:
sd -
x -

store

public void store(Sdata sd,
                  java.lang.Object x)
Store an object and set the lock for the user in sd.user

Parameters:
sd -
x -

delete

public void delete(Sdata sd,
                   java.lang.Object x)
Delete

Parameters:
sd -
x -

fetch

public Finder fetch(Finder x,
                    Sdata sd)
Retrieve data from the store via the given Finder

Parameters:
x -
sd -
Returns:
the given finder

retrieve

public java.lang.Object retrieve(Sdata sd,
                                 java.lang.String name,
                                 long reference,
                                 boolean unlocked)
Retrieves an object without locking it.

Parameters:
sd - the session data
name - of the Bclass
reference - the id
unlocked -
Returns:
The object with the given reference (id) or null.

retrieve

public java.lang.Object retrieve(Sdata sd,
                                 java.lang.String name,
                                 long reference)
Retrieves an object and locks it. Like a get by id

Parameters:
sd -
name -
reference -
Returns:
The object with the given reference (id) or null.

retrieveNext

public java.lang.Object retrieveNext(Sdata sd,
                                     java.lang.Object x)
To enable navigation from one object to the next in store.

Parameters:
sd -
x -
Returns:
the object with the next higher id

retrievePrevious

public java.lang.Object retrievePrevious(Sdata sd,
                                         java.lang.Object x)
To enable navigation from one object to the next in store.

Parameters:
sd -
x -
Returns:
the object with the next lower id

addAll

public void addAll(Sdata sd,
                   java.util.Collection c,
                   java.lang.String name)

repAll

public void repAll(Sdata sd,
                   java.util.Collection c,
                   java.lang.String name)

takeState

public void takeState()
Dumps the data from memory to disk. This gets done periodically by default.
The interval can be configured in web.xml with StateWriteScheduleSeconds in the MainServlet section.
The data gets serialized and compressed with gzip on the fly for efficiency.


getObjectCount

public long getObjectCount()
Count all objects in the Store

Returns:

permitted

public boolean permitted(Sdata sd,
                         java.lang.String name)
Checks is the user in sd.user is allowed to access the Bclass given by name

Parameters:
sd - session data
name - Bclass name
Returns:
true if permitted, false otherwise

unlock

public void unlock(java.lang.Object o,
                   Sdata sd)
Explicitly unlocks an object. This has to be called when finished with an object or it will be locked for others.

Parameters:
o - object to unlock
sd - the session data

lockType

public int lockType(java.lang.Object y,
                    Sdata sd)
This attempts to put a lock for this object and returns the locktype

Parameters:
y - object to check
sd -
Returns:

0 EXRW locker = this user locked it in mode exclusive read and write
1 EXRW other = object is locked by another user
2 EXW locker = this user locked it in mode exclusive write
3 EXW other = object is locked by another user
4 OFF = locking is turned off for this bclass
5 unknown object type

getRefObjects

public java.lang.Object getRefObjects(java.lang.Object x,
                                      Sdata sd)
Used to restore the referenced objects in collections or references.

Parameters:
x -
sd -
Returns:
the given object


Copyright © 2003 Methodyne GmbH, Zug Switzerland. All Rights Reserved.