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

org.jruby.rack.SerialPoolingRackApplicationFactory 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 java.util.Queue;

/**
 * Works like the pooling application factory, with the variation that it will
 * create all application instances (runtimes) serially, using no extra threads.
 *
 * @author Ola Bini 
 */
public class SerialPoolingRackApplicationFactory extends PoolingRackApplicationFactory {
    
    public SerialPoolingRackApplicationFactory(RackApplicationFactory factory) {
        super(factory);
    }
    
    @Override
    protected void launchInitialization(final Queue apps) {
        while ( ! apps.isEmpty() ) {
            final RackApplication app = apps.remove();
            try {
                app.init();
                applicationPool.add(app);
                log(RackLogger.INFO, "added application to pool, size now = " + applicationPool.size());
            }
            catch (RackInitializationException e) {
                log(RackLogger.ERROR, "unable to initialize application", e);
            }
        }
    }
    
    @Override
    protected void waitTillPoolReady() {
        return; // waiting makes no sense here as we're initializing serialy
    }
    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy