Java Code Examples for org.eclipse.wst.server.core.IServer#STATE_STOPPED

The following examples show how to use org.eclipse.wst.server.core.IServer#STATE_STOPPED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalAppEngineConsole.java    From google-cloud-eclipse with Apache License 2.0 8 votes vote down vote up
/**
 * Update the shown name with the server stop/stopping state.
 */
private void updateName(int serverState) {
  final String computedName;
  if (serverState == IServer.STATE_STARTING) {
    computedName = Messages.getString("SERVER_STARTING_TEMPLATE", unprefixedName);
  } else if (serverState == IServer.STATE_STOPPING) {
    computedName = Messages.getString("SERVER_STOPPING_TEMPLATE", unprefixedName);
  } else if (serverState == IServer.STATE_STOPPED) {
    computedName = Messages.getString("SERVER_STOPPED_TEMPLATE", unprefixedName);
  } else {
    computedName = unprefixedName;
  }
  UIJob nameUpdateJob = new UIJob("Update server name") {
    @Override
    public IStatus runInUIThread(IProgressMonitor monitor) {
      LocalAppEngineConsole.this.setName(computedName);
      return Status.OK_STATUS;
    }
  };
  nameUpdateJob.setSystem(true);
  nameUpdateJob.schedule();
}
 
Example 2
Source File: LocalAppEngineServerBehaviour.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Override
public void stop(boolean force) {
  int serverState = getServer().getServerState();
  if (serverState == IServer.STATE_STOPPED) {
    return;
  }
  // If the server seems to be running, and we haven't already tried to stop it,
  // then try to shut it down nicely
  if (devServer != null && (!force || serverState != IServer.STATE_STOPPING)) {
    setServerState(IServer.STATE_STOPPING);
    StopConfiguration.Builder builder = StopConfiguration.builder();
    builder.port(serverPort);
    try {
      devServer.stop(builder.build());
    } catch (AppEngineException ex) {
      logger.log(Level.WARNING, "Error terminating server: " + ex.getMessage(), ex); //$NON-NLS-1$
      terminate();
    }
  } else {
    // we've already given it a chance
    terminate();
  }
}
 
Example 3
Source File: LocalAppEngineServerLaunchConfigurationDelegate.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Override
public void serverChanged(ServerEvent event) {
  Preconditions.checkState(server == event.getServer());
  switch (event.getState()) {
    case IServer.STATE_STARTED:
      openBrowserPage(server);
      fireChangeEvent(DebugEvent.STATE);
      return;

    case IServer.STATE_STOPPED:
      server.removeServerListener(serverEventsListener);
      fireTerminateEvent();
      try {
        logger.fine("Server stopped; terminating launch"); //$NON-NLS-1$
        launch.terminate();
      } catch (DebugException ex) {
        logger.log(Level.WARNING, "Unable to terminate launch", ex); //$NON-NLS-1$
      }
      checkUpdatedDatastoreIndex(launch.getLaunchConfiguration());
      return;

    default:
      fireChangeEvent(DebugEvent.STATE);
      return;
  }
}
 
Example 4
Source File: LocalAppEngineServerLaunchConfigurationDelegate.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Override
public void terminate() throws DebugException {
  int state = server.getServerState();
  if (state != IServer.STATE_STOPPED) {
    serverBehaviour.stop(state == IServer.STATE_STOPPING);
  }
}
 
Example 5
Source File: BOSWebServerManager.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void waitServerStopped(final IProgressMonitor monitor) throws CoreException {
    while (tomcat != null
            && tomcat.getServerState() != IServer.STATE_STOPPED) {
        try {
            Thread.sleep(1000);
        } catch (final InterruptedException e) {
            BonitaStudioLog.error(e, EnginePlugin.PLUGIN_ID);
        }
    }
}
 
Example 6
Source File: LocalAppEngineServerLaunchConfigurationDelegate.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isTerminated() {
  int state = server.getServerState();
  return state == IServer.STATE_STOPPED;
}
 
Example 7
Source File: LocalAppEngineConsole.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
private void update(int serverState) {
  if (serverState == IServer.STATE_STOPPED) {
    disengage(); // we should no longer update
  }
  updateName(serverState);
}
 
Example 8
Source File: GwtWtpPlugin.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Start or stop processes automatically. Start or stop the CodeServer.
 */
private void onDebugEvent(DebugEvent event) throws CoreException {
  if (!(event.getSource() instanceof IProcess)) {
    return;
  }

  IProcess runtimeProcess = (IProcess) event.getSource();
  ILaunch launch = runtimeProcess.getLaunch();
  ILaunchConfiguration launchConfig = launch.getLaunchConfiguration();
  if (launchConfig == null) {
    return;
  }

  IServer server = getServerFromLaunchConfig(launch);
  ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
  ILaunchConfigurationType sdmCodeServerType = launchManager
      .getLaunchConfigurationType(GwtSuperDevModeLaunchConfiguration.TYPE_ID);

  if (launchConfig.getType().equals(sdmCodeServerType)) {
    if (event.getKind() == DebugEvent.CREATE) {
      onAfterCodeServerStarted(event);
    } else if (event.getKind() == DebugEvent.TERMINATE) {
      onAfterCodeServerTerminated(event);
    }
  }

  // pass along the event to server started.
  if (server != null && server.getServerState() == IServer.STATE_STARTING) {
    debugEvent = event;
    startedCodeServer = false; // safety reset
  }

  // WTP Server Start/Stop
  if (server != null && serverListener == null) { // listen for server started. It throws two events...
    serverListener = new IServerListener() {
      @Override
      public void serverChanged(ServerEvent event) {
        if (event.getState() == IServer.STATE_STARTED && !startedCodeServer) {
          startedCodeServer = true;
          onServerStarted(debugEvent);
        }
      }
    };
    server.addServerListener(serverListener);
  }

  if (server != null
      && (server.getServerState() == IServer.STATE_STOPPING || server.getServerState() == IServer.STATE_STOPPED)) {
    // Server Stop: Delineate event for Server Launching and then possibly terminate SDM
    onServerStopped(event);
    serverListener = null;
    startedCodeServer = false;

    onAfterWebServerTerminated(event);
  }
}