RAFo C/S

RandomAccessFile for Objects

com.linxpda.raf.server
Class RAFoRMIServer

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--com.linxpda.raf.server.RAFoRMIServer
All Implemented Interfaces:
java.rmi.Remote, RemoteFile, java.io.Serializable

public class RAFoRMIServer
extends java.rmi.server.UnicastRemoteObject
implements RemoteFile

The RMI server used to allow multiple clients to access RAFo files on a remote server. The RAFoRMIServer is capable of opening multiple RAFo files simultaneously and providing access to these files to multiple clients in a thread safe manner. Thus, only one instance of RAFoRMIServer ever needs to be run on a server to provide access to every RAFo data file on the server to every client on the network.

See Also:
Serialized Form

Constructor Summary
RAFoRMIServer()
          Initializes the RAFoRMIServer.
 
Method Summary
 void close(java.lang.String dbName)
          Closes the RAFo file running the given file.
 boolean containsKey(java.lang.String dbName, java.lang.String key)
          Test for the given key in the given file.
 java.util.Enumeration getKeys(java.lang.String dbName)
          Returns an Enumeration of all keys in the given file.
 java.lang.Object getObject(java.lang.String dbName, java.lang.String key)
          Returns the object associated with the given key in the given data file.
 int getObjectCount(java.lang.String dbName)
          Returns an int of the total number of objects stored in the given file.
 void insertObject(java.lang.String dbName, java.lang.String key, java.lang.Object value)
          Inserts the given object into the given data file and associates it with the given key.
static void main(java.lang.String[] args)
          Runs the RAFoRMIServer utility, creating a new instance and binding it to the rmiregistry.
 void open(java.lang.String dbName)
          Opens a new RAFo file and adds it to the list of available RAFo files.
 void removeObject(java.lang.String dbName, java.lang.String key)
          Removes the object associated with the given key in the given data file.
 void updateObject(java.lang.String dbName, java.lang.String key, java.lang.Object value)
          Replaces the object associated with the given key in the given file with the new Object value.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RAFoRMIServer

public RAFoRMIServer()
              throws java.rmi.RemoteException
Initializes the RAFoRMIServer.

NOTE: Do not call the constructor directly. Rather use the main method to start the server. The main method provides automatic binding to an rmiregistry.

Method Detail

open

public void open(java.lang.String dbName)
          throws java.rmi.RemoteException,
                 java.io.IOException,
                 RAFException
Opens a new RAFo file and adds it to the list of available RAFo files. Future access is gained to these files by providing the dbName as the first parameter in method calls against a remote RAFo object.

Note: The client does not have direct access to remote method calls. They are handled automatically by the remote instance obtained through a call to the RAFo.getRemoteInstance method.

Specified by:
open in interface RemoteFile

close

public void close(java.lang.String dbName)
           throws java.rmi.RemoteException,
                  java.io.IOException,
                  RAFException
Closes the RAFo file running the given file.
Specified by:
close in interface RemoteFile
See Also:
RAFo.close

getObject

public java.lang.Object getObject(java.lang.String dbName,
                                  java.lang.String key)
                           throws java.rmi.RemoteException,
                                  java.io.IOException,
                                  java.lang.ClassNotFoundException,
                                  RAFException
Returns the object associated with the given key in the given data file.
Specified by:
getObject in interface RemoteFile
See Also:
RAFo.getObject

removeObject

public void removeObject(java.lang.String dbName,
                         java.lang.String key)
                  throws java.rmi.RemoteException,
                         java.io.IOException,
                         RAFException
Removes the object associated with the given key in the given data file.
Specified by:
removeObject in interface RemoteFile
See Also:
RAFo.removeObject

insertObject

public void insertObject(java.lang.String dbName,
                         java.lang.String key,
                         java.lang.Object value)
                  throws java.rmi.RemoteException,
                         java.io.IOException,
                         RAFException
Inserts the given object into the given data file and associates it with the given key.
Specified by:
insertObject in interface RemoteFile
See Also:
RAFo.insertObject

updateObject

public void updateObject(java.lang.String dbName,
                         java.lang.String key,
                         java.lang.Object value)
                  throws java.rmi.RemoteException,
                         java.io.IOException,
                         RAFException
Replaces the object associated with the given key in the given file with the new Object value.
Specified by:
updateObject in interface RemoteFile
See Also:
RAFo.updateObject

containsKey

public boolean containsKey(java.lang.String dbName,
                           java.lang.String key)
                    throws java.rmi.RemoteException,
                           RAFException
Test for the given key in the given file.
Specified by:
containsKey in interface RemoteFile
See Also:
RAFo.containsKey

getKeys

public java.util.Enumeration getKeys(java.lang.String dbName)
                              throws java.rmi.RemoteException,
                                     RAFException
Returns an Enumeration of all keys in the given file.
Specified by:
getKeys in interface RemoteFile
See Also:
RAFo.getKeys

getObjectCount

public int getObjectCount(java.lang.String dbName)
                   throws java.rmi.RemoteException,
                          RAFException
Returns an int of the total number of objects stored in the given file.
Specified by:
getObjectCount in interface RemoteFile
See Also:
RAFo.getObjectCount

main

public static void main(java.lang.String[] args)
Runs the RAFoRMIServer utility, creating a new instance and binding it to the rmiregistry. If no arguments are supplied the server will be bound as remote "RAFo" on port '1099'. Arguments are in the order 'remotename' 'port':
java com.linxpda.raf.server.RAFoRMIServer

(c)2001 Linxpda, Inc. www.linxpda.com