1 /*
2 Copyright (c) 2003, Laurent Caillette.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without modifica-
6 tion, are permitted provided that the following conditions are met:
7
8 1. Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10
11 2. Redistributions in binary form must reproduce the above copyright notice,
12 this list of conditions and the following disclaimer in the documentation
13 and/or other materials provided with the distribution.
14
15 3. The end-user documentation included with the redistribution, if any, must
16 include the following acknowledgment: "This product includes software
17 written by Laurent Caillette."
18 Alternately, this acknowledgment may appear in the software itself, if
19 and wherever such third-party acknowledgments normally appear.
20
21 4. The name "Laurent Caillette" must not be used to endorse or
22 promote products derived from this software without
23 prior written permission. For written permission, please contact
24 laurent.caillette@laposte.net
25
26 5. Products derived from this software may not be called
27 "Laurent Caillette", nor may "Laurent Caillette" appear
28 in their name, without prior written permission of the
29 author.
30
31 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
32 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
33 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
34 AUTHOR (LAURENT CAILLETTE) BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
36 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
37 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
40 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 */
42 package tweed.context;
43 import org.apache.avalon.framework.logger.Logger;
44 import tweed.action.ActionPerformer;
45 import tweed.binding.InputValidationHub;
46 import tweed.invocation.CommandInvoker;
47 import tweed.system.bus.EventBus;
48
49 /***
50 * Describes an execution context. An instance of this class acts like
51 * a set of global variables, but in a restricted scope.
52 * A <code>Context</code> implementation must respect following rules:
53 * <ul>
54 * <li>
55 * Immutability: Context instances MUST be immutable, references
56 * to Context member must not change once set. Context members
57 * (like logger) are not supposed to be immutable.
58 * </li><li>
59 * Cascadability: Context objects may be cascaded, with the
60 * ability to propagate events upwards or downards (TODO: implement this).
61 * </li><li>
62 * Logging and members creation order: Context's logger must be set
63 * creating any other members. Default implementations of Context
64 * members often take a <code>Context</code> object as input parameter,
65 * at least for using its <code>Logger</code>.
66 * </li><li>
67 * Factory creation: due to the complexity of Context creation, a
68 * factory must used instead of <code>Context</code> constructor.
69 * </li>
70 * </ul>
71 *
72 *
73 * @see tweed.context.DefaultContextFactory
74 * @see tweed.context.ContextPatcher
75 *
76 * @author Laurent Caillette
77 * @version $Id$
78 */
79 public interface Context extends Contextualized {
80
81 /***
82 * Allows to pass directly a <code>Context</code> object instead
83 * of a {@link Contextualized}. Implementations must return <code>this</code>.
84 */
85 Context getContext() ;
86
87 /***
88 * Returns the base <code>Logger</code> for this context.
89 * @return a non-null <code>Logger</code> instance.
90 */
91 Logger getLogger() ;
92
93
94 /***
95 * Returns the <code>CommandInvoker</code> instance used server-side
96 * for executing <code>Command</code> instances on the server.
97 * @return a <code>CommandInvoker</code> when called in the client context,
98 * <code>null</code> otherwise.
99 */
100 CommandInvoker getInvoker() ;
101
102 /***
103 * Returns if the application is running client-side. It is guaranteed that
104 * the {@link #isServerSide()} method will return the negation of
105 * <code>isClientSide()</code>.
106 * @return <code>true</code> if running client-side, false otherwise.
107 */
108 boolean isClientSide() ;
109
110 /***
111 * Returns if the application is running server-side. It is guaranteed that
112 * the {@link #isClientSide} method will return the negation of
113 * <code>isServerSide()</code>.
114 * @return <code>true</code> if running server-side, false otherwise.
115 */
116 boolean isServerSide() ;
117
118 /***
119 * Returns the event bus for this context.
120 *
121 * @return a non-null <code>EventBus</code> instance if running client-side,
122 * <code>null</code> otherwise.
123 */
124 EventBus getBus() ;
125
126 /***
127 * Returns the <code>ValidationHub</code> that every
128 * {@link tweed.binding.Binding} uses implicitely.
129 * @return a non-null <code>InputValidationHub</code> if running client-side,
130 * <code>null</code> otherwise.
131 */
132 InputValidationHub getInputValidationHub() ;
133
134 /***
135 * Returns the <code>ActionPerformer</code> that processes
136 * {@link tweed.action.ContextAction}s.
137 * @return a non-null <code>ActionPerformer</code> if running client-side,
138 * <code>null</code> otherwise.
139 */
140 ActionPerformer getActionPerformer() ;
141
142
143 }
This page was automatically generated by Maven