1 /*
2 * The contents of this file are subject to the terms of the Common Development and
3 * Distribution License (the License). You may not use this file except in compliance with the
4 * License.
5 *
6 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
7 * specific language governing permission and limitations under the License.
8 *
9 * When distributing Covered Software, include this CDDL Header Notice in each file and include
10 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
11 * Header, with the fields enclosed by brackets [] replaced by your own identifying
12 * information: "Portions copyright [year] [name of copyright owner]".
13 *
14 * Copyright 2012-2014 ForgeRock AS.
15 */
16
17 package org.forgerock.json.resource.http;
18
19 import org.forgerock.services.context.Context;
20 import org.forgerock.json.resource.ResourceException;
21
22 /**
23 * A factory which is responsible for creating new request {@code Context}s for
24 * each JSON request. The returned context must include a
25 * {@link org.forgerock.services.context.RootContext} as its root and may include
26 * zero or more sub-contexts.
27 * <p>
28 * As an example, a context factory may return a context chain which includes
29 * authentication state information.
30 */
31 public interface HttpContextFactory {
32
33 /**
34 * Returns the context which should be used for the provided HTTP request.
35 *
36 * @param parent
37 * The parent context.
38 * @param request
39 * The HTTP request which is about to be processed.
40 * @return The context which should be used for the provided HTTP request.
41 * @throws ResourceException
42 * If a request context could not be obtained.
43 */
44 Context createContext(Context parent, org.forgerock.http.protocol.Request request) throws ResourceException;
45 }