com.sun.jini.outrigger
Class MatchSetProxy

java.lang.Object
  extended by com.sun.jini.outrigger.MatchSetProxy
All Implemented Interfaces:
MatchSet

 class MatchSetProxy
extends Object
implements MatchSet

Outrigger's implementation of MatchSet. Outrigger's implementation of the JavaSpace05.contents method returns objects of this type. Created with an initial set of entries from the match set and supports pre-fetching whenever it needs additional entries. RemoteExceptions encountered when making a remote call to fetch the next batch of entries from the space generally do not invalidate the proxy or the match set.

Note, there is no way to serialize or otherwise copy instances of this class so the default equals implementation should suffice.


Field Summary
private  int i
          Current index into reps
private  EntryRep lastRepReturned
          Last rep returned
private  Lease lease
          Lease assocated with this query
private  EntryRep[] reps
          Last batch fetched from server
private  OutriggerServer space
          The remote server this proxy works with.
private  boolean unpackFailure
          True if reps[i] could not be unpacked
private  Uuid uuid
          ID of the associated query (and lease)
 
Constructor Summary
MatchSetProxy(MatchSetData inital, SpaceProxy2 parent, OutriggerServer space)
           
 
Method Summary
 Lease getLease()
          Returns a proxy to the Lease associated with this match set, or null if this match set is not leased.
 Entry getSnapshot()
          Returns a snapshot of the Entry removed by the last call to next.
 Entry next()
          Removes one Entry from the match set and returns a copy to the caller.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

space

private final OutriggerServer space
The remote server this proxy works with.


uuid

private final Uuid uuid
ID of the associated query (and lease)


lease

private final Lease lease
Lease assocated with this query


reps

private EntryRep[] reps
Last batch fetched from server


lastRepReturned

private EntryRep lastRepReturned
Last rep returned


i

private int i
Current index into reps


unpackFailure

private boolean unpackFailure
True if reps[i] could not be unpacked

Constructor Detail

MatchSetProxy

MatchSetProxy(MatchSetData inital,
              SpaceProxy2 parent,
              OutriggerServer space)
Method Detail

getLease

public Lease getLease()
Description copied from interface: MatchSet
Returns a proxy to the Lease associated with this match set, or null if this match set is not leased.

Specified by:
getLease in interface MatchSet
Returns:
a proxy for the match set's lease, or null if there is no lease associated with this match set

next

public Entry next()
           throws RemoteException,
                  UnusableEntryException
Description copied from interface: MatchSet
Removes one Entry from the match set and returns a copy to the caller. Returns null if the match set is empty. The returned Entry must be unmarshalled in accordance with the Jini Entry Specification.

A given invocation of this method may perform remote communications, but generally the next method is not expected to have remote method constraints that can vary from invocation to invocation. Instead the set of constraints associated with the next method will be fixed at the time the match set was created, even if this object implements an interface like RemoteMethodControl that would otherwise allow the set of constraints associated with the next method to be altered.

Specified by:
next in interface MatchSet
Returns:
an Entry from the match set, or null if the match set is empty
Throws:
RemoteException - if a communication error occurs. If a RemoteException is thrown, no Entry was removed from the match set because of this call
UnusableEntryException - if the entry removed from the match set could not be unmarshalled

getSnapshot

public Entry getSnapshot()
Description copied from interface: MatchSet
Returns a snapshot of the Entry removed by the last call to next. Snapshots are defined in section JS.2.6 of the JavaSpaces Service Specification and are an alternative representation of a given Entry produced by a particular space for use with that same space. Passing a snapshot to a space is generally more efficient than passing the original representation.

Any snapshot returned by this method will meet the same contract as the object returned by passing the result of the last next invocation to JavaSpace.snapshot.

Generally there is a cost associated with calling the JavaSpace.snapshot method. Thus creating a snapshot using that method is usually only worthwhile if the resulting snapshot is used more than once. The cost of invoking this method should be low and should be worthwhile even if the resulting snapshot is used only once.

Specified by:
getSnapshot in interface MatchSet
Returns:
a snapshot of the Entry removed from the match set by the last call to next

toString

public String toString()
Overrides:
toString in class Object


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