001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2014-2015 ForgeRock AS. 015 */ 016 017package org.forgerock.http; 018 019import org.forgerock.http.io.Buffer; 020import org.forgerock.util.Factory; 021import org.slf4j.Logger; 022import org.slf4j.LoggerFactory; 023 024/** 025 * Configuration class to configure the {@code HttpApplication} instance. 026 * 027 * <p>The implementation of this class will be loaded using the {@link java.util.ServiceLoader} framework.</p> 028 */ 029public interface HttpApplication { 030 031 /** 032 * Http Framework core Logger instance. 033 */ 034 Logger LOGGER = LoggerFactory.getLogger(HttpApplication.class); 035 036 /** 037 * Gets the root {@link Handler} that will handle all HTTP requests. 038 * 039 * <p>The {@code Handler} returned from this method MUST be a singleton.</p> 040 * 041 * @return The {@code Handler} to handle HTTP requests. 042 * @throws HttpApplicationException If there is a problem constructing the 043 * root application {@code Handler}. 044 */ 045 Handler start() throws HttpApplicationException; 046 047 /** 048 * Gets the {@link Factory} that will create temporary storage 049 * {@link Buffer}s to handle the processing of requests. 050 * 051 * <p>May return {@code null} indicating that the container should provide 052 * a default buffer factory.</p> 053 * 054 * @return A {@code Buffer} {@code Factory} or {@code null}. 055 */ 056 Factory<Buffer> getBufferFactory(); 057 058 /** 059 * Called when HTTP application is shutdown. 060 * 061 * <p>Implementation should use this method to clear up all remaining 062 * resources.</p> 063 */ 064 void stop(); 065}