/*
(non-Javadoc)

@see com.ibm.ws.sib.admin.JsEngineComponent#serverStopping()
352182
public void serverStopping() {

        final String methodName = "serverStopping";
        if (TRACE.isEntryEnabled()) {
            SibTr.entry(TRACE, methodName);
            SibTr.exit(TRACE, methodName);
        }
        _serverStopping = true;

    }
482796
public final void server() {
    String port = parsedArguments.getString("port");
    String model = parsedArguments.getString(MODEL);
    String lexer = parsedArguments.getString("lexer");
    String dictTag = parsedArguments.getString("dictTag");
    String dictPath = parsedArguments.getString("dictPath");
    String clearFeatures = parsedArguments.getString("clearFeatures");
    String outputFormat = parsedArguments.getString("outputFormat");
    String lang = parsedArguments.getString("language");
    Properties serverproperties = setNameServerProperties(port, model, lang,
        lexer, dictTag, dictPath, clearFeatures, outputFormat);
    new NERTaggerServer(serverproperties);
  }
627008
protected synchronized void doStop() throws Exception
    {
        try
        {
            // Stop servlets
            super.doStop();

            // Stop filters
            for (int i= _filters.size(); i-- > 0;)
            {
                FilterHolder holder= (FilterHolder)_filters.get(i);
                holder.stop();
            }
        }
        finally
        {
            _webApplicationContext= null;
            _sessionListeners= null;
            _requestListeners= null;
            _requestAttributeListeners= null;
            _contextAttributeListeners= null;
        }
    }
876013
public boolean isServerStopping() {

        String thisMethodName = CLASS_NAME + ".isServerStopping()";

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.entry(tc, thisMethodName, this);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.exit(tc, thisMethodName, new Boolean(_serverStopping));
        }

        return _serverStopping;
    }
303305
function cloneServerInitOptions(serverInitOptions) {
    var result = {
        serverUrl: serverInitOptions.serverUrl,
        application: serverInitOptions.application,
        clientApp: serverInitOptions.clientApp,
        tenantOrga: serverInitOptions.tenantOrga,
        logonCallback: serverInitOptions.logonCallback,
    };
    if (result.serverUrl && result.serverUrl[result.serverUrl.length - 1] !== '/') {
        result.serverUrl += '/';
    }
    if (serverInitOptions.clientCertificate) {
        result.clientCertificate = _.clone(serverInitOptions.clientCertificate);
    }
    if (serverInitOptions.agentOptions) {
        result.agentOptions = _.clone(serverInitOptions.agentOptions);
    }
    return result;
}
589764
public void setServerGroups(java.util.Collection<ServerGroup> serverGroups) {
        if (serverGroups == null) {
            this.serverGroups = null;
            return;
        }

        this.serverGroups = new java.util.ArrayList<ServerGroup>(serverGroups);
    }
1195156
public void setStopping()
  {
    if (tc.isEntryEnabled())
    {
      SibTr.entry(tc, "setStopping");
      SibTr.exit(tc, "setStopping");
    }

    _isStopping = true;
    
    return;
  }
1332669
@Nonnull
  public CSSRect setTop (@Nonnull @Nonempty final String sTop)
  {
    ValueEnforcer.notEmpty (sTop, "Top");

    m_sTop = sTop;
    return this;
  }
392069
public ServerListenerBuilder addStoppingCallback(Runnable runnable) {
        requireNonNull(runnable, "runnable");
        serverStoppingCallbacks.add(unused -> runnable.run());
        return this;
    }
31663
@Override
    public void serverStopping() {
        BundleContext bundleContext = componentContext.getBundleContext();
        Collection<ServiceReference<EndpointActivationService>> refs;
        try {
            refs = bundleContext.getServiceReferences(EndpointActivationService.class, null);
        } catch (InvalidSyntaxException x) {
            FFDCFilter.processException(x, getClass().getName(), "61", this);
            throw new RuntimeException(x);
        }
        for (ServiceReference<EndpointActivationService> ref : refs) {
            EndpointActivationService eas = bundleContext.getService(ref);
            try {
                for (ActivationParams a; null != (a = eas.endpointActivationParams.poll());)
                    try {
                        eas.endpointDeactivation((ActivationSpec) a.activationSpec, a.messageEndpointFactory);
                    } catch (Throwable x) {
                        FFDCFilter.processException(x, getClass().getName(), "71", this);
                    }
            } finally {
                bundleContext.ungetService(ref);
            }
        }
    }
1137251
@Override
    public void isLeader() {
        LOG.warn("Server instance with server id {} is elected as leader", serverId);
        serviceState.becomingActive();
        try {
            for (ActiveStateChangeHandler handler : activeStateChangeHandlers) {
                handler.instanceIsActive();
            }
            activeInstanceState.update(serverId);
            serviceState.setActive();
        } catch (Exception e) {
            LOG.error("Got exception while activating", e);
            notLeader();
            rejoinElection();
        }
    }
1266761
@Override
    public void serverStopping() {
        if (bundleContext != null) {
            try {
                Collection<ServiceReference<PauseableComponent>> refs = bundleContext.getServiceReferences(PauseableComponent.class, null);
                for (ServiceReference<PauseableComponent> ref : refs) {

                    PauseableComponent pc = bundleContext.getService(ref);
                    if (!pc.isPaused()) {
                        try {
                            pc.pause();
                        } catch (PauseableComponentException ex) {
                            Tr.warning(tc, "warn.did.not.pause.on.shutdown", ex.getMessage());
                        }
                    }
                }
            } catch (InvalidSyntaxException e) {
                // Should never happen, FFDC and return
                return;
            }
        }

    }
270428
@Override
  public void writeTop(JsonWriterImpl out, T value)
  {
    out.writeStartArray();
    write(out, value);
    out.writeEndArray();
  }
849125
public ProviderConfig<T> setServer(ServerConfig server) {
        if (this.server == null) {
            this.server = new ArrayList<ServerConfig>();
        }
        this.server.add(server);
        return this;
    }
1075347
public void stopServer()
    {
        Log(Level.INFO, "Attempting to stop SocketServer");
        keepRunning = false;
        // Thread will be blocked waiting for input - unblock it by closing the socket underneath it:
        if (this.serverSocket != null)
        {
            try
            {
                this.serverSocket.close();
            }
            catch (IOException e)
            {
                Log(Level.WARNING, "Something happened when closing SocketServer: " + e);
            }
            this.serverSocket = null;
        }
    }
1230652
public static boolean closeServerSocket(ServerSocket serverSocket)
	{
		boolean closed = true;
		try
		{
			if (serverSocket != null && !serverSocket.isClosed())
			{
				serverSocket.close();
				serverSocket = null;
			}
		}
		catch (final IOException e)
		{
			LOGGER.error("IOException occured by trying to close the server socket.", e);
			closed = false;
		}
		finally
		{
			try
			{
				if (serverSocket != null && !serverSocket.isClosed())
				{
					serverSocket.close();
				}
			}
			catch (final IOException e)
			{
				LOGGER.error("IOException occured by trying to close the server socket.", e);
				closed = false;
			}
		}
		return closed;
	}
451073
public void startServer() {

    server = new Server(httpPort);
    server.setHandler(wrapHandlers());

    if (isWebSocketInClassPath()) {
      setupForWebSocket();
    }
    try {
      server.start();
      log().info("server started");

      Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownRunnable()));
      
      if (useStdInShutdown) {
        // generally for use in IDE via JettyRun, Use CTRL-D in IDE console to shutdown
        BufferedReader systemIn = new BufferedReader(new InputStreamReader(System.in, "UTF-8"));
        while((systemIn.readLine()) != null) {
          // ignore anything except CTRL-D by itself
        }
        System.out.println("Shutdown via CTRL-D");
        System.exit(0);
      }

    } catch (Exception e) {
      e.printStackTrace();
      System.exit(100);
    }
  }