Package javax.servlet

Examples of javax.servlet.Servlet


            this.destroy();
            if ( errors != null && errors.size() > 0 ) {
                throw CompilerException.create(errors, this.sourcePath);
            }

            final Servlet servlet = (Servlet) result.loadCompiledClass(this.className).newInstance();

            servlet.init(this.config);
            this.injectFields(servlet);

            this.theServlet = servlet;

        } catch (final Exception ex) {
View Full Code Here


        WebAppBundleContext webAppBundleContext = new WebAppBundleContext("/", mockBundle, this.getClass().getClassLoader());

        final CountDownLatch testLatch = new CountDownLatch(2);

        //Add a Filter to test whether the osgi-bundlecontext is available at init
        webAppBundleContext.addServlet(new ServletHolder(new Servlet()
        {
            public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException
            {
                // Do Nothing
            }
View Full Code Here

            throw new IllegalArgumentException("Malformed resource name [" + name + "]");
        }

        try
        {
            Servlet servlet = new ResourceServlet(name);
            registerServlet(alias, servlet, null, context);
        }
        catch (ServletException e)
        {
            SystemLogger.error("Failed to register resources", e);
View Full Code Here

        }
    }

    public void unregister(String alias)
    {
        final Servlet servlet = this.handlerRegistry.getServletByAlias(alias);
        if (servlet == null)
        {
            // FELIX-4561 - don't bother throwing an exception if we're stopping anyway...
            if ((bundle.getState() & Bundle.STOPPING) != 0)
            {
View Full Code Here

    @Test
    public void testInitParametersOk() throws Exception
    {
        final CountDownLatch initLatch = new CountDownLatch(1);

        Servlet servlet = new HttpServlet()
        {
            @Override
            public void init(ServletConfig config) throws ServletException
            {
                String value1 = config.getInitParameter("key1");
View Full Code Here

    @Test
    public void testAddRemoveServlet() throws Exception
    {
        HandlerRegistry hr = new HandlerRegistry();

        Servlet servlet = Mockito.mock(Servlet.class);
        ServletHandler handler = new ServletHandler(null, servlet, "/foo", "foo");
        assertEquals("Precondition", 0, hr.getServlets().length);
        hr.addServlet(handler);
        Mockito.verify(servlet, Mockito.times(1)).init(Mockito.any(ServletConfig.class));
        assertEquals(1, hr.getServlets().length);
View Full Code Here

    @Test
    public void testAddServletWhileSameServletAddedDuringInit() throws Exception
    {
        final HandlerRegistry hr = new HandlerRegistry();

        Servlet servlet = Mockito.mock(Servlet.class);
        final ServletHandler otherHandler = new ServletHandler(null, servlet, "/bar", "bar");

        Mockito.doAnswer(new Answer<Void>()
        {
            boolean registered = false;
View Full Code Here

    @Test
    public void testAddServletWhileSameAliasAddedDuringInit() throws Exception
    {
        final HandlerRegistry hr = new HandlerRegistry();

        Servlet otherServlet = Mockito.mock(Servlet.class);
        final ServletHandler otherHandler = new ServletHandler(null, otherServlet, "/foo", "bar");

        Servlet servlet = Mockito.mock(Servlet.class);
        Mockito.doAnswer(new Answer<Void>()
        {
            public Void answer(InvocationOnMock invocation) throws Throwable
            {
                // sneakily register another servlet before this one has finished calling init()
View Full Code Here

    @Test
    public void testRemoveAll() throws Exception
    {
        HandlerRegistry hr = new HandlerRegistry();

        Servlet servlet = Mockito.mock(Servlet.class);
        ServletHandler servletHandler = new ServletHandler(null, servlet, "/f", "f");
        hr.addServlet(servletHandler);
        Servlet servlet2 = Mockito.mock(Servlet.class);
        ServletHandler servletHandler2 = new ServletHandler(null, servlet2, "/ff", "ff");
        hr.addServlet(servletHandler2);
        Filter filter = Mockito.mock(Filter.class);
        FilterHandler filterHandler = new FilterHandler(null, filter, "/f", 0, "f");
        hr.addFilter(filterHandler);
View Full Code Here

    @Override
    public void service(ServletRequest req, ServletResponse res)
            throws ServletException, IOException {

        // delegate the request to the registered delegatee servlet
        Servlet delegatee = sling;
        if (delegatee != null) {

            // check for problematic application servers like WebSphere
            // where path info and servlet path is set wrong SLING-2410
            final HttpServletRequest request = (HttpServletRequest) req;
            if ( request.getPathInfo() == null && request.getServletPath() != null
                    && request.getServletPath().endsWith(".jsp") ) {
                req = new HttpServletRequestWrapper(request) {

                    @Override
                    public String getPathInfo() {
                        return request.getServletPath();
                    }

                    @Override
                    public String getServletPath() {
                        return "";
                    }

                };
            }
            delegatee.service(req, res);

        } else if (startFailureCounter > MAX_START_FAILURES) {

            // too many startup retries, fail for ever
            ((HttpServletResponse) res).sendError(HttpServletResponse.SC_NOT_FOUND);
View Full Code Here

TOP

Related Classes of javax.servlet.Servlet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.