com.sun.jini.outrigger
Class OutriggerServerWrapper

java.lang.Object
  extended by com.sun.jini.outrigger.OutriggerServerWrapper
All Implemented Interfaces:
DestroyAdmin, Landlord, OutriggerAdmin, OutriggerServer, ServiceProxyAccessor, Remote, JoinAdmin, TransactionConstants, TransactionParticipant, ProxyAccessor, ServerProxyTrust
Direct Known Subclasses:
PersistentOutriggerImpl, TransientOutriggerImpl

 class OutriggerServerWrapper
extends Object
implements OutriggerServer, ServerProxyTrust, ProxyAccessor

For various reasons there is code that we would like to run before every incoming remote call. To accomplish this we wrap the server in an object that will run the common code and then delegate to the server to do the actual work. This is a base class for these wrappers.

Since:
2.0
Author:
Sun Microsystems, Inc.

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.sun.jini.outrigger.OutriggerServer
OutriggerServer.QueryCookie
 
Nested classes/interfaces inherited from interface com.sun.jini.landlord.Landlord
Landlord.RenewResults
 
Field Summary
private  boolean allowCalls
          If false, hold calls until it becomes true
private  OutriggerServerImpl delegate
          The object being delegated to
private  Throwable failCallsWith
          If non-null cause incoming calls to immediately throw this exception.
 
Fields inherited from interface net.jini.core.transaction.server.TransactionConstants
ABORTED, ACTIVE, COMMITTED, NOTCHANGED, PREPARED, VOTING
 
Constructor Summary
OutriggerServerWrapper(ActivationID activationID, String[] configArgs)
          Create an OutriggerServerWrapper that will delegate to an OutriggerServerImpl created with the specified argument and wrapped by this.
OutriggerServerWrapper(String[] configArgs, LifeCycle lifeCycle, boolean persistent)
          Create an OutriggerServerWrapper that will delegate to a non-activatable OutriggerServerImpl created with the specified configuration and wrapped by this.
 
Method Summary
 void abort(TransactionManager mgr, long id)
          Requests that the participant roll back any changes for the specified transaction and unlock any resources locked by the transaction.
 void addLookupAttributes(Entry[] attrSets)
          Add attribute sets for the service.
 void addLookupGroups(String[] groups)
          Add new groups to the set to join.
 void addLookupLocators(LookupLocator[] locators)
          Add locators for specific new lookup services to join.
(package private)  void allowCalls()
          Allow incoming calls.
 void cancel(Uuid cookie)
          Called by the lease when its cancel method is called.
 Map cancelAll(Uuid[] cookies)
          Called by the lease map when its cancelAll method is called.
 void close(Uuid iterationUuid)
          Forget about the indicated iteration
 void commit(TransactionManager mgr, long id)
          Requests that the participant make all of its PREPARED changes for the specified transaction visible outside of the transaction and unlock any resources locked by the transaction.
 MatchSetData contents(EntryRep[] tmpls, Transaction tr, long leaseTime, long limit)
          Start a new contents query.
 Uuid contents(EntryRep tmpl, Transaction txn)
          Return the remote iterator object needed by JavaSpaceAdmin.contents.
 void delete(Uuid iterationUuid, Uuid entryUuid)
          Delete the given entry if the given iteration is still valid and the entry was retured by the last call to nextReps.
 void destroy()
          Destroy the service, if possible, including its persistent storage.
private  void gate()
          Block until calls are allowed, or until calls are to be rejected.
 Object getAdmin()
          Return the admin proxy for this space.
 Entry[] getLookupAttributes()
          Get the current attribute sets for the service.
 String[] getLookupGroups()
          Get the list of groups to join.
 LookupLocator[] getLookupLocators()
          Get the list of locators of specific lookup services to join.
 Object getProxy()
          Returns a proxy object for this remote object.
 TrustVerifier getProxyVerifier()
          Returns a TrustVerifier that can be used to verify that a proxy can be trusted as a proxy for the service; that is, the isTrustedObject method of the returned verifier can be called with a candidate proxy.
 Object getServiceProxy()
          Returns a proxy object for this object.
(package private)  void holdCalls()
          Cause incoming calls to block until further notice.
 void modifyLookupAttributes(Entry[] attrSetTemplates, Entry[] attrSets)
          Modify the current attribute sets, using the same semantics as ServiceRegistration.modifyAttributes.
 EntryRep[] nextBatch(Uuid contentsQueryUuid, Uuid entryUuid)
          Return the next batch of entries associated with the specified contents query.
 EntryRep[] nextReps(Uuid iterationUuid, int max, Uuid entryUuid)
          Fetch up to max EntryRep objects from the specified iteration.
 EventRegistration notify(EntryRep tmpl, Transaction txn, RemoteEventListener listener, long lease, MarshalledObject handback)
          When entries are written that match this template notify the given listener.
 int prepare(TransactionManager mgr, long id)
          Requests that the participant prepare itself to commit the transaction, and to vote on the outcome of the transaction.
 int prepareAndCommit(TransactionManager mgr, long id)
          A combination of prepare and commit, which can be used by the manager when there is just one participant left to prepare and all other participants (if any) have responded with NOTCHANGED.
 Object read(EntryRep tmpl, Transaction txn, long timeout, OutriggerServer.QueryCookie cookie)
          Find an entry in the space that matches the passed template and is visible to the passed transaction.
 Object readIfExists(EntryRep tmpl, Transaction txn, long timeout, OutriggerServer.QueryCookie cookie)
          Find an entry in the space that matches the passed template and is visible to the passed transaction.
 EventRegistration registerForAvailabilityEvent(EntryRep[] tmpls, Transaction txn, boolean visibilityOnly, RemoteEventListener listener, long leaseTime, MarshalledObject handback)
          When entries that match one or more of the passed templates transition from invisible to visible notify the give listener.
(package private)  void rejectCalls(Throwable t)
          Cause in new or blocked calls to fail with the specified exception.
 void removeLookupGroups(String[] groups)
          Remove groups from the set to join.
 void removeLookupLocators(LookupLocator[] locators)
          Remove locators for specific lookup services from the set to join.
 long renew(Uuid cookie, long extension)
          Called by the lease when its renew method is called.
 Landlord.RenewResults renewAll(Uuid[] cookies, long[] durations)
          Called by the lease map when its renewAll method is called.
 void setLookupGroups(String[] groups)
          Replace the list of groups to join with a new list.
 void setLookupLocators(LookupLocator[] locators)
          Replace the list of locators of specific lookup services to join with a new list.
 JavaSpace space()
          Return the space administered by this object.
 Object take(EntryRep[] tmpls, Transaction tr, long timeout, int limit, OutriggerServer.QueryCookie cookie)
          Find and remove up to limit entries in the space that match one or more of the passed templates and are visible to the passed transaction.
 Object take(EntryRep tmpl, Transaction txn, long timeout, OutriggerServer.QueryCookie cookie)
          Find and remove an entry in the space that matches the passed template and is visible to the passed transaction.
 Object takeIfExists(EntryRep tmpl, Transaction txn, long timeout, OutriggerServer.QueryCookie cookie)
          Find and remove an entry in the space that matches the passed template and is visible to the passed transaction.
 long[] write(EntryRep[] entries, Transaction txn, long[] leaseTimes)
          Write a set of entires into the space.
 long[] write(EntryRep entry, Transaction txn, long lease)
          Write a new entry into the space.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delegate

private final OutriggerServerImpl delegate
The object being delegated to


allowCalls

private boolean allowCalls
If false, hold calls until it becomes true


failCallsWith

private Throwable failCallsWith
If non-null cause incoming calls to immediately throw this exception. Takes presidents over holdCalls. This field is only set to an Error, RemoteException, or RuntimeException and thus can be thrown by an of OutriggerServer's methods.

Constructor Detail

OutriggerServerWrapper

OutriggerServerWrapper(String[] configArgs,
                       LifeCycle lifeCycle,
                       boolean persistent)
                 throws IOException,
                        ConfigurationException,
                        LoginException
Create an OutriggerServerWrapper that will delegate to a non-activatable OutriggerServerImpl created with the specified configuration and wrapped by this.

Parameters:
configArgs - set of strings to be used to obtain a Configuration.
lifeCycle - the object to notify when this service is destroyed.
persistent - If true will throw an ConfigurationException if there is no persistence directory or store specified in the configuration.
Throws:
IOException - if there is problem exporting the server.
ConfigurationException - if the Configuration is malformed.
LoginException - if the loginContext specified in the configuration is non-null and throws an exception when login is attempted.

OutriggerServerWrapper

OutriggerServerWrapper(ActivationID activationID,
                       String[] configArgs)
                 throws IOException,
                        ConfigurationException,
                        LoginException,
                        ActivationException
Create an OutriggerServerWrapper that will delegate to an OutriggerServerImpl created with the specified argument and wrapped by this.

Parameters:
activationID - of the server, must not be null.
configArgs - set of strings to be used to obtain a Configuration.
Throws:
IOException - if there is problem recovering data from disk, exporting the server, or unpacking data.
ConfigurationException - if the Configuration is malformed.
ActivationException - if activatable and there is a problem getting a reference to the activation system.
LoginException - if the loginContext specified in the configuration is non-null and throws an exception when login is attempted.
NullPointerException - if activationID is null.
Method Detail

holdCalls

void holdCalls()
Cause incoming calls to block until further notice.


rejectCalls

void rejectCalls(Throwable t)
Cause in new or blocked calls to fail with the specified exception.

Throws:
IllegalArgumentException - if t is not an Error, RemoteException, or RuntimeException.
NullPointerException - if t is null.

allowCalls

void allowCalls()
Allow incoming calls.


gate

private void gate()
           throws RemoteException
Block until calls are allowed, or until calls are to be rejected.

Throws:
RemoteException - If calls are being rejected with RemoteExceptions.
RuntimeException - If calls are being rejected with RuntimeExceptions.
Error - If calls are being rejected with Errors.

write

public long[] write(EntryRep entry,
                    Transaction txn,
                    long lease)
             throws TransactionException,
                    RemoteException
Description copied from interface: OutriggerServer
Write a new entry into the space.

Specified by:
write in interface OutriggerServer
Throws:
TransactionException - A transaction error occurred
RemoteException

read

public Object read(EntryRep tmpl,
                   Transaction txn,
                   long timeout,
                   OutriggerServer.QueryCookie cookie)
            throws TransactionException,
                   RemoteException,
                   InterruptedException
Description copied from interface: OutriggerServer
Find an entry in the space that matches the passed template and is visible to the passed transaction. Depending on the state of the space and the arguments this call may block if no entry can be immediately returned. The proxy can specify the maximum period it is willing to wait for a response using the timeout parameter. The proxy may choose to breakup a query from the client with a very long timeout into a set of sub-queries. In such cases it may get a QueryCookie as response to the sub-queries, in these cases it should pass the QueryCookie to the next sub-query (if any) associated with the same request from the client.

If a match is found it is returned as an EntryRep. If txn is non-null the entry is read locked by the transaction, this allows other queries to read, but not take the entry. The lock will be released when the transaction is aborted or prepared.

If no match is found the call will block for up to the specified timeout for a match to appear. If there is still no match available the call will return a QueryCookie.

Specified by:
read in interface OutriggerServer
Parameters:
tmpl - The template that describes the entry being searched for. May be null if any visible entry is acceptable.
txn - The transaction the operation should be performed under. Maybe be null. If non-null and entry is found it will read locked/removed under this transaction.
timeout - The maximum number of milliseconds this call should block in the server before returning an answer (this not necessarily the timeout the client asked for.) A value of 0 indicates the initial search should be performed, but if no match can be found null or a QueryCookie (as appropriate) should be returned immediately.
cookie - If this call is a continuation of an earlier query, the cookie from the last sub-query.
Throws:
TransactionException - if there is a problem with the specified transaction such as it can not be joined, or leaves the active state before the call is complete.
RemoteException - if a network failure occurs.
InterruptedException - if the thread in the server is interrupted before the query can be completed.

readIfExists

public Object readIfExists(EntryRep tmpl,
                           Transaction txn,
                           long timeout,
                           OutriggerServer.QueryCookie cookie)
                    throws TransactionException,
                           RemoteException,
                           InterruptedException
Description copied from interface: OutriggerServer
Find an entry in the space that matches the passed template and is visible to the passed transaction. Depending on the state of the space and the arguments this call may block if no entry can be immediately returned. The proxy can specify the maximum period it is willing to wait for a response using the timeout parameter. The proxy may choose to breakup a query from the client with a very long timeout into a set of sub-queries. In such cases it may get a QueryCookie as response to the sub-queries, in these cases it should pass the QueryCookie to the next sub-query (if any) associated with the same request from the client.

If a match is found it is returned as an EntryRep. If txn is non-null the entry is read locked by the transaction, this allows other queries to read, but not take the entry. The lock will be released when the transaction is aborted or prepared.

If no match can be initially found the call will block until either the timeout expires or for a detectable period of time there are no entries in the space (visible to the transaction or not) that match the passed template. If at some point there are no matching entries in the space null will be returned. If the timeout expires and there are matching entries in the space but none are visible to the passed transaction a QueryCookie will be returned.

Specified by:
readIfExists in interface OutriggerServer
Parameters:
tmpl - The template that describes the entry being searched for. May be null if any visible entry is acceptable.
txn - The transaction the operation should be performed under. Maybe be null. If non-null and entry is found it will read locked/removed under this transaction.
timeout - The maximum number of milliseconds this call should block in the server before returning an answer (this not necessarily the timeout the client asked for.) A value of 0 indicates the initial search should be performed, but if no match can be found null or a QueryCookie (as appropriate) should be returned immediately.
cookie - If this call is a continuation of an earlier query, the cookie from the last sub-query.
Throws:
TransactionException - if there is a problem with the specified transaction such as it can not be joined, or leaves the active state before the call is complete.
RemoteException - if a network failure occurs.
InterruptedException - if the thread in the server is interrupted before the query can be completed.

take

public Object take(EntryRep tmpl,
                   Transaction txn,
                   long timeout,
                   OutriggerServer.QueryCookie cookie)
            throws TransactionException,
                   RemoteException,
                   InterruptedException
Description copied from interface: OutriggerServer
Find and remove an entry in the space that matches the passed template and is visible to the passed transaction. Depending on the state of the space and the arguments this call may block if no entry can be immediately returned. The proxy can specify the maximum period it is willing to wait for a response using the timeout parameter. The proxy may choose to breakup a query from the client with a very long timeout into a set of sub-queries. In such cases it may get a QueryCookie as response to the sub-queries, in these cases it should pass the QueryCookie to the next sub-query (if any) associated with the same request from the client.

If a match is found it is returned as an EntryRep. If txn is null the entry is removed from the space. If txn is non-null the entry is exclusively locked by the transaction and will be removed from the space if the transaction is committed.

If no match is found the call will block for up to the specified timeout for a match to appear. If there is still no match available the call will return a QueryCookie.

Specified by:
take in interface OutriggerServer
Parameters:
tmpl - The template that describes the entry being searched for. May be null if any visible entry is acceptable.
txn - The transaction the operation should be performed under. Maybe be null. If non-null and entry is found it will read locked/removed under this transaction.
timeout - The maximum number of milliseconds this call should block in the server before returning an answer (this not necessarily the timeout the client asked for.) A value of 0 indicates the initial search should be performed, but if no match can be found null or a QueryCookie (as appropriate) should be returned immediately.
cookie - If this call is a continuation of an earlier query, the cookie from the last sub-query.
Throws:
TransactionException - if there is a problem with the specified transaction such as it can not be joined, or leaves the active state before the call is complete.
RemoteException - if a network failure occurs.
InterruptedException - if the thread in the server is interrupted before the query can be completed.

takeIfExists

public Object takeIfExists(EntryRep tmpl,
                           Transaction txn,
                           long timeout,
                           OutriggerServer.QueryCookie cookie)
                    throws TransactionException,
                           RemoteException,
                           InterruptedException
Description copied from interface: OutriggerServer
Find and remove an entry in the space that matches the passed template and is visible to the passed transaction. Depending on the state of the space and the arguments this call may block if no entry can be immediately returned. The proxy can specify the maximum period it is willing to wait for a response using the timeout parameter. The proxy may choose to breakup a query from the client with a very long timeout into a set of sub-queries. In such cases it may get a QueryCookie as response to the sub-queries, in these cases it should pass the QueryCookie to the next sub-query (if any) associated with the same request from the client.

If a match is found it is returned as an EntryRep. If txn is null the entry is removed from the space. If txn is non-null the entry is exclusively locked by the transaction and will be removed from the space if the transaction is committed.

If no match can be initially found the call will block until either the timeout expires or for a detectable period of time there are no entries in the space (visible to the transaction or not) that match the passed template. If at some point there are no matching entries in the space null will be returned. If the timeout expires and there are matching entries in the space but none are visible to the passed transaction a QueryCookie will be returned.

Specified by:
takeIfExists in interface OutriggerServer
Parameters:
tmpl - The template that describes the entry being searched for. May be null if any visible entry is acceptable.
txn - The transaction the operation should be performed under. Maybe be null. If non-null and entry is found it will read locked/removed under this transaction.
timeout - The maximum number of milliseconds this call should block in the server before returning an answer (this not necessarily the timeout the client asked for.) A value of 0 indicates the initial search should be performed, but if no match can be found null or a QueryCookie (as appropriate) should be returned immediately.
cookie - If this call is a continuation of an earlier query, the cookie from the last sub-query.
Throws:
TransactionException - if there is a problem with the specified transaction such as it can not be joined, or leaves the active state before the call is complete.
RemoteException - if a network failure occurs.
InterruptedException - if the thread in the server is interrupted before the query can be completed.

notify

public EventRegistration notify(EntryRep tmpl,
                                Transaction txn,
                                RemoteEventListener listener,
                                long lease,
                                MarshalledObject handback)
                         throws TransactionException,
                                RemoteException
Description copied from interface: OutriggerServer
When entries are written that match this template notify the given listener. Matching is done as for read.

Specified by:
notify in interface OutriggerServer
Throws:
TransactionException
RemoteException

registerForAvailabilityEvent

public EventRegistration registerForAvailabilityEvent(EntryRep[] tmpls,
                                                      Transaction txn,
                                                      boolean visibilityOnly,
                                                      RemoteEventListener listener,
                                                      long leaseTime,
                                                      MarshalledObject handback)
                                               throws TransactionException,
                                                      RemoteException
Description copied from interface: OutriggerServer
When entries that match one or more of the passed templates transition from invisible to visible notify the give listener. Matching is done as for read.

Specified by:
registerForAvailabilityEvent in interface OutriggerServer
Parameters:
tmpls - the templates that specify what entries should generate events
txn - if non-null entries that become visible to txn should generate events even if txn is never committed. Registration is terminated when txn leaves the active state
visibilityOnly - if true, events will be generated for this registration only when a matching Entry transitions from invisible to visible, otherwise events will be generated when a matching Entry makes any transition from unavailable to available
listener - object to notify when an entry becomes (re)visible
leaseTime - initial requested lease time for the registration
handback - object to be included with every notification
Returns:
An object with information on the registration
Throws:
TransactionException - if txn is non-null and not active or otherwise invalid
RemoteException

write

public long[] write(EntryRep[] entries,
                    Transaction txn,
                    long[] leaseTimes)
             throws TransactionException,
                    RemoteException
Description copied from interface: OutriggerServer
Write a set of entires into the space.

Specified by:
write in interface OutriggerServer
Returns:
an array of longs that can be used to construct the leases on the client side. The array will have 3 elements for each lease, the first will be the duration, followed by the high order bits of the Uuid and then the lower order bits of the Uuid.
Throws:
TransactionException - A transaction error occurred
RemoteException

take

public Object take(EntryRep[] tmpls,
                   Transaction tr,
                   long timeout,
                   int limit,
                   OutriggerServer.QueryCookie cookie)
            throws TransactionException,
                   RemoteException
Description copied from interface: OutriggerServer
Find and remove up to limit entries in the space that match one or more of the passed templates and are visible to the passed transaction. Depending on the state of the space and the arguments this call may block if no entry can be immediately returned. The proxy can specify the maximum period it is willing to wait for a response using the timeout parameter. The proxy may choose to breakup a query from the client with a very long timeout into a set of sub-queries. In such cases it may get a QueryCookie as response to the sub-queries, in these cases it should pass the QueryCookie to the next sub-query (if any) associated with the same request from the client.

If matchs are found they are returned as in an array of EntryRep. If txn is null the entries are removed from the space. If txn is non-null the entries are exclusively locked by the transaction and will be removed from the space if the transaction is committed.

If there are no matches the call will block for up to the specified timeout for a match to appear. If there is still no match available the call will return a QueryCookie.

Specified by:
take in interface OutriggerServer
Parameters:
tmpls - The templates that describes the entries being searched for
tr - The transaction the operation should be performed under. Maybe be null. If non-null and entries are found they will removed under this transaction.
timeout - The maximum number of milliseconds this call should block in the server before returning an answer (this not necessarily the timeout the client asked for.) A value of 0 indicates the initial search should be performed, but if no match can be found a QueryCookie should be returned immediately.
limit - The maximum number of entries that should be taken
cookie - If this call is a continuation of an earlier query, the cookie from the last sub-query.
Throws:
TransactionException - if there is a problem with the specified transaction such as it can not be joined, or leaves the active state before the call is complete.
RemoteException - if a network failure occurs.

contents

public MatchSetData contents(EntryRep[] tmpls,
                             Transaction tr,
                             long leaseTime,
                             long limit)
                      throws TransactionException,
                             RemoteException
Description copied from interface: OutriggerServer
Start a new contents query. Returns a MatchSetData with the initial batch of entries and (if applicable) the Uuid and initial lease duration. If the entire result set is contained in the returned MatchSetData the Uuid will be null and the lease duration will be -1.

Specified by:
contents in interface OutriggerServer
Parameters:
tmpls - the templates to use for the iteration
tr - the transaction to perform the iteration under, may be null
leaseTime - the requested lease time
limit - the maximum number of entries to return
Returns:
A MatchSetData with the initial batch of entries and (if applicable) the Uuid and initial lease duration. Initial batch will be the empty array if there are no matching entries in the space
Throws:
TransactionException - if tr is non-null and can't be used
RemoteException

nextBatch

public EntryRep[] nextBatch(Uuid contentsQueryUuid,
                            Uuid entryUuid)
                     throws RemoteException
Description copied from interface: OutriggerServer
Return the next batch of entries associated with the specified contents query. If the returned array is not full then the query is complete.

Specified by:
nextBatch in interface OutriggerServer
Parameters:
contentsQueryUuid - the id of the contents query
entryUuid - the id of the last entry in the last batch. If this does not match what the server has on recored it will re-send the previous batch.
Returns:
an array of EntryReps representing the next batch of entries from the query. Query is complete if array is not full. Returns an empty array if there are no entries left
Throws:
NoSuchObjectException - if the server has no record of contentsQueryUuid
RemoteException

renew

public long renew(Uuid cookie,
                  long extension)
           throws LeaseDeniedException,
                  UnknownLeaseException,
                  RemoteException
Description copied from interface: Landlord
Called by the lease when its renew method is called. Renews the lease that is associated with the given cookie.

Specified by:
renew in interface Landlord
Parameters:
cookie - the Uuid associated with the lease who's renew method was called
extension - argument passed to the renew call
Returns:
The new duration the lease should have
Throws:
LeaseDeniedException - if the landlord is unwilling to renew the lease
UnknownLeaseException - if landlord does not know about a lease with the specified cookie
RemoteException - if a communications failure occurs

cancel

public void cancel(Uuid cookie)
            throws UnknownLeaseException,
                   RemoteException
Description copied from interface: Landlord
Called by the lease when its cancel method is called. Cancels the lease that is associated with the given cookie.

Specified by:
cancel in interface Landlord
Parameters:
cookie - the Uuid associated with the lease who's renew method was called
Throws:
UnknownLeaseException - if landlord does not know about a lease with the specified cookie
RemoteException - if a communications failure occurs

getAdmin

public Object getAdmin()
                throws RemoteException
Description copied from interface: OutriggerServer
Return the admin proxy for this space.

Specified by:
getAdmin in interface OutriggerServer
Throws:
RemoteException

prepare

public int prepare(TransactionManager mgr,
                   long id)
            throws UnknownTransactionException,
                   RemoteException
Description copied from interface: TransactionParticipant
Requests that the participant prepare itself to commit the transaction, and to vote on the outcome of the transaction. The participant responds with either PREPARED, indicating that it is prepared; ABORT, indicating that it will abort, or NOTCHANGED, indicating that it did not have any state changed by the transaction (i.e., it was read-only). If the response is PREPARED, the participant must wait until it receives a commit or abort call from the transaction manager; it may query the transaction manager if needed as to the state of the transaction. If the response is ABORT, the participant should roll its state back to undo any changes that occurred due to operations performed under the transaction; it can then discard any information about the transaction. If the response is NOTCHANGED, the participant can immediately discard any knowledge of the transaction.

Specified by:
prepare in interface TransactionParticipant
Parameters:
mgr - the manager of the transaction
id - the transaction ID
Returns:
an int representing this participant's state
Throws:
UnknownTransactionException - if the transaction is unknown to the transaction manager, either because the transaction ID is incorrect or because the transaction is complete and its state has been discarded by the manager.
RemoteException - if there is a communication error

commit

public void commit(TransactionManager mgr,
                   long id)
            throws UnknownTransactionException,
                   RemoteException
Description copied from interface: TransactionParticipant
Requests that the participant make all of its PREPARED changes for the specified transaction visible outside of the transaction and unlock any resources locked by the transaction. All state associated with the transaction can then be discarded by the participant.

Specified by:
commit in interface TransactionParticipant
Parameters:
mgr - the manager of the transaction
id - the transaction ID
Throws:
UnknownTransactionException - if the transaction is unknown to the transaction manager, either because the transaction ID is incorrect or because the transaction is complete and its state has been discarded by the manager.
RemoteException - if there is a communication error

abort

public void abort(TransactionManager mgr,
                  long id)
           throws UnknownTransactionException,
                  RemoteException
Description copied from interface: TransactionParticipant
Requests that the participant roll back any changes for the specified transaction and unlock any resources locked by the transaction. All state associated with the transaction can then be discarded by the participant.

Specified by:
abort in interface TransactionParticipant
Parameters:
mgr - the manager of the transaction
id - the transaction ID
Throws:
UnknownTransactionException - if the transaction is unknown to the transaction manager, either because the transaction ID is incorrect or because the transaction is complete and its state has been discarded by the manager.
RemoteException - if there is a communication error

prepareAndCommit

public int prepareAndCommit(TransactionManager mgr,
                            long id)
                     throws UnknownTransactionException,
                            RemoteException
Description copied from interface: TransactionParticipant
A combination of prepare and commit, which can be used by the manager when there is just one participant left to prepare and all other participants (if any) have responded with NOTCHANGED. The participant's implementation of this method must be equivalent to:
        public int prepareAndCommit(TransactionManager mgr, long id)
            throws UnknownTransactionException, RemoteException
        {
            int result = prepare(mgr, id);
            if (result == PREPARED) {
                commit(mgr, id);
                result = COMMITTED;
            }
            return result;
        }
 

Specified by:
prepareAndCommit in interface TransactionParticipant
Parameters:
mgr - the manager of the transaction
id - the transaction ID
Returns:
an int representing its state
Throws:
UnknownTransactionException - if the transaction is unknown to the transaction manager, either because the transaction ID is incorrect or because the transaction is complete and its state has been discarded by the manager.
RemoteException - if there is a communication error
See Also:
TransactionParticipant.prepare(net.jini.core.transaction.server.TransactionManager, long), TransactionParticipant.commit(net.jini.core.transaction.server.TransactionManager, long)

renewAll

public Landlord.RenewResults renewAll(Uuid[] cookies,
                                      long[] durations)
                               throws RemoteException
Description copied from interface: Landlord
Called by the lease map when its renewAll method is called. Should renew the lease that is associated with each element of cookies

Specified by:
renewAll in interface Landlord
Parameters:
cookies - an array of Uuids, each universally and uniquely identifying a lease granted by this Landlord
durations - an array of longs, each representing an a duration in milliseconds that the client wants the lease associated with the Uuid from the corresponding element of cookies renewed for
Returns:
A RenewResults object that contains the new duration of each lease that was successfully renewed or the exception encountered for each lease that could not be renewed
Throws:
RemoteException - if a communications failure occurs

cancelAll

public Map cancelAll(Uuid[] cookies)
              throws RemoteException
Description copied from interface: Landlord
Called by the lease map when its cancelAll method is called. Should cancel the lease that is associated with each element of cookies

Specified by:
cancelAll in interface Landlord
Parameters:
cookies - an array of Uuids, each universally and uniquely identifying a lease granted by this Landlord
Returns:
If all the leases specified in the cookies could be cancelled return null. Otherwise, return a Map that for each failed cancel attempt maps the corresponding cookie object to an exception describing the failure.
Throws:
RemoteException - if a communications failure occurs

getServiceProxy

public Object getServiceProxy()
                       throws RemoteException
Description copied from interface: ServiceProxyAccessor
Returns a proxy object for this object. This value should not be null.

Specified by:
getServiceProxy in interface ServiceProxyAccessor
Returns:
a proxy object reference
Throws:
RemoteException

space

public JavaSpace space()
                throws RemoteException
Description copied from interface: OutriggerAdmin
Return the space administered by this object.

Specified by:
space in interface OutriggerAdmin
Throws:
RemoteException

contents

public Uuid contents(EntryRep tmpl,
                     Transaction txn)
              throws TransactionException,
                     RemoteException
Description copied from interface: OutriggerAdmin
Return the remote iterator object needed by JavaSpaceAdmin.contents.

Specified by:
contents in interface OutriggerAdmin
Throws:
TransactionException
RemoteException

nextReps

public EntryRep[] nextReps(Uuid iterationUuid,
                           int max,
                           Uuid entryUuid)
                    throws RemoteException
Description copied from interface: OutriggerAdmin
Fetch up to max EntryRep objects from the specified iteration.

Specified by:
nextReps in interface OutriggerAdmin
Parameters:
iterationUuid - The Uuid of the iteration to fetch entries from.
max - Advice on the number of entries to return
entryUuid - Uuid of the last entry received by the caller. If this does not match the ID of the last entry sent by the iterator will re-send that last batch in place of a new batch. May be null in which case a new batch will be sent. The first call to next() should have id set to null
Throws:
RemoteException

delete

public void delete(Uuid iterationUuid,
                   Uuid entryUuid)
            throws RemoteException
Description copied from interface: OutriggerAdmin
Delete the given entry if the given iteration is still valid and the entry was retured by the last call to nextReps.

Specified by:
delete in interface OutriggerAdmin
Parameters:
iterationUuid - The Uuid of a valid iteration.
entryUuid - the Uuid of the entry to be deleted.
Throws:
RemoteException

close

public void close(Uuid iterationUuid)
           throws RemoteException
Description copied from interface: OutriggerAdmin
Forget about the indicated iteration

Specified by:
close in interface OutriggerAdmin
Parameters:
iterationUuid - The Uuid iteration to close.
Throws:
RemoteException

destroy

public void destroy()
             throws RemoteException
Description copied from interface: DestroyAdmin
Destroy the service, if possible, including its persistent storage. This method should (in effect) spawn a separate thread to do the actual work asynchronously, and make a reasonable attempt to let this remote call return successfully. As such, a successful return from this method does not mean that the service has been destroyed. Although the service should make a reasonable attempt to let this remote call return successfully, the service must not wait indefinitely for other (in-progress and subsequent) remote calls to finish before proceeding to destroy itself. Once this method has been called, the service can, but need not, reject all other (in-progress and subsequent) remote calls to the service.

Specified by:
destroy in interface DestroyAdmin
Throws:
RemoteException

getLookupAttributes

public Entry[] getLookupAttributes()
                            throws RemoteException
Description copied from interface: JoinAdmin
Get the current attribute sets for the service.

Specified by:
getLookupAttributes in interface JoinAdmin
Returns:
the current attribute sets for the service
Throws:
RemoteException

addLookupAttributes

public void addLookupAttributes(Entry[] attrSets)
                         throws RemoteException
Description copied from interface: JoinAdmin
Add attribute sets for the service. The resulting set will be used for all future joins. The attribute sets are also added to all currently-joined lookup services.

Specified by:
addLookupAttributes in interface JoinAdmin
Parameters:
attrSets - the attribute sets to add
Throws:
RemoteException

modifyLookupAttributes

public void modifyLookupAttributes(Entry[] attrSetTemplates,
                                   Entry[] attrSets)
                            throws RemoteException
Description copied from interface: JoinAdmin
Modify the current attribute sets, using the same semantics as ServiceRegistration.modifyAttributes. The resulting set will be used for all future joins. The same modifications are also made to all currently-joined lookup services.

Specified by:
modifyLookupAttributes in interface JoinAdmin
Parameters:
attrSetTemplates - the templates for matching attribute sets
attrSets - the modifications to make to matching sets
Throws:
RemoteException
See Also:
ServiceRegistration.modifyAttributes(net.jini.core.entry.Entry[], net.jini.core.entry.Entry[])

getLookupGroups

public String[] getLookupGroups()
                         throws RemoteException
Description copied from interface: JoinAdmin
Get the list of groups to join. An empty array means the service joins no groups (as opposed to "all" groups).

Specified by:
getLookupGroups in interface JoinAdmin
Returns:
an array of groups to join. An empty array means the service joins no groups (as opposed to "all" groups).
Throws:
RemoteException
See Also:
JoinAdmin.setLookupGroups(java.lang.String[])

addLookupGroups

public void addLookupGroups(String[] groups)
                     throws RemoteException
Description copied from interface: JoinAdmin
Add new groups to the set to join. Lookup services in the new groups will be discovered and joined.

Specified by:
addLookupGroups in interface JoinAdmin
Parameters:
groups - groups to join
Throws:
RemoteException
See Also:
JoinAdmin.removeLookupGroups(java.lang.String[])

removeLookupGroups

public void removeLookupGroups(String[] groups)
                        throws RemoteException
Description copied from interface: JoinAdmin
Remove groups from the set to join. Leases are cancelled at lookup services that are not members of any of the remaining groups.

Specified by:
removeLookupGroups in interface JoinAdmin
Parameters:
groups - groups to leave
Throws:
RemoteException
See Also:
JoinAdmin.addLookupGroups(java.lang.String[])

setLookupGroups

public void setLookupGroups(String[] groups)
                     throws RemoteException
Description copied from interface: JoinAdmin
Replace the list of groups to join with a new list. Leases are cancelled at lookup services that are not members of any of the new groups. Lookup services in the new groups will be discovered and joined.

Specified by:
setLookupGroups in interface JoinAdmin
Parameters:
groups - groups to join
Throws:
RemoteException
See Also:
JoinAdmin.getLookupGroups()

getLookupLocators

public LookupLocator[] getLookupLocators()
                                  throws RemoteException
Description copied from interface: JoinAdmin
Get the list of locators of specific lookup services to join.

Specified by:
getLookupLocators in interface JoinAdmin
Returns:
the list of locators of specific lookup services to join
Throws:
RemoteException
See Also:
JoinAdmin.setLookupLocators(net.jini.core.discovery.LookupLocator[])

addLookupLocators

public void addLookupLocators(LookupLocator[] locators)
                       throws RemoteException
Description copied from interface: JoinAdmin
Add locators for specific new lookup services to join. The new lookup services will be discovered and joined.

Specified by:
addLookupLocators in interface JoinAdmin
Parameters:
locators - locators of specific lookup services to join
Throws:
RemoteException
See Also:
JoinAdmin.removeLookupLocators(net.jini.core.discovery.LookupLocator[])

removeLookupLocators

public void removeLookupLocators(LookupLocator[] locators)
                          throws RemoteException
Description copied from interface: JoinAdmin
Remove locators for specific lookup services from the set to join. Any leases held at the lookup services are cancelled.

Specified by:
removeLookupLocators in interface JoinAdmin
Parameters:
locators - locators of specific lookup services to leave
Throws:
RemoteException
See Also:
JoinAdmin.addLookupLocators(net.jini.core.discovery.LookupLocator[])

setLookupLocators

public void setLookupLocators(LookupLocator[] locators)
                       throws RemoteException
Description copied from interface: JoinAdmin
Replace the list of locators of specific lookup services to join with a new list. Leases are cancelled at lookup services that were in the old list but are not in the new list. Any new lookup services will be discovered and joined.

Specified by:
setLookupLocators in interface JoinAdmin
Parameters:
locators - locators of specific lookup services to join
Throws:
RemoteException
See Also:
JoinAdmin.getLookupLocators()

getProxy

public Object getProxy()
Description copied from interface: ProxyAccessor
Returns a proxy object for this remote object. If this remote object is not exported (and hence, no proxy is available), then null is returned.

Specified by:
getProxy in interface ProxyAccessor
Returns:
a proxy, or null

getProxyVerifier

public TrustVerifier getProxyVerifier()
                               throws RemoteException
Description copied from interface: ServerProxyTrust
Returns a TrustVerifier that can be used to verify that a proxy can be trusted as a proxy for the service; that is, the isTrustedObject method of the returned verifier can be called with a candidate proxy. The verifier should be able to verify all proxies for the service, including proxies for resources (such as leases and registrations).

Specified by:
getProxyVerifier in interface ServerProxyTrust
Returns:
a TrustVerifier that can be used to verify that a proxy can be trusted as a proxy for the service
Throws:
RemoteException - if a communication-related exception occurs


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.