Merge pull request #1 from Cosium/upgrade-to-java-8
Upgrade to java 8
diff --git a/dist/pom.xml b/dist/pom.xml
index 558ee71..cd6638d 100644
--- a/dist/pom.xml
+++ b/dist/pom.xml
@@ -51,6 +51,16 @@
</dependency>
<dependency>
+ <groupId>org.apache.vysper.extensions</groupId>
+ <artifactId>xep0124-xep0206-bosh</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.vysper.extensions</groupId>
+ <artifactId>vysper-websockets</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<optional>true</optional>
@@ -216,23 +226,6 @@
<profiles>
<profile>
- <!-- bosh and websockets uses Jetty, which requires Java 1.6 -->
- <activation>
- <jdk>[1.6,)</jdk>
- </activation>
- <dependencies>
- <dependency>
- <groupId>org.apache.vysper.extensions</groupId>
- <artifactId>xep0124-xep0206-bosh</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.vysper.extensions</groupId>
- <artifactId>vysper-websockets</artifactId>
- </dependency>
- </dependencies>
- </profile>
- <profile>
<id>apache-release</id>
<build>
<plugins>
diff --git a/examples/pom.xml b/examples/pom.xml
index 39cc873..8f66d65 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -31,21 +31,8 @@
<packaging>pom</packaging>
<modules>
+ <module>embedded-war</module>
<module>pubsub-client</module>
</modules>
- <profiles>
- <profile>
- <!-- embedded war uses Jetty, which requires Java 1.6 -->
- <activation>
- <jdk>[1.6,)</jdk>
- </activation>
- <modules>
- <module>embedded-war</module>
- <module>pubsub-client</module>
- </modules>
- </profile>
- </profiles>
-
-
</project>
diff --git a/examples/pubsub-client/pom.xml b/examples/pubsub-client/pom.xml
index 7936baf..e128a68 100644
--- a/examples/pubsub-client/pom.xml
+++ b/examples/pubsub-client/pom.xml
@@ -94,7 +94,7 @@
</build>
<properties>
- <maven.compile.source>1.5</maven.compile.source>
- <maven.compile.target>1.5</maven.compile.target>
+ <maven.compile.source>1.8</maven.compile.source>
+ <maven.compile.target>1.8</maven.compile.target>
</properties>
</project>
diff --git a/pom.xml b/pom.xml
index b091229..878daba 100644
--- a/pom.xml
+++ b/pom.xml
@@ -461,7 +461,7 @@
</modules>
<properties>
- <maven.compile.source>1.5</maven.compile.source>
- <maven.compile.target>1.5</maven.compile.target>
+ <maven.compile.source>1.8</maven.compile.source>
+ <maven.compile.target>1.8</maven.compile.target>
</properties>
</project>
diff --git a/server/extensions/pom.xml b/server/extensions/pom.xml
index 2958fd4..ecc6513 100644
--- a/server/extensions/pom.xml
+++ b/server/extensions/pom.xml
@@ -34,23 +34,12 @@
<module>xep0060-pubsub</module>
<module>xep0045-muc</module>
<module>xep0065-socks</module>
+ <module>xep0124-xep0206-bosh</module>
+ <module>websockets</module>
</modules>
<profiles>
<profile>
- <!-- bosh and websockets uses Jetty, which requires Java 1.6 -->
- <activation>
- <jdk>[1.6,)</jdk>
- </activation>
- <modules>
- <module>xep0060-pubsub</module>
- <module>xep0045-muc</module>
- <module>xep0065-socks</module>
- <module>xep0124-xep0206-bosh</module>
- <module>websockets</module>
- </modules>
- </profile>
- <profile>
<id>inttest</id>
<modules>
<module>xep0060-pubsub</module>
diff --git a/server/pom.xml b/server/pom.xml
index 673a5e9..baea78c 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -28,27 +28,17 @@
<artifactId>vysper-server</artifactId>
<name>Apache Vysper Server</name>
<version>0.8-SNAPSHOT</version>
- <packaging>pom</packaging>
+ <packaging>pom</packaging>
<modules>
<module>core</module>
<module>extensions</module>
<module>storage</module>
+ <module>admin-console</module>
</modules>
<profiles>
<profile>
- <!-- admin-console uses Jetty, which requires Java 1.6 -->
- <activation>
- <jdk>[1.6,)</jdk>
- </activation>
- <modules>
- <module>core</module>
- <module>extensions</module>
- <module>admin-console</module>
- </modules>
- </profile>
- <profile>
<id>inttest</id>
<modules>
<module>core</module>
@@ -59,8 +49,8 @@
</profiles>
<properties>
- <maven.compile.source>1.5</maven.compile.source>
- <maven.compile.target>1.5</maven.compile.target>
+ <maven.compile.source>1.8</maven.compile.source>
+ <maven.compile.target>1.8</maven.compile.target>
<vysper.server.version>${project.version}</vysper.server.version>
</properties>
</project>
diff --git a/speccompliance/pom.xml b/speccompliance/pom.xml
index 8784f1d..45078ff 100644
--- a/speccompliance/pom.xml
+++ b/speccompliance/pom.xml
@@ -16,7 +16,8 @@
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>vysper-parent</artifactId>
<groupId>org.apache.vysper</groupId>
@@ -27,25 +28,17 @@
<artifactId>spec-compliance</artifactId>
<name>Apache Vysper Spec compliance</name>
<version>0.8-SNAPSHOT</version>
-
- <profiles>
- <profile>
- <id>default-tools.jar</id>
- <activation>
- <file>
- <exists>${java.home}/../lib/tools.jar</exists>
- </file>
- </activation>
- <dependencies>
- <dependency>
- <groupId>com.sun</groupId>
- <artifactId>tools</artifactId>
- <version>1.4.2</version>
- <scope>system</scope>
- <systemPath>${java.home}/../lib/tools.jar
- </systemPath>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <!-- Disable annotation processing for ourselves. -->
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/speccompliance/src/main/java/org/apache/vysper/compliance/reporting/DocumentSpecCompliantAnnotationFactory.java b/speccompliance/src/main/java/org/apache/vysper/compliance/reporting/DocumentSpecCompliantAnnotationFactory.java
deleted file mode 100644
index 636442f..0000000
--- a/speccompliance/src/main/java/org/apache/vysper/compliance/reporting/DocumentSpecCompliantAnnotationFactory.java
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * 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 org.apache.vysper.compliance.reporting;
-
-import static java.util.Collections.emptySet;
-import static java.util.Collections.unmodifiableCollection;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import org.apache.vysper.compliance.SpecCompliance;
-import org.apache.vysper.compliance.SpecCompliant;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.mirror.apt.Filer;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.ClassDeclaration;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.FieldDeclaration;
-import com.sun.mirror.declaration.MemberDeclaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-
-/**
- * this generates from all SpecCompliant annotations a HTML doc to show what parts of the spec are covered.
- * The table is sorted by implemented spec section and links out to the spec and the apidocs.
- *
- * apt can be invoked like this (tools.jar must be on the classpath)
- * apt -cp build/ant/classes;lib/* -s src/main/java -factory org.apache.vysper.compliance.reporting.DocumentSpecCompliantAnnotationFactory
- * it generates a file spec_compliance.html in src/main/java
- *
- * @author The Apache MINA Project (dev@mina.apache.org)
- */
-public class DocumentSpecCompliantAnnotationFactory implements AnnotationProcessorFactory {
- // Process any set of annotations
- private static final Collection<String> supportedAnnotations = unmodifiableCollection(Arrays
- .asList("org.apache.vysper.compliance.*"));
-
- // No supported options
- private static final Collection<String> supportedOptions = emptySet();
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedAnnotations;
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) {
- return new SpecCompliantClassAP(env);
- }
-
- private static class SpecCompliantClassAP implements AnnotationProcessor {
-
- protected final AnnotationProcessorEnvironment env;
-
- protected AnnotationTypeDeclaration specCompliantAnnotation;
-
- protected AnnotationTypeDeclaration specCompliantCollectionAnnotation;
-
- protected Map<String, SpecDoc> map = new TreeMap<String, SpecDoc>();
-
- protected PrintWriter fileWriter;
-
- SpecCompliantClassAP(AnnotationProcessorEnvironment env) {
- this.env = env;
- specCompliantAnnotation = (AnnotationTypeDeclaration) env
- .getTypeDeclaration("org.apache.vysper.compliance.SpecCompliant");
- specCompliantCollectionAnnotation = (AnnotationTypeDeclaration) env
- .getTypeDeclaration("org.apache.vysper.compliance.SpecCompliance");
-
- try {
- fileWriter = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "",
- new File("spec_compliance.html"), null);
- } catch (IOException e) {
- throw new RuntimeException("could not write to output file", e);
- }
- }
-
- public void process() {
-
- // Retrieve all declarations with SpecCompliant annotations
- Collection<Declaration> declarations = env.getDeclarationsAnnotatedWith(specCompliantAnnotation);
- System.out.println("number of solitairy @SpecCompliant: " + declarations.size());
- for (Declaration declaration : declarations) {
- final SpecDoc doc = new SpecDoc(declaration, declaration.getAnnotation(SpecCompliant.class));
- map.put(doc.getKey(), doc);
- }
-
- // Retrieve all SpecCompliance-typed declarations and extract SpecCompliant annotations
- Collection<Declaration> moreDeclarations = env
- .getDeclarationsAnnotatedWith(specCompliantCollectionAnnotation);
- System.out.println("number of @SpecCompliance: " + moreDeclarations.size());
- for (Declaration declaration : moreDeclarations) {
- final SpecCompliance compliance = declaration.getAnnotation(SpecCompliance.class);
- final SpecCompliant[] specCompliants = compliance.compliant();
- for (SpecCompliant specCompliant : specCompliants) {
- if (specCompliant == null)
- continue;
-
- final SpecDoc doc = new SpecDoc(declaration, specCompliant);
- map.put(doc.getKey(), doc);
- }
- }
-
- // visit every annotation fromt the now sorted map
-
- // write the HTML file
- fileWriter
- .println("<html><head>"
- + "<link rel='stylesheet' type='text/css' href='http://yui.yahooapis.com/2.7.0/build/reset-fonts-grids/reset-fonts-grids.css'>\n"
- + "<link rel='stylesheet' type='text/css' href='http://yui.yahooapis.com/2.7.0/build/base/base-min.css'>\n"
- + "</head><body><table><thead><th>spec</th><th>section</th><th>package</th><th>class</th><th>field/method/etc.</th><th>coverage</th><th>implementation</th><th>comment</th></thead>");
- for (String key : map.keySet()) {
- fileWriter.print("<tr>");
- System.out.println(key);
- final SpecDoc doc = map.get(key);
-
- // spec
- fileWriter.print("<td>");
- final String specURL = doc.getSpecDocURL();
- if (specURL != null)
- fileWriter.print("<a href='" + specURL + "'>");
- final String specDoc = doc.getSpecDoc();
- if (specDoc != null)
- fileWriter.print(specDoc);
- if (specURL != null)
- fileWriter.print("</a>");
- fileWriter.print("</td>");
-
- // spec section
- fileWriter.print("<td>");
- String specSection = doc.getSpecSection();
- if (specSection != null && specSection.length() > 0) {
- if (specSection.endsWith("."))
- specSection = specSection.substring(0, specSection.length() - 1);
- String anchorLink = Character.isDigit(specSection.charAt(0)) ? "#section-" : "#appendix-";
- if (specURL != null)
- fileWriter.print("<a href='" + specURL + anchorLink + specSection + "'>");
- fileWriter.print(specSection);
- if (specURL != null)
- fileWriter.print("</a>");
- }
- fileWriter.print("</td>");
-
- // package
- fileWriter.print("<td>");
- final String packageName = doc.getPackage();
- if (packageName != null) {
- fileWriter.print(o_a_v_shortened(packageName));
- }
- fileWriter.print("</td>");
-
- // class
- fileWriter.print("<td>");
- final String className = doc.getClassName();
- if (className != null) {
- fileWriter.print("<a href='" + doc.getFQClassName().replace(".", "/") + ".html'>");
- fileWriter.print(o_a_v_cut(packageName, className));
- fileWriter.print("</a>");
- }
- fileWriter.print("</td>");
-
- // class element
- fileWriter.print("<td>");
- final String member = doc.getMember();
- if (member != null) {
- if (className != null) {
- fileWriter.print("<a href='" + className.replace(".", "/") + ".html#"
- + doc.getMemberAnchor().replace(",", ",%20") + "'>");
- }
- fileWriter.print(o_a_v_cut(packageName, member));
- if (className != null) {
- fileWriter.print("</a>");
- }
- }
- fileWriter.print("</td>");
-
- // coverage
- fileWriter.print("<td>");
- final SpecCompliant.ComplianceCoverage coverage = doc.getCoverageLevel();
- if (coverage != null)
- fileWriter.print(coverage.toString().toLowerCase());
- fileWriter.print("</td>");
-
- // status
- fileWriter.print("<td>");
- final SpecCompliant.ComplianceStatus complianceStatus = doc.getComplianceStatus();
- if (complianceStatus != null)
- fileWriter.print(complianceStatus.toString().toLowerCase());
- fileWriter.print("</td>");
-
- // comment
- fileWriter.print("<td>");
- final String comment = doc.getComment();
- if (comment != null)
- fileWriter.print(comment);
- fileWriter.print("</td>");
-
- fileWriter.println("</tr>");
-
- }
- fileWriter.println("</table></body>");
- }
-
- private String o_a_v_shortened(String packageString) {
- if (packageString != null && packageString.contains("org.apache.vysper."))
- return packageString.replace("org.apache.vysper.", "o.a.v.");
- return packageString;
- }
-
- private String o_a_v_cut(String packageString, String memberString) {
- if (memberString != null && memberString.contains(packageString + "."))
- return memberString.replace(packageString + ".", "");
- return memberString;
- }
-
- }
-
- static class SpecDoc {
-
- Declaration declaration;
-
- SpecCompliant specCompliant;
-
- SpecDoc(Declaration declaration, SpecCompliant specCompliant) {
- this.declaration = declaration;
- this.specCompliant = specCompliant;
- }
-
- public String getClassName() {
- if (declaration instanceof FieldDeclaration || declaration instanceof MethodDeclaration) {
- MemberDeclaration memberDeclaration = (MemberDeclaration) declaration;
- return memberDeclaration.getDeclaringType().getQualifiedName();
- } else {
- return declaration.getSimpleName();
- }
- }
-
- public String getFQClassName() {
- if (declaration instanceof FieldDeclaration || declaration instanceof MethodDeclaration) {
- MemberDeclaration memberDeclaration = (MemberDeclaration) declaration;
- return memberDeclaration.getDeclaringType().getQualifiedName();
- } else if (declaration instanceof ClassDeclaration) {
- ClassDeclaration classDeclaration = (ClassDeclaration) declaration;
- return classDeclaration.getPackage() + "." + classDeclaration.getSimpleName();
- } else {
- return declaration.getSimpleName();
- }
- }
-
- public String getPackage() {
- if (declaration instanceof TypeDeclaration) {
- TypeDeclaration typeDeclaration = (TypeDeclaration) declaration;
- return typeDeclaration.getPackage().getQualifiedName();
- } else if (declaration instanceof FieldDeclaration || declaration instanceof MethodDeclaration) {
- MemberDeclaration memberDeclaration = (MemberDeclaration) declaration;
- return memberDeclaration.getDeclaringType().getPackage().getQualifiedName();
- } else {
- return null;
- }
- }
-
- public String getMember() {
- if (declaration instanceof FieldDeclaration || declaration instanceof MethodDeclaration) {
- MemberDeclaration memberDeclaration = (MemberDeclaration) declaration;
- return declaration.getSimpleName();
- } else {
- return null;
- }
- }
-
- public String getMemberAnchor() {
- if (declaration instanceof FieldDeclaration || declaration instanceof MethodDeclaration) {
- MemberDeclaration memberDeclaration = (MemberDeclaration) declaration;
- return declaration.toString();
- } else {
- return null;
- }
- }
-
- public String getKey() {
- return getSpecDoc() + " " + getSpecSection() + " " + getClassName() + " " + getMember() + " "
- + getCoverageLevel() + " " + getComplianceStatus();
- }
-
- public String getSpecSection() {
- return specCompliant.section();
- }
-
- public String getSpecDoc() {
- final String specRaw = specCompliant.spec();
- if (specRaw == null)
- return null;
- return specRaw.toLowerCase();
- }
-
- public String getSpecDocURL() {
- final String spec = getSpecDoc();
- if (spec == null)
- return null;
-
- if (spec.startsWith("xep"))
- return "http://xmpp.org/extensions/" + spec + ".html";
- if (spec.startsWith("rfc")) {
- if (!spec.contains("bis")) {
- return "http://tools.ietf.org/html/" + spec;
- } else {
- return "http://tools.ietf.org/html/draft-saintandre-" + spec;
- }
- }
- return null;
- }
-
- public SpecCompliant.ComplianceCoverage getCoverageLevel() {
- return specCompliant.coverage();
- }
-
- public SpecCompliant.ComplianceStatus getComplianceStatus() {
- return specCompliant.status();
- }
-
- public String getComment() {
- return specCompliant.comment();
- }
- }
-}
diff --git a/speccompliance/src/main/java/org/apache/vysper/compliance/reporting/DocumentSpecCompliantAnnotationProcessor.java b/speccompliance/src/main/java/org/apache/vysper/compliance/reporting/DocumentSpecCompliantAnnotationProcessor.java
new file mode 100644
index 0000000..ed97a5f
--- /dev/null
+++ b/speccompliance/src/main/java/org/apache/vysper/compliance/reporting/DocumentSpecCompliantAnnotationProcessor.java
@@ -0,0 +1,360 @@
+/*
+ * 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 org.apache.vysper.compliance.reporting;
+
+import org.apache.vysper.compliance.SpecCompliance;
+import org.apache.vysper.compliance.SpecCompliant;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+import javax.tools.StandardLocation;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import static java.util.Collections.emptySet;
+import static java.util.Collections.unmodifiableSet;
+
+/**
+ * this generates from all SpecCompliant annotations a HTML doc to show what parts of the spec are covered.
+ * The table is sorted by implemented spec section and links out to the spec and the apidocs.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ */
+public class DocumentSpecCompliantAnnotationProcessor extends AbstractProcessor {
+
+ // Process any set of annotations
+ private static final Set<String> supportedAnnotations = unmodifiableSet(
+ Collections.singleton("org.apache.vysper.compliance.*"));
+
+ // No supported options
+ private static final Set<String> supportedOptions = emptySet();
+
+ protected ProcessingEnvironment env;
+
+ protected TypeElement specCompliantAnnotation;
+
+ protected TypeElement specCompliantCollectionAnnotation;
+
+ protected Map<String, SpecDoc> map = new TreeMap<String, SpecDoc>();
+
+ protected PrintWriter fileWriter;
+
+ @Override
+ public synchronized void init(ProcessingEnvironment processingEnv) {
+ super.init(processingEnv);
+ this.env = processingEnv;
+ specCompliantAnnotation = processingEnv.getElementUtils().getTypeElement("org.apache.vysper.compliance.SpecCompliant");
+ specCompliantCollectionAnnotation = processingEnv.getElementUtils().getTypeElement("org.apache.vysper.compliance.SpecCompliance");
+ try {
+ this.fileWriter = new PrintWriter(processingEnv.getFiler()
+ .createResource(StandardLocation.SOURCE_OUTPUT, "", "spec_compliance.html").openWriter());
+ } catch (IOException e) {
+ throw new RuntimeException("could not write to output file", e);
+ }
+ }
+
+ @Override
+ public Set<String> getSupportedAnnotationTypes() {
+ return supportedAnnotations;
+ }
+
+ @Override
+ public Set<String> getSupportedOptions() {
+ return supportedOptions;
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ // Retrieve all declarations with SpecCompliant annotations
+ Collection<? extends Element> declarations = roundEnv.getElementsAnnotatedWith(SpecCompliant.class);
+ System.out.println("number of solitairy @SpecCompliant: " + declarations.size());
+ for (Element declaration : declarations) {
+ final SpecDoc doc = new SpecDoc(declaration, declaration.getAnnotation(SpecCompliant.class));
+ map.put(doc.getKey(), doc);
+ }
+
+ // Retrieve all SpecCompliance-typed declarations and extract SpecCompliant annotations
+ Collection<? extends Element> moreDeclarations = roundEnv
+ .getElementsAnnotatedWith(specCompliantCollectionAnnotation);
+ System.out.println("number of @SpecCompliance: " + moreDeclarations.size());
+ for (Element declaration : moreDeclarations) {
+ final SpecCompliance compliance = declaration.getAnnotation(SpecCompliance.class);
+ final SpecCompliant[] specCompliants = compliance.compliant();
+ for (SpecCompliant specCompliant : specCompliants) {
+ if (specCompliant == null) {
+ continue;
+ }
+
+ final SpecDoc doc = new SpecDoc(declaration, specCompliant);
+ map.put(doc.getKey(), doc);
+ }
+ }
+
+ // visit every annotation fromt the now sorted map
+
+ // write the HTML file
+ fileWriter
+ .println("<html><head>"
+ + "<link rel='stylesheet' type='text/css' href='http://yui.yahooapis.com/2.7.0/build/reset-fonts-grids/reset-fonts-grids.css'>\n"
+ + "<link rel='stylesheet' type='text/css' href='http://yui.yahooapis.com/2.7.0/build/base/base-min.css'>\n"
+ + "</head><body><table><thead><th>spec</th><th>section</th><th>package</th><th>class</th><th>field/method/etc.</th><th>coverage</th><th>implementation</th><th>comment</th></thead>");
+ for (String key : map.keySet()) {
+ fileWriter.print("<tr>");
+ System.out.println(key);
+ final SpecDoc doc = map.get(key);
+
+ // spec
+ fileWriter.print("<td>");
+ final String specURL = doc.getSpecDocURL();
+ if (specURL != null) {
+ fileWriter.print("<a href='" + specURL + "'>");
+ }
+ final String specDoc = doc.getSpecDoc();
+ if (specDoc != null) {
+ fileWriter.print(specDoc);
+ }
+ if (specURL != null) {
+ fileWriter.print("</a>");
+ }
+ fileWriter.print("</td>");
+
+ // spec section
+ fileWriter.print("<td>");
+ String specSection = doc.getSpecSection();
+ if (specSection != null && specSection.length() > 0) {
+ if (specSection.endsWith(".")) {
+ specSection = specSection.substring(0, specSection.length() - 1);
+ }
+ String anchorLink = Character.isDigit(specSection.charAt(0)) ? "#section-" : "#appendix-";
+ if (specURL != null) {
+ fileWriter.print("<a href='" + specURL + anchorLink + specSection + "'>");
+ }
+ fileWriter.print(specSection);
+ if (specURL != null) {
+ fileWriter.print("</a>");
+ }
+ }
+ fileWriter.print("</td>");
+
+ // package
+ fileWriter.print("<td>");
+ final String packageName = doc.getPackage();
+ if (packageName != null) {
+ fileWriter.print(o_a_v_shortened(packageName));
+ }
+ fileWriter.print("</td>");
+
+ // class
+ fileWriter.print("<td>");
+ final String className = doc.getClassName();
+ if (className != null) {
+ fileWriter.print("<a href='" + doc.getFQClassName().replace(".", "/") + ".html'>");
+ fileWriter.print(o_a_v_cut(packageName, className));
+ fileWriter.print("</a>");
+ }
+ fileWriter.print("</td>");
+
+ // class element
+ fileWriter.print("<td>");
+ final String member = doc.getMember();
+ if (member != null) {
+ if (className != null) {
+ fileWriter.print("<a href='" + className.replace(".", "/") + ".html#"
+ + doc.getMemberAnchor().replace(",", ",%20") + "'>");
+ }
+ fileWriter.print(o_a_v_cut(packageName, member));
+ if (className != null) {
+ fileWriter.print("</a>");
+ }
+ }
+ fileWriter.print("</td>");
+
+ // coverage
+ fileWriter.print("<td>");
+ final SpecCompliant.ComplianceCoverage coverage = doc.getCoverageLevel();
+ if (coverage != null) {
+ fileWriter.print(coverage.toString().toLowerCase());
+ }
+ fileWriter.print("</td>");
+
+ // status
+ fileWriter.print("<td>");
+ final SpecCompliant.ComplianceStatus complianceStatus = doc.getComplianceStatus();
+ if (complianceStatus != null) {
+ fileWriter.print(complianceStatus.toString().toLowerCase());
+ }
+ fileWriter.print("</td>");
+
+ // comment
+ fileWriter.print("<td>");
+ final String comment = doc.getComment();
+ if (comment != null) {
+ fileWriter.print(comment);
+ }
+ fileWriter.print("</td>");
+
+ fileWriter.println("</tr>");
+
+ }
+ fileWriter.println("</table></body>");
+
+ return true;
+ }
+
+ private String o_a_v_shortened(String packageString) {
+ if (packageString != null && packageString.contains("org.apache.vysper.")) {
+ return packageString.replace("org.apache.vysper.", "o.a.v.");
+ }
+ return packageString;
+ }
+
+ private String o_a_v_cut(String packageString, String memberString) {
+ if (memberString != null && memberString.contains(packageString + ".")) {
+ return memberString.replace(packageString + ".", "");
+ }
+ return memberString;
+ }
+
+ static class SpecDoc {
+
+ Element declaration;
+
+ SpecCompliant specCompliant;
+
+ SpecDoc(Element declaration, SpecCompliant specCompliant) {
+ this.declaration = declaration;
+ this.specCompliant = specCompliant;
+ }
+
+ public String getClassName() {
+ if (declaration.getKind().isField() || declaration instanceof ExecutableElement) {
+ TypeElement typeElement = (TypeElement) declaration.getEnclosingElement();
+ return typeElement.getQualifiedName().toString();
+ } else {
+ return declaration.getSimpleName().toString();
+ }
+ }
+
+ public String getFQClassName() {
+ if (declaration.getKind().isField() || declaration instanceof ExecutableElement) {
+ TypeElement typeElement = (TypeElement) declaration.getEnclosingElement();
+ return typeElement.getQualifiedName().toString();
+ } else if (declaration instanceof TypeElement) {
+ return ((TypeElement) declaration).getQualifiedName().toString();
+ } else {
+ return declaration.getSimpleName().toString();
+ }
+ }
+
+ public String getPackage() {
+ if (declaration instanceof TypeElement
+ || declaration.getKind().isField()
+ || declaration instanceof ExecutableElement) {
+ Element enclosingElement = declaration;
+ while (true) {
+ enclosingElement = enclosingElement.getEnclosingElement();
+ if (enclosingElement == null) {
+ return null;
+ }
+ if (!(enclosingElement instanceof PackageElement)) {
+ continue;
+ }
+ return ((PackageElement) enclosingElement).getQualifiedName().toString();
+ }
+ } else {
+ return null;
+ }
+ }
+
+ public String getMember() {
+ if (declaration.getKind().isField() || declaration instanceof ExecutableElement) {
+ return declaration.getSimpleName().toString();
+ } else {
+ return null;
+ }
+ }
+
+ public String getMemberAnchor() {
+ if (declaration.getKind().isField() || declaration instanceof ExecutableElement) {
+ return declaration.getSimpleName().toString();
+ } else {
+ return null;
+ }
+ }
+
+ public String getKey() {
+ return getSpecDoc() + " " + getSpecSection() + " " + getClassName() + " " + getMember() + " "
+ + getCoverageLevel() + " " + getComplianceStatus();
+ }
+
+ public String getSpecSection() {
+ return specCompliant.section();
+ }
+
+ public String getSpecDoc() {
+ final String specRaw = specCompliant.spec();
+ if (specRaw == null) {
+ return null;
+ }
+ return specRaw.toLowerCase();
+ }
+
+ public String getSpecDocURL() {
+ final String spec = getSpecDoc();
+ if (spec == null) {
+ return null;
+ }
+
+ if (spec.startsWith("xep")) {
+ return "http://xmpp.org/extensions/" + spec + ".html";
+ }
+ if (spec.startsWith("rfc")) {
+ if (!spec.contains("bis")) {
+ return "http://tools.ietf.org/html/" + spec;
+ } else {
+ return "http://tools.ietf.org/html/draft-saintandre-" + spec;
+ }
+ }
+ return null;
+ }
+
+ public SpecCompliant.ComplianceCoverage getCoverageLevel() {
+ return specCompliant.coverage();
+ }
+
+ public SpecCompliant.ComplianceStatus getComplianceStatus() {
+ return specCompliant.status();
+ }
+
+ public String getComment() {
+ return specCompliant.comment();
+ }
+ }
+}
diff --git a/speccompliance/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/speccompliance/src/main/resources/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 0000000..b8aa4de
--- /dev/null
+++ b/speccompliance/src/main/resources/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1 @@
+org.apache.vysper.compliance.reporting.DocumentSpecCompliantAnnotationProcessor
\ No newline at end of file