• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ExchangeImpl类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.apache.cxf.message.ExchangeImpl的典型用法代码示例。如果您正苦于以下问题:Java ExchangeImpl类的具体用法?Java ExchangeImpl怎么用?Java ExchangeImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

ExchangeImpl类属于org.apache.cxf.message包,在下文中一共展示了ExchangeImpl类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setupCamelDestination

点赞 3

import org.apache.cxf.message.ExchangeImpl; //导入依赖的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: getTestExchange

点赞 3

import org.apache.cxf.message.ExchangeImpl; //导入依赖的package包/类
private Exchange getTestExchange() {
   Exchange exchange = new ExchangeImpl();
   Message message = new MessageImpl();
   message.setExchange(exchange);
   exchange.setInMessage(message);
   exchange.put(BindingOperationInfo.class, new BindingOperationInfo());
   Service service = new ServiceImpl();
   MethodDispatcher md = new MethodDispatcher() {
      @Override
      public Method getMethod(BindingOperationInfo op) {
         return this.getClass().getMethods()[0];
      }
      @Override
      public BindingOperationInfo getBindingOperation(Method m, Endpoint endpoint) {
         return null;
      }
      @Override
      public void bind(OperationInfo o, Method... methods) {
      }
   };
   service.put(MethodDispatcher.class.getName(), md);
   exchange.put(Service.class, service);
   return exchange;
}
 

开发者ID:jbossws,
项目名称:jbossws-cxf,
代码行数:25,
代码来源:JBossWSInvokerTest.java

示例3: process

点赞 2

import org.apache.cxf.message.ExchangeImpl; //导入依赖的package包/类
public boolean process(Exchange camelExchange, AsyncCallback callback) {
    LOG.trace("Process exchange: {} in an async way.", camelExchange);
    
    try {
        // create CXF exchange
        ExchangeImpl cxfExchange = new ExchangeImpl();
        // set the Bus on the exchange in case the CXF interceptor need to access it from exchange
        cxfExchange.put(Bus.class, endpoint.getBus());
        
        // prepare binding operation info
        BindingOperationInfo boi = prepareBindingOperation(camelExchange, cxfExchange);
        
        Map<String, Object> invocationContext = new HashMap<String, Object>();
        Map<String, Object> responseContext = new HashMap<String, Object>();
        invocationContext.put(Client.RESPONSE_CONTEXT, responseContext);
        invocationContext.put(Client.REQUEST_CONTEXT, prepareRequest(camelExchange, cxfExchange));
        
        CxfClientCallback cxfClientCallback = new CxfClientCallback(callback, camelExchange, cxfExchange, boi, 
                                                                    endpoint.getCxfBinding());
        // send the CXF async request
        client.invoke(cxfClientCallback, boi, getParams(endpoint, camelExchange), 
                      invocationContext, cxfExchange);
        if (boi.getOperationInfo().isOneWay()) {
            callback.done(false);
        }
    } catch (Throwable ex) {
        // error occurred before we had a chance to go async
        // so set exception and invoke callback true
        camelExchange.setException(ex);
        callback.done(true);
        return true;
    }
    return false;
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:35,
代码来源:CxfProducer.java

示例4: shouldRequireFailoverWhereIOExceptionHasBeenThrown

点赞 2

import org.apache.cxf.message.ExchangeImpl; //导入依赖的package包/类
@Test
public void shouldRequireFailoverWhereIOExceptionHasBeenThrown() {
	circuitBreakerTargetSelector = new CircuitSwitcherTargetSelector(null, 0, 0, null);

	Exchange exchange = new ExchangeImpl();
	Message message = new SoapMessage(Soap11.getInstance());
	exchange.setOutMessage(message);
	message.put(Exception.class, new IOException());

	boolean requiresFailover = circuitBreakerTargetSelector.requiresFailover(exchange);
	assertTrue(requiresFailover);
}
 

开发者ID:jaceko,
项目名称:cxf-circuit-switcher,
代码行数:13,
代码来源:CircuitSwitcherTargetSelectorTest.java

示例5: testRoundTripDestination

点赞 2

import org.apache.cxf.message.ExchangeImpl; //导入依赖的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

示例6: testRoundTripDestinationWithFault

点赞 2

import org.apache.cxf.message.ExchangeImpl; //导入依赖的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

示例7: setupCamelExchange

点赞 2

import org.apache.cxf.message.ExchangeImpl; //导入依赖的package包/类
private Exchange setupCamelExchange(String requestURI, String requestPath, HttpServletRequest request) {
    org.apache.camel.Message camelMessage = EasyMock
        .createMock(org.apache.camel.Message.class);
    Exchange camelExchange = EasyMock.createMock(Exchange.class);
    camelExchange.getProperty(CamelTransportConstants.CXF_EXCHANGE,
        org.apache.cxf.message.Exchange.class);
    EasyMock.expectLastCall().andReturn(new ExchangeImpl());
    camelExchange.hasOut();
    EasyMock.expectLastCall().andReturn(false);
    camelExchange.getIn();
    EasyMock.expectLastCall().andReturn(camelMessage).times(3);
    camelMessage.getHeaders();
    EasyMock.expectLastCall().andReturn(Collections.emptyMap()).times(2);
    camelMessage.getHeader(Exchange.CONTENT_TYPE, String.class);
    EasyMock.expectLastCall().andReturn(null);
    camelMessage.getHeader("Accept", String.class);
    EasyMock.expectLastCall().andReturn(null);
    camelMessage.getHeader(Exchange.HTTP_CHARACTER_ENCODING, String.class);
    EasyMock.expectLastCall().andReturn(null);
    camelMessage.getHeader(Exchange.CHARSET_NAME, String.class);
    EasyMock.expectLastCall().andReturn(null);
    camelMessage.getHeader(Exchange.HTTP_URI, String.class);
    EasyMock.expectLastCall().andReturn(requestURI);
    camelMessage.getHeader(Exchange.HTTP_PATH, String.class);
    EasyMock.expectLastCall().andReturn(requestPath);
    camelMessage.getHeader(Exchange.HTTP_BASE_URI, String.class);
    EasyMock.expectLastCall().andReturn(requestPath);
    camelMessage.getHeader(Exchange.HTTP_METHOD, String.class);
    EasyMock.expectLastCall().andReturn("GET");
    camelMessage.getHeader(Exchange.HTTP_QUERY, String.class);
    EasyMock.expectLastCall().andReturn("");
    camelMessage.getHeader(Exchange.HTTP_SERVLET_REQUEST);
    EasyMock.expectLastCall().andReturn(request);
    camelMessage.getHeader(Exchange.HTTP_SERVLET_RESPONSE);
    EasyMock.expectLastCall().andReturn(null);

    camelMessage.getBody(InputStream.class);
    EasyMock.expectLastCall().andReturn(
        new ByteArrayInputStream("".getBytes()));
    EasyMock.replay(camelExchange, camelMessage);
    return camelExchange;
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:43,
代码来源:DefaultCxfMessageMapperTest.java

示例8: call

点赞 2

import org.apache.cxf.message.ExchangeImpl; //导入依赖的package包/类
@Override
public SOAPMessage call(SOAPMessage msgOut, Object addressObject) throws SOAPException 
{
   checkClosed();
   
   String address = getAddress(addressObject);
   ConduitInitiator ci = getConduitInitiator(address);
    
    
   // create a new Message and Exchange
   EndpointInfo info = new EndpointInfo();
   info.setAddress(address);
   Message outMessage = new MessageImpl();
   Exchange exch = new ExchangeImpl();
   outMessage.setExchange(exch);
   exch.put("org.apache.cxf.transport.process_fault_on_http_400", true); //JBWS-3945
    
   // sent SOAPMessage
   try 
   {
      final Conduit c = ci.getConduit(info, BusFactory.getThreadDefaultBus(false)); //TODO verify bus

      if (msgOut.saveRequired())
      {
         msgOut.saveChanges();
      }
    
      Map<String, List<String>> outHeaders = new HashMap<String, List<String>>();
      for (Iterator<?> it = msgOut.getMimeHeaders().getAllHeaders(); it.hasNext();) 
      {
         MimeHeader mimeHeader = (MimeHeader)it.next();
         if ("Content-Type".equals(mimeHeader.getName())) 
         {
            outMessage.put(Message.CONTENT_TYPE, mimeHeader.getValue());
         }
            
         // disable the chunked encoding if requested
         if ("Transfer-Encoding".equals(mimeHeader.getName())
             && "disabled".equals(mimeHeader.getValue())
             && c instanceof HTTPConduit) 
         {
            ((HTTPConduit)c).getClient().setAllowChunking(false);
            continue;
         }
            
         List<String> values = outHeaders.get(mimeHeader.getName());
         if (values == null) 
         {
            values = new ArrayList<String>();
            outHeaders.put(mimeHeader.getName(), values);
         } 
         values.add(mimeHeader.getValue());
      }
      outMessage.put(Message.HTTP_REQUEST_METHOD, "POST");
      outMessage.put(Message.PROTOCOL_HEADERS, outHeaders);
      c.prepare(outMessage);
        
      OutputStream outs = outMessage.getContent(OutputStream.class);
      msgOut.writeTo(outs);
        
      c.setMessageObserver(createMessageObserver(c));
        
      c.close(outMessage);
   } 
   catch (Exception ex) 
   {
      throw MESSAGES.soapMessageCouldNotBeSent(ex);
   }    

   // read SOAPMessage        
   return readSoapMessage(exch); 
}
 

开发者ID:jbossws,
项目名称:jbossws-cxf,
代码行数:73,
代码来源:SOAPConnectionImpl.java

示例9: get

点赞 2

import org.apache.cxf.message.ExchangeImpl; //导入依赖的package包/类
@Override
public SOAPMessage get(Object addressObject) throws SOAPException 
{
   checkClosed();
   
   String address = getAddress(addressObject);
   ConduitInitiator ci = getConduitInitiator(address);
    
    
   // create a new Message and Exchange
   EndpointInfo info = new EndpointInfo();
   info.setAddress(address);
   Message outMessage = new MessageImpl();
   Exchange exch = new ExchangeImpl();
   outMessage.setExchange(exch);
    
   // sent GET request
   try 
   {
      final Conduit c = ci.getConduit(info, BusFactory.getThreadDefaultBus(false)); //TODO verify bus
      
      if (c instanceof HTTPConduit)
      {
         ((HTTPConduit)c).getClient().setAutoRedirect(true);
      }
        
      outMessage.put(Message.HTTP_REQUEST_METHOD, "GET");
      c.prepare(outMessage);
        
      c.setMessageObserver(createMessageObserver(c));
        
      c.close(outMessage);
   } 
   catch (Exception ex) 
   {
      throw MESSAGES.getRequestCouldNotBeSent(ex);
   }    

   // read SOAPMessage
   return readSoapMessage(exch);
}
 

开发者ID:jbossws,
项目名称:jbossws-cxf,
代码行数:42,
代码来源:SOAPConnectionImpl.java

示例10: run

点赞 2

import org.apache.cxf.message.ExchangeImpl; //导入依赖的package包/类
public void run()
{
   while (true)
   {
      if (socket == null)
      {
         return;
      }
      try
      {
         byte bytes[] = new byte[64 * 1024];
         final DatagramPacket p = new DatagramPacket(bytes, bytes.length);
         socket.receive(p);

         LoadingByteArrayOutputStream out = new LoadingByteArrayOutputStream()
         {
            public void close() throws IOException
            {
               super.close();
               final DatagramPacket p2 = new DatagramPacket(getRawBytes(), 0, this.size(), p.getSocketAddress());
               socket.send(p2);
            }
         };

         UDPConnectionInfo info = new UDPConnectionInfo(out, new ByteArrayInputStream(bytes, 0, p.getLength()));

         final MessageImpl m = new MessageImpl();
         final Exchange exchange = new ExchangeImpl();
         exchange.setDestination(UDPDestination.this);
         m.setDestination(UDPDestination.this);
         exchange.setInMessage(m);
         m.setContent(InputStream.class, info.in);
         m.put(UDPConnectionInfo.class, info);
         queue.execute(new Runnable()
         {
            public void run()
            {
               getMessageObserver().onMessage(m);
            }
         });
      }
      catch (IOException e)
      {
         if (socket != null) {
            LOG.log(Level.SEVERE, e.toString());
         }
      }
   }
}
 

开发者ID:jbossws,
项目名称:jbossws-cxf,
代码行数:50,
代码来源:UDPDestination.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)