anon.client
Class AbstractAutoSwitchedMixCascadeContainer

java.lang.Object
  extended by java.util.Observable
      extended by anon.client.BasicTrustModel
          extended by anon.infoservice.AbstractMixCascadeContainer
              extended by anon.client.AbstractAutoSwitchedMixCascadeContainer
All Implemented Interfaces:
ITrustModel, IServiceContainer
Direct Known Subclasses:
Controller.AutoSwitchedMixCascadeContainer, JAPController.AutoSwitchedMixCascadeContainer

public abstract class AbstractAutoSwitchedMixCascadeContainer
extends AbstractMixCascadeContainer

This class returns a new random cascade from all currently available cascades every time getNextCascade() is called. If all available cascades have been returned once, this class starts again by choosing the random cascades from all available ones.

Author:
Rolf Wendolsky

Field Summary
private  java.util.Hashtable m_alreadyTriedCascades
           
private  boolean m_bKeepCurrentCascade
           
private  boolean m_bSkipInitialCascade
           
private  MixCascade m_currentCascade
           
private  MixCascade m_initialCascade
           
private  java.util.Random m_random
           
 
Constructor Summary
AbstractAutoSwitchedMixCascadeContainer(boolean a_bSkipInitialCascade, MixCascade a_initialCascade)
           
 
Method Summary
 void checkTrust(MixCascade a_cascade)
           
 MixCascade getCurrentCascade()
          Returns the last return value of getNextCascade().
 MixCascade getInitialCascade()
           
 MixCascade getNextCascade()
          Must return a MixCascade and never null.
private  MixCascade getNextCascade(boolean a_bForceNextRandom)
           
 MixCascade getNextRandomCascade()
          Explicitly chooses the next cascade at random.
abstract  boolean isPaidServiceAllowed()
           
abstract  boolean isReconnectedAutomatically()
           
abstract  boolean isServiceAutoSwitched()
           
private  boolean isSuitableCascade(MixCascade a_cascade)
           
 void keepCurrentService(boolean a_bKeepCurrentCascade)
          Optional method that should allow to return the last MixCascade (Service) that was returned by getNextService() also the next time this method is called.
 boolean setCurrentCascade(MixCascade a_cascade)
           
 
Methods inherited from class anon.infoservice.AbstractMixCascadeContainer
getCurrentService
 
Methods inherited from class anon.client.BasicTrustModel
isTrusted, isTrusted
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface anon.client.ITrustModel
isTrusted
 

Field Detail

m_alreadyTriedCascades

private java.util.Hashtable m_alreadyTriedCascades

m_random

private java.util.Random m_random

m_initialCascade

private MixCascade m_initialCascade

m_currentCascade

private MixCascade m_currentCascade

m_bKeepCurrentCascade

private boolean m_bKeepCurrentCascade

m_bSkipInitialCascade

private boolean m_bSkipInitialCascade
Constructor Detail

AbstractAutoSwitchedMixCascadeContainer

public AbstractAutoSwitchedMixCascadeContainer(boolean a_bSkipInitialCascade,
                                               MixCascade a_initialCascade)
Method Detail

getInitialCascade

public final MixCascade getInitialCascade()

getNextRandomCascade

public final MixCascade getNextRandomCascade()
Explicitly chooses the next cascade at random. If auto-reconnect is active, this method is equal to getNextCascade().

Returns:
the next cascade at random

getNextCascade

public final MixCascade getNextCascade()
Description copied from class: AbstractMixCascadeContainer
Must return a MixCascade and never null. The returned MixCascade may change with every call of this method.

Specified by:
getNextCascade in class AbstractMixCascadeContainer
Returns:
a MixCascade and never null

getNextCascade

private final MixCascade getNextCascade(boolean a_bForceNextRandom)

isServiceAutoSwitched

public abstract boolean isServiceAutoSwitched()
Specified by:
isServiceAutoSwitched in interface IServiceContainer
Specified by:
isServiceAutoSwitched in class AbstractMixCascadeContainer

isReconnectedAutomatically

public abstract boolean isReconnectedAutomatically()
Specified by:
isReconnectedAutomatically in interface IServiceContainer
Specified by:
isReconnectedAutomatically in class AbstractMixCascadeContainer

isPaidServiceAllowed

public abstract boolean isPaidServiceAllowed()

isSuitableCascade

private final boolean isSuitableCascade(MixCascade a_cascade)

getCurrentCascade

public final MixCascade getCurrentCascade()
Description copied from class: AbstractMixCascadeContainer
Returns the last return value of getNextCascade().

Specified by:
getCurrentCascade in class AbstractMixCascadeContainer
Returns:
the last return value of getNextCascade() (may be null if no call has been done yet)

setCurrentCascade

public final boolean setCurrentCascade(MixCascade a_cascade)

keepCurrentService

public final void keepCurrentService(boolean a_bKeepCurrentCascade)
Description copied from class: AbstractMixCascadeContainer
Optional method that should allow to return the last MixCascade (Service) that was returned by getNextService() also the next time this method is called.

Specified by:
keepCurrentService in interface IServiceContainer
Specified by:
keepCurrentService in class AbstractMixCascadeContainer
Parameters:
a_bKeepCurrentCascade - allows or dissallows to keep the current cascade for the next call

checkTrust

public final void checkTrust(MixCascade a_cascade)
                      throws TrustException,
                             java.security.SignatureException
Specified by:
checkTrust in interface ITrustModel
Overrides:
checkTrust in class BasicTrustModel
Throws:
TrustException
java.security.SignatureException