streampipes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zehn...@apache.org
Subject [incubator-streampipes] 03/25: Add first static property examples
Date Tue, 17 Dec 2019 09:48:04 GMT
This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git

commit 82c73a7ae56008ae88dfe38f079481cbb4f2cda9
Author: Dominik Riemer <riemer@fzi.de>
AuthorDate: Sun Feb 17 17:28:32 2019 +0100

    Add first static property examples
---
 .gitlab-ci.yml                                     |  2 +-
 README.md                                          |  5 +-
 development/.env                                   |  4 +
 pom.xml                                            |  4 +
 .../pom.xml                                        | 83 +++++++++++++++++++++
 .../streampipes/pe/examples/jvm/ExamplesInit.java  | 41 +++++++++++
 .../pe/examples/jvm/base/DummyController.java      | 39 ++++++++++
 .../pe/examples/jvm/base/DummyEngine.java          | 41 +++++++++++
 .../pe/examples/jvm/base/DummyParameters.java      | 26 +++++++
 .../pe/examples/jvm/config/ConfigKeys.java         | 26 +++++++
 .../pe/examples/jvm/config/ExamplesJvmConfig.java  | 85 ++++++++++++++++++++++
 .../NumberParameterExampleController.java          | 65 +++++++++++++++++
 .../TextParameterExampleController.java            | 65 +++++++++++++++++
 13 files changed, 484 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 324ddb4..0837c89 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -11,7 +11,7 @@ variables:
 
 stages:
   - build
-#  - github
+  - github
 
 build:
   image: maven:3-jdk-8
diff --git a/README.md b/README.md
index 7272aeb..41fca20 100644
--- a/README.md
+++ b/README.md
@@ -11,10 +11,13 @@ Read the full documentation at [https://docs.streampipes.org](https://docs.strea
 
 ### StreamPipes Pipeline Elements Examples
 
-The pipeline elements defined in this repository do nothing - they only serve to provide
examples on how pipeline 
+The pipeline elements defined in this repository **do nothing** - they only serve to provide
examples on how pipeline 
 elements can be created with StreamPipes. The examples are referenced in the SDK guide 
 (https://docs.streampipes.org/docs/dev-guide-introduction)
 
+If you are looking for **real** pipeline elements that can be installed in StreamPipes, have
a look at 
+[https://www.github.com/streampipes/streampipes-pipeline-elements](StreamPipes Pipeline Elements).
+
 ### Feedback
 
 We'd love to hear your feedback! Contact us at [feedback@streampipes.org](mailto:feedback@streampipes.org)
diff --git a/development/.env b/development/.env
new file mode 100644
index 0000000..1db03dc
--- /dev/null
+++ b/development/.env
@@ -0,0 +1,4 @@
+# Those parameters are used by IntelliJ to set the default consul parameters for development
+SP_PORT=6009
+SP_HOST=localhost
+SP_ICON_HOST=localhost
diff --git a/pom.xml b/pom.xml
index bc32dcd..3c0b75a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,11 @@
 
     <groupId>org.streampipes</groupId>
     <artifactId>streampipes-pipeline-elements-examples</artifactId>
+    <packaging>pom</packaging>
     <version>0.60.2-SNAPSHOT</version>
+    <modules>
+        <module>streampipes-pipeline-elements-examples-processors-jvm</module>
+    </modules>
 
     <properties>
         <streampipes.version>0.60.2-SNAPSHOT</streampipes.version>
diff --git a/streampipes-pipeline-elements-examples-processors-jvm/pom.xml b/streampipes-pipeline-elements-examples-processors-jvm/pom.xml
new file mode 100644
index 0000000..2aeb124
--- /dev/null
+++ b/streampipes-pipeline-elements-examples-processors-jvm/pom.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>streampipes-pipeline-elements-examples</artifactId>
+        <groupId>org.streampipes</groupId>
+        <version>0.60.2-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>streampipes-pipeline-elements-examples-processors-jvm</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.streampipes</groupId>
+            <artifactId>streampipes-wrapper-standalone</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.streampipes</groupId>
+            <artifactId>streampipes-sdk</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.streampipes</groupId>
+            <artifactId>streampipes-container-standalone</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.streampipes</groupId>
+            <artifactId>streampipes-config</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.streampipes</groupId>
+            <artifactId>streampipes-dataformat-json</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.streampipes</groupId>
+            <artifactId>streampipes-messaging-kafka</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>
+                <version>2.3</version>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>shade</goal>
+                        </goals>
+                        <configuration>
+                            <createDependencyReducedPom>false</createDependencyReducedPom>
+                            <transformers>
+                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+                                    <mainClass>org.streampipes.pe.examples.jvm.ExamplesInit</mainClass>
+                                </transformer>
+                                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"
/>
+                            </transformers>
+                            <filters>
+
+                                <filter>
+                                    <artifact>*:*</artifact>
+                                    <excludes>
+                                        <exclude>META-INF/*.SF</exclude>
+                                        <exclude>META-INF/*.DSA</exclude>
+                                        <exclude>META-INF/*.RSA</exclude>
+                                        <exclude>META-INF/maven/com.github.jsonld-java/jsonld-java/pom.xml</exclude>
+                                        <exclude>META-INF/maven/com.github.jsonld-java/jsonld-java-sesame/pom.xml
+                                        </exclude>
+                                    </excludes>
+                                </filter>
+                            </filters>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+        <finalName>streampipes-processors-filters-jvm</finalName>
+
+    </build>
+</project>
\ No newline at end of file
diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/ExamplesInit.java
b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/ExamplesInit.java
new file mode 100644
index 0000000..48a9a4f
--- /dev/null
+++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/ExamplesInit.java
@@ -0,0 +1,41 @@
+/*
+Copyright 2019 FZI Forschungszentrum Informatik
+
+Licensed 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.streampipes.pe.examples.jvm;
+
+import org.streampipes.container.init.DeclarersSingleton;
+import org.streampipes.container.standalone.init.StandaloneModelSubmitter;
+import org.streampipes.dataformat.json.JsonDataFormatFactory;
+import org.streampipes.messaging.jms.SpJmsProtocolFactory;
+import org.streampipes.messaging.kafka.SpKafkaProtocolFactory;
+import org.streampipes.pe.examples.jvm.config.ExamplesJvmConfig;
+import org.streampipes.pe.examples.jvm.staticproperty.NumberParameterExampleController;
+import org.streampipes.pe.examples.jvm.staticproperty.TextParameterExampleController;
+
+public class ExamplesInit extends StandaloneModelSubmitter {
+
+  public static void main(String[] args) {
+    DeclarersSingleton
+            .getInstance()
+            .add(new TextParameterExampleController())
+            .add(new NumberParameterExampleController());
+
+    DeclarersSingleton.getInstance().registerDataFormat(new JsonDataFormatFactory());
+    DeclarersSingleton.getInstance().registerProtocol(new SpKafkaProtocolFactory());
+    DeclarersSingleton.getInstance().registerProtocol(new SpJmsProtocolFactory());
+
+    new ExamplesInit().init(ExamplesJvmConfig.INSTANCE);
+  }
+}
diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/base/DummyController.java
b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/base/DummyController.java
new file mode 100644
index 0000000..effa3dd
--- /dev/null
+++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/base/DummyController.java
@@ -0,0 +1,39 @@
+/*
+Copyright 2019 FZI Forschungszentrum Informatik
+
+Licensed 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.streampipes.pe.examples.jvm.base;
+
+import org.streampipes.model.graph.DataProcessorDescription;
+import org.streampipes.model.graph.DataProcessorInvocation;
+import org.streampipes.sdk.extractor.ProcessingElementParameterExtractor;
+import org.streampipes.wrapper.params.binding.EventProcessorBindingParams;
+import org.streampipes.wrapper.standalone.ConfiguredEventProcessor;
+import org.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer;
+
+public class DummyController<B extends EventProcessorBindingParams> extends
+        StandaloneEventProcessingDeclarer<B> {
+
+  @Override
+  public DataProcessorDescription declareModel() {
+    return null;
+  }
+
+  @Override
+  public ConfiguredEventProcessor<B> onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor
extractor) {
+    return null;
+  }
+
+
+}
diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/base/DummyEngine.java
b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/base/DummyEngine.java
new file mode 100644
index 0000000..dcf3897
--- /dev/null
+++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/base/DummyEngine.java
@@ -0,0 +1,41 @@
+/*
+Copyright 2019 FZI Forschungszentrum Informatik
+
+Licensed 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.streampipes.pe.examples.jvm.base;
+
+import org.streampipes.commons.exceptions.SpRuntimeException;
+import org.streampipes.model.runtime.Event;
+import org.streampipes.wrapper.context.EventProcessorRuntimeContext;
+import org.streampipes.wrapper.params.binding.EventProcessorBindingParams;
+import org.streampipes.wrapper.routing.SpOutputCollector;
+import org.streampipes.wrapper.runtime.EventProcessor;
+
+public class DummyEngine<B extends EventProcessorBindingParams> implements EventProcessor<B>
{
+
+  @Override
+  public void onInvocation(B parameters, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext
runtimeContext) throws SpRuntimeException {
+
+  }
+
+  @Override
+  public void onEvent(Event event, SpOutputCollector collector) throws SpRuntimeException
{
+
+  }
+
+  @Override
+  public void onDetach() throws SpRuntimeException {
+
+  }
+}
diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/base/DummyParameters.java
b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/base/DummyParameters.java
new file mode 100644
index 0000000..9dffcfd
--- /dev/null
+++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/base/DummyParameters.java
@@ -0,0 +1,26 @@
+/*
+Copyright 2019 FZI Forschungszentrum Informatik
+
+Licensed 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.streampipes.pe.examples.jvm.base;
+
+import org.streampipes.model.graph.DataProcessorInvocation;
+import org.streampipes.wrapper.params.binding.EventProcessorBindingParams;
+
+public class DummyParameters extends EventProcessorBindingParams {
+
+  public DummyParameters(DataProcessorInvocation graph) {
+    super(graph);
+  }
+}
diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/config/ConfigKeys.java
b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/config/ConfigKeys.java
new file mode 100644
index 0000000..f04db93
--- /dev/null
+++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/config/ConfigKeys.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2018 FZI Forschungszentrum Informatik
+ *
+ * Licensed 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.streampipes.pe.examples.jvm.config;
+
+public class ConfigKeys {
+    final static String HOST = "SP_HOST";
+    final static String PORT = "SP_PORT";
+    final static String ICON_HOST = "SP_ICON_HOST";
+    final static String ICON_PORT = "SP_ICON_PORT";
+    final static String SERVICE_NAME_KEY = "SP_SERVICE_NAME";
+}
diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/config/ExamplesJvmConfig.java
b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/config/ExamplesJvmConfig.java
new file mode 100644
index 0000000..510706c
--- /dev/null
+++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/config/ExamplesJvmConfig.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2017 FZI Forschungszentrum Informatik
+ *
+ * Licensed 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.streampipes.pe.examples.jvm.config;
+
+
+import org.streampipes.config.SpConfig;
+import org.streampipes.container.model.PeConfig;
+
+public enum ExamplesJvmConfig implements PeConfig {
+  INSTANCE;
+
+  private SpConfig config;
+
+  public final static String serverUrl;
+  public final static String iconBaseUrl;
+
+  private final static String service_id = "pe/org.streampipes.processors.examples.jvm";
+  private final static String service_name = "Processors Examples JVM";
+  private final static String service_container_name = "processors-examples-jvm";
+
+  ExamplesJvmConfig() {
+    config = SpConfig.getSpConfig(service_id);
+    config.register(ConfigKeys.HOST, service_container_name, "Hostname for the pe esper");
+    config.register(ConfigKeys.PORT, 8090, "Port for the pe esper");
+
+    config.register(ConfigKeys.ICON_HOST, "backend", "Hostname for the icon host");
+    config.register(ConfigKeys.ICON_PORT, 80, "Port for the icons in nginx");
+
+    config.register(ConfigKeys.SERVICE_NAME_KEY, service_name, "The name of the service");
+
+  }
+
+  static {
+    serverUrl = ExamplesJvmConfig.INSTANCE.getHost() + ":" + ExamplesJvmConfig.INSTANCE.getPort();
+    iconBaseUrl = "http://" + ExamplesJvmConfig.INSTANCE.getIconHost() + ":" + ExamplesJvmConfig.INSTANCE.getIconPort()
+ "/assets/img/pe_icons";
+  }
+
+  public static final String getIconUrl(String pictureName) {
+    return iconBaseUrl + "/" + pictureName + ".png";
+  }
+
+  @Override
+  public String getHost() {
+    return config.getString(ConfigKeys.HOST);
+  }
+
+  @Override
+  public int getPort() {
+    return config.getInteger(ConfigKeys.PORT);
+  }
+
+  public String getIconHost() {
+    return config.getString(ConfigKeys.ICON_HOST);
+  }
+
+  public int getIconPort() {
+    return config.getInteger(ConfigKeys.ICON_PORT);
+  }
+
+  @Override
+  public String getId() {
+    return service_id;
+  }
+
+  @Override
+  public String getName() {
+    return config.getString(ConfigKeys.SERVICE_NAME_KEY);
+  }
+
+
+}
diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java
b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java
new file mode 100644
index 0000000..1493510
--- /dev/null
+++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java
@@ -0,0 +1,65 @@
+/*
+Copyright 2019 FZI Forschungszentrum Informatik
+
+Licensed 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.streampipes.pe.examples.jvm.staticproperty;
+
+import org.streampipes.model.graph.DataProcessorDescription;
+import org.streampipes.model.graph.DataProcessorInvocation;
+import org.streampipes.pe.examples.jvm.base.DummyEngine;
+import org.streampipes.pe.examples.jvm.base.DummyParameters;
+import org.streampipes.sdk.builder.ProcessingElementBuilder;
+import org.streampipes.sdk.builder.StreamRequirementsBuilder;
+import org.streampipes.sdk.extractor.ProcessingElementParameterExtractor;
+import org.streampipes.sdk.helpers.EpRequirements;
+import org.streampipes.sdk.helpers.Labels;
+import org.streampipes.sdk.helpers.OutputStrategies;
+import org.streampipes.sdk.helpers.SupportedFormats;
+import org.streampipes.sdk.helpers.SupportedProtocols;
+import org.streampipes.wrapper.standalone.ConfiguredEventProcessor;
+import org.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer;
+
+public class NumberParameterExampleController extends StandaloneEventProcessingDeclarer<DummyParameters>
{
+
+  private static final String SP_KEY = "my-example-key";
+
+  @Override
+  public DataProcessorDescription declareModel() {
+    return ProcessingElementBuilder.create("org.streampipes.examples.staticproperty" +
+            ".numberparameter", "Number Parameter Example", "")
+            .requiredStream(StreamRequirementsBuilder.
+                    create()
+                    .requiredProperty(EpRequirements.anyProperty())
+                    .build())
+            .outputStrategy(OutputStrategies.keep())
+            .supportedProtocols(SupportedProtocols.kafka())
+            .supportedFormats(SupportedFormats.jsonFormat())
+
+            // create a simple text parameter
+            .requiredIntegerParameter(Labels.from(SP_KEY, "Example Name", "Example Description"))
+
+            .build();
+  }
+
+  @Override
+  public ConfiguredEventProcessor<DummyParameters> onInvocation(DataProcessorInvocation
graph, ProcessingElementParameterExtractor extractor) {
+
+    // Extract the text parameter value
+    String textParameter = extractor.singleValueParameter(SP_KEY, String.class);
+
+    // now the text parameter would be added to a parameter class (omitted for this example)
+
+    return new ConfiguredEventProcessor<>(new DummyParameters(graph), DummyEngine::new);
+  }
+}
diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/TextParameterExampleController.java
b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/TextParameterExampleController.java
new file mode 100644
index 0000000..e0d6352
--- /dev/null
+++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/TextParameterExampleController.java
@@ -0,0 +1,65 @@
+/*
+Copyright 2019 FZI Forschungszentrum Informatik
+
+Licensed 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.streampipes.pe.examples.jvm.staticproperty;
+
+import org.streampipes.model.graph.DataProcessorDescription;
+import org.streampipes.model.graph.DataProcessorInvocation;
+import org.streampipes.pe.examples.jvm.base.DummyEngine;
+import org.streampipes.pe.examples.jvm.base.DummyParameters;
+import org.streampipes.sdk.builder.ProcessingElementBuilder;
+import org.streampipes.sdk.builder.StreamRequirementsBuilder;
+import org.streampipes.sdk.extractor.ProcessingElementParameterExtractor;
+import org.streampipes.sdk.helpers.EpRequirements;
+import org.streampipes.sdk.helpers.Labels;
+import org.streampipes.sdk.helpers.OutputStrategies;
+import org.streampipes.sdk.helpers.SupportedFormats;
+import org.streampipes.sdk.helpers.SupportedProtocols;
+import org.streampipes.wrapper.standalone.ConfiguredEventProcessor;
+import org.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer;
+
+public class TextParameterExampleController extends StandaloneEventProcessingDeclarer<DummyParameters>
{
+
+  private static final String SP_KEY = "my-example-key";
+
+  @Override
+  public DataProcessorDescription declareModel() {
+    return ProcessingElementBuilder.create("org.streampipes.examples.staticproperty" +
+            ".textparameter", "Text Parameter Example", "")
+            .requiredStream(StreamRequirementsBuilder.
+                    create()
+                    .requiredProperty(EpRequirements.anyProperty())
+                    .build())
+            .outputStrategy(OutputStrategies.keep())
+            .supportedProtocols(SupportedProtocols.kafka())
+            .supportedFormats(SupportedFormats.jsonFormat())
+
+            // create a simple text parameter
+            .requiredTextParameter(Labels.from(SP_KEY, "Example Name", "Example Description"))
+
+            .build();
+  }
+
+  @Override
+  public ConfiguredEventProcessor<DummyParameters> onInvocation(DataProcessorInvocation
graph, ProcessingElementParameterExtractor extractor) {
+
+    // Extract the text parameter value
+    String textParameter = extractor.singleValueParameter(SP_KEY, String.class);
+
+    // now the text parameter would be added to a parameter class (omitted for this example)
+
+    return new ConfiguredEventProcessor<>(new DummyParameters(graph), DummyEngine::new);
+  }
+}


Mime
View raw message