KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > dev > shell > ShellJavaScriptHost


1 /*
2  * Copyright 2007 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16 package com.google.gwt.dev.shell;
17
18 import com.google.gwt.core.ext.UnableToCompleteException;
19
20 /**
21  * This interface contains all of the methods that must be exposed to a hosted
22  * mode application via its JavaScriptHost class. JavaScriptHost contains a
23  * method called setHost() that must be called when a new application is
24  * initialized.
25  *
26  * This interface works with JavaScriptHost to keep running applications at
27  * arms-length via an isolated class loader (this requires that there be no
28  * explicit dependencies between the shell and any client-side classes).
29  */

30 public interface ShellJavaScriptHost {
31
32   /**
33    * Defines a new native JavaScript function.
34    *
35    * @param name the function's name, usually a JSNI signature
36    * @param paramNames parameter names
37    * @param js the script body
38    */

39   abstract void createNative(String JavaDoc file, int line, String JavaDoc name,
40       String JavaDoc[] paramNames, String JavaDoc js);
41
42   /**
43    * Call this when a JavaScript exception is caught.
44    */

45   abstract void exceptionCaught(int number, String JavaDoc name, String JavaDoc description);
46
47   /**
48    * Invoke a native JavaScript function that returns a boolean value.
49    */

50   abstract boolean invokeNativeBoolean(String JavaDoc name, Object JavaDoc jthis,
51       Class JavaDoc[] types, Object JavaDoc[] args) throws Throwable JavaDoc;
52
53   /**
54    * Invoke a native JavaScript function that returns a byte value.
55    */

56   abstract byte invokeNativeByte(String JavaDoc name, Object JavaDoc jthis, Class JavaDoc[] types,
57       Object JavaDoc[] args) throws Throwable JavaDoc;
58
59   /**
60    * Invoke a native JavaScript function that returns a character value.
61    */

62   abstract char invokeNativeChar(String JavaDoc name, Object JavaDoc jthis, Class JavaDoc[] types,
63       Object JavaDoc[] args) throws Throwable JavaDoc;
64
65   /**
66    * Invoke a native JavaScript function that returns a double value.
67    */

68   abstract double invokeNativeDouble(String JavaDoc name, Object JavaDoc jthis, Class JavaDoc[] types,
69       Object JavaDoc[] args) throws Throwable JavaDoc;
70
71   /**
72    * Invoke a native JavaScript function that returns a float value.
73    */

74   abstract float invokeNativeFloat(String JavaDoc name, Object JavaDoc jthis, Class JavaDoc[] types,
75       Object JavaDoc[] args) throws Throwable JavaDoc;
76
77   /**
78    * Invoke a native JavaScript function that returns a handle value.
79    */

80   abstract Object JavaDoc invokeNativeHandle(String JavaDoc name, Object JavaDoc jthis,
81       Class JavaDoc returnType, Class JavaDoc[] types, Object JavaDoc[] args) throws Throwable JavaDoc;
82
83   /**
84    * Invoke a native JavaScript function that returns an integer value.
85    */

86   abstract int invokeNativeInt(String JavaDoc name, Object JavaDoc jthis, Class JavaDoc[] types,
87       Object JavaDoc[] args) throws Throwable JavaDoc;
88
89   /**
90    * Invoke a native JavaScript function that returns a long value.
91    */

92   abstract long invokeNativeLong(String JavaDoc name, Object JavaDoc jthis, Class JavaDoc[] types,
93       Object JavaDoc[] args) throws Throwable JavaDoc;
94
95   /**
96    * Invoke a native JavaScript function that returns an object value.
97    */

98   abstract Object JavaDoc invokeNativeObject(String JavaDoc name, Object JavaDoc jthis, Class JavaDoc[] types,
99       Object JavaDoc[] args) throws Throwable JavaDoc;
100
101   /**
102    * Invoke a native JavaScript function that returns a short value.
103    */

104   abstract short invokeNativeShort(String JavaDoc name, Object JavaDoc jthis, Class JavaDoc[] types,
105       Object JavaDoc[] args) throws Throwable JavaDoc;
106
107   /**
108    * Invoke a native JavaScript function that returns a string value.
109    */

110   abstract String JavaDoc invokeNativeString(String JavaDoc name, Object JavaDoc jthis, Class JavaDoc[] types,
111       Object JavaDoc[] args) throws Throwable JavaDoc;
112
113   /**
114    * Invoke a native JavaScript function that returns no value.
115    */

116   abstract void invokeNativeVoid(String JavaDoc name, Object JavaDoc jthis, Class JavaDoc[] types,
117       Object JavaDoc[] args) throws Throwable JavaDoc;
118
119   /**
120    * Logs to the dev shell logger.
121    */

122   abstract void log(String JavaDoc message, Throwable JavaDoc e);
123
124   /**
125    * Resolves a deferred binding request and create the requested object.
126    */

127   abstract Object JavaDoc rebindAndCreate(String JavaDoc requestedTypeName)
128       throws UnableToCompleteException;
129 }
130
Popular Tags