當前位置: 首頁>>代碼示例>>Java>>正文


Java ExchangePhase.IN屬性代碼示例

本文整理匯總了Java中org.switchyard.ExchangePhase.IN屬性的典型用法代碼示例。如果您正苦於以下問題:Java ExchangePhase.IN屬性的具體用法?Java ExchangePhase.IN怎麽用?Java ExchangePhase.IN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.switchyard.ExchangePhase的用法示例。


在下文中一共展示了ExchangePhase.IN屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: send

@Override
public synchronized void send(Message message) {
    assertMessageOK(message);

    // Set exchange phase
    if (_phase == null) {
        _phase = ExchangePhase.IN;
        initContentType(message);
    } else if (_phase.equals(ExchangePhase.IN)) {
        _phase = ExchangePhase.OUT;
        initContentType(message);
        // set relatesTo header on OUT context
        Object propertyValue = _message.getContext().getPropertyValue(MESSAGE_ID);
        message.getContext().setProperty(RELATES_TO, propertyValue)
            .addLabels(BehaviorLabel.TRANSIENT.label());
    } else {
        throw RuntimeMessages.MESSAGES.sendMessageNotAllowed(_phase.toString());
    }

    sendInternal(message);
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:21,代碼來源:ExchangeImpl.java

示例2: handleMessage

/**
 * Transform the current message on the exchange.
 * @param exchange exchange
 * @throws TransformationFailureException transformation failure exception
 */
@Override
public void handleMessage(Exchange exchange) throws TransformationFailureException {
    // Initialize transform sequence for operation types
    if (exchange.getPhase() == ExchangePhase.IN) {
        initInTransformSequence(exchange);
    } else {
        initOutTransformSequence(exchange);
    }
    
    // Apply transforms to the message...
    TransformSequence transformSequence = _registry.getTransformSequence(TransformSequence.getCurrentMessageType(exchange), TransformSequence.getTargetMessageType(exchange));
    if (transformSequence != null) {
        transformSequence.associateWith(exchange.getMessage());
    }

    TransformSequence.applySequence(exchange, _registry);
    if (!TransformSequence.assertTransformsApplied(exchange)) {
        QName actualPayloadType = TransformSequence.getCurrentMessageType(exchange);
        QName expectedPayloadType = TransformSequence.getTargetMessageType(exchange);
        throw new TransformationFailureException(RuntimeMessages.MESSAGES.transformationsNotApplied(expectedPayloadType.toString(), actualPayloadType.toString()));
    }

    // Replace the CONTENT_TYPE property to indicate current content type after transform
    setContentType(exchange);
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:30,代碼來源:TransformHandler.java

示例3: handleMessage

@Override
public void handleMessage(Exchange exchange) throws HandlerException {
    // only set the provider on the 'IN' phase
    if (ExchangePhase.IN != exchange.getPhase()) {
        return;
    }
    
    // is a provider already set?
    if (exchange.getProvider() != null) {
        return;
    }
    
    List<Service> services = _domain.getServices(exchange.getConsumer().getTargetServiceName());
    if (services == null || services.isEmpty()) {
        throw RuntimeMessages.MESSAGES.noRegisteredService(exchange.getConsumer().getName().toString());
    }

    // At this stage, just pick the first service implementation we find and go with
    // it.  In the future, it would be nice if we could make this pluggable.
    Service service = services.get(0);
    ServiceOperation consumerOp = exchange.getContract().getConsumerOperation();
    ServiceOperation providerOp = service.getInterface().getOperation(consumerOp.getName());
    
    if (providerOp == null) {
        // try for a default operation
        if (service.getInterface().getOperations().size() == 1) {
            providerOp = service.getInterface().getOperations().iterator().next();
        } else {
            throw RuntimeMessages.MESSAGES.operationNotIncluded(consumerOp.getName(), 
                    service.getName().toString());
        }
    }
    
    // set provider contract and details on exchange
    exchange.provider(service, providerOp);
    for (Policy policy : service.getServiceMetadata().getRequiredPolicies()) {
        PolicyUtil.require(exchange, policy);
    }
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:39,代碼來源:AddressingHandler.java


注:本文中的org.switchyard.ExchangePhase.IN屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。