Coverage Report - org.apache.camel.component.cxf.CxfInvokeConsumer
 
Classes in this File Line Coverage Branch Coverage Complexity
CxfInvokeConsumer
0% 
0% 
0
 
 1  
 /**
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.camel.component.cxf;
 18  
 
 19  
 import org.apache.camel.Processor;
 20  
 import org.apache.camel.impl.DefaultConsumer;
 21  
 import org.apache.cxf.endpoint.ServerImpl;
 22  
 import org.apache.cxf.frontend.ServerFactoryBean;
 23  
 import org.apache.cxf.message.Message;
 24  
 
 25  
 /**
 26  
  * A consumer of exchanges for a service in CXF
 27  
  * 
 28  
  * @version $Revision: 563665 $
 29  
  */
 30  
 public class CxfInvokeConsumer extends DefaultConsumer<CxfExchange> {
 31  
     protected CxfInvokeEndpoint cxfEndpoint;
 32  
     private ServerImpl server;
 33  
 
 34  
     public CxfInvokeConsumer(CxfInvokeEndpoint endpoint, Processor processor) {
 35  0
         super(endpoint, processor);
 36  0
         this.cxfEndpoint = endpoint;
 37  0
     }
 38  
 
 39  
     @Override
 40  
     protected void doStart() throws Exception {
 41  0
         super.doStart();
 42  
         // TODO we need to add custom cxf message observer and wire the
 43  
         // incomingCxfMessage method. Also, custom cxf interceptors are
 44  
         // needed in order to object SOAP/XML message. Currently, the
 45  
         // CXF service invoker will invoke the service class.
 46  0
         if (server != null) {
 47  
             // start a cxf service
 48  0
             ServerFactoryBean svrBean = new ServerFactoryBean();
 49  0
             svrBean.setAddress(getEndpoint().getEndpointUri());
 50  0
             svrBean.setServiceClass(Class.forName(cxfEndpoint.getProperty(CxfConstants.IMPL)));
 51  0
             svrBean.setBus(cxfEndpoint.getBus());
 52  
 
 53  0
             server = (ServerImpl)svrBean.create();
 54  0
             server.start();
 55  
         }
 56  0
     }
 57  
 
 58  
     @Override
 59  
     protected void doStop() throws Exception {
 60  0
         if (server != null) {
 61  0
             server.stop();
 62  0
             server = null;
 63  
         }
 64  0
         super.doStop();
 65  0
     }
 66  
 
 67  
     // TODO this method currently is not being called.
 68  
     protected void incomingCxfMessage(Message message) {
 69  
         try {
 70  0
             CxfExchange exchange = cxfEndpoint.createExchange(message);
 71  0
             getProcessor().process(exchange);
 72  0
         } catch (Exception e) {
 73  
             // TODO: what do do if we are getting processing errors from camel?
 74  
             // Shutdown?
 75  0
             e.printStackTrace();
 76  0
         }
 77  0
     }
 78  
 }