11package gwt .react .client .components ;
22
3- import gwt .interop .utils .client .collections .JsStringMap ;
43import gwt .interop .utils .client .plainobjects .JsPlainObj ;
5- import gwt .interop .utils .shared .collections .StringMap ;
64import gwt .react .client .proptypes .BaseProps ;
75
86/**
@@ -12,8 +10,6 @@ public class ComponentUtils {
1210 private ComponentUtils () {
1311 }
1412
15- private static StringMap <ComponentConstructorFn > constructorLookup = JsStringMap .create () ;
16-
1713 /**
1814 * Given the Class of a JsType annotated {@link Component} class, return the constructor function to use in Javascript
1915 * @param cls The Class
@@ -22,39 +18,7 @@ private ComponentUtils() {
2218 * @param <T> The type of {@link Component}
2319 * @return The constructor function
2420 */
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+ }-*/ ;
6024}
0 commit comments