KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > eip > EIPSpringComponent


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.servicemix.eip;
18
19 import org.apache.servicemix.common.BaseComponent;
20 import org.apache.servicemix.common.BaseLifeCycle;
21 import org.apache.servicemix.common.ServiceUnit;
22 import org.apache.servicemix.common.xbean.XBeanServiceUnit;
23
24 /**
25  *
26  * @author gnodet
27  * @version $Revision: 376451 $
28  * @org.apache.xbean.XBean element="component"
29  * description="An EIP component"
30  */

31 public class EIPSpringComponent extends BaseComponent {
32
33     private EIPEndpoint[] endpoints;
34
35     /**
36      * @return Returns the endpoints.
37      */

38     public EIPEndpoint[] getEndpoints() {
39         return endpoints;
40     }
41
42     /**
43      * @param endpoints The endpoints to set.
44      */

45     public void setEndpoints(EIPEndpoint[] endpoints) {
46         this.endpoints = endpoints;
47     }
48     
49     /* (non-Javadoc)
50      * @see org.servicemix.common.BaseComponent#createLifeCycle()
51      */

52     protected BaseLifeCycle createLifeCycle() {
53         return new LifeCycle();
54     }
55
56     /**
57      * @author gnodet
58      */

59     public class LifeCycle extends EIPLifeCycle {
60
61         protected ServiceUnit su;
62         
63         public LifeCycle() {
64             super(EIPSpringComponent.this);
65         }
66         
67         /* (non-Javadoc)
68          * @see org.servicemix.common.BaseLifeCycle#doInit()
69          */

70         protected void doInit() throws Exception JavaDoc {
71             super.doInit();
72             su = new XBeanServiceUnit();
73             su.setComponent(EIPSpringComponent.this);
74             for (int i = 0; i < endpoints.length; i++) {
75                 endpoints[i].setServiceUnit(su);
76                 endpoints[i].validate();
77                 su.addEndpoint(endpoints[i]);
78             }
79             getRegistry().registerServiceUnit(su);
80         }
81
82         /* (non-Javadoc)
83          * @see org.servicemix.common.BaseLifeCycle#doStart()
84          */

85         protected void doStart() throws Exception JavaDoc {
86             super.doStart();
87             su.start();
88         }
89         
90         /* (non-Javadoc)
91          * @see org.servicemix.common.BaseLifeCycle#doStop()
92          */

93         protected void doStop() throws Exception JavaDoc {
94             su.stop();
95             super.doStop();
96         }
97         
98         /* (non-Javadoc)
99          * @see org.servicemix.common.BaseLifeCycle#doShutDown()
100          */

101         protected void doShutDown() throws Exception JavaDoc {
102             su.shutDown();
103             super.doShutDown();
104         }
105     }
106
107 }
108
Popular Tags