diff --git a/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/pom.xml b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/pom.xml new file mode 100644 index 0000000000..a18d0b3dbf --- /dev/null +++ b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/pom.xml @@ -0,0 +1,48 @@ + + + + 4.0.0 + + org.apache.nifi + nifi-maven-archetypes + 0.3.0-SNAPSHOT + + + nifi-service-bundle-archetype + maven-archetype + + + + + org.apache.maven.archetype + archetype-packaging + 2.2 + + + + + + + org.apache.maven.plugins + maven-archetype-plugin + 2.2 + + + + + + + diff --git a/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..5ed0b1ddfc --- /dev/null +++ b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,55 @@ + + + + + + + 0.3.0-SNAPSHOT + + + ${groupId}.${artifactBaseName} + + + + + nifi-__artifactBaseName__-api + + **/*.java + + + + nifi-__artifactBaseName__-api/src/main/java + + + nifi-__artifactBaseName__ + + **/*.java + + + + nifi-__artifactBaseName__/src/main/java + + + nifi-__artifactBaseName__/src/test/java + + + nifi-__artifactBaseName__-api-nar + + + nifi-__artifactBaseName__-nar + + + \ No newline at end of file diff --git a/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__-api-nar/pom.xml b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__-api-nar/pom.xml new file mode 100644 index 0000000000..52a3264838 --- /dev/null +++ b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__-api-nar/pom.xml @@ -0,0 +1,42 @@ + + + + 4.0.0 + + + ${groupId} + ${rootArtifactId} + ${version} + + + nifi-${artifactBaseName}-api-nar + ${version} + nar + + + + org.apache.nifi + nifi-standard-services-api-nar + nar + + + ${groupId} + nifi-${artifactBaseName}-api + ${version} + + + + diff --git a/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__-api/pom.xml b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__-api/pom.xml new file mode 100644 index 0000000000..26c11d66b5 --- /dev/null +++ b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__-api/pom.xml @@ -0,0 +1,35 @@ + + + + 4.0.0 + + + ${groupId} + ${rootArtifactId} + ${version} + + + nifi-${artifactBaseName}-api + jar + + + + org.apache.nifi + nifi-api + provided + + + diff --git a/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__-api/src/main/java/MyService.java b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__-api/src/main/java/MyService.java new file mode 100644 index 0000000000..df58f5e17c --- /dev/null +++ b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__-api/src/main/java/MyService.java @@ -0,0 +1,30 @@ +/* + * 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 ${package}; + +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.controller.ControllerService; +import org.apache.nifi.processor.exception.ProcessException; + +@Tags({"example"}) +@CapabilityDescription("Example Service API.") +public interface MyService extends ControllerService { + + public void execute() throws ProcessException; + +} diff --git a/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__-nar/pom.xml b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__-nar/pom.xml new file mode 100644 index 0000000000..0d8ea5604d --- /dev/null +++ b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__-nar/pom.xml @@ -0,0 +1,43 @@ + + + + 4.0.0 + + + ${groupId} + ${rootArtifactId} + ${version} + + + nifi-${artifactBaseName}-nar + ${version} + nar + + + + ${groupId} + nifi-${artifactBaseName}-api-nar + ${version} + nar + + + ${groupId} + nifi-${artifactBaseName} + ${version} + + + + diff --git a/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__/pom.xml b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__/pom.xml new file mode 100644 index 0000000000..fdbb58bbf1 --- /dev/null +++ b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__/pom.xml @@ -0,0 +1,59 @@ + + + + 4.0.0 + + + ${groupId} + ${rootArtifactId} + ${version} + + + nifi-${artifactBaseName} + jar + + + + ${groupId} + nifi-${artifactBaseName}-api + ${version} + + + org.apache.nifi + nifi-api + provided + + + org.apache.nifi + nifi-processor-utils + + + org.apache.nifi + nifi-mock + test + + + org.slf4j + slf4j-simple + test + + + junit + junit + test + + + diff --git a/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__/src/main/java/StandardMyService.java b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__/src/main/java/StandardMyService.java new file mode 100644 index 0000000000..193e6b7e20 --- /dev/null +++ b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__/src/main/java/StandardMyService.java @@ -0,0 +1,80 @@ +/* + * 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 ${package}; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; + +@Tags({ "example"}) +@CapabilityDescription("Example ControllerService implementation of MyService.") +public class StandardMyService extends AbstractControllerService implements MyService { + + public static final PropertyDescriptor MY_PROPERTY = new PropertyDescriptor + .Builder().name("My Property") + .description("Example Property") + .required(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + + private static final List properties; + + static { + final List props = new ArrayList<>(); + props.add(MY_PROPERTY); + properties = Collections.unmodifiableList(props); + } + + @Override + protected List getSupportedPropertyDescriptors() { + return properties; + } + + /** + * @param context + * the configuration context + * @throws InitializationException + * if unable to create a database connection + */ + @OnEnabled + public void onEnabled(final ConfigurationContext context) throws InitializationException { + + } + + @OnDisabled + public void shutdown() { + + } + + @Override + public void execute() throws ProcessException { + + } + +} diff --git a/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService new file mode 100644 index 0000000000..811fcd31b7 --- /dev/null +++ b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService @@ -0,0 +1,15 @@ +# 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}.StandardMyService \ No newline at end of file diff --git a/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__/src/test/java/TestProcessor.java b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__/src/test/java/TestProcessor.java new file mode 100644 index 0000000000..be00a70d1c --- /dev/null +++ b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__/src/test/java/TestProcessor.java @@ -0,0 +1,45 @@ +/* + * 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 ${package}; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.exception.ProcessException; + +public class TestProcessor extends AbstractProcessor { + + @Override + public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { + } + + @Override + protected List getSupportedPropertyDescriptors() { + List propDescs = new ArrayList<>(); + propDescs.add(new PropertyDescriptor.Builder() + .name("MyService test processor") + .description("MyService test processor") + .identifiesControllerService(MyService.class) + .required(true) + .build()); + return propDescs; + } +} diff --git a/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__/src/test/java/TestStandardMyService.java b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__/src/test/java/TestStandardMyService.java new file mode 100644 index 0000000000..3f430e6726 --- /dev/null +++ b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/nifi-__artifactBaseName__/src/test/java/TestStandardMyService.java @@ -0,0 +1,45 @@ +/* + * 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 ${package}; + +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.util.TestRunner; +import org.apache.nifi.util.TestRunners; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class TestStandardMyService { + + @Before + public void init() { + + } + + @Test + public void testService() throws InitializationException { + final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class); + final StandardMyService service = new StandardMyService(); + runner.addControllerService("test-good", service); + + runner.setProperty(service, StandardMyService.MY_PROPERTY, "test-value"); + runner.enableControllerService(service); + + runner.assertValid(service); + } + +} diff --git a/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/pom.xml b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..0f32431518 --- /dev/null +++ b/nifi/nifi-maven-archetypes/nifi-service-bundle-archetype/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,37 @@ + + + + 4.0.0 + + + org.apache.nifi + nifi-nar-bundles + ${nifiVersion} + + + ${groupId} + ${artifactId} + ${version} + pom + + + nifi-${artifactBaseName}-api + nifi-${artifactBaseName}-api-nar + nifi-${artifactBaseName} + nifi-${artifactBaseName}-nar + + + diff --git a/nifi/nifi-maven-archetypes/pom.xml b/nifi/nifi-maven-archetypes/pom.xml index 74f544ba59..b8176047e7 100644 --- a/nifi/nifi-maven-archetypes/pom.xml +++ b/nifi/nifi-maven-archetypes/pom.xml @@ -25,5 +25,6 @@ pom nifi-processor-bundle-archetype + nifi-service-bundle-archetype