Java Code Examples for com.facebook.react.bridge.JavaScriptModuleRegistry

The following are top voted examples for showing how to use com.facebook.react.bridge.JavaScriptModuleRegistry. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: RNLearn_Project1   File: ReactInstanceManager.java   View source code 6 votes vote down vote up
private void processPackage(
  ReactPackage reactPackage,
  NativeModuleRegistryBuilder nativeModuleRegistryBuilder,
  JavaScriptModuleRegistry.Builder jsModulesBuilder) {
  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "processPackage")
    .arg("className", reactPackage.getClass().getSimpleName())
    .flush();
  if (reactPackage instanceof ReactPackageLogger) {
    ((ReactPackageLogger) reactPackage).startProcessPackage();
  }
  nativeModuleRegistryBuilder.processPackage(reactPackage);

  for (Class<? extends JavaScriptModule> jsModuleClass : reactPackage.createJSModules()) {
    jsModulesBuilder.add(jsModuleClass);
  }
  if (reactPackage instanceof ReactPackageLogger) {
    ((ReactPackageLogger) reactPackage).endProcessPackage();
  }
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
 
Example 2
Project: RNLearn_Project1   File: ReactInstanceManager.java   View source code 6 votes vote down vote up
private void processPackage(
  ReactPackage reactPackage,
  NativeModuleRegistryBuilder nativeModuleRegistryBuilder,
  JavaScriptModuleRegistry.Builder jsModulesBuilder) {
  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "processPackage")
    .arg("className", reactPackage.getClass().getSimpleName())
    .flush();
  if (reactPackage instanceof ReactPackageLogger) {
    ((ReactPackageLogger) reactPackage).startProcessPackage();
  }
  nativeModuleRegistryBuilder.processPackage(reactPackage);

  for (Class<? extends JavaScriptModule> jsModuleClass : reactPackage.createJSModules()) {
    jsModulesBuilder.add(jsModuleClass);
  }
  if (reactPackage instanceof ReactPackageLogger) {
    ((ReactPackageLogger) reactPackage).endProcessPackage();
  }
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
 
Example 3
Project: RNLearn_Project1   File: CatalystInstanceImpl.java   View source code 5 votes vote down vote up
private CatalystInstanceImpl(
    final ReactQueueConfigurationSpec ReactQueueConfigurationSpec,
    final JavaScriptExecutor jsExecutor,
    final NativeModuleRegistry registry,
    final JavaScriptModuleRegistry jsModuleRegistry,
    final JSBundleLoader jsBundleLoader,
    NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler) {
  FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge.");
  mHybridData = initHybrid();

  mReactQueueConfiguration = ReactQueueConfigurationImpl.create(
      ReactQueueConfigurationSpec,
      new NativeExceptionHandler());
  mBridgeIdleListeners = new CopyOnWriteArrayList<>();
  mJavaRegistry = registry;
  mJSModuleRegistry = jsModuleRegistry;
  mJSBundleLoader = jsBundleLoader;
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  mNativeModulesQueueThread = mReactQueueConfiguration.getNativeModulesQueueThread();
  mTraceListener = new JSProfilerTraceListener(this);

  FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge before initializeBridge");
  initializeBridge(
    new BridgeCallback(this),
    jsExecutor,
    mReactQueueConfiguration.getJSQueueThread(),
    mNativeModulesQueueThread,
    mJavaRegistry.getJavaModules(this),
    mJavaRegistry.getCxxModules());
  FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge after initializeBridge");
  mMainExecutorToken = getMainExecutorToken();
}
 
Example 4
Project: RNLearn_Project1   File: CatalystInstanceImpl.java   View source code 5 votes vote down vote up
private CatalystInstanceImpl(
    final ReactQueueConfigurationSpec ReactQueueConfigurationSpec,
    final JavaScriptExecutor jsExecutor,
    final NativeModuleRegistry registry,
    final JavaScriptModuleRegistry jsModuleRegistry,
    final JSBundleLoader jsBundleLoader,
    NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler) {
  FLog.w(ReactConstants.TAG, "Initializing React Xplat Bridge.");
  mHybridData = initHybrid();

  mReactQueueConfiguration = ReactQueueConfigurationImpl.create(
      ReactQueueConfigurationSpec,
      new NativeExceptionHandler());
  mBridgeIdleListeners = new CopyOnWriteArrayList<>();
  mJavaRegistry = registry;
  mJSModuleRegistry = jsModuleRegistry;
  mJSBundleLoader = jsBundleLoader;
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  mNativeModulesQueueThread = mReactQueueConfiguration.getNativeModulesQueueThread();
  mTraceListener = new JSProfilerTraceListener(this);

  FLog.w(ReactConstants.TAG, "Initializing React Xplat Bridge before initializeBridge");
  initializeBridge(
    new BridgeCallback(this),
    jsExecutor,
    mReactQueueConfiguration.getJSQueueThread(),
    mNativeModulesQueueThread,
    mJavaRegistry.getJavaModules(this),
    mJavaRegistry.getCxxModules());
  FLog.w(ReactConstants.TAG, "Initializing React Xplat Bridge after initializeBridge");
  mMainExecutorToken = getMainExecutorToken();
}
 
Example 5
Project: react-native-workers   File: ReactContextBuilder.java   View source code 5 votes vote down vote up
private void addJSModules(JavaScriptModuleRegistry.Builder jsModulesBuilder) {
    for (int i = 0; i < reactPackages.size(); i++) {
        ReactPackage reactPackage = reactPackages.get(i);
        for (Class<? extends JavaScriptModule> jsModuleClass : reactPackage.createJSModules()) {
            jsModulesBuilder.add(jsModuleClass);
        }
    }
}
 
Example 6
Project: Ironman   File: XReactInstanceManagerImpl.java   View source code 5 votes vote down vote up
private void processPackage(
  ReactPackage reactPackage,
  ReactApplicationContext reactContext,
  List<ModuleSpec> moduleSpecs,
  Map<Class, ReactModuleInfo> reactModuleInfoMap,
  JavaScriptModuleRegistry.Builder jsModulesBuilder) {
  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "processPackage")
    .arg("className", reactPackage.getClass().getSimpleName())
    .flush();
  if (mLazyNativeModulesEnabled && reactPackage instanceof LazyReactPackage) {
    LazyReactPackage lazyReactPackage = (LazyReactPackage) reactPackage;
    ReactModuleInfoProvider instance = lazyReactPackage.getReactModuleInfoProvider();
    Map<Class, ReactModuleInfo> map = instance.getReactModuleInfos();
    if (!map.isEmpty()) {
      reactModuleInfoMap.putAll(map);
    }
    moduleSpecs.addAll(lazyReactPackage.getNativeModules(reactContext));
  } else {
    FLog.d(
      ReactConstants.TAG,
      reactPackage.getClass().getSimpleName() +
        " is not a LazyReactPackage, falling back to old version.");
    for (NativeModule nativeModule : reactPackage.createNativeModules(reactContext)) {
      moduleSpecs.add(
          new ModuleSpec(nativeModule.getClass(), new EagerModuleProvider(nativeModule)));
    }
  }

  for (Class<? extends JavaScriptModule> jsModuleClass : reactPackage.createJSModules()) {
    jsModulesBuilder.add(jsModuleClass);
  }
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
 
Example 7
Project: Ironman   File: CatalystInstanceImpl.java   View source code 5 votes vote down vote up
private CatalystInstanceImpl(
    final ReactQueueConfigurationSpec ReactQueueConfigurationSpec,
    final JavaScriptExecutor jsExecutor,
    final NativeModuleRegistry registry,
    final JavaScriptModuleRegistry jsModuleRegistry,
    final JSBundleLoader jsBundleLoader,
    NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler) {
  FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge.");
  mHybridData = initHybrid();

  mReactQueueConfiguration = ReactQueueConfigurationImpl.create(
      ReactQueueConfigurationSpec,
      new NativeExceptionHandler());
  mBridgeIdleListeners = new CopyOnWriteArrayList<>();
  mJavaRegistry = registry;
  mJSModuleRegistry = jsModuleRegistry;
  mJSBundleLoader = jsBundleLoader;
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  mTraceListener = new JSProfilerTraceListener(this);

  initializeBridge(
    new BridgeCallback(this),
    jsExecutor,
    mReactQueueConfiguration.getJSQueueThread(),
    mReactQueueConfiguration.getNativeModulesQueueThread(),
    mJavaRegistry.getModuleRegistryHolder(this));
  mMainExecutorToken = getMainExecutorToken();
}
 
Example 8
Project: RNLearn_Project1   File: CatalystInstanceImpl.java   View source code 4 votes vote down vote up
public Builder setJSModuleRegistry(JavaScriptModuleRegistry jsModuleRegistry) {
  mJSModuleRegistry = jsModuleRegistry;
  return this;
}
 
Example 9
Project: RNLearn_Project1   File: CatalystInstanceImpl.java   View source code 4 votes vote down vote up
public Builder setJSModuleRegistry(JavaScriptModuleRegistry jsModuleRegistry) {
  mJSModuleRegistry = jsModuleRegistry;
  return this;
}
 
Example 10
Project: Ironman   File: CatalystInstanceImpl.java   View source code 4 votes vote down vote up
public Builder setJSModuleRegistry(JavaScriptModuleRegistry jsModuleRegistry) {
  mJSModuleRegistry = jsModuleRegistry;
  return this;
}