01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package jsx3;
17:
18: import java.util.Collection;
19:
20: import jsx3.app.Server;
21:
22: import org.directwebremoting.ScriptSession;
23: import org.directwebremoting.proxy.ScriptProxy;
24:
25: /**
26: * A Factory class to allow access to GI components in the same way that the
27: * global Javascript variable(s) do on the client.
28: * @author Joe Walker [joe at getahead dot ltd dot uk]
29: */
30: public class GI {
31: /**
32: * Get access to a Server instance with the given name
33: * @param scriptSessions A collection of ScriptSessions that we should act on.
34: * @param name The name to get access to
35: * @return A new Server proxy instance
36: */
37: public static Server getServer(
38: Collection<ScriptSession> scriptSessions, String name) {
39: ScriptProxy proxy = new ScriptProxy(scriptSessions);
40: return new Server(null, name + ".", proxy);
41: }
42:
43: /**
44: * Get access to a Server instance with the given name
45: * @param scriptSession The ScriptSessions that we should act on.
46: * @param name The name to get access to
47: * @return A new Server proxy instance
48: */
49: public static Server getServer(ScriptSession scriptSession,
50: String name) {
51: ScriptProxy proxy = new ScriptProxy(scriptSession);
52: return new Server(null, name + ".", proxy);
53: }
54: }
|