예제 #1
0
  public Message toMessage(Object obj, Session session)
      throws JMSException, MessageConversionException {
    if (!(obj instanceof OperationLog)) {
      throw new MessageConversionException("Object isn't a WorkState");
    }

    OperationLog optLog = (OperationLog) obj;
    MapMessage msg = session.createMapMessage();
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    msg.setInt("mainType", optLog.getMainType().intValue());
    msg.setInt("minorType", optLog.getMinorType().intValue());
    msg.setInt("ctrlUnitId", optLog.getCtrlUnitId().intValue());
    msg.setInt("userId", optLog.getUserId().intValue());
    msg.setString("triggerTime", dateFormat.format(optLog.getTriggerTime()));
    msg.setInt("resourceId", optLog.getResourceId().intValue());
    msg.setString("logTxt", optLog.getLogTxt());

    return msg;
  }