• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MessageObserver类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Logger类代码示例发布时间:2022-05-22
下一篇:
Java ODatabaseExport类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap