All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jruby.rack.RackServlet Maven / Gradle / Ivy

Go to download

A servlet bridge for (Ruby-based) Rack applications that allow them to run in Java Application servers using JRuby.

There is a newer version: 1.2.2
Show newest version
/*
 * Copyright (c) 2010-2012 Engine Yard, Inc.
 * Copyright (c) 2007-2009 Sun Microsystems, Inc.
 * This source code is available under the MIT license.
 * See the file LICENSE.txt for details.
 */

package org.jruby.rack;

import javax.servlet.ServletConfig;

public class RackServlet extends AbstractServlet {

    private RackDispatcher dispatcher;
    private RackContext context;

    /** Default constructor for servlet container */
    public RackServlet() {
    }
    
    /** dependency injection ctor, used by unit tests */
    public RackServlet(RackDispatcher dispatcher, RackContext context) {
        this.dispatcher = dispatcher;
        this.context = context;
    }

    @Override
    public void init(ServletConfig config) {
        if (dispatcher == null) {
            context = (RackContext) config.getServletContext().getAttribute(RackApplicationFactory.RACK_CONTEXT);
            dispatcher = new DefaultRackDispatcher(context);
        }
    }

    @Override
    public RackDispatcher getDispatcher() {
        return dispatcher;
    }

    @Override
    public RackContext getContext() {
        return context;
    }
    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy