NIFI-13187 - Modernize Archetypes

This closes #8783.

Signed-off-by: Joseph Witt <joewitt@apache.org>
This commit is contained in:
bob 2024-05-08 20:28:36 -05:00 committed by Joseph Witt
parent 4c68691faf
commit 4faad38c16
No known key found for this signature in database
GPG Key ID: 9093BF854F811A1A
2 changed files with 13 additions and 24 deletions

View File

@ -33,9 +33,6 @@ import org.apache.nifi.processor.ProcessorInitializationContext;
import org.apache.nifi.processor.Relationship; import org.apache.nifi.processor.Relationship;
import org.apache.nifi.processor.util.StandardValidators; import org.apache.nifi.processor.util.StandardValidators;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -47,16 +44,17 @@ import java.util.Set;
public class MyProcessor extends AbstractProcessor { public class MyProcessor extends AbstractProcessor {
public static final PropertyDescriptor MY_PROPERTY = new PropertyDescriptor public static final PropertyDescriptor MY_PROPERTY = new PropertyDescriptor
.Builder().name("MY_PROPERTY") .Builder()
.displayName("My property") .name("My Property")
.displayName("My Property")
.description("Example Property") .description("Example Property")
.required(true) .required(true)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.build(); .build();
public static final Relationship MY_RELATIONSHIP = new Relationship.Builder() public static final Relationship REL_SUCCESS = new Relationship.Builder()
.name("MY_RELATIONSHIP") .name("success")
.description("Example relationship") .description("Example success relationship")
.build(); .build();
private List<PropertyDescriptor> descriptors; private List<PropertyDescriptor> descriptors;
@ -65,13 +63,9 @@ public class MyProcessor extends AbstractProcessor {
@Override @Override
protected void init(final ProcessorInitializationContext context) { protected void init(final ProcessorInitializationContext context) {
descriptors = new ArrayList<>(); descriptors = List.of(MY_PROPERTY);
descriptors.add(MY_PROPERTY);
descriptors = Collections.unmodifiableList(descriptors);
relationships = new HashSet<>(); relationships = Set.of(REL_SUCCESS);
relationships.add(MY_RELATIONSHIP);
relationships = Collections.unmodifiableSet(relationships);
} }
@Override @Override
@ -96,5 +90,7 @@ public class MyProcessor extends AbstractProcessor {
return; return;
} }
// TODO implement // TODO implement
session.transfer(flowFile, REL_SUCCESS);
} }
} }

View File

@ -16,8 +16,6 @@
*/ */
package ${package}; package ${package};
import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import org.apache.nifi.annotation.documentation.CapabilityDescription; import org.apache.nifi.annotation.documentation.CapabilityDescription;
@ -35,20 +33,15 @@ import org.apache.nifi.reporting.InitializationException;
public class StandardMyService extends AbstractControllerService implements MyService { public class StandardMyService extends AbstractControllerService implements MyService {
public static final PropertyDescriptor MY_PROPERTY = new PropertyDescriptor public static final PropertyDescriptor MY_PROPERTY = new PropertyDescriptor
.Builder().name("MY_PROPERTY") .Builder()
.name("My Property")
.displayName("My Property") .displayName("My Property")
.description("Example Property") .description("Example Property")
.required(true) .required(true)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.build(); .build();
private static final List<PropertyDescriptor> properties; private static final List<PropertyDescriptor> properties = List.of(MY_PROPERTY);
static {
final List<PropertyDescriptor> props = new ArrayList<>();
props.add(MY_PROPERTY);
properties = Collections.unmodifiableList(props);
}
@Override @Override
protected List<PropertyDescriptor> getSupportedPropertyDescriptors() { protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {