Skip to content

Commit

Permalink
SWITCHYARD-1828 Distinguish between binding lifecycle not present and…
Browse files Browse the repository at this point in the history
… stopped
  • Loading branch information
cunningt committed Jul 14, 2015
1 parent a9118f8 commit a392be4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ public enum State {
/** Started. */
STARTED,
/** Stopping. */
STOPPING;
STOPPING,
/** Stopped. */
STOPPED;
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public String getValue(Binding binding) {
@Override
public String getValue(Binding binding) {
return binding.getState() == null
|| EnumSet.<State> of(State.NONE, State.STOPPING).contains(binding.getState()) ? Singleton.MESSAGES.label_start()
|| EnumSet.<State> of(State.NONE, State.STOPPING, State.STOPPED).contains(binding.getState()) ? Singleton.MESSAGES.label_start()
: Singleton.MESSAGES.label_stop();
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public synchronized void start() {
if (_state == State.STARTED) {
// already started
return;
} else if (_state != State.NONE) {
} else if ((_state == State.STARTING) || (_state == State.STARTED)
|| (_state == State.STOPPING)) {
throw BaseDeployMessages.MESSAGES.invalidHandlerState();
}
final ClassLoader oldTCCL = Thread.currentThread().getContextClassLoader();
Expand All @@ -72,7 +73,7 @@ protected void doStart() {

@Override
public synchronized void stop() {
if (_state == State.NONE) {
if ((_state == State.NONE) || (_state == State.STOPPED)) {
// already stopped
return;
} else if (_state != State.STARTED) {
Expand All @@ -87,7 +88,7 @@ public synchronized void stop() {
setState(State.STOPPING);
try {
doStop();
setState(State.NONE);
setState(State.STOPPED);
} catch (RuntimeException e) {
setState(State.STARTED);
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ public enum State {
* In the process of stopping, i.e. stop() has been invoked, but has not
* yet completed.
*/
STOPPING;
STOPPING,
/**
* The object has stopped.
*/
STOPPED;
}

/**
Expand Down

0 comments on commit a392be4

Please sign in to comment.