use of org.apache.cxf.message.Exchange in project cxf by apache.
the class AbstractJMSTester method createMessageObserver.
protected MessageObserver createMessageObserver() {
return new MessageObserver() {
public void onMessage(Message m) {
Exchange exchange = new ExchangeImpl();
exchange.setInMessage(m);
m.setExchange(exchange);
destMessage = m;
}
};
}
use of org.apache.cxf.message.Exchange in project cxf by apache.
the class STSTokenRetrieverTest method prepareMessage.
private MessageImpl prepareMessage(Bus bus, STSClient stsClient, String serviceAddress) throws EndpointException {
MessageImpl message = new MessageImpl();
message.put(SecurityConstants.STS_CLIENT, stsClient);
message.put(Message.ENDPOINT_ADDRESS, serviceAddress);
Exchange exchange = new ExchangeImpl();
ServiceInfo si = new ServiceInfo();
Service s = new ServiceImpl(si);
EndpointInfo ei = new EndpointInfo();
Endpoint ep = new EndpointImpl(bus, s, ei);
ei.setBinding(new BindingInfo(si, null));
message.setExchange(exchange);
exchange.put(Endpoint.class, ep);
return message;
}
use of org.apache.cxf.message.Exchange in project fabric8 by jboss-fuse.
the class LoadBalanceTargetSelector method getNextConduit.
protected Conduit getNextConduit(Message message) {
Conduit answer = null;
Exchange exchange = message.getExchange();
EndpointInfo ei = endpoint.getEndpointInfo();
String address = loadBalanceStrategy.getNextAlternateAddress();
if (overrideAddress(message)) {
// We need to override the Endpoint Address here
message.put(Message.ENDPOINT_ADDRESS, address);
}
try {
ConduitInitiatorManager conduitInitiatorMgr = exchange.getBus().getExtension(ConduitInitiatorManager.class);
if (conduitInitiatorMgr != null) {
ConduitInitiator conduitInitiator = conduitInitiatorMgr.getConduitInitiatorForUri(address);
if (conduitInitiator != null) {
EndpointReferenceType epr = new EndpointReferenceType();
AttributedURIType ad = new AttributedURIType();
ad.setValue(address);
epr.setAddress(ad);
answer = conduitInitiator.getConduit(ei, epr, exchange.getBus());
MessageObserver observer = exchange.get(MessageObserver.class);
if (observer != null) {
answer.setMessageObserver(observer);
} else {
getLogger().warning("MessageObserver not found");
}
} else {
getLogger().warning("ConduitInitiator not found: " + ei.getAddress());
}
} else {
getLogger().warning("ConduitInitiatorManager not found");
}
} catch (IOException ex) {
throw new Fault(ex);
}
return answer;
}
use of org.apache.cxf.message.Exchange in project tesb-rt-se by Talend.
the class FlowIdProducerIn method handleMessage.
/* (non-Javadoc)
* @see org.apache.cxf.interceptor.Interceptor#handleMessage(org.apache.cxf.message.Message)
*/
public void handleMessage(T message) throws Fault {
String flowId = FlowIdHelper.getFlowId(message);
if (flowId == null) {
flowId = FlowIdProtocolHeaderCodec.readFlowId(message);
}
if (flowId == null) {
flowId = FlowIdSoapCodec.readFlowId(message);
}
if (flowId == null) {
Exchange ex = message.getExchange();
if (null != ex) {
Message reqMsg = ex.getOutMessage();
if (null != reqMsg) {
flowId = FlowIdHelper.getFlowId(reqMsg);
if (null != flowId) {
LOG.fine("Using FlowId '" + flowId + "' from exchange.");
}
}
}
}
if (flowId != null) {
LOG.fine("FlowId '" + flowId + "' found in incoming message.");
} else {
flowId = ContextUtils.generateUUID();
LOG.fine("No flowId found in incoming message! Generate new flowId " + flowId);
}
FlowIdHelper.setFlowId(message, flowId);
}
use of org.apache.cxf.message.Exchange in project tesb-rt-se by Talend.
the class FlowIdProducerOut method handleResponseOut.
/**
* Handling out responce.
*
* @param message
* the message
* @throws Fault
* the fault
*/
protected void handleResponseOut(T message) throws Fault {
Message reqMsg = message.getExchange().getInMessage();
if (reqMsg == null) {
LOG.warning("InMessage is null!");
return;
}
// No flowId for oneway message
Exchange ex = reqMsg.getExchange();
if (ex.isOneWay()) {
return;
}
String reqFid = FlowIdHelper.getFlowId(reqMsg);
// if some interceptor throws fault before FlowIdProducerIn fired
if (reqFid == null) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Some interceptor throws fault.Setting FlowId in response.");
}
reqFid = FlowIdProtocolHeaderCodec.readFlowId(message);
}
// write IN message to SAM repo in case fault
if (reqFid == null) {
Message inMsg = ex.getInMessage();
reqFid = FlowIdProtocolHeaderCodec.readFlowId(inMsg);
if (null != reqFid) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("FlowId '" + reqFid + "' found in message of fault incoming exchange.");
LOG.fine("Calling EventProducerInterceptor to log IN message");
}
handleINEvent(ex, reqFid);
}
}
if (reqFid == null) {
reqFid = FlowIdSoapCodec.readFlowId(message);
}
if (reqFid != null) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("FlowId '" + reqFid + "' found in incoming message.");
}
} else {
reqFid = ContextUtils.generateUUID();
// write IN message to SAM repo in case fault
if (null != ex.getOutFaultMessage()) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("FlowId '" + reqFid + "' generated for fault message.");
LOG.fine("Calling EventProducerInterceptor to log IN message");
}
handleINEvent(ex, reqFid);
}
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("No flowId found in incoming message! Generate new flowId " + reqFid);
}
}
FlowIdHelper.setFlowId(message, reqFid);
}
Aggregations