com.sun.jini.reggie
Class ConstrainableServiceLease

java.lang.Object
  extended by com.sun.jini.lease.AbstractLease
      extended by com.sun.jini.reggie.RegistrarLease
          extended by com.sun.jini.reggie.ServiceLease
              extended by com.sun.jini.reggie.ConstrainableServiceLease
All Implemented Interfaces:
Serializable, RemoteMethodControl, Lease, ReferentUuid

final class ConstrainableServiceLease
extends ServiceLease
implements RemoteMethodControl

ServiceLease subclass that supports constraints.

Author:
Sun Microsystems, Inc.

Field Summary
private  MethodConstraints constraints
          Client constraints for this proxy, or null
private static Method[] methodMappings
          Mappings between Lease and Registrar methods
private static long serialVersionUID
           
 
Fields inherited from class com.sun.jini.reggie.ServiceLease
serviceID
 
Fields inherited from class com.sun.jini.reggie.RegistrarLease
leaseID, registrarID, server
 
Fields inherited from class com.sun.jini.lease.AbstractLease
expiration, serialFormat
 
Fields inherited from interface net.jini.core.lease.Lease
ABSOLUTE, ANY, DURATION, FOREVER
 
Constructor Summary
ConstrainableServiceLease(Registrar server, ServiceID registrarID, ServiceID serviceID, Uuid leaseID, long expiration, MethodConstraints constraints)
          Creates new ConstrainableServiceLease with given server reference, event and lease IDs, expiration time and client constraints.
 
Method Summary
 boolean canBatch(Lease lease)
          Two leases can be batched if they are both RegistrarLeases, share the same server, and have compatible constraints.
 LeaseMap createLeaseMap(long duration)
          Creates a constraint-aware lease map.
 MethodConstraints getConstraints()
          Returns the client constraints placed on this proxy.
private  ProxyTrustIterator getProxyTrustIterator()
          Returns iterator used by ProxyTrustVerifier to retrieve a trust verifier for this object.
private  void readObject(ObjectInputStream in)
          Verifies that the client constraints for this proxy are consistent with those set on the underlying server ref.
 RemoteMethodControl setConstraints(MethodConstraints constraints)
          Returns a new copy of this proxy with the client constraints set to the specified constraints.
 
Methods inherited from class com.sun.jini.reggie.ServiceLease
cancel, doRenew, getInstance, getLeaseType, getRegID, getServiceID
 
Methods inherited from class com.sun.jini.reggie.RegistrarLease
equals, getReferentUuid, getRegistrar, getRegistrarID, hashCode, setExpiration, toString
 
Methods inherited from class com.sun.jini.lease.AbstractLease
getExpiration, getSerialFormat, renew, setSerialFormat
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

methodMappings

private static final Method[] methodMappings
Mappings between Lease and Registrar methods


constraints

private final MethodConstraints constraints
Client constraints for this proxy, or null

Constructor Detail

ConstrainableServiceLease

ConstrainableServiceLease(Registrar server,
                          ServiceID registrarID,
                          ServiceID serviceID,
                          Uuid leaseID,
                          long expiration,
                          MethodConstraints constraints)
Creates new ConstrainableServiceLease with given server reference, event and lease IDs, expiration time and client constraints.

Method Detail

createLeaseMap

public LeaseMap createLeaseMap(long duration)
Creates a constraint-aware lease map.

Specified by:
createLeaseMap in interface Lease
Overrides:
createLeaseMap in class RegistrarLease
Parameters:
duration - the duration to put into a Long and use as the value for the current lease in the created LeaseMap
Returns:
the created LeaseMap object

canBatch

public boolean canBatch(Lease lease)
Two leases can be batched if they are both RegistrarLeases, share the same server, and have compatible constraints.

Specified by:
canBatch in interface Lease
Overrides:
canBatch in class RegistrarLease
Parameters:
lease - the Lease to be evaluated
Returns:
a boolean indicating whether or not the lease given as a parameter can be batched (placed in the same LeaseMap) with the current lease

setConstraints

public RemoteMethodControl setConstraints(MethodConstraints constraints)
Description copied from interface: RemoteMethodControl
Returns a new copy of this proxy with the client constraints set to the specified constraints. These constraints completely replace (in the copy) any client constraints previously placed on this proxy; calling the getConstraints method of the copy returns the identical constraints instance. The original proxy is not modified. A null value is interpreted as mapping all methods to empty constraints (one that has no requirements and no preferences). For any given remote call, the specific client requirements and preferences to be satisfied are given by the return value of invoking the getConstraints method of the specified MethodConstraints instance with a Method object representing the remote method.

Client constraints placed on a proxy are included in the serialized state of the proxy. This allows third-party services to be transparent to the client's needs. For example, if remote object s1 obtains a proxy for remote object s2, and passes that proxy to remote object s3, expecting s3 to invoke a remote method on s2, then s1 can control that call by placing its constraints directly on the proxy before passing it to s3. If s3 does not wish to be transparent in this way, then it should explicitly replace the client constraints on received proxies with whatever constraints are appropriate to implement its own policy.

Specified by:
setConstraints in interface RemoteMethodControl
Parameters:
constraints - client constraints, or null
Returns:
a new copy of this proxy with the client constraints set to the specified constraints
See Also:
RemoteMethodControl.getConstraints()

getConstraints

public MethodConstraints getConstraints()
Description copied from interface: RemoteMethodControl
Returns the client constraints placed on this proxy. The return value can be null, which is interpreted as mapping all methods to empty constraints (one that has no requirements and no preferences).

Specified by:
getConstraints in interface RemoteMethodControl
Returns:
the client constraints, or null
See Also:
RemoteMethodControl.setConstraints(net.jini.core.constraint.MethodConstraints)

getProxyTrustIterator

private ProxyTrustIterator getProxyTrustIterator()
Returns iterator used by ProxyTrustVerifier to retrieve a trust verifier for this object.


readObject

private void readObject(ObjectInputStream in)
                 throws IOException,
                        ClassNotFoundException
Verifies that the client constraints for this proxy are consistent with those set on the underlying server ref.

Throws:
IOException
ClassNotFoundException


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