KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > binding > axis2 > Axis2BC


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2006 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: Axis2BC.java 154 25 sept. 06 alouis $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.binding.axis2;
23
24 import java.io.File JavaDoc;
25 import java.util.logging.Level JavaDoc;
26
27 import javax.jbi.JBIException;
28
29 import org.apache.axis2.AxisFault;
30 import org.apache.axis2.context.ConfigurationContext;
31 import org.apache.axis2.context.ConfigurationContextFactory;
32 import org.objectweb.petals.binding.axis2.listener.jbi.JBIListener;
33 import org.objectweb.petals.binding.axis2.listener.soap.SOAPListenerManager;
34 import org.objectweb.petals.component.common.bc.AbstractBindingComponent;
35 import org.objectweb.petals.component.common.su.ServiceUnitListener;
36 import org.objectweb.petals.component.common.su.SimpleServiceUnitManager;
37
38 /**
39  * The Axis2 Component.
40  *
41  * @author alouis - EBM Websourcing
42  *
43  */

44 public class Axis2BC extends AbstractBindingComponent {
45
46     /**
47      * The listener processing request providing from the NMR
48      */

49     protected JBIListener listener;
50
51     /**
52      * The listener processing SOAP request providing from Petals outside.
53      */

54     protected SOAPListenerManager externalListenerManager;
55
56     // //////////////////////////////////////////////////////:
57
// Component implementation
58
// //////////////////////////////////////////////////////:
59

60     @Override JavaDoc
61     public void start() throws JBIException {
62         super.start();
63         try {
64             externalListenerManager.start();
65         } catch (AxisFault e) {
66             getLogger().severe(e.getMessage());
67             throw new JBIException(e);
68         }
69     }
70
71     @Override JavaDoc
72     public void stop() throws JBIException {
73         super.stop();
74         try {
75             externalListenerManager.stop();
76         } catch (AxisFault e) {
77             getLogger().severe(e.getMessage());
78             throw new JBIException(e);
79         }
80     }
81
82     @Override JavaDoc
83     protected void init(BindingComponentInitializer initializer) {
84
85         // get the BindingSUManager
86
SimpleServiceUnitManager bindingSUM = (SimpleServiceUnitManager) getServiceUnitManager();
87
88         // get axis configuration context
89
ConfigurationContext axisConfigurationContext = null;
90         try {
91             axisConfigurationContext = ConfigurationContextFactory
92                 .createConfigurationContextFromFileSystem(getContext()
93                     .getInstallRoot(), getContext().getInstallRoot()
94                     + File.separator + "axis2.xml");
95         } catch (AxisFault e) {
96             getLogger()
97                 .log(
98                     Level.INFO,
99                     "Can not create AXIS configuration context. "
100                         + "Please verify that the axis2.xml file is in your component install root path !");
101         }
102
103         // set service unit listener
104
ServiceUnitListener suListener = new Axis2BCSUListener(
105             axisConfigurationContext, getContext(), getLogger());
106         setServiceUnitListener(suListener);
107
108         // create internal listener, will handle internal WS queries to external
109
// services
110
listener = new JBIListener(bindingSUM, getLogger());
111
112         // create external listener, will handle incoming SOAP queries
113
externalListenerManager = new SOAPListenerManager(getContext(),
114             getChannel(), bindingSUM, axisConfigurationContext, getLogger());
115
116         initializer.setExternalListenerManager(externalListenerManager);
117         initializer.setJbiListener(listener);
118
119     }
120 }
121
Popular Tags