void processAppCommand ( final HttpServerExchange exchange , final RequestData requestData , final MCMPAction action ) throws IOException { final String contextPath = requestData . getFirst ( CONTEXT ) ; final String jvmRoute = requestData . getFirst ( JVMROUTE ) ; final String aliases = requestData . getFirst ( ALIAS ) ; if ( contextPath == null || jvmRoute == null || aliases == null ) { processError ( TYPESYNTAX , SMISFLD , exchange ) ; return ; } final List < String > virtualHosts = Arrays . asList ( aliases . split ( "," ) ) ; if ( virtualHosts == null || virtualHosts . isEmpty ( ) ) { processError ( TYPESYNTAX , SCONBAD , exchange ) ; return ; } String response = null ; switch ( action ) { case ENABLE : if ( ! container . enableContext ( contextPath , jvmRoute , virtualHosts ) ) { processError ( MCMPErrorCode . CANT_UPDATE_CONTEXT , exchange ) ; return ; } break ; case DISABLE : if ( ! container . disableContext ( contextPath , jvmRoute , virtualHosts ) ) { processError ( MCMPErrorCode . CANT_UPDATE_CONTEXT , exchange ) ; return ; } break ; case STOP : int i = container . stopContext ( contextPath , jvmRoute , virtualHosts ) ; final StringBuilder builder = new StringBuilder ( ) ; builder . append ( "Type=STOP-APP-RSP,JvmRoute=" ) . append ( jvmRoute ) ; builder . append ( "Alias=" ) . append ( aliases ) ; builder . append ( "Context=" ) . append ( contextPath ) ; builder . append ( "Requests=" ) . append ( i ) ; response = builder . toString ( ) ; break ; case REMOVE : if ( ! container . removeContext ( contextPath , jvmRoute , virtualHosts ) ) { processError ( MCMPErrorCode . CANT_UPDATE_CONTEXT , exchange ) ; return ; } break ; default : { processError ( TYPESYNTAX , SMISFLD , exchange ) ; return ; } } if ( response != null ) { sendResponse ( exchange , response ) ; } else { processOK ( exchange ) ; } }
Process a command targeting an application .