本文整理汇总了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);
}
示例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);
}
示例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);
}
}