net.jini.space
Interface JavaSpace


public abstract interface JavaSpace

This interface is implemented by servers that export a JavaSpaces(TM) technology service. The operations in this interface are the public methods that all such spaces support.

See Also:
Entry

Field Summary
static long NO_WAIT
          Wait for no time at all.
 
Method Summary
 EventRegistration notify(Entry tmpl, Transaction txn, RemoteEventListener listener, long lease, java.rmi.MarshalledObject handback)
          When entries are written that match this template notify the given listener with a RemoteEvent that includes the handback object.
 Entry read(Entry tmpl, Transaction txn, long timeout)
          Read any matching entry from the space, blocking until one exists.
 Entry readIfExists(Entry tmpl, Transaction txn, long timeout)
          Read any matching entry from the space, returning null if there is currently is none.
 Entry snapshot(Entry e)
          Return a snapshot of the given entry.
 Entry take(Entry tmpl, Transaction txn, long timeout)
          Take a matching entry from the space, waiting until one exists.
 Entry takeIfExists(Entry tmpl, Transaction txn, long timeout)
          Take a matching entry from the space, returning null if there is currently is none.
 Lease write(Entry entry, Transaction txn, long lease)
          Write a new entry into the space.
 

Field Detail

NO_WAIT

public static final long NO_WAIT
Wait for no time at all. This is used as a timeout value in various read and take calls.
See Also:
read(net.jini.core.entry.Entry, net.jini.core.transaction.Transaction, long), readIfExists(net.jini.core.entry.Entry, net.jini.core.transaction.Transaction, long), take(net.jini.core.entry.Entry, net.jini.core.transaction.Transaction, long), takeIfExists(net.jini.core.entry.Entry, net.jini.core.transaction.Transaction, long)
Method Detail

write

public Lease write(Entry entry,
                   Transaction txn,
                   long lease)
            throws TransactionException,
                   java.lang.SecurityException,
                   java.rmi.RemoteException
Write a new entry into the space.
Throws:
TransactionException - A transaction error occurred

read

public Entry read(Entry tmpl,
                  Transaction txn,
                  long timeout)
           throws UnusableEntryException,
                  TransactionException,
                  java.lang.SecurityException,
                  java.lang.InterruptedException,
                  java.rmi.RemoteException
Read any matching entry from the space, blocking until one exists. Return null if the timeout expires.
Parameters:
tmpl - The template used for matching. Matching is done against tmpl with blank fields being wildcards ("match anything") other fields being values ("match exactly on the serialized form").
txn - The transaction (if any) under which to work.
timeout - How long the client is willing to wait for a transactionally proper matching entry. A timeout of NO_WAIT means to wait no time at all; this is equivalent to a wait of zero.
Throws:
TransactionException - A transaction error occurred

readIfExists

public Entry readIfExists(Entry tmpl,
                          Transaction txn,
                          long timeout)
                   throws UnusableEntryException,
                          TransactionException,
                          java.lang.SecurityException,
                          java.lang.InterruptedException,
                          java.rmi.RemoteException
Read any matching entry from the space, returning null if there is currently is none. Matching and timeouts are done as in read, except that blocking in this call is done only if necessary to wait for transactional state to settle.
Throws:
TransactionException - A transaction error occurred
See Also:
read(net.jini.core.entry.Entry, net.jini.core.transaction.Transaction, long)

take

public Entry take(Entry tmpl,
                  Transaction txn,
                  long timeout)
           throws UnusableEntryException,
                  TransactionException,
                  java.lang.SecurityException,
                  java.lang.InterruptedException,
                  java.rmi.RemoteException
Take a matching entry from the space, waiting until one exists. Matching is and timeout done as for read.
Throws:
TransactionException - A transaction error occurred
See Also:
read(net.jini.core.entry.Entry, net.jini.core.transaction.Transaction, long)

takeIfExists

public Entry takeIfExists(Entry tmpl,
                          Transaction txn,
                          long timeout)
                   throws UnusableEntryException,
                          TransactionException,
                          java.lang.SecurityException,
                          java.lang.InterruptedException,
                          java.rmi.RemoteException
Take a matching entry from the space, returning null if there is currently is none. Matching is and timeout done as for read, except that blocking in this call is done only if necessary to wait for transactional state to settle.
Throws:
TransactionException - A transaction error occurred
See Also:
read(net.jini.core.entry.Entry, net.jini.core.transaction.Transaction, long)

notify

public EventRegistration notify(Entry tmpl,
                                Transaction txn,
                                RemoteEventListener listener,
                                long lease,
                                java.rmi.MarshalledObject handback)
                         throws TransactionException,
                                java.lang.SecurityException,
                                java.rmi.RemoteException
When entries are written that match this template notify the given listener with a RemoteEvent that includes the handback object. Matching is done as for read.
See Also:
read(net.jini.core.entry.Entry, net.jini.core.transaction.Transaction, long), EventRegistration

snapshot

public Entry snapshot(Entry e)
               throws java.rmi.RemoteException
Return a snapshot of the given entry. The snapshot can be used anywhere the original entry can be, and will maintain the same value as the original entry, even if the entry is modified after the snapshot is taken. The implementation of the JavaSpace interface the snapshot more efficient to use than repeated uses of the original entry.

Using a snapshot with a different space than the one that produced it yields unpredictable results.



Copyright © 1999 Sun Microsystems, Inc. All rights reserved