1
1
package gwt .react .client .components ;
2
2
3
- import gwt .interop .utils .client .collections .JsStringMap ;
4
3
import gwt .interop .utils .client .plainobjects .JsPlainObj ;
5
- import gwt .interop .utils .shared .collections .StringMap ;
6
4
import gwt .react .client .proptypes .BaseProps ;
7
5
8
6
/**
@@ -12,8 +10,6 @@ public class ComponentUtils {
12
10
private ComponentUtils () {
13
11
}
14
12
15
- private static StringMap <ComponentConstructorFn > constructorLookup = JsStringMap .create () ;
16
-
17
13
/**
18
14
* Given the Class of a JsType annotated {@link Component} class, return the constructor function to use in Javascript
19
15
* @param cls The Class
@@ -22,39 +18,7 @@ private ComponentUtils() {
22
18
* @param <T> The type of {@link Component}
23
19
* @return The constructor function
24
20
*/
25
- public static <P extends BaseProps , S extends JsPlainObj , T extends Component <P , S >> ComponentConstructorFn <P > getCtorFn (Class <T > cls ) {
26
- return getCtorFn (cls , cls .getName ());
27
- }
28
-
29
- /**
30
- * Given the fully qualified name of a JsType annotated {@link Component} class, return the constructor function to use in Javascript
31
- * @param cls The Class
32
- * @param actualClassName The fully qualified name. This is useful if it does not match the className of cls.
33
- * @param <P>
34
- * @return The constructor function
35
- */
36
- public static <P extends BaseProps , S extends JsPlainObj , T extends Component <P , S >> ComponentConstructorFn <P > getCtorFn (Class <T > cls , String actualClassName ) {
37
- ComponentConstructorFn <P > fn = constructorLookup .get (actualClassName );
38
-
39
- if (fn == null ) {
40
- fn = getJSConstructorFn (actualClassName );
41
- assert (fn != null );
42
-
43
- constructorLookup .put (actualClassName , fn );
44
- }
45
- return fn ;
46
- }
47
-
48
- /**
49
- * TODO find a more efficient way of obtaining the constructor function
50
- */
51
- private static native <P extends BaseProps > ComponentConstructorFn <P > getJSConstructorFn (String className ) /*-{
52
- var namespaces = className.split(".");
53
- var context = $wnd;
54
-
55
- for (var i = 0; i < namespaces.length; i++) {
56
- context = context[namespaces[i]];
57
- }
58
- return context;
59
- }-*/ ;
21
+ public static native <P extends BaseProps , S extends JsPlainObj , T extends Component <P , S >> ComponentConstructorFn <P > getCtorFn (Class <T > cls ) /*-{
22
+ return [email protected] ::jsConstructor;
23
+ }-*/ ;
60
24
}
0 commit comments