Esempio n. 1
0
  /**
   * Process statistics for this message
   *
   * @param synCtx the current message
   */
  protected void prepareForEndpointStatistics(MessageContext synCtx) {
    // Setting Required property to reportForComponent the End Point aspects
    if (definition != null && definition.isStatisticsEnable()) {
      String opName = null;

      if (synCtx.getProperty(SynapseConstants.ENDPOINT_OPERATION) != null) {
        opName = synCtx.getProperty(SynapseConstants.ENDPOINT_OPERATION).toString();
      } else if (synCtx instanceof Axis2MessageContext) {
        AxisOperation operation =
            ((Axis2MessageContext) synCtx).getAxis2MessageContext().getAxisOperation();
        if (operation != null) {
          opName = operation.getName().getLocalPart();
        }
        if (opName == null
            || SynapseConstants.SYNAPSE_OPERATION_NAME.getLocalPart().equals(opName)) {
          String soapAction = synCtx.getSoapAction();
          opName = null;
          if (soapAction != null) {
            int index = soapAction.indexOf("urn:");
            if (index >= 0) {
              opName = soapAction.substring("urn:".length());
            } else {
              opName = soapAction;
            }
          }
        }
      }

      AspectConfiguration oldConfiguration = definition.getAspectConfiguration();
      if (opName != null) {
        AspectConfiguration newConfiguration =
            new AspectConfiguration(
                oldConfiguration.getId() + SynapseConstants.STATISTICS_KEY_SEPARATOR + opName);
        if (oldConfiguration.isStatisticsEnable()) {
          newConfiguration.enableStatistics();
        }
        if (oldConfiguration.isTracingEnabled()) {
          newConfiguration.enableTracing();
        }
      }
    }
  }