001: /*
002: * Copyright 2005-2007 Noelios Consulting.
003: *
004: * The contents of this file are subject to the terms of the Common Development
005: * and Distribution License (the "License"). You may not use this file except in
006: * compliance with the License.
007: *
008: * You can obtain a copy of the license at
009: * http://www.opensource.org/licenses/cddl1.txt See the License for the specific
010: * language governing permissions and limitations under the License.
011: *
012: * When distributing Covered Code, include this CDDL HEADER in each file and
013: * include the License file at http://www.opensource.org/licenses/cddl1.txt If
014: * applicable, add the following below this CDDL HEADER, with the fields
015: * enclosed by brackets "[]" replaced with your own identifying information:
016: * Portions Copyright [yyyy] [name of copyright owner]
017: */
018:
019: package com.noelios.restlet;
020:
021: import java.util.logging.Logger;
022:
023: import org.restlet.Context;
024: import org.restlet.Server;
025: import org.restlet.data.Form;
026: import org.restlet.data.Parameter;
027: import org.restlet.data.Request;
028: import org.restlet.data.Response;
029: import org.restlet.util.Series;
030:
031: /**
032: * Server connector helper.
033: *
034: * @author Jerome Louvel (contact@noelios.com)
035: */
036: public class ServerHelper extends ConnectorHelper {
037: /** The server to help. */
038: private Server server;
039:
040: /**
041: * Constructor.
042: *
043: * @param server
044: * The client to help.
045: */
046: public ServerHelper(Server server) {
047: this .server = server;
048: }
049:
050: /**
051: * Returns the server to help.
052: *
053: * @return The server to help.
054: */
055: public Server getServer() {
056: return this .server;
057: }
058:
059: /**
060: * Returns the server parameters.
061: *
062: * @return The server parameters.
063: */
064: public Series<Parameter> getParameters() {
065: Series<Parameter> result = (getServer() != null) ? getServer()
066: .getContext().getParameters() : null;
067: if (result == null)
068: result = new Form();
069: return result;
070: }
071:
072: /**
073: * Returns the server logger.
074: *
075: * @return The server logger.
076: */
077: public Logger getLogger() {
078: return getServer().getLogger();
079: }
080:
081: /**
082: * Returns the server context.
083: *
084: * @return The server context.
085: */
086: public Context getContext() {
087: return getServer().getContext();
088: }
089:
090: /**
091: * Handles a call.
092: *
093: * @param request
094: * The request to handle.
095: * @param response
096: * The response to update.
097: */
098: public void handle(Request request, Response response) {
099: getServer().handle(request, response);
100: }
101:
102: /**
103: * Sets the server to help.
104: *
105: * @param server
106: * The server to help.
107: */
108: public void setServer(Server server) {
109: this.server = server;
110: }
111:
112: }
|