public IllegalStateTransitionException(AMQState originalState, Type frame) : base("No valid state transition defined for receiving frame " + frame + " from state " + originalState) { _originalState = originalState; _frame = frame; }
public AMQStateManager() { _syncLock = new object(); _state2HandlersMap = new Hashtable(); _stateListeners = ArrayList.Synchronized(new ArrayList(5)); _currentState = AMQState.CONNECTION_NOT_STARTED; RegisterListeners(); }
public void StateChanged(AMQState oldState, AMQState newState) { _newState = newState; if (_logger.IsDebugEnabled) { _logger.Debug("stateChanged called"); } if (_state == newState) { _newStateAchieved = true; if (_logger.IsDebugEnabled) { _logger.Debug("New state reached so notifying monitor"); } _resetEvent.Set(); } }
public void AttainState(AMQState s) { if (_currentState != s) { StateWaiter sw = null; try { _logger.Debug("Adding state wait to reach state " + s); sw = new StateWaiter(s); AddStateListener(sw); sw.WaituntilStateHasChanged(); // at this point the state will have changed. } finally { RemoveStateListener(sw); } } }
/// <summary> /// Changes the state. /// </summary> /// <param name="newState">The new state.</param> /// <exception cref="AMQException">if there is an error changing state</exception> public void ChangeState(AMQState newState) { if (InfoLoggingHack) { _logger.Debug("State changing to " + newState + " from old state " + _currentState); } _logger.Debug("State changing to " + newState + " from old state " + _currentState); AMQState oldState = _currentState; _currentState = newState; lock ( _syncLock ) { foreach (IStateListener l in _stateListeners) { l.StateChanged(oldState, newState); } } }
/// <summary> /// Finds the state transition handler. /// </summary> /// <param name="currentState">State of the current.</param> /// <param name="frame">The frame.</param> /// <returns></returns> /// <exception cref="IllegalStateTransitionException">if the state transition if not allowed</exception> private IStateAwareMethodListener FindStateTransitionHandler(AMQState currentState, AMQMethodBody frame) { Type clazz = frame.GetType(); if (_logger.IsDebugEnabled) { _logger.Debug("Looking for state transition handler for frame " + clazz); } IDictionary classToHandlerMap = (IDictionary)_state2HandlersMap[currentState]; if (classToHandlerMap == null) { // if no specialised per state handler is registered look for a // handler registered for "all" states return(FindStateTransitionHandler(AMQState.ALL, frame)); } IStateAwareMethodListener handler = (IStateAwareMethodListener)classToHandlerMap[clazz]; if (handler == null) { if (currentState == AMQState.ALL) { _logger.Debug("No state transition handler defined for receiving frame " + frame); Console.WriteLine(" *** No state transition handler defined for receiving frame " + frame); //KHC return(null); } else { // if no specialised per state handler is registered look for a // handler registered for "all" states return(FindStateTransitionHandler(AMQState.ALL, frame)); } } else { return(handler); } }
/// <summary> /// Finds the state transition handler. /// </summary> /// <param name="currentState">State of the current.</param> /// <param name="frame">The frame.</param> /// <returns></returns> /// <exception cref="IllegalStateTransitionException">if the state transition if not allowed</exception> private IStateAwareMethodListener FindStateTransitionHandler(AMQState currentState, AMQMethodBody frame) { Type clazz = frame.GetType(); if (_logger.IsDebugEnabled) { _logger.Debug("Looking for state transition handler for frame " + clazz); } IDictionary classToHandlerMap = (IDictionary) _state2HandlersMap[currentState]; if (classToHandlerMap == null) { // if no specialised per state handler is registered look for a // handler registered for "all" states return FindStateTransitionHandler(AMQState.ALL, frame); } IStateAwareMethodListener handler = (IStateAwareMethodListener) classToHandlerMap[clazz]; if (handler == null) { if (currentState == AMQState.ALL) { _logger.Debug("No state transition handler defined for receiving frame " + frame); Console .WriteLine (" *** No state transition handler defined for receiving frame " + frame); //KHC return null; } else { // if no specialised per state handler is registered look for a // handler registered for "all" states return FindStateTransitionHandler(AMQState.ALL, frame); } } else { return handler; } }
/// <summary> /// Changes the state. /// </summary> /// <param name="newState">The new state.</param> /// <exception cref="AMQException">if there is an error changing state</exception> public void ChangeState(AMQState newState) { if (InfoLoggingHack) { _logger.Debug("State changing to " + newState + " from old state " + _currentState); } _logger.Debug("State changing to " + newState + " from old state " + _currentState); AMQState oldState = _currentState; _currentState = newState; lock ( _syncLock ) { foreach ( IStateListener l in _stateListeners ) { l.StateChanged(oldState, newState); } } }
public AMQStateChangedEvent(AMQState oldState, AMQState newState) { _oldState = oldState; _newState = newState; }
public StateWaiter(AMQState state) { _state = state; }
protected IllegalStateTransitionException(SerializationInfo info, StreamingContext ctxt) : base(info, ctxt) { _originalState = (AMQState)info.GetValue("OriginalState", typeof(AMQState)); _frame = (Type)info.GetValue("FrameType", typeof(Type)); }