mil.dod.th.ose.remote/src/mil/dod/th/ose/remote/osgi/EventAdminMessageService.java
private Message registerForEvent(final TerraHarvestMessage request, final EventAdminNamespace message, 
            final RemoteChannel channel) throws IOException 
    {
        //parse the message
        final EventRegistrationRequestData requestData = 
                EventRegistrationRequestData.parseFrom(message.getData());

        Integer regId = registrationExists(requestData, request.getSourceId(), request.getEncryptType());
        if (regId != -1)
        {
            m_Logging.debug("Use existing registration %d", regId);
        }
        else
        {
            registerListenerLocally(++m_LastRegId, requestData, request.getSourceId(), request.getEncryptType(), -1);
            regId = m_LastRegId;

            try
            {
                persistRegistration(requestData, m_LastRegId, request.getSourceId(), request.getEncryptType());
            }
            catch (final PersistenceFailedException exception) 
            {
                // send appropriate response
                final String errorDesc = "Failed persisting the remote registration, the registration will not be "
                        + "known if the system restarts.";
                m_MessageFactory.createBaseErrorMessage(request, ErrorCode.PERSIST_ERROR,
                        errorDesc + exception.getMessage()).queue(channel);
                m_Logging.error(exception, errorDesc);
                return requestData;
            }
        }
        
        //construct response message
        final EventRegistrationResponseData data = EventRegistrationResponseData.newBuilder().
                setId(regId).build();
        m_MessageFactory.createEventAdminResponseMessage(request, EventAdminMessageType.EventRegistrationResponse, 
                data).queue(channel);
        
        m_Logging.info("Registered to listen to events remotely with given request: %s", requestData.toString());
        
        return requestData;
    }
/**
     * Method that registers for notifications of certain events based on the remote 
     * event topic and filter contained within the incoming message.  
     * 
     * @param request
     *      entire remote message for the request
     * @param message
     *      message containing the string filter and topic of a remote event
     * @param channel
     *      channel to use for sending a response
     * @throws IOException 
     *      if message cannot be parsed or if response message cannot be sent
     * @return
     *      the data message for this request 
     */
Method that registers for notifications of certain events based on the remote
event topic and filter contained within the incoming message.


Method that registers for notifications of certain events based on the remote event topic and filter contained within the incoming message .
private Message registerForEvent(final TerraHarvestMessage request, final EventAdminNamespace message, 
            final RemoteChannel channel) throws IOException 
    {
        final EventRegistrationRequestData requestData = 
                EventRegistrationRequestData.parseFrom(message.getData());
        Integer regId = registrationExists(requestData, request.getSourceId(), request.getEncryptType());
        if (regId != -1)
        {
            m_Logging.debug("Use existing registration %d", regId);
        }
        else
        {
            registerListenerLocally(++m_LastRegId, requestData, request.getSourceId(), request.getEncryptType(), -1);
            regId = m_LastRegId;
            try
            {
                persistRegistration(requestData, m_LastRegId, request.getSourceId(), request.getEncryptType());
            }
            catch (final PersistenceFailedException exception) 
            {
                final String errorDesc = "Failed persisting the remote registration, the registration will not be "
                        + "known if the system restarts.";
                m_MessageFactory.createBaseErrorMessage(request, ErrorCode.PERSIST_ERROR,
                        errorDesc + exception.getMessage()).queue(channel);
                m_Logging.error(exception, errorDesc);
                return requestData;
            }
        }
        final EventRegistrationResponseData data = EventRegistrationResponseData.newBuilder().
                setId(regId).build();
        m_MessageFactory.createEventAdminResponseMessage(request, EventAdminMessageType.EventRegistrationResponse, 
                data).queue(channel);
        m_Logging.info("Registered to listen to events remotely with given request: %s", requestData.toString());
        return requestData;
    }
private Message registerForEvent ( final TerraHarvestMessage request , final EventAdminNamespace message , final RemoteChannel channel ) throws IOException { final EventRegistrationRequestData requestData = EventRegistrationRequestData . parseFrom ( message . getData ( ) ) ; Integer regId = registrationExists ( requestData , request . getSourceId ( ) , request . getEncryptType ( ) ) ; if ( regId != - 1 ) { m_Logging . debug ( "Use existing registration %d" , regId ) ; } else { registerListenerLocally ( ++ m_LastRegId , requestData , request . getSourceId ( ) , request . getEncryptType ( ) , - 1 ) ; regId = m_LastRegId ; try { persistRegistration ( requestData , m_LastRegId , request . getSourceId ( ) , request . getEncryptType ( ) ) ; } catch ( final PersistenceFailedException exception ) { final String errorDesc = "Failed persisting the remote registration, the registration will not be " + "known if the system restarts." ; m_MessageFactory . createBaseErrorMessage ( request , ErrorCode . PERSIST_ERROR , errorDesc + exception . getMessage ( ) ) . queue ( channel ) ; m_Logging . error ( exception , errorDesc ) ; return requestData ; } } final EventRegistrationResponseData data = EventRegistrationResponseData . newBuilder ( ) . setId ( regId ) . build ( ) ; m_MessageFactory . createEventAdminResponseMessage ( request , EventAdminMessageType . EventRegistrationResponse , data ) . queue ( channel ) ; m_Logging . info ( "Registered to listen to events remotely with given request: %s" , requestData . toString ( ) ) ; return requestData ; }
Method that registers for notifications of certain events based on the remote
 event topic and filter contained within the incoming message.
Method that registers for notifications of certain events based on the remote event topic and filter contained within the incoming message .
//parse the message // send appropriate response //construct response message