autohit.universe
Interface Universe

All Known Implementing Classes:
UniverseLocal

public interface Universe

Universe server interface. The locking mechinism is optional.

Version:
1.0 Version History EPG - New - 18Apr03
Author:
Erich P. Gatejen

Method Summary
 void close()
          This will always be called when the universe is destroyed
 void discard(java.lang.String name)
          Discard an object.
 boolean exists(java.lang.String name)
          Check to see if an object exists
 void flush(java.lang.String name)
          Flush an object.
 void genesis(UniverseProperties props)
          This will always be called when the universe server is created.
 java.lang.Object get(java.lang.String name)
          Load an object from the universe.
 javax.activation.DataSource getDataSource(java.lang.String name)
          Get a DataSource that can interact with this universe object
 javax.activation.FileDataSource getFileDataSource(java.lang.String name)
          Get a FileDataSource that can interact with this universe object.
 java.io.InputStream getStream(java.lang.String name)
          Get an InputStream that can read from a universe object
 java.lang.Object getUnique(java.lang.String name)
          Load an object from the universe.
 boolean isLocked(java.lang.String name)
          Check to see if the object is locked
 void lock(java.lang.String name)
          Lock an object.
 boolean lockIfNotLocked(java.lang.String name)
          Lock an object.
 void put(java.lang.String name, java.lang.Object o)
          Save an object into the universe.
 java.io.OutputStream putStream(java.lang.String name)
          Get an output stream to a universe object.
 void release(java.lang.String name)
          Release a lock on an object.
 void remove(java.lang.String name)
          Remove an object from the universe
 java.lang.String reserveUnique(java.lang.String base)
          Reserve unique object universe.
 long size(java.lang.String name)
          Report the size object from the universe
 

Method Detail

genesis

public void genesis(UniverseProperties props)
             throws UniverseException
This will always be called when the universe server is created. It is the one and only chance to get a reference to the properties file and do any post-construction setup.

Parameters:
props - a universe property set
Returns:
the loaded object
Throws:
UniverseException
See Also:
UniverseProperties

close

public void close()
           throws UniverseException
This will always be called when the universe is destroyed

Throws:
UniverseException

get

public java.lang.Object get(java.lang.String name)
                     throws UniverseException
Load an object from the universe. (Not a class! It is possible that this is a shared, loaded object. That is up to the implimentor.)

Parameters:
name - universe name
Returns:
the loaded object
Throws:
UniverseException

getUnique

public java.lang.Object getUnique(java.lang.String name)
                           throws UniverseException
Load an object from the universe. Guarantee it is a unique instance of it.

Parameters:
name - universe name
Returns:
the loaded object
Throws:
UniverseException

reserveUnique

public java.lang.String reserveUnique(java.lang.String base)
                               throws UniverseException
Reserve unique object universe. Guarantee it is a unique instance of it. Great for temp objects.

Parameters:
base - base path for the object (including root object name)
Returns:
name of the reserved unique object.
Throws:
UniverseException

getStream

public java.io.InputStream getStream(java.lang.String name)
                              throws UniverseException
Get an InputStream that can read from a universe object

Parameters:
name - universe name
Returns:
a stream to the object
Throws:
UniverseException

getDataSource

public javax.activation.DataSource getDataSource(java.lang.String name)
                                          throws UniverseException
Get a DataSource that can interact with this universe object

Parameters:
name - universe name
Returns:
a data source
Throws:
UniverseException

getFileDataSource

public javax.activation.FileDataSource getFileDataSource(java.lang.String name)
                                                  throws UniverseException
Get a FileDataSource that can interact with this universe object. The universe must handle making sure the object at least appears local to the FileDataSource

Parameters:
name - universe name
Returns:
a data source
Throws:
UniverseException

put

public void put(java.lang.String name,
                java.lang.Object o)
         throws UniverseException
Save an object into the universe. It should use standard serialization. If this won't work correctly, then serialize it yourself to saveStream(String name, OutputStream s).

Parameters:
name - universe name
o - the object
Throws:
UniverseException

putStream

public java.io.OutputStream putStream(java.lang.String name)
                               throws UniverseException
Get an output stream to a universe object. Caller responsible for streaming and closing.

Parameters:
name - universe name
Returns:
a stream to the object
Throws:
UniverseException

lock

public void lock(java.lang.String name)
          throws UniverseException
Lock an object. This is blocking.

Parameters:
name - universe name
Throws:
UniverseException

lockIfNotLocked

public boolean lockIfNotLocked(java.lang.String name)
                        throws UniverseException
Lock an object. This is NON blocking.

Parameters:
name - universe name
Returns:
true if lock completed, false is already locked
Throws:
UniverseException

isLocked

public boolean isLocked(java.lang.String name)
                 throws UniverseException
Check to see if the object is locked

Parameters:
name - universe name
Returns:
true if the object is locked, otherwise false
Throws:
UniverseException

release

public void release(java.lang.String name)
             throws UniverseException
Release a lock on an object.

Parameters:
name - universe name
Throws:
UniverseException

exists

public boolean exists(java.lang.String name)
               throws UniverseException
Check to see if an object exists

Parameters:
name - universe name
Returns:
true if the object exists, otherwise false
Throws:
UniverseException

flush

public void flush(java.lang.String name)
           throws UniverseException
Flush an object. Typically not useful unless caching is implemented

Parameters:
name - universe name
Returns:
true if the object exists, otherwise false
Throws:
UniverseException

discard

public void discard(java.lang.String name)
             throws UniverseException
Discard an object. Typically not useful unless caching is implemented

Parameters:
name - universe name
Returns:
true if the object exists, otherwise false
Throws:
UniverseException

remove

public void remove(java.lang.String name)
            throws UniverseException
Remove an object from the universe

Parameters:
name - universe name
Returns:
true if the object exists, otherwise false
Throws:
UniverseException

size

public long size(java.lang.String name)
          throws UniverseException
Report the size object from the universe

Parameters:
name - universe name
Returns:
the size or 0 if empty
Throws:
UniverseException


Test.