Package net.jxta.endpoint

Examples of net.jxta.endpoint.MessageElement


       
        Message ackMsg = new Message();
       
        //echo the mode
        String mode = MODE_WEB;
        MessageElement modeMsgElement =
            msg.getMessageElement(MESSAGE_MODE, MESSAGE_MODE);
        if(modeMsgElement != null) {
            mode = modeMsgElement.toString();
        }       
        ackMsg.addMessageElement(MESSAGE_MODE,
                              new StringMessageElement(MESSAGE_MODE,
                                                       mode,
                                                       null));
       
        ackMsg.addMessageElement(BULK_MESSAGE_MODE,
                new StringMessageElement(BULK_MESSAGE_MODE,
                                         "BULK",
                                         null));
       
        //echo the id
        MessageElement idMsgElement =
        msg.getMessageElement(MESSAGE_ID, MESSAGE_ID);
        String id = idMsgElement.toString();
        ackMsg.addMessageElement(MESSAGE_ID,
                              new StringMessageElement(MESSAGE_ID,
                                                       id,
                                                       null));
        //echo the appid
        MessageElement appidMsgElement =
            msg.getMessageElement(MESSAGE_APPID, MESSAGE_APPID);
        String appid = appidMsgElement.toString();
        ackMsg.addMessageElement(MESSAGE_APPID,
                              new StringMessageElement(MESSAGE_APPID,
                                                       appid,
                                                       null));
        //********** test begin**********************
        //get the current command
        MessageElement commandMsgElement =
            msg.getMessageElement(MESSAGE_COMMAND, MESSAGE_COMMAND);
        String previousCommand = commandMsgElement.toString();
        String theCommand = RETURN_MSG_COMMAND;
        if(previousCommand.equals(ReplicationState.HC_COMMAND)) {
            theCommand = RETURN_HC_MSG_COMMAND;
        }
        //this is a return command
View Full Code Here


    }
   
    static List<String> extractAckIdsListFromMessage(Message msg) {
        List<String> result = new ArrayList();
        byte[] data = null;
        MessageElement ackIdsMsgElement =
            msg.getMessageElement(MESSAGE_ACK_IDS_LIST, MESSAGE_ACK_IDS_LIST);
        if(ackIdsMsgElement != null) {
            data = ackIdsMsgElement.getBytes(false);
        }
        try {
            result = (ArrayList)getObjectValue(data);
        } catch (Exception ex) {
            //deliberate no-op
View Full Code Here

   
    /**
     * true means void return command (i.e. method)
     */   
    public static boolean isVoidMethodReturnMessage(Message msg) {       
        MessageElement commandMsgElement =
            msg.getMessageElement(MESSAGE_COMMAND, MESSAGE_COMMAND);
        String methodName = commandMsgElement.toString();
        if(_logger.isLoggable(Level.FINE)) {
            _logger.fine("ReplicationState>>isVoidMethodReturnMessage:methodName = " + methodName);
        }       
        if(methodName == null) {
            return false;
View Full Code Here

   
    /**
     * true means void return command (i.e. method)
     */   
    public static boolean isHCMessage(Message msg) {       
        MessageElement commandMsgElement =
            msg.getMessageElement(MESSAGE_COMMAND, MESSAGE_COMMAND);
        String methodName = commandMsgElement.toString();
        if(_logger.isLoggable(Level.FINE)) {
            _logger.fine("ReplicationState>>isHCMessage:methodName = " + methodName);
        }       
        if(methodName == null) {
            return false;
View Full Code Here

    /**
     * get extra param from message
     */   
    public static String getExtraParamFromMessage(Message msg) {
        String result = "";
        MessageElement extraParamMsgElement =
            msg.getMessageElement(MESSAGE_EXTRA_PARAM, MESSAGE_EXTRA_PARAM);
        if(extraParamMsgElement != null) {
            result = extraParamMsgElement.toString();
        }
        return result;
    }     
View Full Code Here

    /**
     * @param msg
     * true means a response message
     */   
    public static boolean isResponseMessage(Message msg) {       
        MessageElement commandMsgElement =
            msg.getMessageElement(MESSAGE_COMMAND, MESSAGE_COMMAND);
        String methodName = commandMsgElement.toString();
        if(_logger.isLoggable(Level.FINE)) {
            _logger.fine("ReplicationState>>isResponseMessage:methodName = " + methodName);
        }       
         if(methodName == null) {
            return false;
View Full Code Here

    /**
     * true means ack is required
     */   
    public static boolean isAckRequiredForMessage(Message msg) {
        String ackRequiredString = "N";
        MessageElement ackRequiredMsgElement =
            msg.getMessageElement(MESSAGE_ACK_REQUIRED, MESSAGE_ACK_REQUIRED);
        if(ackRequiredMsgElement != null) {
            ackRequiredString = ackRequiredMsgElement.toString();
        }
        return("Y".equalsIgnoreCase(ackRequiredString));      
    }    
View Full Code Here

        if(!this.getReplicationMeasurementEnabled()) {
            return;
        }
        int measurementInterval = this.getReplicationMeasurementInterval();
        long id = -1L;
        MessageElement idMsgElement =
            receivedMessage.getMessageElement(MESSAGE_ID, MESSAGE_ID);
        if(idMsgElement != null) {
            id = (Long.decode(idMsgElement.toString())).longValue();
            //System.out.println("messageReceived: bulkId = " + id);
        }
        if(id % measurementInterval != 0) {
            return;
        }
        //get send start time for measurements
        long sendStartTime = -1L;
        MessageElement sendStartMsgElement =
            receivedMessage.getMessageElement(MESSAGE_SEND_START_TIME, MESSAGE_SEND_START_TIME);
        if(sendStartMsgElement != null) {
            sendStartTime =
                (Long.decode(sendStartMsgElement.toString())).longValue();
            if(sendStartTime > 0L) {
                //System.out.println("message receipt time: " + (System.currentTimeMillis() - sendStartTime));
            }
        }
        _logger.log(Level.INFO, "messageReceiptSucceeded: bulkId = " + id + " receiptTime = "
View Full Code Here

    private void printIdMessageReceiptStats(Message receivedMessage) {
        if(!this.getReplicationMeasurementEnabled()) {
            return;
        }
        String id = "";
        MessageElement idMsgElement =
            receivedMessage.getMessageElement(MESSAGE_ID, MESSAGE_ID);
        if(idMsgElement != null) {
            id = idMsgElement.toString();
        }
        //get send start time for measurements
        long sendStartTime = -1L;
        MessageElement sendStartMsgElement =
            receivedMessage.getMessageElement(MESSAGE_SEND_START_TIME, MESSAGE_SEND_START_TIME);
        if(sendStartMsgElement != null) {
            sendStartTime =
                (Long.decode(sendStartMsgElement.toString())).longValue();
        }
        _logger.log(Level.INFO, "messageReceiptSucceeded: id = " + id + " receiptTime = "
            + (System.currentTimeMillis() - sendStartTime));        
    }   
View Full Code Here

                }
                return;
            }

            // get the message element named SenderMessage
            MessageElement msgElement = msg.getMessageElement(SenderMessage, SenderMessage);
            MessageElement idMsgElement = msg.getMessageElement(MESSAGE_ID, MESSAGE_ID);
            if(msgElement != null) {
                if(_logger.isLoggable(Level.FINEST)) {
                    _logger.finest("msgElement=" + msgElement.toString());
                }               
            }
            if(idMsgElement != null) {
                if(_logger.isLoggable(Level.FINEST)) {
                    _logger.finest("idMsgElement=" + idMsgElement.toString());
                }                
            }           

            // Get message
            if (msgElement != null) {
View Full Code Here

TOP

Related Classes of net.jxta.endpoint.MessageElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.