public interface JavaSpace
Entry
Modifier and Type | Field and Description |
---|---|
static long |
NO_WAIT
Wait for no time at all.
|
Modifier and Type | Method and Description |
---|---|
EventRegistration |
notify(Entry tmpl,
Transaction txn,
RemoteEventListener listener,
long lease,
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)
The process of serializing an entry for transmission to a JavaSpaces service will be
identical if the same entry is used twice.
|
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.
|
static final long NO_WAIT
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)
,
Constant Field ValuesLease write(Entry entry, Transaction txn, long lease) throws TransactionException, RemoteException
IPojoSpace.write(Object, Transaction, long, long,
int)
with UpdateModifiers.WRITE_ONLY
.entry
- the entry to writetxn
- the transaction object, if any, under which to perform the writelease
- the requested lease time, in millisecondsTransactionException
- if a transaction error occursRemoteException
- if a communication error occursEntry read(Entry tmpl, Transaction txn, long timeout) throws UnusableEntryException, TransactionException, InterruptedException, RemoteException
null
if the timeout expires.tmpl
- The template used for matching. Matching is done against tmpl
with null
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.UnusableEntryException
- if any serialized field of the entry being read cannot be
deserialized for any reasonTransactionException
- if a transaction error occursInterruptedException
- if the thread in which the read occurs is interruptedRemoteException
- if a communication error occursIllegalArgumentException
- if a negative timeout value is usedEntry readIfExists(Entry tmpl, Transaction txn, long timeout) throws UnusableEntryException, TransactionException, InterruptedException, RemoteException
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.tmpl
- The template used for matching. Matching is done against tmpl
with null
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.UnusableEntryException
- if any serialized field of the entry being read cannot be
deserialized for any reasonTransactionException
- if a transaction error occursInterruptedException
- if the thread in which the read occurs is interruptedRemoteException
- if a communication error occursIllegalArgumentException
- if a negative timeout value is usedread(net.jini.core.entry.Entry, net.jini.core.transaction.Transaction, long)
Entry take(Entry tmpl, Transaction txn, long timeout) throws UnusableEntryException, TransactionException, InterruptedException, RemoteException
read
.tmpl
- The template used for matching. Matching is done against tmpl
with null
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.UnusableEntryException
- if any serialized field of the entry being read cannot be
deserialized for any reasonTransactionException
- if a transaction error occursInterruptedException
- if the thread in which the take occurs is interruptedRemoteException
- if a communication error occursIllegalArgumentException
- if a negative timeout value is usedread(net.jini.core.entry.Entry, net.jini.core.transaction.Transaction, long)
Entry takeIfExists(Entry tmpl, Transaction txn, long timeout) throws UnusableEntryException, TransactionException, InterruptedException, RemoteException
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.tmpl
- The template used for matching. Matching is done against tmpl
with null
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.UnusableEntryException
- if any serialized field of the entry being read cannot be
deserialized for any reasonTransactionException
- if a transaction error occursInterruptedException
- if the thread in which the take occurs is interruptedRemoteException
- if a communication error occursIllegalArgumentException
- if a negative timeout value is usedread(net.jini.core.entry.Entry, net.jini.core.transaction.Transaction, long)
EventRegistration notify(Entry tmpl, Transaction txn, RemoteEventListener listener, long lease, MarshalledObject handback) throws TransactionException, RemoteException
listener
with
a RemoteEvent
that includes the handback
object. Matching is done
as for read
.tmpl
- The template used for matching. Matching is done against tmpl
with null
fields being wildcards ("match anything") other fields
being values ("match exactly on the serialized form").txn
- The transaction (if any) under which to work.listener
- The remote event listener to notify.lease
- the requested lease time, in millisecondshandback
- An object to send to the listener as part of the event notification.TransactionException
- if a transaction error occursRemoteException
- if a communication error occursIllegalArgumentException
- if the lease time requested is not Lease.ANY and is
negativeread(net.jini.core.entry.Entry, net.jini.core.transaction.Transaction, long)
,
EventRegistration
Entry snapshot(Entry e) throws RemoteException
read
or take
.
The client-side implementations of read
and take
cannot reasonably
avoid this duplicated effort, since they have no efficient way of checking whether the same
template is being used without intervening modification.
The snapshot
method gives the JavaSpaces service implementor a way to reduce the
impact of repeated use of the same entry. Invoking snapshot
with an
Entry
will return another Entry
object that contains a
snapshot of the original entry. Using the returned snapshot entry is equivalent to
using the unmodified original entry in all operations on the same JavaSpaces service.
Modifications to the original entry will not affect the snapshot. You can
snapshot
a null
template; snapshot
may or may not
return null given a null
template.
The entry returned from snapshot
will be guaranteed equivalent to the original
unmodified object only when used with the space. Using the snapshot with any other JavaSpaces
service will generate an IllegalArgumentException
unless the other space can use
it because of knowledge about the JavaSpaces service that generated the snapshot. The
snapshot will be a different object from the original, may or may not have the same hash
code, and equals
may or may not return true
when invoked with the
original object, even if the original object is unmodified.
A snapshot is guaranteed to work only within the virtual machine in which it was generated.
If a snapshot is passed to another virtual machine (for example, in a parameter of an RMI
call), using it--even with the same JavaSpaces service--may generate an
IllegalArgumentException
.e
- the entry to take a snapshot of.RemoteException
- if a communication error occursCopyright © GigaSpaces.