hi,

I had time to go through your comment and I think what you suggest is the
correct way to address the problem.
So +1 for that.

Then I looked into the our code and found that we have also done the same
technique with separate two
Transport listeners :).

Because we have our own two transport listeners this code gives us problems,

// This method should not be part of the public API. In particular we must
not allow subclasses
    // to override this method because we don't make any guarantees as to
when exactly this method
    // is called.
    private void preprocessRequest(HttpServletRequest req) throws
ServletException {
        initContextRoot(req);

        AxisServletListener listener = req.isSecure() ? httpsListener :
httpListener;
        if (listener == null) {
            throw new ServletException(req.getScheme() + " is forbidden");
        } else {
            // Autodetect the port number if necessary
            if (listener.getPort() == -1) {
                listener.setPort(req.getServerPort());
            }
        }
    }

Here you assume anyone use Axis2 as a library has used AxisServletListner
and kept it as a private variable in Axis2Servlet.

Instead of I would like to implement this method like this,


// This method should not be part of the public API. In particular we must
not allow subclasses
    // to override this method because we don't make any guarantees as to
when exactly this method
    // is called.
    private void preprocessRequest(HttpServletRequest req) throws
ServletException {
        initContextRoot(req);

        TransportInDescription transportInDescription =
                req.isSecure() ?
this.axisConfiguration.getTransportIn(Constants.TRANSPORT_HTTPS) :

this.axisConfiguration.getTransportIn(Constants.TRANSPORT_HTTP);
        if (transportInDescription == null) {
            throw new ServletException(req.getScheme() + " is forbidden");
        } else {
            if (transportInDescription.getReceiver() instanceof
AxisServletListener) {
                AxisServletListener listener = (AxisServletListener)
transportInDescription.getReceiver();
                if (listener.getPort() == -1) {
                    listener.setPort(req.getServerPort());
                }
            }
        }
    }

In this way we do not keep the Axis2Specific listener and take it from the
axis configuration and check for port only if it is an Axis2Servlet
listener.

WDYT?

thanks,
Amila.



On Sat, Aug 22, 2009 at 12:45 PM, Srinath Perera <hemap...@gmail.com> wrote:

> > I am not sure whether clearly understand the difference between how
> > AxisServelet works and how SimpleHTTPServer works. In the case of
> > AxisServlet, we first start AxisServlet and then we start Axis2, so when
> > we start Axis2 we already have HTTP listener running (and hence
> > TransportInDec). So once the system start we just create a
> > TransportInDec using servlet and set that as the HTTP TransportDec (and
> > of course we replace what is in axis2.xml for HTTP with this
> > transportInDec, and we must do that). Whereas in SimpleHTTPServer, we
> > first start Axis2 and then we use transport in axis2.xml to configure
> > the system, so we use the tarnporInDec to configure the SimpleHTTPServer.
>
> Yep, this is right. One reason it is there is that to allow both
> simple HTTP server and servlet share the same axis2.xml which is not
> required, rather a convenience. In a servlet case transport receiver
> is not initialized at all (I do not think it has changed).
>
> Thanks
> Srinath
>
> --
> ============================
> Srinath Perera, Ph.D.
>   WSO2 Inc. http://wso2.com
>   Blog: http://srinathsview.blogspot.com/
>



-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/

Reply via email to