mirror of https://github.com/apache/nifi.git
NIFI-3896 - Makes DeprecationNotice more intuitive. This closes #1799
Update developers guide on how to deprecate a component
This commit is contained in:
parent
5cf4bf61b3
commit
289dde098e
|
@ -36,8 +36,9 @@ import java.lang.annotation.Target;
|
||||||
@Target({ElementType.TYPE})
|
@Target({ElementType.TYPE})
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Inherited
|
@Inherited
|
||||||
|
|
||||||
public @interface DeprecationNotice {
|
public @interface DeprecationNotice {
|
||||||
Class<? extends ConfigurableComponent>[] value() default {};
|
Class<? extends ConfigurableComponent>[] alternatives() default {};
|
||||||
|
|
||||||
String[] classNames() default {};
|
String[] classNames() default {};
|
||||||
|
|
||||||
|
|
|
@ -2379,6 +2379,22 @@ bundled with an extension that requires it, even if @RequiresInstanceClassLoadin
|
||||||
logged to help avoid this bad practice.
|
logged to help avoid this bad practice.
|
||||||
|
|
||||||
|
|
||||||
|
[[deprecation]]
|
||||||
|
== Deprecating a Component
|
||||||
|
Sometimes it may be desirable to deprecate a component. Whenever this occurs the developer may use the
|
||||||
|
@DeprecationNotice annotation to indicate that a component has been deprecated, aloowing the developer
|
||||||
|
to describe a reason for the deprecation and suggest alternative components. An example of how to do this can
|
||||||
|
be found below:
|
||||||
|
|
||||||
|
[source, java]
|
||||||
|
----
|
||||||
|
@DeprecationNotice(alternatives = {ListenSyslog.class}, classNames = {"org.apache.nifi.processors.standard.ListenRELP"}, reason = "Technologyhas been superseded", )
|
||||||
|
public class ListenOldProtocol extends AbstractProcessor {
|
||||||
|
----
|
||||||
|
As you can see, the alternatives can be used to define and array of alternative Components, while classNames can be
|
||||||
|
used to represent the similar content through an array of strings.
|
||||||
|
|
||||||
|
|
||||||
== How to contribute to Apache NiFi
|
== How to contribute to Apache NiFi
|
||||||
|
|
||||||
We are always excited to have contributions from the community - especially from new contributors!
|
We are always excited to have contributions from the community - especially from new contributors!
|
||||||
|
|
|
@ -249,7 +249,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
||||||
xmlStreamWriter.writeCharacters("Please consider using one the following alternatives: ");
|
xmlStreamWriter.writeCharacters("Please consider using one the following alternatives: ");
|
||||||
|
|
||||||
|
|
||||||
Class<? extends ConfigurableComponent>[] componentNames = deprecationNotice.value();
|
Class<? extends ConfigurableComponent>[] componentNames = deprecationNotice.alternatives();
|
||||||
String[] classNames = deprecationNotice.classNames();
|
String[] classNames = deprecationNotice.classNames();
|
||||||
|
|
||||||
if (componentNames.length > 0 || classNames.length > 0) {
|
if (componentNames.length > 0 || classNames.length > 0) {
|
||||||
|
|
|
@ -57,7 +57,7 @@ import java.util.Set;
|
||||||
@DynamicRelationship(name = "name from dynamic property", description = "all files that match the properties XPath")
|
@DynamicRelationship(name = "name from dynamic property", description = "all files that match the properties XPath")
|
||||||
@Stateful(scopes = {Scope.CLUSTER, Scope.LOCAL}, description = "state management description")
|
@Stateful(scopes = {Scope.CLUSTER, Scope.LOCAL}, description = "state management description")
|
||||||
@Restricted("processor restriction description")
|
@Restricted("processor restriction description")
|
||||||
@DeprecationNotice({FullyDocumentedProcessor.class, FullyDocumentedReportingTask.class})
|
@DeprecationNotice(alternatives = {FullyDocumentedProcessor.class, FullyDocumentedReportingTask.class})
|
||||||
public class DeprecatedProcessor extends AbstractProcessor {
|
public class DeprecatedProcessor extends AbstractProcessor {
|
||||||
|
|
||||||
public static final PropertyDescriptor DIRECTORY = new PropertyDescriptor.Builder().name("Input Directory")
|
public static final PropertyDescriptor DIRECTORY = new PropertyDescriptor.Builder().name("Input Directory")
|
||||||
|
|
Loading…
Reference in New Issue