Make JavaScriptExecutor.Factory a configurable property of ReactInstanceManager

Reviewed By: mhorowitz

Differential Revision: D5662431

fbshipit-source-id: 17dca2744de645740cef252efbf83902acde5046
This commit is contained in:
Michał Gregorczyk
2017-08-21 13:32:46 -07:00
committed by Facebook Github Bot
parent 606a876df7
commit 73f17908e6
8 changed files with 64 additions and 32 deletions

View File

@@ -13,27 +13,12 @@ import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
@DoNotStrip
public class JSCJavaScriptExecutor extends JavaScriptExecutor {
public static class Factory implements JavaScriptExecutor.Factory {
private ReadableNativeMap mJSCConfig;
public Factory() {
WritableNativeMap jscConfig = new WritableNativeMap();
jscConfig.putString("OwnerIdentity", "ReactNative");
mJSCConfig = jscConfig;
}
@Override
public JavaScriptExecutor create() throws Exception {
return new JSCJavaScriptExecutor(mJSCConfig);
}
}
/* package */ class JSCJavaScriptExecutor extends JavaScriptExecutor {
static {
ReactBridge.staticInit();
}
private JSCJavaScriptExecutor(ReadableNativeMap jscConfig) {
/* package */ JSCJavaScriptExecutor(ReadableNativeMap jscConfig) {
super(initHybrid(jscConfig));
}

View File

@@ -0,0 +1,19 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.react.bridge;
public class JSCJavaScriptExecutorFactory implements JavaScriptExecutorFactory {
@Override
public JavaScriptExecutor create() throws Exception {
WritableNativeMap jscConfig = new WritableNativeMap();
jscConfig.putString("OwnerIdentity", "ReactNative");
return new JSCJavaScriptExecutor(jscConfig);
}
}

View File

@@ -14,10 +14,6 @@ import com.facebook.proguard.annotations.DoNotStrip;
@DoNotStrip
public abstract class JavaScriptExecutor {
public interface Factory {
JavaScriptExecutor create() throws Exception;
}
private final HybridData mHybridData;
protected JavaScriptExecutor(HybridData hybridData) {

View File

@@ -0,0 +1,14 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.react.bridge;
public interface JavaScriptExecutorFactory {
JavaScriptExecutor create() throws Exception;
}

View File

@@ -24,7 +24,7 @@ import com.facebook.proguard.annotations.DoNotStrip;
*/
@DoNotStrip
public class ProxyJavaScriptExecutor extends JavaScriptExecutor {
public static class Factory implements JavaScriptExecutor.Factory {
public static class Factory implements JavaScriptExecutorFactory {
private final JavaJSExecutor.Factory mJavaJSExecutorFactory;
public Factory(JavaJSExecutor.Factory javaJSExecutorFactory) {