Repository: tapestry-5 Updated Branches: refs/heads/master aca075cb7 -> 53c883074
TAP5-2192 : missing description in JSON export for classes and tags for component libraries Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/53c88307 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/53c88307 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/53c88307 Branch: refs/heads/master Commit: 53c8830740de179bcfe9c6f03aa27bdf975a0607 Parents: aca075c Author: Thiago H. de Paula Figueiredo <[email protected]> Authored: Sat Jul 5 16:14:19 2014 -0300 Committer: Thiago H. de Paula Figueiredo <[email protected]> Committed: Sat Jul 5 16:14:19 2014 -0300 ---------------------------------------------------------------------- .../corelib/pages/ComponentLibraries.java | 45 +++++++++++++++++--- 1 file changed, 38 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/53c88307/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/ComponentLibraries.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/ComponentLibraries.java b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/ComponentLibraries.java index 675063c..2779e6b 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/ComponentLibraries.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/ComponentLibraries.java @@ -30,7 +30,6 @@ import org.apache.tapestry5.json.JSONObject; import org.apache.tapestry5.services.ComponentClassResolver; import org.apache.tapestry5.services.ComponentLibraryInfo; import org.apache.tapestry5.util.TextStreamResponse; -import org.eclipse.jetty.io.NetworkTrafficListener.Empty; /** * Page used to describe the component libraries being used in the application. @@ -201,6 +200,14 @@ public class ComponentLibraries putIfNotNull("issueTrackerUrl", info.getIssueTrackerUrl(), infoJsonObject); putIfNotNull("dependencyInfoUrl", info.getDependencyManagementInfoUrl(), infoJsonObject); + if (info.getTags() != null) + { + for (String tag : info.getTags()) + { + infoJsonObject.accumulate("tags", tag); + } + } + object.put("info", infoJsonObject); } @@ -223,19 +230,43 @@ public class ComponentLibraries { logicalName = logicalName.replace("core/", ""); final String className = getClassName(logicalName, type, componentClassResolver); - JSONObject claszJsonObject = new JSONObject(); - claszJsonObject.put("logicalName", logicalName); - claszJsonObject.put("class", className); + JSONObject classJsonObject = new JSONObject(); + classJsonObject.put("logicalName", logicalName); + classJsonObject.put("class", className); if (info != null) { - putIfNotNull("sourceUrl", info.getSourceUrl(className), claszJsonObject); - putIfNotNull("javadocUrl", info.getJavadocUrl(className), claszJsonObject); + putIfNotNull("sourceUrl", info.getSourceUrl(className), classJsonObject); + putIfNotNull("javadocUrl", info.getJavadocUrl(className), classJsonObject); + } + try + { + final Description description = getClass(className); + if (description != null) + { + putIfNotNull("description", description.text(), classJsonObject); + if (description.tags().length > 0) + { + for (String tag : description.tags()) + { + classJsonObject.accumulate("tag", tag); + } + } + } + } + catch (ClassNotFoundException e) + { + throw new RuntimeException(e); } - classesJsonArray.put(claszJsonObject); + classesJsonArray.put(classJsonObject); } object.put(property, classesJsonArray); } } + + private Description getClass(final String className) throws ClassNotFoundException + { + return Class.forName(className).getAnnotation(Description.class); + } private void putIfNotNull(String propertyName, String value, JSONObject object) {
