本文整理汇总了Java中org.apache.cxf.transport.MessageObserver类的典型用法代码示例。如果您正苦于以下问题:Java MessageObserver类的具体用法?Java MessageObserver怎么用?Java MessageObserver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageObserver类属于org.apache.cxf.transport包,在下文中一共展示了MessageObserver类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setupCamelDestination
import org.apache.cxf.transport.MessageObserver; //导入依赖的package包/类
public CamelDestination setupCamelDestination(EndpointInfo endpointInfo, boolean send) throws IOException {
ConduitInitiator conduitInitiator = EasyMock.createMock(ConduitInitiator.class);
CamelDestination camelDestination = new CamelDestination(context, bus, conduitInitiator, endpointInfo);
if (send) {
// setMessageObserver
observer = new MessageObserver() {
public void onMessage(Message m) {
Exchange exchange = new ExchangeImpl();
exchange.setInMessage(m);
m.setExchange(exchange);
destMessage = m;
}
};
camelDestination.setMessageObserver(observer);
}
return camelDestination;
}
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:CamelDestinationTest.java
示例2: setupCamelConduit
import org.apache.cxf.transport.MessageObserver; //导入依赖的package包/类
protected CamelConduit setupCamelConduit(EndpointInfo endpointInfo, boolean send, boolean decoupled) {
if (decoupled) {
// setup the reference type
} else {
target = EasyMock.createMock(EndpointReferenceType.class);
}
CamelConduit camelConduit = new CamelConduit(context, bus, endpointInfo, target);
if (send) {
// setMessageObserver
observer = new MessageObserver() {
public void onMessage(Message m) {
inMessage = m;
}
};
camelConduit.setMessageObserver(observer);
}
return camelConduit;
}
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:CamelTransportTestSupport.java
示例3: setExchangeProperties
import org.apache.cxf.transport.MessageObserver; //导入依赖的package包/类
protected void setExchangeProperties(Exchange exchange, Endpoint ep) {
if (ep != null) {
exchange.put(Endpoint.class, ep);
exchange.put(Service.class, ep.getService());
if (ep.getEndpointInfo().getService() != null) {
exchange.put(ServiceInfo.class, ep.getEndpointInfo()
.getService());
exchange.put(InterfaceInfo.class, ep.getEndpointInfo()
.getService().getInterface());
}
exchange.put(Binding.class, ep.getBinding());
exchange.put(BindingInfo.class, ep.getEndpointInfo().getBinding());
}
exchange.put(MessageObserver.class, this);
exchange.put(Bus.class, getBus());
}
开发者ID:ow2-chameleon,项目名称:fuchsia,代码行数:18,代码来源:ProtobufClient.java
示例4: CamelOutputStream
import org.apache.cxf.transport.MessageObserver; //导入依赖的package包/类
CamelOutputStream(String targetCamelEndpointUri, Producer producer,
HeaderFilterStrategy headerFilterStrategy, MessageObserver observer,
Message m) {
this.targetCamelEndpointUri = targetCamelEndpointUri;
this.producer = producer;
this.headerFilterStrategy = headerFilterStrategy;
this.observer = observer;
outMessage = m;
}
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:CamelOutputStream.java
示例5: createMessageObserver
import org.apache.cxf.transport.MessageObserver; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private MessageObserver createMessageObserver(final Conduit c)
{
return new MessageObserver()
{
public void onMessage(Message inMessage)
{
LoadingByteArrayOutputStream bout = new LoadingByteArrayOutputStream();
try
{
IOUtils.copy(inMessage.getContent(InputStream.class), bout);
inMessage.getExchange().put(InputStream.class, bout.createInputStream());
Map<String, List<String>> inHeaders =
(Map<String, List<String>>)inMessage.get(Message.PROTOCOL_HEADERS);
inMessage.getExchange().put(Message.PROTOCOL_HEADERS, inHeaders);
c.close(inMessage);
}
catch (IOException e)
{
//ignore
Logger.getLogger(SOAPConnectionImpl.class).trace(e);
}
}
};
}
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:28,代码来源:SOAPConnectionImpl.java
示例6: handleMessage
import org.apache.cxf.transport.MessageObserver; //导入依赖的package包/类
public final void handleMessage(SoapMessage message) {
String schemaNamespace = "";
InterceptorChain chain = message.getInterceptorChain();
// Scan the incoming message for its schema namespace
try {
// Create a buffered stream so that we get back the original stream after scanning
InputStream is = message.getContent(InputStream.class);
BufferedInputStream bis = new BufferedInputStream(is);
bis.mark(bis.available());
message.setContent(InputStream.class, bis);
String encoding = (String) message.get(Message.ENCODING);
XMLStreamReader reader = xmlInputFactory.createXMLStreamReader(bis, encoding);
DepthXMLStreamReader xmlReader = new DepthXMLStreamReader(reader);
if (xmlReader.nextTag() == XMLStreamConstants.START_ELEMENT) {
String ns = xmlReader.getNamespaceURI();
SoapVersion soapVersion = SoapVersionFactory.getInstance().getSoapVersion(ns);
// Advance just past header
StaxUtils.toNextTag(xmlReader, soapVersion.getBody());
// Past body
xmlReader.nextTag();
}
schemaNamespace = xmlReader.getName().getNamespaceURI();
bis.reset();
} catch (IOException | XMLStreamException ex) {
log.error("Exception happened", ex);
}
// Init the lookup, when the first message ever arrives
if (actualServers.isEmpty()) {
initServerLookupMap(message);
}
// We redirect the message to the actual OCPP service
Server targetServer = actualServers.get(schemaNamespace);
// Redirect the request
if (targetServer != null) {
MessageObserver mo = targetServer.getDestination().getMessageObserver();
mo.onMessage(message);
}
// Now the response has been put in the message, abort the chain
chain.abort();
}
开发者ID:RWTH-i5-IDSG,项目名称:steve-plugsurfing,代码行数:49,代码来源:MediatorInInterceptor.java
示例7: asyncInvokeFromWorkQueue
import org.apache.cxf.transport.MessageObserver; //导入依赖的package包/类
protected void asyncInvokeFromWorkQueue(final org.apache.camel.Exchange exchange) throws IOException {
Runnable runnable = new Runnable() {
public void run() {
try {
syncInvoke(exchange);
} catch (Throwable e) {
((PhaseInterceptorChain)outMessage.getInterceptorChain()).abort();
outMessage.setContent(Exception.class, e);
((PhaseInterceptorChain)outMessage.getInterceptorChain()).unwind(outMessage);
MessageObserver mo = outMessage.getInterceptorChain().getFaultObserver();
if (mo == null) {
mo = outMessage.getExchange().get(MessageObserver.class);
}
mo.onMessage(outMessage);
}
}
};
try {
Executor ex = outMessage.getExchange().get(Executor.class);
if (ex != null) {
outMessage.getExchange().put(Executor.class.getName()
+ ".USING_SPECIFIED", Boolean.TRUE);
ex.execute(runnable);
} else {
WorkQueueManager mgr = outMessage.getExchange().get(Bus.class)
.getExtension(WorkQueueManager.class);
AutomaticWorkQueue qu = mgr.getNamedWorkQueue("camel-cxf-conduit");
if (qu == null) {
qu = mgr.getAutomaticWorkQueue();
}
// need to set the time out somewhere
qu.execute(runnable);
}
} catch (RejectedExecutionException rex) {
if (!hasLoggedAsyncWarning) {
LOG.warn("Executor rejected background task to retrieve the response. Suggest increasing the workqueue settings.");
hasLoggedAsyncWarning = true;
}
LOG.info("Executor rejected background task to retrieve the response, running on current thread.");
syncInvoke(exchange);
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:44,代码来源:CamelOutputStream.java
示例8: testRoundTripDestination
import org.apache.cxf.transport.MessageObserver; //导入依赖的package包/类
@Test
public void testRoundTripDestination() throws Exception {
inMessage = null;
EndpointInfo conduitEpInfo = new EndpointInfo();
conduitEpInfo.setAddress("camel://direct:Producer");
// set up the conduit send to be true
CamelConduit conduit = setupCamelConduit(conduitEpInfo, true, false);
final Message outMessage = new MessageImpl();
endpointInfo.setAddress("camel://direct:EndpointA");
final CamelDestination destination = setupCamelDestination(endpointInfo, true);
// set up MessageObserver for handling the conduit message
MessageObserver observer = new MessageObserver() {
public void onMessage(Message m) {
try {
Exchange exchange = new ExchangeImpl();
exchange.setInMessage(m);
m.setExchange(exchange);
verifyReceivedMessage(m, "HelloWorld");
//verifyHeaders(m, outMessage);
// setup the message for
Conduit backConduit;
backConduit = getBackChannel(destination, m);
// wait for the message to be got from the conduit
Message replyMessage = new MessageImpl();
sendoutMessage(backConduit, replyMessage, true, "HelloWorld Response");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
MockEndpoint error = context.getEndpoint("mock:error", MockEndpoint.class);
error.expectedMessageCount(0);
//this call will active the camelDestination
destination.setMessageObserver(observer);
// set is one way false for get response from destination
// need to use another thread to send the request message
sendoutMessage(conduit, outMessage, false, "HelloWorld");
// wait for the message to be got from the destination,
// create the thread to handler the Destination incoming message
verifyReceivedMessage(inMessage, "HelloWorld Response");
error.assertIsSatisfied();
destination.shutdown();
}
开发者ID:HydAu,项目名称:Camel,代码行数:48,代码来源:CamelDestinationTest.java
示例9: testRoundTripDestinationWithFault
import org.apache.cxf.transport.MessageObserver; //导入依赖的package包/类
@Test
public void testRoundTripDestinationWithFault() throws Exception {
inMessage = null;
EndpointInfo conduitEpInfo = new EndpointInfo();
conduitEpInfo.setAddress("camel://direct:Producer");
// set up the conduit send to be true
CamelConduit conduit = setupCamelConduit(conduitEpInfo, true, false);
final Message outMessage = new MessageImpl();
endpointInfo.setAddress("camel://direct:EndpointA");
final CamelDestination destination = setupCamelDestination(endpointInfo, true);
destination.setCheckException(true);
// set up MessageObserver for handling the conduit message
MessageObserver observer = new MessageObserver() {
public void onMessage(Message m) {
try {
Exchange exchange = new ExchangeImpl();
exchange.setInMessage(m);
m.setExchange(exchange);
verifyReceivedMessage(m, "HelloWorld");
//verifyHeaders(m, outMessage);
// setup the message for
Conduit backConduit;
backConduit = getBackChannel(destination, m);
// wait for the message to be got from the conduit
Message replyMessage = new MessageImpl();
replyMessage.setContent(Exception.class, new RuntimeCamelException());
sendoutMessage(backConduit, replyMessage, true, "HelloWorld Fault");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
MockEndpoint error = context.getEndpoint("mock:error", MockEndpoint.class);
error.expectedMessageCount(1);
//this call will active the camelDestination
destination.setMessageObserver(observer);
// set is one way false for get response from destination
// need to use another thread to send the request message
sendoutMessage(conduit, outMessage, false, "HelloWorld");
// wait for the message to be got from the destination,
// create the thread to handler the Destination incoming message
verifyReceivedMessage(inMessage, "HelloWorld Fault");
error.assertIsSatisfied();
destination.shutdown();
}
开发者ID:HydAu,项目名称:Camel,代码行数:53,代码来源:CamelDestinationTest.java
示例10: setMessageObserver
import org.apache.cxf.transport.MessageObserver; //导入依赖的package包/类
/**
* Register a message observer for incoming messages.
*
* @param observer the observer to notify on receipt of incoming
*/
public void setMessageObserver(MessageObserver observer) {
// shouldn't be called for a back channel conduit
}
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:CamelDestination.java
注:本文中的org.apache.cxf.transport.MessageObserver类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论