Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## scone.netobjects
Class NetNodeCache

    java.lang.Object
      java.util.Observable
          scone.netobjects.NetNodeCache

All Implemented Interfaces:
  TableRecordCacheInterface

    public class NetNodeCache

extends java.util.Observable
implements TableRecordCacheInterface

Caches all NetNode objects.
Use the static methods provided by this class to obtain NetNode objects.

Author:
  Harald Weinreich, Volkert Buchmann

Field Summary
`protected static CacheTable` | `cache` key1=id key2=uri
`protected java.util.Vector` | `items`
`static java.lang.Object` | `lock` used to synchronize this cache
`protected static NetNodeCache` | `observable`
`protected static int` | `observePeriod`

Method Summary
`protected void` | `addItem(java.lang.Object o)`
`static void` | `clean()` stores the cached NetNodes and removes empty entries from the cache.
`static NetNode` | `get(NetNode base, java.lang.String link)` get/create a NetNode by NetNodebase and link
`static NetNode` | `get(SimpleUri sUri)` get/create a NetNode by SimpleUri NetNodes are stored only on demand or if cache cleaer (@link{CacheTable}) is running.
`static NetNode` | `get(SimpleUri sUri, boolean persistent)` get/create a NetNode by SimpleUri
`static NetNode` | `get(java.lang.String uriString)` get/create a NetNode by plain String
`static NetNode` | `get(java.lang.String id, boolean persistent)` returns the NetNode stored in the database under the specified id.
`static NetNode` | `getById(java.lang.String id)` returns the NetNode stored in the database under the specified id.
`static int` | `getNetNodeCount(java.lang.String sqlClause)` This method returns a number of NetNodes to a given query string.
`static int` | `getNetNodeCount(java.lang.String tables, java.lang.String sqlClause)` This method returns a number of NetNodes to a given query string.
`static java.util.Vector` | `getNetNodes(java.lang.String sqlClause)` This method returns a Vector of NetNodes to a given query string
`static int` | `getObservePeriod()` returns how long the cache waits until it notifies Observers about new events
`static void` | `init(int timeTillCleanUp, int gcType)` Create a new cache for NetNodes.
`void` | `notifyObservers()`
`static void` | `putObserver(java.util.Observer o)` adds an Observer to the NetNodeCache class.
`static void` | `removeObserver(java.util.Observer o)` removes an Observer from the NetNodeCache class.
`static void` | `setObservePeriod(int period)` sets how long the cache waits until it notifies Observers about new events

Methods inherited from class java.util.Observable
`addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, setChanged`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### observable

    protected static NetNodeCache observable

### observePeriod

    protected static int observePeriod

### cache

    protected static CacheTable cache

  key1=id
  key2=uri

### lock

    public static java.lang.Object lock

  used to synchronize this cache

### items

    protected java.util.Vector items

Method Detail

### init

    public static void init(int timeTillCleanUp,
                            int gcType)

  Create a new cache for NetNodes.

  Parameters:
    `timeTillCleanUp` - Interval to store objects from cache to database
    `gcType` - Garbage collector type: LAZYGC or EAGERGC. See CacheTable.java

### setObservePeriod

    public static void setObservePeriod(int period)

  sets how long the cache waits until it notifies Observers about new events

  Parameters:
    `period` - the period in miliseconds

### getObservePeriod

    public static int getObservePeriod()

  returns how long the cache waits until it notifies Observers about new events

  Returns:
    the peroid in miliseconds

### putObserver

    public static void putObserver(java.util.Observer o)

  adds an Observer to the NetNodeCache class.
  Use this static method instead of addObserver() !

  Parameters:
    `o` - the Observer

### removeObserver

    public static void removeObserver(java.util.Observer o)

  removes an Observer from the NetNodeCache class.
  Use this static method instead of deleteObserver() !

  Parameters:
    `o` - the Observer

### get

    public static NetNode get(java.lang.String uriString)

  get/create a NetNode by plain String

  Parameters:
    `uriString` - the String representation of the URI of the node

### get

    public static NetNode get(NetNode base,
                              java.lang.String link)

  get/create a NetNode by NetNodebase and link

  Parameters:
    `base` - the NetNode of the present page
    `link` - the String declared by the link

### get

    public static NetNode get(SimpleUri sUri)

  get/create a NetNode by SimpleUri
  NetNodes are stored only on demand or if cache cleaer (@link{CacheTable}) is running. This Method does not changethe state of NetNodes (persistent / non-persistent) of NetNodes already cached.

  If the netNode shall be made persistent immediately, call get(SimpleUri, true).
  If new NetNodes shall not be made persistent, call get(SimpleUri, false).
  To explicitly change the state of a NetNode call @link{TableRecord#setPersistent}

  Parameters:
    `sUri` - the URI

### get

    public static NetNode get(SimpleUri sUri,
                              boolean persistent)

  get/create a NetNode by SimpleUri

  Parameters:
    `sUri` - the URI
    `persistent` - shall the NetNode be made persistent?
    true: yes, write NOW to database
    false: no, never. netNode.setPersistent is set to false
    For deferred DB persistency call get-method without boolean parameter.

### getById

    public static NetNode getById(java.lang.String id)

  returns the NetNode stored in the database under the specified id.

  Parameters:
    `id` - the id
  Returns:
    the NetNode or null if it does not exist

### get

    public static NetNode get(java.lang.String id,
                              boolean persistent)

  returns the NetNode stored in the database under the specified id.

  Parameters:
    `sUri` - the URI
    `persistent` - shall the NetNode be made persistent?
    true: yes, now,
    false: no never.
    For deferred DB persistency call get-method without boolean parameter.

### getNetNodes

    public static java.util.Vector getNetNodes(java.lang.String sqlClause)

  This method returns a Vector of NetNodes to a given query string

  Parameters:
    `sqlClause` - The where clause for the query string.

### getNetNodeCount

    public static int getNetNodeCount(java.lang.String tables,
                                      java.lang.String sqlClause)

  This method returns a number of NetNodes to a given query string.

  Parameters:
    `tables` - The table names.
    `sqlClause` - The where clause for the query string.
  Returns:
    The number of nodes.

### getNetNodeCount

    public static int getNetNodeCount(java.lang.String sqlClause)

  This method returns a number of NetNodes to a given query string.

  Parameters:
    `sqlClause` - The where clause for the query string.
  Returns:
    The number of nodes.

### clean

    public static void clean()

  stores the cached NetNodes and removes empty entries from the cache.

### addItem

    protected void addItem(java.lang.Object o)

### notifyObservers

    public void notifyObservers()

  Overrides:
    `notifyObservers` in class `java.util.Observable`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD