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

org.simpleframework.http.resource.ResourceContainer Maven / Gradle / Ivy

/*
 * ResourceProcessor.java February 2001
 *
 * Copyright (C) 2001, Niall Gallagher 
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General 
 * Public License along with this library; if not, write to the 
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
 * Boston, MA  02111-1307  USA
 */
  
package org.simpleframework.http.resource;

import org.simpleframework.http.Response;
import org.simpleframework.http.Request;
import org.simpleframework.http.core.Container;

/**
 * The ResourceContainer is an implementation of the
 * Container interface for handling an arbitrary set
 * of resources. This container will accept any HTTP transaction
 * and delegate the processing of that transation to a resource.
 * This resolves the resource to use using an implementation of 
 * the ResourceEngine interface. 
 * 

* This provides a very simple means to manage individual targets * using separate resource implementations. It also provides an * ideal location to introduce path mapping functionality. * * @author Niall Gallagher */ public class ResourceContainer implements Container { /** * The engine that resolves the resources to be used. */ private final ResourceEngine engine; /** * Constructor for the ResourceContainer object. * This requires a resource engine which it uses to map the * request targets to a given implementation or instance. * This is essentially a router to the Resource * objects that have been mapped to a given request path. * * @param engine the engine used to resolve resources */ public ResourceContainer(ResourceEngine engine){ this.engine = engine; } /** * This method is where most of the work is done to retrieve * the Resource and process the HTTP request. This * will basically use the resolve method of the * issued ResourceEngine to acquire resources. * * @param req the Request to be processed * @param resp the Response to be processed */ public void handle(Request req, Response resp){ engine.resolve(req.getAddress()).handle(req,resp); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy