コード例 #1
0
  /**
   * Save endpoint properties
   *
   * @param model
   * @param endpoint
   */
  protected void saveProperties(EndPoint model, AbstractEndpoint endpoint) {
    for (Iterator<EndPointProperty> iterator = model.getProperties().iterator();
        iterator.hasNext(); ) {
      EndPointProperty property = iterator.next();
      MediatorProperty mediatorProperty = new MediatorProperty();
      mediatorProperty.setName(property.getName());

      if (property.getValueType().toString().equals("EXPRESSION")) {
        SynapseXPath XPath = null;
        try {
          XPath = new SynapseXPath(property.getValueExpression().getPropertyValue());
          for (int i = 0; i < property.getValueExpression().getNamespaces().keySet().size(); ++i) {
            String prefix =
                (String) property.getValueExpression().getNamespaces().keySet().toArray()[i];
            String namespaceUri = property.getValueExpression().getNamespaces().get(prefix);
            XPath.addNamespace(prefix, namespaceUri);
            mediatorProperty.setExpression(XPath);
          }
        } catch (JaxenException e) {
          log.error("Error while persisting Endpoint properties", e);
        }
      } else if (property.getValueType().toString().equals("LITERAL")) {
        mediatorProperty.setValue(property.getValue());
      }

      mediatorProperty.setScope(property.getScope().toString().toLowerCase());
      endpoint.addProperty(mediatorProperty);
    }
  }
コード例 #2
0
  public OMElement serializeSpecificMediator(Mediator m) {

    if (!(m instanceof RelayTransformerMediator)) {
      handleException("Unsupported mediator passed in for serialization : " + m.getType());
    }

    RelayTransformerMediator mediator = (RelayTransformerMediator) m;
    OMElement relayTransformer = fac.createOMElement("relayTransformer", synNS);

    if (mediator.getXsltKey() != null) {
      // Serialize Value using ValueSerializer
      ValueSerializer keySerializer = new ValueSerializer();
      keySerializer.serializeValue(mediator.getXsltKey(), XMLConfigConstants.KEY, relayTransformer);
    } else {
      handleException("Invalid relayTransformer mediator. XSLT registry key is required");
    }
    saveTracingState(relayTransformer, mediator);

    if (mediator.getSource() != null) {

      SynapseXPathSerializer.serializeXPath(mediator.getSource(), relayTransformer, "source");
    }
    if (mediator.getTargetPropertyName() != null) {
      relayTransformer.addAttribute(
          fac.createOMAttribute("target", nullNS, mediator.getTargetPropertyName()));
    }
    if (mediator.getInputType() != null) {
      relayTransformer.addAttribute(
          fac.createOMAttribute("input", nullNS, mediator.getInputType()));
    }
    serializeProperties(relayTransformer, mediator.getProperties());
    List<MediatorProperty> features = mediator.getFeatures();
    if (!features.isEmpty()) {
      for (MediatorProperty mp : features) {
        OMElement prop = fac.createOMElement("feature", synNS, relayTransformer);
        if (mp.getName() != null) {
          prop.addAttribute(fac.createOMAttribute("name", nullNS, mp.getName()));
        } else {
          handleException("The Feature name is missing");
        }
        if (mp.getValue() != null) {
          prop.addAttribute(fac.createOMAttribute("value", nullNS, mp.getValue()));
        } else {
          handleException("The Feature value is missing");
        }
      }
    }
    serializeMediatorProperties(relayTransformer, mediator.getAttributes(), ATTRIBUTE_Q);

    ResourceMapSerializer.serializeResourceMap(relayTransformer, mediator.getResourceMap());

    return relayTransformer;
  }
コード例 #3
0
 /**
  * Add all the properties to the endpoint
  *
  * @param mediatorProperties <code>Collection</code> of properties to be added
  */
 public void addProperties(Collection<MediatorProperty> mediatorProperties) {
   for (MediatorProperty property : mediatorProperties) {
     properties.put(property.getName(), property);
   }
 }
コード例 #4
0
 /**
  * Add a property to the endpoint.
  *
  * @param property property to be added
  */
 public void addProperty(MediatorProperty property) {
   properties.put(property.getName(), property);
 }
コード例 #5
0
  public void send(MessageContext synCtx) {

    logSetter();

    Integer statisticReportingIndex = null;
    boolean isStatisticsEnabled = RuntimeStatisticCollector.isStatisticsEnabled();
    if (isStatisticsEnabled) {
      statisticReportingIndex =
          OpenEventCollector.reportEntryEvent(
              synCtx,
              getReportingName(),
              definition.getAspectConfiguration(),
              ComponentType.ENDPOINT);
    }

    boolean traceOn = isTraceOn(synCtx);
    boolean traceOrDebugOn = isTraceOrDebugOn(traceOn);

    if (!initialized) {
      // can't send to a non-initialized endpoint. This is a program fault
      throw new IllegalStateException(
          "not initialized, " + "endpoint must be in initialized state");
    }

    prepareForEndpointStatistics(synCtx);

    if (traceOrDebugOn) {
      String address = definition.getAddress();
      if (address == null && synCtx.getTo() != null && synCtx.getTo().getAddress() != null) {
        // compute address for the default endpoint only for logging purposes
        address = synCtx.getTo().getAddress();
      }

      traceOrDebug(
          traceOn,
          "Sending message through endpoint : " + getName() + " resolving to address = " + address);
      traceOrDebug(
          traceOn,
          "SOAPAction: " + (synCtx.getSoapAction() != null ? synCtx.getSoapAction() : "null"));
      traceOrDebug(
          traceOn,
          "WSA-Action: " + (synCtx.getWSAAction() != null ? synCtx.getWSAAction() : "null"));
      if (traceOn && trace.isTraceEnabled()) {
        trace.trace("Envelope : \n" + synCtx.getEnvelope());
      }
    }

    // push the errorHandler sequence into the current message as the fault handler
    if (errorHandler != null) {
      Mediator errorHandlerMediator = synCtx.getSequence(errorHandler);
      if (errorHandlerMediator != null) {
        if (traceOrDebugOn) {
          traceOrDebug(
              traceOn,
              "Setting the onError handler : "
                  + errorHandler
                  + " for the endpoint : "
                  + endpointName);
        }
        synCtx.pushFaultHandler(new MediatorFaultHandler(errorHandlerMediator));
      } else {
        log.warn(
            "onError handler sequence : "
                + errorHandler
                + " for : "
                + endpointName
                + " cannot be found");
      }
    }

    // register this as the immediate fault handler for this message.
    synCtx.pushFaultHandler(this);
    // add this as the last endpoint to process this message - used by statistics counting code
    synCtx.setProperty(SynapseConstants.LAST_ENDPOINT, this);
    // set message level metrics collector
    org.apache.axis2.context.MessageContext axis2Ctx =
        ((Axis2MessageContext) synCtx).getAxis2MessageContext();
    axis2Ctx.setProperty(BaseConstants.METRICS_COLLECTOR, metricsMBean);

    if (contentAware) {
      try {
        RelayUtils.buildMessage(((Axis2MessageContext) synCtx).getAxis2MessageContext(), false);
        axis2Ctx.setProperty(RelayConstants.FORCE_RESPONSE_EARLY_BUILD, Boolean.TRUE);
        if (forceBuildMC) {
          ((Axis2MessageContext) synCtx).getAxis2MessageContext().getEnvelope().build();
        }
      } catch (Exception e) {
        handleException("Error while building message", e);
      }
    }

    evaluateProperties(synCtx);

    // if the envelope preserving set build the envelope
    MediatorProperty preserveEnv = getProperty(SynapseConstants.PRESERVE_ENVELOPE);
    if (preserveEnv != null
        && JavaUtils.isTrueExplicitly(
            preserveEnv.getValue() != null
                ? preserveEnv.getValue()
                : preserveEnv.getEvaluatedExpression(synCtx))) {
      if (traceOrDebugOn) {
        traceOrDebug(
            traceOn,
            "Preserving the envelope by building it before "
                + "sending, since it is explicitly set");
      }
      synCtx.getEnvelope().build();
    }

    // Send the message through this endpoint
    synCtx.getEnvironment().send(definition, synCtx);

    if (isStatisticsEnabled) {
      CloseEventCollector.closeEntryEvent(
          synCtx, getReportingName(), ComponentType.ENDPOINT, statisticReportingIndex, false);
    }
  }