com.taobao.weex.bridge.Invoker Java Examples

The following examples show how to use com.taobao.weex.bridge.Invoker. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TypeModuleFactory.java    From weex with Apache License 2.0 6 votes vote down vote up
private void generateMethodMap() {
  WXLogUtils.d(TAG, "extractMethodNames");
  ArrayList<String> methods = new ArrayList<>();
  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 && anno instanceof WXModuleAnno) {
          methods.add(method.getName());
          methodMap.put(method.getName(), new MethodInvoker(method));
          break;
        }
      }
    }
  } catch (Throwable e) {
    WXLogUtils.e("[WXModuleManager] extractMethodNames:" + e.getStackTrace());
  }
  mMethods = methods;
  mMethodMap = methodMap;
}
 
Example #2
Source File: SimpleComponentHolder.java    From weex-uikit with MIT License 5 votes vote down vote up
@Override
public synchronized Invoker getPropertyInvoker(String name){
    if (mPropertyInvokers == null) {
      generate();
    }

  return mPropertyInvokers.get(name);
}
 
Example #3
Source File: TypeModuleFactory.java    From weex with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, Invoker> getMethodMap() {
  if (mMethodMap == null) {
    generateMethodMap();
  }
  return mMethodMap;
}
 
Example #4
Source File: ComponentHolder.java    From weex with Apache License 2.0 5 votes vote down vote up
public Invoker getMethod(String name){
  if(mMethods == null){
    generate();
  }

  return mMethods.get(name);
}
 
Example #5
Source File: ComponentHolder.java    From weex with Apache License 2.0 5 votes vote down vote up
private synchronized void generate(){
  WXLogUtils.d(TAG,"Generate Component:"+mClz.getSimpleName());
  HashMap<String, Invoker> methods = new HashMap<>();

  Annotation[] annotations;
  Annotation anno;
  for (Method method : mClz.getMethods()) {
    annotations = method.getDeclaredAnnotations();
    for (int i = 0,annotationsCount = annotations.length;
         i < annotationsCount; ++i) {
      anno = annotations[i];
      if (anno != null && anno instanceof WXComponentProp) {
        String name = ((WXComponentProp) anno).name();
        methods.put(name, new MethodInvoker(method));
        break;
      }
    }
  }

  mMethods = methods;
  try {
    mConstructor = mClz.getConstructor(WXSDKInstance.class, WXDomObject.class, WXVContainer.class, boolean.class);
  } catch (NoSuchMethodException e) {
    try {
      //compatible deprecated constructor
      mConstructor = mClz.getConstructor(WXSDKInstance.class, WXDomObject.class, WXVContainer.class,String.class, boolean.class);
    } catch (NoSuchMethodException e1) {
      e1.printStackTrace();
      throw new WXRuntimeException("Can't find constructor of component.");
    }
    e.printStackTrace();
  }
}
 
Example #6
Source File: TypeModuleFactory.java    From weex-uikit with MIT License 5 votes vote down vote up
@Override
public Invoker getMethodInvoker(String name) {
  if (mMethodMap == null) {
    generateMethodMap();
  }
  return mMethodMap.get(name);
}
 
Example #7
Source File: ExternalLoaderComponentHolder.java    From weex-uikit with MIT License 5 votes vote down vote up
@Override
public Invoker getMethodInvoker(String name) {
  if(mMethodInvokers == null && !generate()){
    return null;
  }
  return mMethodInvokers.get(name);
}
 
Example #8
Source File: ExternalLoaderComponentHolder.java    From weex-uikit with MIT License 5 votes vote down vote up
@Override
public synchronized Invoker getPropertyInvoker(String name){
  if (mPropertyInvokers == null && !generate()) {
    return null;
  }

  return mPropertyInvokers.get(name);
}
 
Example #9
Source File: ExternalLoaderComponentHolder.java    From weex-uikit with MIT License 5 votes vote down vote up
private synchronized boolean generate(){
  if(mClass==null){
    return false;
  }

  Pair<Map<String, Invoker>, Map<String, Invoker>> methodPair = SimpleComponentHolder.getMethods(mClass);
  mPropertyInvokers = methodPair.first;
  mMethodInvokers = methodPair.second;
  return true;
}
 
Example #10
Source File: WXComponent.java    From weex-uikit with MIT License 5 votes vote down vote up
public final void invoke(String method, JSONArray args) {
  final Invoker invoker = mHolder.getMethodInvoker(method);
  if (invoker != null) {
    try {
      getInstance()
          .getNativeInvokeHelper()
          .invoke(this,invoker,args);

    } catch (Exception e) {
      WXLogUtils.e("[WXComponent] updateProperties :" + "class:" + getClass() + "method:" + invoker.toString() + " function " + WXLogUtils.getStackTrace(e));
    }
  }else{
    onInvokeUnknownMethod(method,args);
  }
}
 
Example #11
Source File: SimpleComponentHolder.java    From weex-uikit with MIT License 5 votes vote down vote up
@Override
public Invoker getMethodInvoker(String name) {
  if(mMethodInvokers == null){
    generate();
  }
  return mMethodInvokers.get(name);
}
 
Example #12
Source File: SimpleComponentHolder.java    From weex-uikit with MIT License 5 votes vote down vote up
private synchronized void generate(){
  if(WXEnvironment.isApkDebugable()) {
    WXLogUtils.d(TAG, "Generate Component:" + mClz.getSimpleName());
  }

  Pair<Map<String, Invoker>, Map<String, Invoker>> methodPair = getMethods(mClz);
  mPropertyInvokers = methodPair.first;
  mMethodInvokers = methodPair.second;
}
 
Example #13
Source File: TypeModuleFactory.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public Invoker getMethodInvoker(String name) {
  if (mMethodMap == null) {
    generateMethodMap();
  }
  return mMethodMap.get(name);
}
 
Example #14
Source File: ExternalLoaderComponentHolder.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public Invoker getMethodInvoker(String name) {
  if(mMethodInvokers == null && !generate()){
    return null;
  }
  return mMethodInvokers.get(name);
}
 
Example #15
Source File: ExternalLoaderComponentHolder.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized Invoker getPropertyInvoker(String name){
  if (mPropertyInvokers == null && !generate()) {
    return null;
  }

  return mPropertyInvokers.get(name);
}
 
Example #16
Source File: ExternalLoaderComponentHolder.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
private synchronized boolean generate(){
  if(mClass==null){
    return false;
  }

  Pair<Map<String, Invoker>, Map<String, Invoker>> methodPair = SimpleComponentHolder.getMethods(mClass);
  mPropertyInvokers = methodPair.first;
  mMethodInvokers = methodPair.second;
  return true;
}
 
Example #17
Source File: WXComponent.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public final void invoke(String method, JSONArray args) {
  final Invoker invoker = mHolder.getMethodInvoker(method);
  if (invoker != null) {
    try {
      getInstance()
          .getNativeInvokeHelper()
          .invoke(this,invoker,args);

    } catch (Exception e) {
      WXLogUtils.e("[WXComponent] updateProperties :" + "class:" + getClass() + "method:" + invoker.toString() + " function " + WXLogUtils.getStackTrace(e));
    }
  }else{
    onInvokeUnknownMethod(method,args);
  }
}
 
Example #18
Source File: SimpleComponentHolder.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public Invoker getMethodInvoker(String name) {
  if(mMethodInvokers == null){
    generate();
  }
  return mMethodInvokers.get(name);
}
 
Example #19
Source File: SimpleComponentHolder.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized Invoker getPropertyInvoker(String name){
    if (mPropertyInvokers == null) {
      generate();
    }

  return mPropertyInvokers.get(name);
}
 
Example #20
Source File: SimpleComponentHolder.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
private synchronized void generate(){
  if(WXEnvironment.isApkDebugable()) {
    WXLogUtils.d(TAG, "Generate Component:" + mClz.getSimpleName());
  }

  Pair<Map<String, Invoker>, Map<String, Invoker>> methodPair = getMethods(mClz);
  mPropertyInvokers = methodPair.first;
  mMethodInvokers = methodPair.second;
}
 
Example #21
Source File: ComponentHolderTest.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
@Override
public Invoker getMethodInvoker(String name) {
  return null;
}
 
Example #22
Source File: ComponentHolderTest.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
@Override
public Invoker getPropertyInvoker(String name) {
  return null;
}
 
Example #23
Source File: Actions.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
public static DOMAction getModuleInvocationAction(@NonNull WXModule wxModule, @NonNull JSONArray args,
                                                  @NonNull Invoker invoker) {
  return new ModuleInvocationAction(wxModule, args, invoker);
}
 
Example #24
Source File: ComponentHolderTest.java    From weex-uikit with MIT License 4 votes vote down vote up
@Override
public Invoker getPropertyInvoker(String name) {
  return null;
}
 
Example #25
Source File: ComponentHolderTest.java    From weex-uikit with MIT License 4 votes vote down vote up
@Override
public Invoker getMethodInvoker(String name) {
  return null;
}
 
Example #26
Source File: ModuleInvocationAction.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
ModuleInvocationAction(@NonNull WXModule wxModule, @NonNull JSONArray args, @NonNull Invoker invoker) {
    this.mWXModule = wxModule;
    this.mArgs = args;
    this.mInvoker = invoker;
}
 
Example #27
Source File: IFComponentHolder.java    From weex-uikit with MIT License votes vote down vote up
Invoker getPropertyInvoker(String name); 
Example #28
Source File: IFComponentHolder.java    From ucar-weex-core with Apache License 2.0 votes vote down vote up
Invoker getPropertyInvoker(String name);