KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > net > axis > server > AxisServiceServlet


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 package org.jboss.net.axis.server;
9
10 import org.jboss.axis.AxisFault;
11 import org.jboss.axis.ConfigurationException;
12 import org.jboss.axis.MessageContext;
13 import org.jboss.axis.server.AxisServer;
14 import org.jboss.axis.transport.http.AxisServlet;
15 import org.jboss.axis.transport.http.HTTPConstants;
16
17 import javax.servlet.http.HttpServletRequest JavaDoc;
18 import javax.servlet.http.HttpServletResponse JavaDoc;
19 import java.io.PrintWriter JavaDoc;
20
21 /**
22  * <p>
23  * An AxisServlet that is able to extract the corresponding AxisEngine
24  * from its installation context and builds the right message contexts for the
25  * JBoss classloading and deployment architecture.
26  * </p>
27  * <p>
28  * This servlet will also reconstruct proper SOAPAction for http-get accesses
29  * in order not to rely on unsecure url-mapping
30  * </p>
31  * @author <a HREF="mailto:Christoph.Jung@infor.de">Christoph G. Jung</a>
32  * @created 7. September 2001, 19:17
33  * @version $Revision: 1.12.6.2 $
34  */

35
36 public class AxisServiceServlet extends AxisServlet
37 {
38
39    /** reference to the server */
40    protected AxisServer server = null;
41
42    /** Creates new AxisServlet */
43    public AxisServiceServlet()
44    {
45    }
46
47    /**
48     * override AxisServlet.getEngine() in order to redirect to
49     * the corresponding AxisEngine.
50     */

51    public org.jboss.axis.server.AxisServer getEngine() throws AxisFault
52    {
53       if (server == null)
54       {
55          // we need to extract the engine from the
56
// rootcontext
57
String JavaDoc installation =
58                  getConfigurationContext();
59          // call the static service method to find the installed engine
60
try
61          {
62             server =
63                     JMXEngineConfigurationFactory
64                     .newJMXFactory(installation)
65                     .getAxisServer();
66          }
67          catch (NullPointerException JavaDoc e)
68          {
69             throw new AxisFault("Could not access JMX configuration factory.",
70                     e);
71          }
72       }
73
74       return server;
75    }
76
77    /** access configuration context */
78    protected String JavaDoc getConfigurationContext()
79    {
80       return getInitParameter(org.jboss.net.axis.Constants.CONFIGURATION_CONTEXT);
81    }
82
83    /* (non-Javadoc)
84     * a list request comes through get and
85     * does not need a particularly specified messagecontext
86     * except to hook classloading information on.
87     * @see org.jboss.axis.transport.http.AxisServlet#reportAvailableServices(javax.servlet.http.HttpServletResponse, java.io.PrintWriter, javax.servlet.http.HttpServletRequest)
88     */

89    protected void reportAvailableServices(HttpServletResponse JavaDoc arg0,
90                                           PrintWriter JavaDoc arg1,
91                                           HttpServletRequest JavaDoc arg2)
92            throws ConfigurationException, AxisFault
93    {
94       MessageContext fake = new MessageContext(getEngine());
95       AxisServer.setCurrentMessageContext(fake);
96       super.reportAvailableServices(arg0, arg1, arg2);
97    }
98
99    /* (non-Javadoc)
100     * through get, we will not be presented with a correct soapaction,
101     * hence we fake it to the context path (see AxisServlet.getSoapAction())
102     * @see org.jboss.axis.transport.http.AxisServlet#processMethodRequest(org.jboss.axis.MessageContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.io.PrintWriter)
103     */

104 // protected void processMethodRequest(
105
// MessageContext arg0,
106
// HttpServletRequest arg1,
107
// HttpServletResponse arg2,
108
// PrintWriter arg3)
109
// throws AxisFault
110
// {
111
// fakeSoapAction(arg0);
112
// super.processMethodRequest(arg0, arg1, arg2, arg3);
113
// }
114

115    /* (non-Javadoc)
116     * through get, we will not be presented with a correct soapaction,
117     * hence we fake it to the context path (see AxisServlet.getSoapAction())
118     * @see org.jboss.axis.transport.http.AxisServlet#processWsdlRequest(org.jboss.axis.MessageContext, javax.servlet.http.HttpServletResponse, java.io.PrintWriter)
119     */

120 // protected void processWsdlRequest(
121
// MessageContext arg0,
122
// HttpServletResponse arg1,
123
// PrintWriter arg2)
124
// throws AxisFault
125
// {
126
// fakeSoapAction(arg0);
127
// super.processWsdlRequest(arg0, arg1, arg2);
128
// }
129

130    /** set soap action uri to the path info */
131    protected void fakeSoapAction(MessageContext arg0)
132    {
133       String JavaDoc pathInfo = (String JavaDoc)arg0.getProperty(HTTPConstants.MC_HTTP_SERVLETPATHINFO);
134       if (pathInfo == null)
135       {
136          pathInfo = "";
137       }
138       else if (pathInfo.startsWith("/"))
139       {
140          pathInfo = pathInfo.substring(1);
141       }
142       arg0.setSOAPActionURI(pathInfo);
143    }
144
145 }
Popular Tags