KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > jsr181 > Jsr181LifeCycle


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.jsr181;
18
19 import javax.jbi.component.ComponentContext;
20
21 import org.apache.servicemix.common.BaseComponent;
22 import org.apache.servicemix.common.BaseLifeCycle;
23 import org.apache.servicemix.jsr181.xfire.JbiTransport;
24 import org.codehaus.xfire.DefaultXFire;
25 import org.codehaus.xfire.XFire;
26 import org.codehaus.xfire.transport.Transport;
27
28 public class Jsr181LifeCycle extends BaseLifeCycle {
29
30     protected XFire xfire;
31     protected Jsr181Configuration configuration;
32     
33     public Jsr181LifeCycle(BaseComponent component) {
34         super(component);
35         configuration = new Jsr181Configuration();
36     }
37
38     /**
39      * @return Returns the configuration.
40      */

41     public Jsr181Configuration getConfiguration() {
42         return configuration;
43     }
44
45     /* (non-Javadoc)
46      * @see org.servicemix.common.BaseComponentLifeCycle#getExtensionMBean()
47      */

48     protected Object JavaDoc getExtensionMBean() throws Exception JavaDoc {
49         return configuration;
50     }
51
52     /**
53      * @return Returns the xfire.
54      */

55     public XFire getXFire() {
56         return xfire;
57     }
58
59     /* (non-Javadoc)
60      * @see org.servicemix.common.BaseLifeCycle#doInit()
61      */

62     protected void doInit() throws Exception JavaDoc {
63         super.doInit();
64         configuration.setRootDir(context.getWorkspaceRoot());
65         configuration.load();
66         xfire = createXFire(this.context);
67     }
68     
69     public static XFire createXFire(ComponentContext context) {
70         XFire xfire = new DefaultXFire();
71         Object JavaDoc[] transports = xfire.getTransportManager().getTransports().toArray();
72         for (int i = 0; i < transports.length; i++) {
73             xfire.getTransportManager().unregister((Transport) transports[i]);
74         }
75         xfire.getTransportManager().register(new JbiTransport(context));
76         return xfire;
77     }
78     
79 }
80
Popular Tags