com.jrockit.memleak
Class Policy

java.lang.Object
  extended by com.jrockit.memleak.Policy
Direct Known Subclasses:
Policy.TimeStampPolicy, Policy.TokenPolicy

public abstract class Policy
extends java.lang.Object

Policy to control caching, prefetch, and synchronous behavior of Memleak remote operations.

The policy mainly affects operations in two ways:

Author:
mpersson

Nested Class Summary
static class Policy.TimeStampPolicy
          A Policy only accepting values arriving after this point in time.
static class Policy.TokenPolicy
          Policy with a notification token.
 
Field Summary
static Policy CACHED_OR_NULL
          Policy when you don't want any round trips, just the latest (if anything) already in the cache.
static Policy NOTHING_CACHED
          Policy when you don't want anything that is cached.
static Policy PREFETCH_SOMETHING
          Initiate prefetch if nothing is cached.
static Policy SOMETHING
          Policy when you just want something (non-null), but don't care if it is old.
 
Constructor Summary
protected Policy()
          Internal constructor for subclasses.
 
Method Summary
protected abstract  Policy createPrefetch()
          Create a new prefetching Policy.
 Policy derivedPrefetch()
           
static Policy.TokenPolicy forToken(java.lang.Object token)
          Create a prefetch Policy.TokenPolicy that uses token to notify when the result has arrived.
static Policy.TimeStampPolicy fromNow()
          Create a new Policy.TokenPolicy only accepting values arriving after this point in time.
<T> T
getAcceptable(IResult<T> result)
           
 boolean isDoneOrToken(IResult<?> result)
           
 boolean requireNewerThan(IResult<?> result)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CACHED_OR_NULL

public static final Policy CACHED_OR_NULL
Policy when you don't want any round trips, just the latest (if anything) already in the cache. (This may still cause round trips in non-caching implementations.)


SOMETHING

public static final Policy SOMETHING
Policy when you just want something (non-null), but don't care if it is old. Only does round trips when nothing is cached.


PREFETCH_SOMETHING

public static final Policy PREFETCH_SOMETHING
Initiate prefetch if nothing is cached.


NOTHING_CACHED

public static final Policy NOTHING_CACHED
Policy when you don't want anything that is cached. This will cause round trips.

Constructor Detail

Policy

protected Policy()
Internal constructor for subclasses.

Method Detail

fromNow

public static Policy.TimeStampPolicy fromNow()
Create a new Policy.TokenPolicy only accepting values arriving after this point in time. It is recommended that this is only used on explicit user request, such as a refresh.

Returns:
a Policy.TimeStampPolicy only accepting values from this point in time.

forToken

public static Policy.TokenPolicy forToken(java.lang.Object token)
Create a prefetch Policy.TokenPolicy that uses token to notify when the result has arrived.

Parameters:
token -
Returns:
a Policy.TokenPolicy
See Also:
INotificationService

createPrefetch

protected abstract Policy createPrefetch()
Create a new prefetching Policy.

Returns:
the policy

requireNewerThan

public boolean requireNewerThan(IResult<?> result)
Parameters:
result -
Returns:
true if a newer result than result is needed.

getAcceptable

public <T> T getAcceptable(IResult<T> result)
                throws GarbageCollectedException,
                       SpiException
Type Parameters:
T -
Parameters:
result -
Returns:
the value or possibly null if the result is pending and this policy is non-blocking.
Throws:
GarbageCollectedException
SpiException

isDoneOrToken

public boolean isDoneOrToken(IResult<?> result)
Parameters:
result -
Returns:
The result of result.isDone()

derivedPrefetch

public Policy derivedPrefetch()
Returns:
a policy similar to this one but that triggers a prefetch if needed. When used in an operation, the return value (typically null) should be ignored.


Copyright © 1999, 2011, Oracle and/or its affiliates. All rights reserved.