casa.JION.space
Class JavaSpace

java.lang.Object
  extended by casa.JION.space.JavaSpace
All Implemented Interfaces:
net.jini.space.JavaSpace

public class JavaSpace
extends java.lang.Object
implements net.jini.space.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.

Author:
Sun Microsystems, Inc.
See Also:
Entry

Nested Class Summary
 class JavaSpace.MyProcessor
          The Class MyProcessor.
 class JavaSpace.MyProcessor_Notify
          The Class MyProcessor_Notify.
 
Field Summary
 
Fields inherited from interface net.jini.space.JavaSpace
NO_WAIT
 
Method Summary
 Entry detail(java.lang.String id)
          This function will print all the fields of a specific entry.
 void doCancel(Lease lease)
          This function can be called only by Lease.cancel() function.
 void doRenew(Lease lease)
          This function can be called only by Lease.renew() function.
 Lease getLease(java.lang.String id)
          This function retrieve the specific lease from the lease directory.
 void listEntries(java.io.PrintStream out)
          This function will print a list of entries exist on the local space.
 void listNotifies(java.io.PrintStream out)
          This function will print a list of entries exist on the local space.
static void main(java.lang.String[] args)
          The main method.
 net.jini.core.event.EventRegistration notify(net.jini.core.entry.Entry tmpl, net.jini.core.transaction.Transaction txn, net.jini.core.event.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.
 void outOffDate()
          Out off date.
 net.jini.core.entry.Entry read(net.jini.core.entry.Entry tmpl, net.jini.core.transaction.Transaction txn, long timeout)
          Read any matching entry from the space, blocking until one exists.
 net.jini.core.entry.Entry readIfExists(net.jini.core.entry.Entry tmpl, net.jini.core.transaction.Transaction txn, long timeout)
          Read any matching entry from the space, returning null if there is currently is none.
 net.jini.core.entry.Entry snapshot(net.jini.core.entry.Entry e)
          The process of serializing an entry for transmission to a JavaSpaces service will be identical if the same entry is used twice.
 net.jini.core.entry.Entry take(net.jini.core.entry.Entry tmpl, net.jini.core.transaction.Transaction txn, long timeout)
          Take a matching entry from the space, waiting until one exists.
 net.jini.core.entry.Entry takeIfExists(net.jini.core.entry.Entry tmpl, net.jini.core.transaction.Transaction txn, long timeout)
          Take a matching entry from the space, returning null if there is currently is none.
 net.jini.core.lease.Lease write(net.jini.core.entry.Entry entry, net.jini.core.transaction.Transaction txn, long lease)
          Write a new entry into the space.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

write

public net.jini.core.lease.Lease write(net.jini.core.entry.Entry entry,
                                       net.jini.core.transaction.Transaction txn,
                                       long lease)
                                throws net.jini.core.transaction.TransactionException,
                                       java.rmi.RemoteException
Write a new entry into the space.

Specified by:
write in interface net.jini.space.JavaSpace
Parameters:
entry - the entry to write
txn - the transaction object, if any, under which to perform the write
lease - the requested lease time, in milliseconds
Returns:
a lease for the entry that was written to the space
Throws:
net.jini.core.transaction.TransactionException - if a transaction error occurs
java.rmi.RemoteException - if a communication error occurs

take

public net.jini.core.entry.Entry take(net.jini.core.entry.Entry tmpl,
                                      net.jini.core.transaction.Transaction txn,
                                      long timeout)
                               throws net.jini.core.entry.UnusableEntryException,
                                      net.jini.core.transaction.TransactionException,
                                      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.

Specified by:
take in interface net.jini.space.JavaSpace
Parameters:
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.
Returns:
the entry taken from the space
Throws:
net.jini.core.entry.UnusableEntryException - if any serialized field of the entry being read cannot be deserialized for any reason
net.jini.core.transaction.TransactionException - if a transaction error occurs
java.lang.InterruptedException - if the thread in which the take occurs is interrupted
java.rmi.RemoteException - if a communication error occurs
java.lang.IllegalArgumentException - if a negative timeout value is used
See Also:
read(net.jini.core.entry.Entry, net.jini.core.transaction.Transaction, long)

read

public net.jini.core.entry.Entry read(net.jini.core.entry.Entry tmpl,
                                      net.jini.core.transaction.Transaction txn,
                                      long timeout)
                               throws net.jini.core.entry.UnusableEntryException,
                                      net.jini.core.transaction.TransactionException,
                                      java.lang.InterruptedException,
                                      java.rmi.RemoteException
Read any matching entry from the space, blocking until one exists. Return null if the timeout expires.

Specified by:
read in interface net.jini.space.JavaSpace
Parameters:
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.
Returns:
a copy of the entry read from the space
Throws:
net.jini.core.entry.UnusableEntryException - if any serialized field of the entry being read cannot be deserialized for any reason
net.jini.core.transaction.TransactionException - if a transaction error occurs
java.lang.InterruptedException - if the thread in which the read occurs is interrupted
java.rmi.RemoteException - if a communication error occurs
java.lang.IllegalArgumentException - if a negative timeout value is used

readIfExists

public net.jini.core.entry.Entry readIfExists(net.jini.core.entry.Entry tmpl,
                                              net.jini.core.transaction.Transaction txn,
                                              long timeout)
                                       throws net.jini.core.entry.UnusableEntryException,
                                              net.jini.core.transaction.TransactionException,
                                              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.

Specified by:
readIfExists in interface net.jini.space.JavaSpace
Parameters:
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.
Returns:
a copy of the entry read from the space
Throws:
net.jini.core.entry.UnusableEntryException - if any serialized field of the entry being read cannot be deserialized for any reason
net.jini.core.transaction.TransactionException - if a transaction error occurs
java.lang.InterruptedException - if the thread in which the read occurs is interrupted
java.rmi.RemoteException - if a communication error occurs
java.lang.IllegalArgumentException - if a negative timeout value is used
See Also:
read(net.jini.core.entry.Entry, net.jini.core.transaction.Transaction, long)

takeIfExists

public net.jini.core.entry.Entry takeIfExists(net.jini.core.entry.Entry tmpl,
                                              net.jini.core.transaction.Transaction txn,
                                              long timeout)
                                       throws net.jini.core.entry.UnusableEntryException,
                                              net.jini.core.transaction.TransactionException,
                                              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.

Specified by:
takeIfExists in interface net.jini.space.JavaSpace
Parameters:
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.
Returns:
the entry taken from the space
Throws:
net.jini.core.entry.UnusableEntryException - if any serialized field of the entry being read cannot be deserialized for any reason
net.jini.core.transaction.TransactionException - if a transaction error occurs
java.lang.InterruptedException - if the thread in which the take occurs is interrupted
java.rmi.RemoteException - if a communication error occurs
java.lang.IllegalArgumentException - if a negative timeout value is used
See Also:
read(net.jini.core.entry.Entry, net.jini.core.transaction.Transaction, long)

notify

public net.jini.core.event.EventRegistration notify(net.jini.core.entry.Entry tmpl,
                                                    net.jini.core.transaction.Transaction txn,
                                                    net.jini.core.event.RemoteEventListener listener,
                                                    long lease,
                                                    java.rmi.MarshalledObject handback)
                                             throws net.jini.core.transaction.TransactionException,
                                                    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.

Specified by:
notify in interface net.jini.space.JavaSpace
Parameters:
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 milliseconds
handback - An object to send to the listener as part of the event notification.
Returns:
the event registration to the the registrant
Throws:
net.jini.core.transaction.TransactionException - if a transaction error occurs
java.rmi.RemoteException - if a communication error occurs
java.lang.IllegalArgumentException - if the lease time requested is not Lease.ANY and is negative
See Also:
read(net.jini.core.entry.Entry, net.jini.core.transaction.Transaction, long), EventRegistration

snapshot

public net.jini.core.entry.Entry snapshot(net.jini.core.entry.Entry e)
                                   throws java.rmi.RemoteException
The process of serializing an entry for transmission to a JavaSpaces service will be identical if the same entry is used twice. This is most likely to be an issue with templates that are used repeatedly to search for entries with 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.

Specified by:
snapshot in interface net.jini.space.JavaSpace
Parameters:
e - the entry to take a snapshot of.
Returns:
a snapshot of the entry.
Throws:
java.rmi.RemoteException - if a communication error occurs

listEntries

public void listEntries(java.io.PrintStream out)
This function will print a list of entries exist on the local space.

Parameters:
out - the out

listNotifies

public void listNotifies(java.io.PrintStream out)
This function will print a list of entries exist on the local space.

Parameters:
out - the out

detail

public Entry detail(java.lang.String id)
This function will print all the fields of a specific entry.

Parameters:
id - Entry's id
Returns:
the casa. jio n.entry. entry

doCancel

public void doCancel(Lease lease)
This function can be called only by Lease.cancel() function. It will cancel the specific lease

Parameters:
lease - the lease

doRenew

public void doRenew(Lease lease)
This function can be called only by Lease.renew() function. It will renew the expiration for the entry specified by @param id

Parameters:
lease - the lease

getLease

public Lease getLease(java.lang.String id)
This function retrieve the specific lease from the lease directory.

Parameters:
id - the id
Returns:
the lease

outOffDate

public void outOffDate()
Out off date.


main

public static void main(java.lang.String[] args)
The main method.

Parameters:
args - the arguments