net.craftforge.essential.controller
Class Controller

java.lang.Object
  extended by net.craftforge.essential.controller.Controller

public class Controller
extends Object

Since:
02.12.2010
Author:
Christian Bick

Method Summary
static Controller getInstance(String packagePath)
          Controls instantiation process to ensure that only one controller per package path and default configuration is used.
static Controller getInstance(String packagePath, Configuration config)
          Controls instantiation process to ensure that only one controller per package path and configuration (identified by name) is used.
 int perform(Request request, Response response)
          Performs a request on the controller, using the response to write back the serialized result.
 int perform(String httpMethod, String urlInfoPart, Map<String,String[]> requestHeaders, Map<String,String[]> requestParameters, InputStream inputStream, OutputStream outputStream)
          Performs a request on a controller using the HTTP method and info part to allocate the resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Controller getInstance(String packagePath,
                                     Configuration config)
Controls instantiation process to ensure that only one controller per package path and configuration (identified by name) is used.

Parameters:
packagePath - The package path
config - The configuration
Returns:
The controller responsible for the package path and configuration combination

getInstance

public static Controller getInstance(String packagePath)
Controls instantiation process to ensure that only one controller per package path and default configuration is used.

Parameters:
packagePath - The package path
Returns:
The controller responsible for the package path using the default configuration

perform

public int perform(String httpMethod,
                   String urlInfoPart,
                   Map<String,String[]> requestHeaders,
                   Map<String,String[]> requestParameters,
                   InputStream inputStream,
                   OutputStream outputStream)
            throws ControllerException
Performs a request on a controller using the HTTP method and info part to allocate the resource. Uses the URL info part and request parameters for invoking the resource method. Uses the header information to properly to serialize the result into the output. Uses the output stream for writing back the serialized result.

Parameters:
httpMethod - The HTTP method
urlInfoPart - The URL info part (to identify the resource by this framework)
requestHeaders - The request headers a map (keys = header names, values = header content)
requestParameters - The request parameters
inputStream - The input stream of the request body
outputStream - The output stream of the response body
Returns:
The resulting HTTP status code
Throws:
ControllerException - Failed to perform the request

perform

public int perform(Request request,
                   Response response)
            throws ControllerException
Performs a request on the controller, using the response to write back the serialized result.

Parameters:
request - The request
response - The response.
Returns:
The resulting HTTP status code
Throws:
ControllerException - Failed to perform the request


Copyright © 2011. All Rights Reserved.