camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/6] camel git commit: CAMEL-11168: Add deprecationNote to @Metadata
Date Thu, 20 Jul 2017 14:49:01 GMT
CAMEL-11168: Add deprecationNote to @Metadata


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7b9ce032
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7b9ce032
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7b9ce032

Branch: refs/heads/master
Commit: 7b9ce032fe64b312d5f77442faa93c55ec503330
Parents: 7dde22d
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Jul 20 15:55:38 2017 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu Jul 20 16:48:21 2017 +0200

----------------------------------------------------------------------
 .../camel/component/bean/BeanEndpoint.java      |  4 +-
 .../component/binding/BindingEndpoint.java      |  2 +-
 .../component/dataset/DataSetEndpoint.java      |  3 --
 .../tools/apt/CoreEipAnnotationProcessor.java   |  2 +-
 .../tools/apt/EndpointAnnotationProcessor.java  | 13 ++++--
 .../tools/apt/SpringAnnotationProcessor.java    | 42 +++++++++++++++-----
 .../tools/apt/helper/JsonSchemaHelper.java      |  6 ++-
 7 files changed, 51 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7b9ce032/camel-core/src/main/java/org/apache/camel/component/bean/BeanEndpoint.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanEndpoint.java
index 77075f7..bbaf39d 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanEndpoint.java
@@ -44,8 +44,8 @@ public class BeanEndpoint extends DefaultEndpoint {
             + " Cache can be enabled if the bean in the Registry is defined as a singleton
scope.")
     private boolean cache;
     @UriParam(label = "advanced", description = "How to treat the parameters which are passed
from the message body."
-            + "true means the message body should be an array of parameters. Note: This option
is used internally by Camel, and is not intended for end users to use.")
-    @Deprecated
+            + "true means the message body should be an array of parameters.")
+    @Deprecated @Metadata(deprecationNode = "This option is used internally by Camel, and
is not intended for end users to use.")
     private boolean multiParameterArray;
     @UriParam(prefix = "bean.", label = "advanced", description = "Used for configuring additional
properties on the bean", multiValue = true)
     private Map<String, Object> parameters;

http://git-wip-us.apache.org/repos/asf/camel/blob/7b9ce032/camel-core/src/main/java/org/apache/camel/component/binding/BindingEndpoint.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/binding/BindingEndpoint.java
b/camel-core/src/main/java/org/apache/camel/component/binding/BindingEndpoint.java
index da6e58f..0af96df 100644
--- a/camel-core/src/main/java/org/apache/camel/component/binding/BindingEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/binding/BindingEndpoint.java
@@ -52,7 +52,7 @@ import static org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint;
  *
  * @deprecated use {@link org.apache.camel.spi.Contract} instead
  */
-@Deprecated
+@Deprecated @Metadata(deprecationNode = "Use org.apache.camel.spi.Contract instead")
 @UriEndpoint(firstVersion = "2.11.0", scheme = "binding", title = "Binding", syntax = "binding:bindingName:delegateUri",
     consumerClass = BindingConsumerProcessor.class, label = "core,transformation")
 public class BindingEndpoint extends DefaultEndpoint implements HasBinding {

http://git-wip-us.apache.org/repos/asf/camel/blob/7b9ce032/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetEndpoint.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetEndpoint.java
b/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetEndpoint.java
index ac3de6a..a781d4f 100644
--- a/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetEndpoint.java
@@ -89,9 +89,6 @@ public class DataSetEndpoint extends MockEndpoint implements Service {
     public Consumer createConsumer(Processor processor) throws Exception {
         Consumer answer = new DataSetConsumer(this, processor);
         configureConsumer(answer);
-
-        // expectedMessageCount((int) size);
-
         return answer;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/7b9ce032/tooling/apt/src/main/java/org/apache/camel/tools/apt/CoreEipAnnotationProcessor.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/CoreEipAnnotationProcessor.java
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/CoreEipAnnotationProcessor.java
index 857b95c..9736311 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/CoreEipAnnotationProcessor.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/CoreEipAnnotationProcessor.java
@@ -194,7 +194,7 @@ public class CoreEipAnnotationProcessor {
             String doc = entry.getDocumentation();
             doc = sanitizeDescription(doc, false);
             buffer.append(JsonSchemaHelper.toJson(entry.getName(), entry.getDisplayName(),
entry.getKind(), entry.isRequired(), entry.getType(), entry.getDefaultValue(), doc,
-                    entry.isDeprecated(), false, null, null, entry.isEnumType(), entry.getEnums(),
entry.isOneOf(), entry.getOneOfTypes(),
+                    entry.isDeprecated(), entry.getDeprecationNode(), false, null, null,
entry.isEnumType(), entry.getEnums(), entry.isOneOf(), entry.getOneOfTypes(),
                     entry.isAsPredicate(), null, null, false));
         }
         buffer.append("\n  }");

http://git-wip-us.apache.org/repos/asf/camel/blob/7b9ce032/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
index ac9290d..a8088da 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
@@ -182,6 +182,7 @@ public class EndpointAnnotationProcessor extends AbstractProcessor {
         buffer.append("\n    \"description\": \"").append(componentModel.getDescription()).append("\",");
         buffer.append("\n    \"label\": \"").append(getOrElse(componentModel.getLabel(),
"")).append("\",");
         buffer.append("\n    \"deprecated\": ").append(componentModel.isDeprecated()).append(",");
+        buffer.append("\n    \"deprecationNote\": \"").append(getOrElse(componentModel.getDeprecationNode(),
"")).append("\",");
         buffer.append("\n    \"async\": ").append(componentModel.isAsync()).append(",");
         buffer.append("\n    \"consumerOnly\": ").append(componentModel.isConsumerOnly()).append(",");
         buffer.append("\n    \"producerOnly\": ").append(componentModel.isProducerOnly()).append(",");
@@ -230,7 +231,7 @@ public class EndpointAnnotationProcessor extends AbstractProcessor {
             boolean asPredicate = false;
 
             buffer.append(JsonSchemaHelper.toJson(entry.getName(), entry.getDisplayName(),
"property", required, entry.getType(), defaultValue, doc,
-                entry.isDeprecated(), entry.isSecret(), entry.getGroup(), entry.getLabel(),
entry.isEnumType(), entry.getEnums(),
+                entry.isDeprecated(), entry.getDeprecationNode(), entry.isSecret(), entry.getGroup(),
entry.getLabel(), entry.isEnumType(), entry.getEnums(),
                 false, null, asPredicate, optionalPrefix, prefix, multiValue));
         }
         buffer.append("\n  },");
@@ -282,7 +283,7 @@ public class EndpointAnnotationProcessor extends AbstractProcessor {
             boolean asPredicate = false;
 
             buffer.append(JsonSchemaHelper.toJson(entry.getName(), entry.getDisplayName(),
"path", required, entry.getType(), defaultValue, doc,
-                entry.isDeprecated(), entry.isSecret(), entry.getGroup(), entry.getLabel(),
entry.isEnumType(), entry.getEnums(),
+                entry.isDeprecated(), entry.getDeprecationNote(), entry.isSecret(), entry.getGroup(),
entry.getLabel(), entry.isEnumType(), entry.getEnums(),
                 false, null, asPredicate, optionalPrefix, prefix, multiValue));
         }
 
@@ -328,7 +329,7 @@ public class EndpointAnnotationProcessor extends AbstractProcessor {
             boolean asPredicate = false;
 
             buffer.append(JsonSchemaHelper.toJson(entry.getName(), entry.getDisplayName(),
"parameter", required, entry.getType(), defaultValue,
-                doc, entry.isDeprecated(), entry.isSecret(), entry.getGroup(), entry.getLabel(),
entry.isEnumType(), entry.getEnums(),
+                doc, entry.isDeprecated(), entry.getDeprecationNote(), entry.isSecret(),
entry.getGroup(), entry.getLabel(), entry.isEnumType(), entry.getEnums(),
                 false, null, asPredicate, optionalPrefix, prefix, multiValue));
         }
         buffer.append("\n  }");
@@ -395,6 +396,12 @@ public class EndpointAnnotationProcessor extends AbstractProcessor {
             }
             model.setDeprecated(deprecated);
 
+            String deprecationNote = null;
+            if (endpointClassElement.getAnnotation(Metadata.class) != null) {
+                deprecationNote = endpointClassElement.getAnnotation(Metadata.class).deprecationNode();
+            }
+            model.setDeprecationNode(deprecationNote);
+
             if (map.containsKey("groupId")) {
                 model.setGroupId(map.get("groupId"));
             } else {

http://git-wip-us.apache.org/repos/asf/camel/blob/7b9ce032/tooling/apt/src/main/java/org/apache/camel/tools/apt/SpringAnnotationProcessor.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/SpringAnnotationProcessor.java
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/SpringAnnotationProcessor.java
index 289e22f..a346f5f 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/SpringAnnotationProcessor.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/SpringAnnotationProcessor.java
@@ -149,7 +149,7 @@ public class SpringAnnotationProcessor {
             doc = sanitizeDescription(doc, false);
 
             buffer.append(JsonSchemaHelper.toJson(entry.getName(), entry.getDisplayName(),
entry.getKind(), entry.isRequired(), entry.getType(), entry.getDefaultValue(), doc,
-                    entry.isDeprecated(), false, null, null, entry.isEnumType(), entry.getEnums(),
entry.isOneOf(), entry.getOneOfTypes(), entry.isAsPredicate(),
+                    entry.isDeprecated(), entry.getDeprecationNote(), false, null, null,
entry.isEnumType(), entry.getEnums(), entry.isOneOf(), entry.getOneOfTypes(), entry.isAsPredicate(),
                 null, null, false));
         }
         buffer.append("\n  }");
@@ -286,12 +286,16 @@ public class SpringAnnotationProcessor {
             }
         }
 
-        boolean deprecated = fieldElement.getAnnotation(Deprecated.class) != null;
         String displayName = null;
         Metadata metadata = fieldElement.getAnnotation(Metadata.class);
         if (metadata != null) {
             displayName = metadata.displayName();
         }
+        boolean deprecated = fieldElement.getAnnotation(Deprecated.class) != null;
+        String deprecationNote = null;
+        if (metadata != null) {
+            deprecationNote = metadata.deprecationNode();
+        }
 
         // special for id as its inherited from camel-core
         if ("id".equals(name) && isNullOrEmpty(docComment)) {
@@ -302,7 +306,8 @@ public class SpringAnnotationProcessor {
             }
         }
 
-        EipOption ep = new EipOption(name, displayName, "attribute", fieldTypeName, required,
defaultValue, docComment, deprecated, isEnum, enums, false, null, false);
+        EipOption ep = new EipOption(name, displayName, "attribute", fieldTypeName, required,
defaultValue, docComment,
+            deprecated, deprecationNote, isEnum, enums, false, null, false);
         eipOptions.add(ep);
 
         return false;
@@ -320,7 +325,8 @@ public class SpringAnnotationProcessor {
         Set<String> oneOfTypes = new TreeSet<String>();
         oneOfTypes.add("route");
 
-        EipOption ep = new EipOption("route", "Route", "element", fieldTypeName, false, "",
"Contains the Camel routes", false, false, null, true, oneOfTypes, false);
+        EipOption ep = new EipOption("route", "Route", "element", fieldTypeName, false, "",
"Contains the Camel routes",
+            false, null, false, null, true, oneOfTypes, false);
         eipOptions.add(ep);
     }
 
@@ -336,7 +342,8 @@ public class SpringAnnotationProcessor {
         Set<String> oneOfTypes = new TreeSet<String>();
         oneOfTypes.add("rest");
 
-        EipOption ep = new EipOption("rest", "Rest", "element", fieldTypeName, false, "",
"Contains the rest services defined using the rest-dsl", false, false, null, true, oneOfTypes,
false);
+        EipOption ep = new EipOption("rest", "Rest", "element", fieldTypeName, false, "",
"Contains the rest services defined using the rest-dsl",
+            false, null,  false, null, true, oneOfTypes, false);
         eipOptions.add(ep);
     }
 
@@ -413,15 +420,19 @@ public class SpringAnnotationProcessor {
             }
             boolean oneOf = !oneOfTypes.isEmpty();
 
-            boolean deprecated = fieldElement.getAnnotation(Deprecated.class) != null;
             boolean asPredicate = false;
             String displayName = null;
             Metadata metadata = fieldElement.getAnnotation(Metadata.class);
             if (metadata != null) {
                 displayName = metadata.displayName();
             }
+            boolean deprecated = fieldElement.getAnnotation(Deprecated.class) != null;
+            String deprecationNote = null;
+            if (metadata != null) {
+                deprecationNote = metadata.deprecationNode();
+            }
 
-            EipOption ep = new EipOption(name, displayName, kind, fieldTypeName, required,
defaultValue, docComment, deprecated, isEnum, enums, oneOf, oneOfTypes, asPredicate);
+            EipOption ep = new EipOption(name, displayName, kind, fieldTypeName, required,
defaultValue, docComment, deprecated, deprecationNote, isEnum, enums, oneOf, oneOfTypes, asPredicate);
             eipOptions.add(ep);
         }
     }
@@ -461,8 +472,13 @@ public class SpringAnnotationProcessor {
             if (metadata != null) {
                 displayName = metadata.displayName();
             }
+            boolean deprecated = fieldElement.getAnnotation(Deprecated.class) != null;
+            String deprecationNote = null;
+            if (metadata != null) {
+                deprecationNote = metadata.deprecationNode();
+            }
 
-            EipOption ep = new EipOption(name, kind, displayName, fieldTypeName, required,
defaultValue, docComment, false, false, null, true, oneOfTypes, false);
+            EipOption ep = new EipOption(name, kind, displayName, fieldTypeName, required,
defaultValue, docComment, deprecated, deprecationNote, false, null, true, oneOfTypes, false);
             eipOptions.add(ep);
         }
     }
@@ -555,14 +571,15 @@ public class SpringAnnotationProcessor {
         private String defaultValue;
         private String documentation;
         private boolean deprecated;
+        private String deprecationNote;
         private boolean enumType;
         private Set<String> enums;
         private boolean oneOf;
         private Set<String> oneOfTypes;
         private boolean asPredicate;
 
-        private EipOption(String name, String displayName, String kind, String type, boolean
required, String defaultValue, String documentation, boolean deprecated,
-                          boolean enumType, Set<String> enums, boolean oneOf, Set<String>
oneOfTypes, boolean asPredicate) {
+        private EipOption(String name, String displayName, String kind, String type, boolean
required, String defaultValue, String documentation,
+                          boolean deprecated, String deprecationNote, boolean enumType, Set<String>
enums, boolean oneOf, Set<String> oneOfTypes, boolean asPredicate) {
             this.name = name;
             this.displayName = displayName;
             this.kind = kind;
@@ -571,6 +588,7 @@ public class SpringAnnotationProcessor {
             this.defaultValue = defaultValue;
             this.documentation = documentation;
             this.deprecated = deprecated;
+            this.deprecationNote = deprecationNote;
             this.enumType = enumType;
             this.enums = enums;
             this.oneOf = oneOf;
@@ -610,6 +628,10 @@ public class SpringAnnotationProcessor {
             return deprecated;
         }
 
+        public String getDeprecationNote() {
+            return deprecationNote;
+        }
+
         public boolean isEnumType() {
             return enumType;
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/7b9ce032/tooling/apt/src/main/java/org/apache/camel/tools/apt/helper/JsonSchemaHelper.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/helper/JsonSchemaHelper.java
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/helper/JsonSchemaHelper.java
index baba1c0..7e3ec25 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/helper/JsonSchemaHelper.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/helper/JsonSchemaHelper.java
@@ -42,7 +42,7 @@ public final class JsonSchemaHelper {
     }
 
     public static String toJson(String name, String displayName, String kind, Boolean required,
String type, String defaultValue, String description,
-                                Boolean deprecated, Boolean secret, String group, String
label, boolean enumType, Set<String> enums,
+                                Boolean deprecated, String deprecationNote, Boolean secret,
String group, String label, boolean enumType, Set<String> enums,
                                 boolean oneOfType, Set<String> oneOffTypes, boolean
asPredicate, String optionalPrefix, String prefix, boolean multiValue) {
         String typeName = JsonSchemaHelper.getType(type, enumType);
 
@@ -128,6 +128,10 @@ public final class JsonSchemaHelper {
             // boolean value
             sb.append(deprecated.toString());
         }
+        if (!Strings.isNullOrEmpty(deprecationNote)) {
+            sb.append(", \"deprecationNote\": ");
+            sb.append(Strings.doubleQuote(deprecationNote));
+        }
 
         if (secret != null) {
             sb.append(", \"secret\": ");


Mime
View raw message