01: /*
02: * Copyright 2005-2007 Noelios Consulting.
03: *
04: * The contents of this file are subject to the terms of the Common Development
05: * and Distribution License (the "License"). You may not use this file except in
06: * compliance with the License.
07: *
08: * You can obtain a copy of the license at
09: * http://www.opensource.org/licenses/cddl1.txt See the License for the specific
10: * language governing permissions and limitations under the License.
11: *
12: * When distributing Covered Code, include this CDDL HEADER in each file and
13: * include the License file at http://www.opensource.org/licenses/cddl1.txt If
14: * applicable, add the following below this CDDL HEADER, with the fields
15: * enclosed by brackets "[]" replaced with your own identifying information:
16: * Portions Copyright [yyyy] [name of copyright owner]
17: */
18:
19: package com.noelios.restlet.component;
20:
21: import java.util.logging.Logger;
22:
23: import org.restlet.Component;
24: import org.restlet.Context;
25: import org.restlet.Uniform;
26:
27: import com.noelios.restlet.TemplateDispatcher;
28:
29: /**
30: * Context allowing access to the component's connectors.
31: *
32: * @author Jerome Louvel (contact@noelios.com)
33: */
34: public class ComponentContext extends Context {
35: /** The component helper. */
36: private ComponentHelper componentHelper;
37:
38: /**
39: * Constructor.
40: *
41: * @param componentHelper
42: * The component helper.
43: */
44: public ComponentContext(ComponentHelper componentHelper) {
45: this (componentHelper, Logger.getLogger(Component.class
46: .getCanonicalName()));
47: }
48:
49: /**
50: * Constructor.
51: *
52: * @param componentHelper
53: * The component helper.
54: * @param logger
55: * The logger instance of use.
56: */
57: public ComponentContext(ComponentHelper componentHelper,
58: Logger logger) {
59: super (logger);
60: this .componentHelper = componentHelper;
61: }
62:
63: /**
64: * Returns a call dispatcher.
65: *
66: * @return A call dispatcher.
67: */
68: public Uniform getDispatcher() {
69: return new TemplateDispatcher(this , getComponentHelper()
70: .getClientRouter());
71: }
72:
73: /**
74: * Returns the component helper.
75: *
76: * @return The component helper.
77: */
78: protected ComponentHelper getComponentHelper() {
79: return this .componentHelper;
80: }
81:
82: /**
83: * Sets the component helper.
84: *
85: * @param componentHelper
86: * The component helper.
87: */
88: protected void setComponentHelper(ComponentHelper componentHelper) {
89: this.componentHelper = componentHelper;
90: }
91: }
|