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.lwcontainer;
18:
19: import java.util.ArrayList;
20: import java.util.List;
21:
22: import org.apache.servicemix.common.BaseComponent;
23: import org.apache.servicemix.common.xbean.AbstractXBeanDeployer;
24: import org.apache.servicemix.jbi.container.ActivationSpec;
25: import org.apache.servicemix.jbi.container.SpringServiceUnitContainer;
26: import org.apache.xbean.kernel.Kernel;
27: import org.apache.xbean.kernel.StringServiceName;
28:
29: public class LwContainerXBeanDeployer extends AbstractXBeanDeployer {
30:
31: public LwContainerXBeanDeployer(BaseComponent component) {
32: super (component);
33: }
34:
35: protected String getXBeanFile() {
36: return "servicemix";
37: }
38:
39: protected List getServices(Kernel kernel) {
40: try {
41: Object jbi = kernel
42: .getService(new StringServiceName("jbi"));
43: SpringServiceUnitContainer suContainer = (SpringServiceUnitContainer) jbi;
44: ActivationSpec[] specs = suContainer.getActivationSpecs();
45: List services = new ArrayList();
46: if (specs != null) {
47: for (int i = 0; i < specs.length; i++) {
48: services.add(new LwContainerEndpoint(specs[i]));
49: }
50: }
51: if (suContainer.getComponents() != null
52: || suContainer.getEndpoints() != null
53: || suContainer.getListeners() != null
54: || suContainer.getServices() != null) {
55: services.add(new LwContainerExtra(suContainer
56: .getComponents(), suContainer.getEndpoints(),
57: suContainer.getListeners(), suContainer
58: .getServices()));
59: }
60: return services;
61: } catch (Exception e) {
62: throw new RuntimeException("Can not find 'jbi' bean", e);
63: }
64: }
65:
66: }
|