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