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

org.jruby.rack.servlet.ServletRackConfig 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.servlet;

import org.jruby.rack.DefaultRackConfig;
import org.jruby.rack.RackLogger;
import org.jruby.rack.logging.ServletContextLogger;

import javax.servlet.ServletContext;

/**
 * Servlet environment version of RackConfig.
 */
public class ServletRackConfig extends DefaultRackConfig {

    private final ServletContext context;

    public ServletRackConfig(ServletContext context) {
        this.context = context;
    }

    @Override
    public String getProperty(String key) {
        String value;
        if ((value = context.getInitParameter(key)) != null) {
            return value;
        }
        return super.getProperty(key);
    }

    @Override
    public String getProperty(String key, String defaultValue) {
        String value;
        if ((value = context.getInitParameter(key)) != null) {
            return value;
        }
        return super.getProperty(key, defaultValue);
    }

    @Override
    protected RackLogger createLogger(String loggerClass) {
        if (loggerClass == null || loggerClass.equals(ServletContextLogger.class.getName())) {
            return new ServletContextLogger(context);
        }
        return super.createLogger(loggerClass);
    }

    public ServletContext getServletContext() {
        return context;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy