jPOS 1.6.1 API Documentation

org.jpos.space
Class JDBMSpace

java.lang.Object
  extended by java.util.TimerTask
      extended by org.jpos.space.JDBMSpace
All Implemented Interfaces:
java.lang.Runnable, Space

public class JDBMSpace
extends java.util.TimerTask
implements Space

JDBM based persistent space implementation

Since:
1.4.7
Version:
$Revision: 2594 $ $Date: 2008-01-22 08:41:31 -0800 (Tue, 22 Jan 2008) $
Author:
Alejandro Revilla, Kris Leite

Field Summary
static long GCDELAY
           
 
Method Summary
 void close()
          close this space - use with care
 void commit()
          force commit
 void gc()
          garbage collector.
 java.lang.String getKeys()
           
static JDBMSpace getSpace()
           
static JDBMSpace getSpace(java.lang.String name)
          creates a named JDBMSpace (filename used for storage is the same as the given name)
static JDBMSpace getSpace(java.lang.String name, java.lang.String filename)
          creates a named JDBMSpace
 java.lang.Object in(java.lang.Object key)
          Take an entry from the space, waiting forever until one exists.
 java.lang.Object in(java.lang.Object key, long timeout)
          Take an entry from the space, waiting forever until one exists.
 java.lang.Object inp(java.lang.Object key)
          In probe takes an entry from the space if one exists, return null otherwise.
 void out(java.lang.Object key, java.lang.Object value)
          Write a new entry into the Space
 void out(java.lang.Object key, java.lang.Object value, long timeout)
          Write a new entry into the Space The entry will timeout after the specified period
 void push(java.lang.Object key, java.lang.Object value)
          Write a new entry at the head of a queue.
 void push(java.lang.Object key, java.lang.Object value, long timeout)
          Write a new entry into the Space at the head of a queue The entry will timeout after the specified period
 java.lang.Object rd(java.lang.Object key)
          Read an entry from the space, waiting forever until one exists.
 java.lang.Object rd(java.lang.Object key, long timeout)
          Read an entry from the space, waiting a limited amount of time until one exists.
 java.lang.Object rdp(java.lang.Object key)
          Read probe reads an entry from the space if one exists, return null otherwise.
 void rollback()
          force rollback
 void run()
           
 void setAutoCommit(boolean b)
          Use with utmost care and at your own risk.
 long size(java.lang.Object key)
           
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GCDELAY

public static final long GCDELAY
See Also:
Constant Field Values
Method Detail

getSpace

public static final JDBMSpace getSpace()
Returns:
reference to default JDBMSpace

getSpace

public static final JDBMSpace getSpace(java.lang.String name)
creates a named JDBMSpace (filename used for storage is the same as the given name)

Parameters:
name - the Space name
Returns:
reference to named JDBMSpace

getSpace

public static final JDBMSpace getSpace(java.lang.String name,
                                       java.lang.String filename)
creates a named JDBMSpace

Parameters:
name - the Space name
filename - the storage file name
Returns:
reference to named JDBMSpace

setAutoCommit

public void setAutoCommit(boolean b)
Use with utmost care and at your own risk. If you are to perform several operations on the space you should synchronize on the space, i.e:
   synchronized (sp) {
     sp.setAutoCommit (false);
     sp.out (..., ...)
     sp.out (..., ...)
     ...
     ...
     sp.inp (...);
     sp.commit ();    // or sp.rollback ();
     sp.setAutoCommit (true);
   }
 

Parameters:
b - true or false

commit

public void commit()
force commit

See Also:
setAutoCommit(boolean)

rollback

public void rollback()
force rollback

See Also:
setAutoCommit(boolean)

close

public void close()
close this space - use with care


out

public void out(java.lang.Object key,
                java.lang.Object value)
Write a new entry into the Space

Specified by:
out in interface Space
Parameters:
key - Entry's key
value - Object value

out

public void out(java.lang.Object key,
                java.lang.Object value,
                long timeout)
Write a new entry into the Space The entry will timeout after the specified period

Specified by:
out in interface Space
Parameters:
key - Entry's key
value - Object value
timeout - entry timeout in millis

push

public void push(java.lang.Object key,
                 java.lang.Object value)
Description copied from interface: Space
Write a new entry at the head of a queue.

Specified by:
push in interface Space
Parameters:
key - Entry's key
value - Object value

push

public void push(java.lang.Object key,
                 java.lang.Object value,
                 long timeout)
Write a new entry into the Space at the head of a queue The entry will timeout after the specified period

Specified by:
push in interface Space
Parameters:
key - Entry's key
value - Object value
timeout - entry timeout in millis

rdp

public java.lang.Object rdp(java.lang.Object key)
Read probe reads an entry from the space if one exists, return null otherwise.

Specified by:
rdp in interface Space
Parameters:
key - Entry's key
Returns:
value or null

inp

public java.lang.Object inp(java.lang.Object key)
In probe takes an entry from the space if one exists, return null otherwise.

Specified by:
inp in interface Space
Parameters:
key - Entry's key
Returns:
value or null

in

public java.lang.Object in(java.lang.Object key)
Description copied from interface: Space
Take an entry from the space, waiting forever until one exists.

Specified by:
in in interface Space
Parameters:
key - Entry's key
Returns:
value

in

public java.lang.Object in(java.lang.Object key,
                           long timeout)
Take an entry from the space, waiting forever until one exists.

Specified by:
in in interface Space
Parameters:
key - Entry's key
timeout - millis to wait
Returns:
value

rd

public java.lang.Object rd(java.lang.Object key)
Read an entry from the space, waiting forever until one exists.

Specified by:
rd in interface Space
Parameters:
key - Entry's key
Returns:
value

rd

public java.lang.Object rd(java.lang.Object key,
                           long timeout)
Read an entry from the space, waiting a limited amount of time until one exists.

Specified by:
rd in interface Space
Parameters:
key - Entry's key
timeout - millis to wait
Returns:
value or null

size

public long size(java.lang.Object key)
Returns:
aproximately queue size

run

public void run()
Specified by:
run in interface java.lang.Runnable
Specified by:
run in class java.util.TimerTask

gc

public void gc()
garbage collector. removes expired entries


getKeys

public java.lang.String getKeys()

jPOS.org