Search in sources :

Example 1 with WXModuleAnno

use of com.taobao.weex.common.WXModuleAnno in project incubator-weex by apache.

the class ConfigModuleFactory method generateMethodMap.

private void generateMethodMap() {
    if (WXEnvironment.isApkDebugable()) {
        WXLogUtils.d(TAG, "extractMethodNames:" + mClazz.getSimpleName());
    }
    HashMap<String, Invoker> methodMap = new HashMap<>();
    try {
        for (Method method : mClazz.getMethods()) {
            // iterates all the annotations available in the method
            for (Annotation anno : method.getDeclaredAnnotations()) {
                if (anno != null) {
                    if (anno instanceof JSMethod) {
                        JSMethod methodAnnotation = (JSMethod) anno;
                        String name = JSMethod.NOT_SET.equals(methodAnnotation.alias()) ? method.getName() : methodAnnotation.alias();
                        methodMap.put(name, new MethodInvoker(method, methodAnnotation.uiThread()));
                        break;
                    } else if (anno instanceof WXModuleAnno) {
                        WXModuleAnno methodAnnotation = (WXModuleAnno) anno;
                        methodMap.put(method.getName(), new MethodInvoker(method, methodAnnotation.runOnUIThread()));
                        break;
                    }
                }
            }
        }
    } catch (Throwable e) {
        WXLogUtils.e("[WXModuleManager] extractMethodNames:", e);
    }
    mMethodMap = methodMap;
}
Also used : WXModuleAnno(com.taobao.weex.common.WXModuleAnno) MethodInvoker(com.taobao.weex.bridge.MethodInvoker) Invoker(com.taobao.weex.bridge.Invoker) HashMap(java.util.HashMap) JSMethod(com.taobao.weex.annotation.JSMethod) Method(java.lang.reflect.Method) JSMethod(com.taobao.weex.annotation.JSMethod) Annotation(java.lang.annotation.Annotation) MethodInvoker(com.taobao.weex.bridge.MethodInvoker)

Aggregations

JSMethod (com.taobao.weex.annotation.JSMethod)1 Invoker (com.taobao.weex.bridge.Invoker)1 MethodInvoker (com.taobao.weex.bridge.MethodInvoker)1 WXModuleAnno (com.taobao.weex.common.WXModuleAnno)1 Annotation (java.lang.annotation.Annotation)1 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1