Rename EnsembleListeger to EnsembleListener
This commit is contained in:
@@ -22,44 +22,44 @@ import org.springframework.statemachine.StateMachineContext;
|
||||
import org.springframework.statemachine.listener.AbstractCompositeListener;
|
||||
|
||||
/**
|
||||
* Default {@link EnsembleListeger} dispatcher.
|
||||
* Default {@link EnsembleListener} dispatcher.
|
||||
*
|
||||
* @author Janne Valkealahti
|
||||
*
|
||||
* @param <S> the type of state
|
||||
* @param <E> the type of event
|
||||
*/
|
||||
public class CompositeEnsembleListener<S, E> extends AbstractCompositeListener<EnsembleListeger<S, E>> implements
|
||||
EnsembleListeger<S, E> {
|
||||
public class CompositeEnsembleListener<S, E> extends AbstractCompositeListener<EnsembleListener<S, E>> implements
|
||||
EnsembleListener<S, E> {
|
||||
|
||||
@Override
|
||||
public void stateMachineJoined(StateMachine<S, E> stateMachine, StateMachineContext<S, E> context) {
|
||||
for (Iterator<EnsembleListeger<S, E>> iterator = getListeners().reverse(); iterator.hasNext();) {
|
||||
EnsembleListeger<S, E> listener = iterator.next();
|
||||
for (Iterator<EnsembleListener<S, E>> iterator = getListeners().reverse(); iterator.hasNext();) {
|
||||
EnsembleListener<S, E> listener = iterator.next();
|
||||
listener.stateMachineJoined(stateMachine, context);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateMachineLeft(StateMachine<S, E> stateMachine, StateMachineContext<S, E> context) {
|
||||
for (Iterator<EnsembleListeger<S, E>> iterator = getListeners().reverse(); iterator.hasNext();) {
|
||||
EnsembleListeger<S, E> listener = iterator.next();
|
||||
for (Iterator<EnsembleListener<S, E>> iterator = getListeners().reverse(); iterator.hasNext();) {
|
||||
EnsembleListener<S, E> listener = iterator.next();
|
||||
listener.stateMachineLeft(stateMachine, context);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateChanged(StateMachineContext<S, E> context) {
|
||||
for (Iterator<EnsembleListeger<S, E>> iterator = getListeners().reverse(); iterator.hasNext();) {
|
||||
EnsembleListeger<S, E> listener = iterator.next();
|
||||
for (Iterator<EnsembleListener<S, E>> iterator = getListeners().reverse(); iterator.hasNext();) {
|
||||
EnsembleListener<S, E> listener = iterator.next();
|
||||
listener.stateChanged(context);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ensembleError(StateMachineEnsembleException exception) {
|
||||
for (Iterator<EnsembleListeger<S, E>> iterator = getListeners().reverse(); iterator.hasNext();) {
|
||||
EnsembleListeger<S, E> listener = iterator.next();
|
||||
for (Iterator<EnsembleListener<S, E>> iterator = getListeners().reverse(); iterator.hasNext();) {
|
||||
EnsembleListener<S, E> listener = iterator.next();
|
||||
listener.ensembleError(exception);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ public class DistributedStateMachine<S, E> extends LifecycleObjectSupport implem
|
||||
* Bridge for instructing delegating machine based on what
|
||||
* is happening in an ensemble.
|
||||
*/
|
||||
private class LocalEnsembleListener implements EnsembleListeger<S, E> {
|
||||
private class LocalEnsembleListener implements EnsembleListener<S, E> {
|
||||
|
||||
@Override
|
||||
public void stateMachineJoined(final StateMachine<S, E> stateMachine, final StateMachineContext<S, E> context) {
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.statemachine.ensemble;
|
||||
|
||||
import org.springframework.statemachine.StateMachine;
|
||||
import org.springframework.statemachine.StateMachineContext;
|
||||
|
||||
/**
|
||||
* {@code EnsembleListeger} for various ensemble events.
|
||||
*
|
||||
* @author Janne Valkealahti
|
||||
*
|
||||
* @param <S> the type of state
|
||||
* @param <E> the type of event
|
||||
*/
|
||||
public interface EnsembleListeger<S, E> {
|
||||
|
||||
/**
|
||||
* Called when state machine joined an ensemble. This callback
|
||||
* is guaranteed to be called for a {@link StateMachine} who
|
||||
* requested a join. User of this listener should check that a
|
||||
* {@link StateMachine} is the one interested of. Implementation
|
||||
* may choose to notify other {@link StateMachine} joins if it is
|
||||
* able to do so. This may be called multiple time in case ensemble
|
||||
* has made a choice to leave machine due to ensemble errors.
|
||||
*
|
||||
* @param stateMachine the state machine
|
||||
* @param context the state machine context
|
||||
*/
|
||||
void stateMachineJoined(StateMachine<S, E> stateMachine, StateMachineContext<S, E> context);
|
||||
|
||||
/**
|
||||
* Called when state machine left an ensemble. This callback
|
||||
* is guaranteed to be called for a {@link StateMachine} who
|
||||
* requested a leave. User of this listener should check that a
|
||||
* {@link StateMachine} is the one interested of. Implementation
|
||||
* may choose to notify other {@link StateMachine} leaves if it is
|
||||
* able to do so.
|
||||
*
|
||||
* @param stateMachine the state machine
|
||||
* @param context the state machine context
|
||||
*/
|
||||
void stateMachineLeft(StateMachine<S, E> stateMachine, StateMachineContext<S, E> context);
|
||||
|
||||
/**
|
||||
* Called when ensemble is discovering a state change.
|
||||
*
|
||||
* @param context the state machine context
|
||||
*/
|
||||
void stateChanged(StateMachineContext<S, E> context);
|
||||
|
||||
/**
|
||||
* Called when {@link StateMachineEnsemble} resulted an error.
|
||||
*
|
||||
* @param exception the exception
|
||||
*/
|
||||
void ensembleError(StateMachineEnsembleException exception);
|
||||
|
||||
}
|
||||
@@ -33,8 +33,8 @@ public interface StateMachineEnsemble<S, E> {
|
||||
* Request a join to a state machine ensemble. This method
|
||||
* is a request to join an ensemble and doesn't guarantee
|
||||
* a requester will eventually successfully join. Join operation
|
||||
* needs to be used together with {@link EnsembleListeger} and
|
||||
* {@link EnsembleListeger#stateMachineJoined(StateMachine, StateMachineContext)}
|
||||
* needs to be used together with {@link EnsembleListener} and
|
||||
* {@link EnsembleListener#stateMachineJoined(StateMachine, StateMachineContext)}
|
||||
* is called with a {@link StateMachine} instance for successful join.
|
||||
*
|
||||
* @param stateMachine the state machine
|
||||
@@ -45,7 +45,7 @@ public interface StateMachineEnsemble<S, E> {
|
||||
* Request a leave from an ensemble. This method is a request to
|
||||
* leave an ensemble. After this method is called no further processing
|
||||
* is done for a instance of {@link StateMachine}. Additionally
|
||||
* {@link EnsembleListeger#stateMachineLeft(StateMachine, StateMachineContext)}
|
||||
* {@link EnsembleListener#stateMachineLeft(StateMachine, StateMachineContext)}
|
||||
* is called when leave request is fully processed.
|
||||
*
|
||||
* @param stateMachine the state machine
|
||||
@@ -57,14 +57,14 @@ public interface StateMachineEnsemble<S, E> {
|
||||
*
|
||||
* @param listener the listener
|
||||
*/
|
||||
void addEnsembleListener(EnsembleListeger<S, E> listener);
|
||||
void addEnsembleListener(EnsembleListener<S, E> listener);
|
||||
|
||||
/**
|
||||
* Removes the ensemble listener.
|
||||
*
|
||||
* @param listener the listener
|
||||
*/
|
||||
void removeEnsembleListener(EnsembleListeger<S, E> listener);
|
||||
void removeEnsembleListener(EnsembleListener<S, E> listener);
|
||||
|
||||
/**
|
||||
* Sets the state as a {@link StateMachineContext}.
|
||||
|
||||
@@ -42,12 +42,12 @@ public abstract class StateMachineEnsembleObjectSupport<S, E> extends LifecycleO
|
||||
public abstract void leave(StateMachine<S, E> stateMachine);
|
||||
|
||||
@Override
|
||||
public void addEnsembleListener(EnsembleListeger<S, E> listener) {
|
||||
public void addEnsembleListener(EnsembleListener<S, E> listener) {
|
||||
ensembleListener.register(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeEnsembleListener(EnsembleListeger<S, E> listener) {
|
||||
public void removeEnsembleListener(EnsembleListener<S, E> listener) {
|
||||
ensembleListener.unregister(listener);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.springframework.statemachine.StateMachine;
|
||||
import org.springframework.statemachine.StateMachineContext;
|
||||
import org.springframework.statemachine.StateMachineException;
|
||||
import org.springframework.statemachine.access.StateMachineAccessor;
|
||||
import org.springframework.statemachine.ensemble.EnsembleListeger;
|
||||
import org.springframework.statemachine.ensemble.EnsembleListener;
|
||||
import org.springframework.statemachine.ensemble.StateMachineEnsembleException;
|
||||
import org.springframework.statemachine.listener.StateMachineListener;
|
||||
import org.springframework.statemachine.state.State;
|
||||
@@ -641,7 +641,7 @@ public class ZookeeperStateMachineEnsembleTests extends AbstractZookeeperTests {
|
||||
return new AnnotationConfigApplicationContext();
|
||||
}
|
||||
|
||||
private class TestEnsembleListener implements EnsembleListeger<String, String> {
|
||||
private class TestEnsembleListener implements EnsembleListener<String, String> {
|
||||
|
||||
volatile CountDownLatch joinedLatch = new CountDownLatch(1);
|
||||
volatile CountDownLatch eventLatch = new CountDownLatch(1);
|
||||
|
||||
Reference in New Issue
Block a user