01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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.servicemix.cxfbc;
18:
19: import java.util.List;
20:
21: import org.apache.cxf.Bus;
22: import org.apache.cxf.BusFactory;
23: import org.apache.cxf.bus.spring.SpringBusFactory;
24: import org.apache.servicemix.common.DefaultComponent;
25:
26: /**
27: *
28: * @author gnodet
29: * @org.apache.xbean.XBean element="component"
30: */
31: public class CxfBcComponent extends DefaultComponent {
32:
33: private CxfBcEndpointType[] endpoints;
34:
35: private Bus bus;
36:
37: private String busCfg;
38:
39: /**
40: * @return the endpoints
41: */
42: public CxfBcEndpointType[] getEndpoints() {
43: return endpoints;
44: }
45:
46: /**
47: * @param endpoints
48: * the endpoints to set
49: */
50: public void setEndpoints(CxfBcEndpointType[] endpoints) {
51: this .endpoints = endpoints;
52: }
53:
54: @Override
55: protected List getConfiguredEndpoints() {
56: return asList(endpoints);
57: }
58:
59: @Override
60: protected Class[] getEndpointClasses() {
61: return new Class[] { CxfBcProvider.class, CxfBcConsumer.class };
62: }
63:
64: @Override
65: protected void doInit() throws Exception {
66: if (getBusConfig() != null) {
67: SpringBusFactory bf = new SpringBusFactory();
68: bus = bf.createBus(getBusConfig());
69: } else {
70: bus = BusFactory.newInstance().createBus();
71: }
72: super .doInit();
73: }
74:
75: public Bus getBus() {
76: return bus;
77: }
78:
79: public void setBusConfig(String busConfig) {
80: this .busCfg = busConfig;
81: }
82:
83: public String getBusConfig() {
84: return busCfg;
85: }
86: }
|