Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] To the Server object from a ServletConfig

Hi All:

To get to the Server object from a ServletConfig I use:

    public static Server getServer(final ServletConfig servletConfig) {
        final ServletContext servletContext = servletConfig.getServletContext();
        if (servletContext instanceof ServletContextHandler.Context) {
            final ServletContextHandler.Context jettyServletContext = (ServletContextHandler.Context) servletContext;
            return jettyServletContext.getContextHandler().getServer();
        }
        return null;
    }

But, in 8.1.3, org.eclipse.jetty.server.handler.ContextHandler.Context.getContextHandler() is defined as:

        public ContextHandler getContextHandler()
        {
            // TODO reduce visibility of this method
            return ContextHandler.this;
        }

Implementing this TODO would torpedo my solution.

Is there better way to get the Server object from a ServletConfig?

Thank you,
Gary

--
E-Mail: garydgregory@xxxxxxxxx | ggregory@xxxxxxxxxx
JUnit in Action, 2nd Ed: http://bit.ly/ECvg0
Spring Batch in Action: http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Back to the top