mil.dod.th.ose.remote/src/mil/dod/th/ose/remote/osgi/BundleManagementMessageService.java
public Message stopBundle(final BundleNamespace message, final TerraHarvestMessage thMessage, 
        final RemoteChannel channel) throws IOException
    {
        //parse request
        final StopRequestData request = StopRequestData.parseFrom(message.getData());
        
        //get the specified bundle
        final Bundle bundle = m_Context.getBundle(request.getBundleId());
        if (bundle == null)
        {
            m_MessageFactory.createBaseErrorMessage(thMessage, ErrorCode.INVALID_VALUE, 
                String.format("The bundle %d requested to stop does not exist!", request.getBundleId())).queue(channel);
        }
        else
        {
            //try to stop bundle
            try
            {
                bundle.stop();
            }
            catch (final BundleException exception)
            {
                //send error
                queueBundleErrorMessage(thMessage, BundleErrorCode.OSGiBundleException, 
                    String.format("The bundle %d could not be stopped : %s", request.getBundleId(),
                        exception.getMessage()), channel);
                m_Logging.error(exception, "A request to stop a bundle, with an id of %d failed",
                        request.getBundleId());
                return request;
            }
            //send response
            m_MessageFactory.createBundleResponseMessage(thMessage, BundleMessageType.StopResponse, null).
                queue(channel);
        }
        
        return request;
    }
/**
     * Handle the stop bundle request.
     * @param message
     *    the message that contains the request to stop a specified bundle
     * @param thMessage
     *    the terra harvest message that the request was originally contained in
     * @param channel
     *    the channel that was used to send request
     * @return
     *    the parsed request message
     * @throws IOException
     *    thrown if the request message cannot be parsed
     */
Handle the stop bundle request.
Handle the stop bundle request .
public Message stopBundle(final BundleNamespace message, final TerraHarvestMessage thMessage, 
        final RemoteChannel channel) throws IOException
    {
        final StopRequestData request = StopRequestData.parseFrom(message.getData());
        final Bundle bundle = m_Context.getBundle(request.getBundleId());
        if (bundle == null)
        {
            m_MessageFactory.createBaseErrorMessage(thMessage, ErrorCode.INVALID_VALUE, 
                String.format("The bundle %d requested to stop does not exist!", request.getBundleId())).queue(channel);
        }
        else
        {
            try
            {
                bundle.stop();
            }
            catch (final BundleException exception)
            {
                queueBundleErrorMessage(thMessage, BundleErrorCode.OSGiBundleException, 
                    String.format("The bundle %d could not be stopped : %s", request.getBundleId(),
                        exception.getMessage()), channel);
                m_Logging.error(exception, "A request to stop a bundle, with an id of %d failed",
                        request.getBundleId());
                return request;
            }
            m_MessageFactory.createBundleResponseMessage(thMessage, BundleMessageType.StopResponse, null).
                queue(channel);
        }
        return request;
    }
public Message stopBundle ( final BundleNamespace message , final TerraHarvestMessage thMessage , final RemoteChannel channel ) throws IOException { final StopRequestData request = StopRequestData . parseFrom ( message . getData ( ) ) ; final Bundle bundle = m_Context . getBundle ( request . getBundleId ( ) ) ; if ( bundle == null ) { m_MessageFactory . createBaseErrorMessage ( thMessage , ErrorCode . INVALID_VALUE , String . format ( "The bundle %d requested to stop does not exist!" , request . getBundleId ( ) ) ) . queue ( channel ) ; } else { try { bundle . stop ( ) ; } catch ( final BundleException exception ) { queueBundleErrorMessage ( thMessage , BundleErrorCode . OSGiBundleException , String . format ( "The bundle %d could not be stopped : %s" , request . getBundleId ( ) , exception . getMessage ( ) ) , channel ) ; m_Logging . error ( exception , "A request to stop a bundle, with an id of %d failed" , request . getBundleId ( ) ) ; return request ; } m_MessageFactory . createBundleResponseMessage ( thMessage , BundleMessageType . StopResponse , null ) . queue ( channel ) ; } return request ; }
Handle the stop bundle request.
Handle the stop bundle request .
//parse request //get the specified bundle //try to stop bundle //send error //send response