You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by gu...@apache.org on 2023/06/07 08:22:03 UTC
[flink] 02/14: Introduce ExecutionEnvironment, whose implementation can be obtained from API via reflection.
This is an automated email from the ASF dual-hosted git repository.
guoweijie pushed a commit to branch process-func-api-poc-weijie
in repository https://gitbox.apache.org/repos/asf/flink.git
commit 82a01017c6f4b9acf37466f892624c7401c2b4f3
Author: Xintong Song <to...@gmail.com>
AuthorDate: Tue May 30 19:41:02 2023 +0800
Introduce ExecutionEnvironment, whose implementation can be obtained from API via reflection.
---
.../processfunction/api/ExecutionEnvironment.java | 31 +++++++++++++++++++++
.../flink/processfunction/examples/SimpleMap.java | 28 +++++++++++++++++++
.../processfunction/ExecutionEnvironmentImpl.java | 32 ++++++++++++++++++++++
3 files changed, 91 insertions(+)
diff --git a/flink-process-function-api/src/main/java/org/apache/flink/processfunction/api/ExecutionEnvironment.java b/flink-process-function-api/src/main/java/org/apache/flink/processfunction/api/ExecutionEnvironment.java
new file mode 100644
index 00000000000..a13d60d9385
--- /dev/null
+++ b/flink-process-function-api/src/main/java/org/apache/flink/processfunction/api/ExecutionEnvironment.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.processfunction.api;
+
+public abstract class ExecutionEnvironment {
+ public static ExecutionEnvironment getExecutionEnvironment()
+ throws ReflectiveOperationException {
+ return (ExecutionEnvironment)
+ Class.forName("org.apache.flink.processfunction.ExecutionEnvironmentImpl")
+ .getMethod("newInstance")
+ .invoke(null);
+ }
+
+ public abstract void foo();
+}
diff --git a/flink-process-function-examples/src/main/java/org/apache/flink/processfunction/examples/SimpleMap.java b/flink-process-function-examples/src/main/java/org/apache/flink/processfunction/examples/SimpleMap.java
new file mode 100644
index 00000000000..531b87e214e
--- /dev/null
+++ b/flink-process-function-examples/src/main/java/org/apache/flink/processfunction/examples/SimpleMap.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.processfunction.examples;
+
+import org.apache.flink.processfunction.api.ExecutionEnvironment;
+
+/** Usage: Must be executed with flink-process-function jar in classpath. */
+public class SimpleMap {
+ public static void main(String[] args) throws Exception {
+ ExecutionEnvironment.getExecutionEnvironment().foo();
+ }
+}
diff --git a/flink-process-function/src/main/java/org/apache/flink/processfunction/ExecutionEnvironmentImpl.java b/flink-process-function/src/main/java/org/apache/flink/processfunction/ExecutionEnvironmentImpl.java
new file mode 100644
index 00000000000..8ea8f33a093
--- /dev/null
+++ b/flink-process-function/src/main/java/org/apache/flink/processfunction/ExecutionEnvironmentImpl.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.processfunction;
+
+import org.apache.flink.processfunction.api.ExecutionEnvironment;
+
+public class ExecutionEnvironmentImpl extends ExecutionEnvironment {
+ public static ExecutionEnvironmentImpl newInstance() {
+ return new ExecutionEnvironmentImpl();
+ }
+
+ @Override
+ public void foo() {
+ System.out.println(getClass().getSimpleName());
+ }
+}