ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1730087 - in /webservices/axiom/trunk: axiom-api/ axiom-api/src/main/java/org/apache/axiom/om/impl/builder/ buildutils/no-package-cycles-enforcer-rule/src/main/java/org/apache/axiom/buildutils/enforcer/ devguide/src/docbkx/ devguide/src/do...
Date Fri, 12 Feb 2016 18:26:13 GMT
Author: veithen
Date: Fri Feb 12 18:26:13 2016
New Revision: 1730087

URL: http://svn.apache.org/viewvc?rev=1730087&view=rev
Log:
Set up no-package-cycles-enforcer-rule on axiom-api to prevent new package cycles.

Removed:
    webservices/axiom/trunk/devguide/src/docbkx/images/
Modified:
    webservices/axiom/trunk/axiom-api/pom.xml
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/Builder.java
    webservices/axiom/trunk/buildutils/no-package-cycles-enforcer-rule/src/main/java/org/apache/axiom/buildutils/enforcer/ClassProcessor.java
    webservices/axiom/trunk/buildutils/no-package-cycles-enforcer-rule/src/main/java/org/apache/axiom/buildutils/enforcer/NoPackageCyclesEnforcerRule.java
    webservices/axiom/trunk/buildutils/no-package-cycles-enforcer-rule/src/main/java/org/apache/axiom/buildutils/enforcer/ReferenceCollector.java
    webservices/axiom/trunk/devguide/src/docbkx/devguide.xml

Modified: webservices/axiom/trunk/axiom-api/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/pom.xml?rev=1730087&r1=1730086&r2=1730087&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/pom.xml (original)
+++ webservices/axiom/trunk/axiom-api/pom.xml Fri Feb 12 18:26:13 2016
@@ -253,6 +253,82 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <artifactId>maven-enforcer-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>enforce-no-package-cycles</id>
+                        <goals>
+                            <goal>enforce</goal>
+                        </goals>
+                        <phase>process-classes</phase>
+                        <configuration>
+                            <rules>
+                                <noPackageCycles implementation="org.apache.axiom.buildutils.enforcer.NoPackageCyclesEnforcerRule">
+                                    <ignore>
+                                        <!-- o.a.a.attachments shouldn't depend on o.a.a.om
-->
+                                        org.apache.axiom.attachments.Attachments -> org.apache.axiom.om.OMAttachmentAccessor,
+                                        org.apache.axiom.attachments.Attachments -> org.apache.axiom.om.OMException,
+                                        org.apache.axiom.attachments.AttachmentsDelegate
-> org.apache.axiom.om.OMException,
+                                        org.apache.axiom.attachments.AttachmentSet ->
org.apache.axiom.om.OMException,
+                                        org.apache.axiom.attachments.IncomingAttachmentStreams
-> org.apache.axiom.om.OMException,
+                                        org.apache.axiom.attachments.MIMEMessage -> org.apache.axiom.om.OMException,
+                                        org.apache.axiom.attachments.MIMEMessage -> org.apache.axiom.om.util.DetachableInputStream,
+                                        org.apache.axiom.attachments.MultipartAttachmentStreams
-> org.apache.axiom.om.OMException,
+                                        org.apache.axiom.attachments.PartImpl -> org.apache.axiom.om.OMException,
+                                        org.apache.axiom.attachments.PartImpl -> org.apache.axiom.om.util.DetachableInputStream,
+                                        <!-- Bad API design: a public API shouldn't depend
on classes in an impl package in its interface -->
+                                        org.apache.axiom.attachments.lifecycle.LifecycleManager
-> org.apache.axiom.attachments.lifecycle.impl.FileAccessor,
+                                        <!-- o.a.a.soap should be a layer on top of o.a.a.om
-->
+                                        org.apache.axiom.om.OMAbstractFactory -> org.apache.axiom.soap.SOAPFactory,
+                                        org.apache.axiom.om.OMMetaFactory -> org.apache.axiom.soap.SOAPFactory,
+                                        org.apache.axiom.om.OMMetaFactory -> org.apache.axiom.soap.SOAPModelBuilder,
+                                        org.apache.axiom.om.OMXMLBuilderFactory -> org.apache.axiom.soap.SOAPFactory,
+                                        org.apache.axiom.om.OMXMLBuilderFactory -> org.apache.axiom.soap.SOAPModelBuilder,
+                                        <!-- This should eventually be deprecated/removed
-->
+                                        org.apache.axiom.om.util.ElementHelper -> org.apache.axiom.soap.SOAPFactory,
+                                        org.apache.axiom.om.util.ElementHelper -> org.apache.axiom.soap.SOAPHeaderBlock,
+                                        <!-- The public API shouldn't depend on classes
in o.a.a.om.util -->
+                                        org.apache.axiom.om.OMMetaFactory -> org.apache.axiom.om.util.StAXParserConfiguration,
+                                        org.apache.axiom.om.OMXMLBuilderFactory -> org.apache.axiom.om.util.StAXParserConfiguration,
+                                        org.apache.axiom.om.OMOutputFormat -> org.apache.axiom.om.util.StAXWriterConfiguration,
+                                        org.apache.axiom.om.impl.MTOMXMLStreamWriter ->
org.apache.axiom.om.util.StAXWriterConfiguration,
+                                        org.apache.axiom.om.OMOutputFormat -> org.apache.axiom.om.util.XMLStreamWriterFilter,
+                                        org.apache.axiom.om.impl.MTOMXMLStreamWriter ->
org.apache.axiom.om.util.XMLStreamWriterFilter,
+                                        <!-- StAXUtils is in the wrong package (should
be o.a.a.util.stax) -->
+                                        org.apache.axiom.om.ds.AbstractOMDataSource ->
org.apache.axiom.om.util.StAXUtils,
+                                        org.apache.axiom.om.ds.AbstractPushOMDataSource ->
org.apache.axiom.om.util.StAXUtils,
+                                        org.apache.axiom.om.ds.ByteArrayDataSource ->
org.apache.axiom.om.util.StAXUtils,
+                                        org.apache.axiom.om.ds.CharArrayDataSource ->
org.apache.axiom.om.util.StAXUtils,
+                                        org.apache.axiom.om.ds.InputStreamDataSource ->
org.apache.axiom.om.util.StAXUtils,
+                                        org.apache.axiom.om.ds.ParserInputStreamDataSource
-> org.apache.axiom.om.util.StAXUtils,
+                                        org.apache.axiom.om.impl.MTOMXMLStreamWriter ->
org.apache.axiom.om.util.StAXUtils,
+                                        <!-- This should go away in a redesign of the
OMDataSource API -->
+                                        org.apache.axiom.om.ds.AbstractPullOMDataSource ->
org.apache.axiom.om.impl.serialize.StreamingOMSerializer,
+                                        <!-- ParserInputStreamDataSource will be deprecated
-->
+                                        org.apache.axiom.om.ds.ParserInputStreamDataSource$Data
-> org.apache.axiom.om.util.CommonUtils,
+                                        <!-- TODO: CustomBuilder should not be in an impl
package -->
+                                        org.apache.axiom.om.impl.builder.CustomBuilder ->
org.apache.axiom.om.OMDataSource,
+                                        org.apache.axiom.om.impl.builder.CustomBuilder ->
org.apache.axiom.om.OMException,
+                                        <!-- TODO: Detachable should go to om-aspects
-->
+                                        org.apache.axiom.om.impl.builder.Detachable ->
org.apache.axiom.om.OMException,
+                                        <!-- TODO -->
+                                        org.apache.axiom.om.impl.MTOMXMLStreamWriter ->
org.apache.axiom.om.util.CommonUtils,
+                                        org.apache.axiom.om.impl.OMMultipartWriter ->
org.apache.axiom.om.util.CommonUtils
+                                    </ignore>
+                                </noPackageCycles>
+                            </rules>
+                        </configuration>
+                    </execution>
+                </executions>
+                <dependencies>
+                    <dependency>
+                        <groupId>${project.groupId}</groupId>
+                        <artifactId>no-package-cycles-enforcer-rule</artifactId>
+                        <version>${project.version}</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
         </plugins>
     </build>
 

Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/Builder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/Builder.java?rev=1730087&r1=1730086&r2=1730087&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/Builder.java
(original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/Builder.java
Fri Feb 12 18:26:13 2016
@@ -21,7 +21,7 @@ package org.apache.axiom.om.impl.builder
 import org.apache.axiom.om.OMXMLParserWrapper;
 
 /**
- * For internal use only.
+ * @deprecated
  */
 public interface Builder extends OMXMLParserWrapper {
     /**

Modified: webservices/axiom/trunk/buildutils/no-package-cycles-enforcer-rule/src/main/java/org/apache/axiom/buildutils/enforcer/ClassProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/buildutils/no-package-cycles-enforcer-rule/src/main/java/org/apache/axiom/buildutils/enforcer/ClassProcessor.java?rev=1730087&r1=1730086&r2=1730087&view=diff
==============================================================================
--- webservices/axiom/trunk/buildutils/no-package-cycles-enforcer-rule/src/main/java/org/apache/axiom/buildutils/enforcer/ClassProcessor.java
(original)
+++ webservices/axiom/trunk/buildutils/no-package-cycles-enforcer-rule/src/main/java/org/apache/axiom/buildutils/enforcer/ClassProcessor.java
Fri Feb 12 18:26:13 2016
@@ -26,6 +26,7 @@ import org.objectweb.asm.Type;
 
 final class ClassProcessor extends ClassVisitor {
     private final ReferenceCollector referenceCollector;
+    private boolean deprecated;
     private ReferenceProcessor referenceProcessor;
     
     ClassProcessor(ReferenceCollector referenceCollector) {
@@ -36,29 +37,38 @@ final class ClassProcessor extends Class
     @Override
     public void visit(int version, int access, String name, String signature, String superName,
             String[] interfaces) {
-        referenceProcessor = new ReferenceProcessor(referenceCollector, Type.getObjectType(name).getClassName());
-        referenceProcessor.processType(Type.getObjectType(superName));
-        for (String iface : interfaces) {
-            referenceProcessor.processType(Type.getObjectType(iface));
+        deprecated = (access & Opcodes.ACC_DEPRECATED) != 0;
+        if (!deprecated) {
+            referenceProcessor = new ReferenceProcessor(referenceCollector, Type.getObjectType(name).getClassName());
+            referenceProcessor.processType(Type.getObjectType(superName));
+            for (String iface : interfaces) {
+                referenceProcessor.processType(Type.getObjectType(iface));
+            }
         }
     }
 
     @Override
     public FieldVisitor visitField(int access, String name, String desc, String signature,
             Object value) {
-        referenceProcessor.processType(Type.getType(desc));
+        if (!deprecated) {
+            referenceProcessor.processType(Type.getType(desc));
+        }
         return null;
     }
 
     @Override
     public MethodVisitor visitMethod(int access, String name, String desc, String signature,
             String[] exceptions) {
-        referenceProcessor.processType(Type.getMethodType(desc));
-        if (exceptions != null) {
-            for (String exception : exceptions) {
-                referenceProcessor.processType(Type.getObjectType(exception));
+        if (!deprecated && (access & Opcodes.ACC_DEPRECATED) == 0) {
+            referenceProcessor.processType(Type.getMethodType(desc));
+            if (exceptions != null) {
+                for (String exception : exceptions) {
+                    referenceProcessor.processType(Type.getObjectType(exception));
+                }
             }
+            return new MethodProcessor(referenceProcessor);
+        } else {
+            return null;
         }
-        return new MethodProcessor(referenceProcessor);
     }
 }

Modified: webservices/axiom/trunk/buildutils/no-package-cycles-enforcer-rule/src/main/java/org/apache/axiom/buildutils/enforcer/NoPackageCyclesEnforcerRule.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/buildutils/no-package-cycles-enforcer-rule/src/main/java/org/apache/axiom/buildutils/enforcer/NoPackageCyclesEnforcerRule.java?rev=1730087&r1=1730086&r2=1730087&view=diff
==============================================================================
--- webservices/axiom/trunk/buildutils/no-package-cycles-enforcer-rule/src/main/java/org/apache/axiom/buildutils/enforcer/NoPackageCyclesEnforcerRule.java
(original)
+++ webservices/axiom/trunk/buildutils/no-package-cycles-enforcer-rule/src/main/java/org/apache/axiom/buildutils/enforcer/NoPackageCyclesEnforcerRule.java
Fri Feb 12 18:26:13 2016
@@ -22,6 +22,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.maven.enforcer.rule.api.EnforcerRule;
@@ -32,6 +33,7 @@ import org.codehaus.plexus.util.Director
 import org.objectweb.asm.ClassReader;
 
 public class NoPackageCyclesEnforcerRule implements EnforcerRule {
+    private String ignore;
 
     @Override
     public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException {
@@ -40,11 +42,18 @@ public class NoPackageCyclesEnforcerRule
             if (!classesDir.exists()) {
                 return;
             }
+            Set<Reference> ignoredClassReferences = new HashSet<Reference>();
+            if (ignore != null) {
+                for (String ignoreRule : ignore.split(",")) {
+                    String[] s = ignoreRule.split("->");
+                    ignoredClassReferences.add(new Reference(s[0].trim(), s[1].trim()));
+                }
+            }
             DirectoryScanner ds = new DirectoryScanner();
             ds.setIncludes(new String[] { "**/*.class" });
             ds.setBasedir(classesDir);
             ds.scan();
-            ReferenceCollector referenceCollector = new ReferenceCollector();
+            ReferenceCollector referenceCollector = new ReferenceCollector(ignoredClassReferences);
             for (String relativePath : ds.getIncludedFiles()) {
                 try {
                     InputStream in = new FileInputStream(new File(classesDir, relativePath));

Modified: webservices/axiom/trunk/buildutils/no-package-cycles-enforcer-rule/src/main/java/org/apache/axiom/buildutils/enforcer/ReferenceCollector.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/buildutils/no-package-cycles-enforcer-rule/src/main/java/org/apache/axiom/buildutils/enforcer/ReferenceCollector.java?rev=1730087&r1=1730086&r2=1730087&view=diff
==============================================================================
--- webservices/axiom/trunk/buildutils/no-package-cycles-enforcer-rule/src/main/java/org/apache/axiom/buildutils/enforcer/ReferenceCollector.java
(original)
+++ webservices/axiom/trunk/buildutils/no-package-cycles-enforcer-rule/src/main/java/org/apache/axiom/buildutils/enforcer/ReferenceCollector.java
Fri Feb 12 18:26:13 2016
@@ -30,20 +30,28 @@ import org.jgrapht.graph.DefaultDirected
 import org.jgrapht.graph.DirectedSubgraph;
 
 final class ReferenceCollector {
+    private final Set<Reference> ignoredClassReferences;
     private final Set<Reference> packageReferences = new HashSet<>();
     private final Map<Reference,Reference> classReferenceSamples = new HashMap<>();
     
+    ReferenceCollector(Set<Reference> ignoredClassReferences) {
+        this.ignoredClassReferences = ignoredClassReferences;
+    }
+
     private static String getPackageName(String className) {
         return className.substring(0, className.lastIndexOf('.'));
     }
     
     void collectClassReference(String from, String to) {
-        String fromPackage = getPackageName(from);
-        String toPackage = getPackageName(to);
-        if (!fromPackage.equals(toPackage)) {
-            Reference packageReference = new Reference(fromPackage, toPackage);
-            if (packageReferences.add(packageReference)) {
-                classReferenceSamples.put(packageReference, new Reference(from, to));
+        Reference classReference = new Reference(from, to);
+        if (!ignoredClassReferences.contains(classReference)) {
+            String fromPackage = getPackageName(from);
+            String toPackage = getPackageName(to);
+            if (!fromPackage.equals(toPackage)) {
+                Reference packageReference = new Reference(fromPackage, toPackage);
+                if (packageReferences.add(packageReference)) {
+                    classReferenceSamples.put(packageReference, classReference);
+                }
             }
         }
     }

Modified: webservices/axiom/trunk/devguide/src/docbkx/devguide.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/devguide/src/docbkx/devguide.xml?rev=1730087&r1=1730086&r2=1730087&view=diff
==============================================================================
--- webservices/axiom/trunk/devguide/src/docbkx/devguide.xml (original)
+++ webservices/axiom/trunk/devguide/src/docbkx/devguide.xml Fri Feb 12 18:26:13 2016
@@ -413,47 +413,6 @@ javax.xml.stream.XMLOutputFactory=com.be
             <itemizedlist>
                 <listitem>
                     <para>
-                        Check the dependencies between Java packages in the <filename>axiom-api</filename>
module.
-                        The <package>org.apache.axiom.util</package> package
(including its subpackages) is specified
-                        to contain utility classes that don't depend on higher level APIs.
More precisely,
-                        <package>org.apache.axiom.util</package> should only
have dependencies on
-                        <package>org.apache.axiom.ext</package>, but not e.g.
on <package>org.apache.axiom.om</package>.
-                        <link xlink:href="http://www.hello2morrow.com/products/sonarj">SonarJ</link>
can be used
-                        to check these dependencies. The following figure shows the expected
structure:
-                    </para>
-                    <figure>
-                        <title>Package dependencies for r944680</title>
-                        <mediaobject>
-                            <imageobject>
-                                <imagedata fileref="sonarj-944680.png" format="PNG"/>
-                            </imageobject>
-                        </mediaobject>
-                    </figure>
-                    <para>
-                        In contrast, the following figure shows an earlier trunk version
of <filename>axiom-api</filename>
-                        with incorrect layering and cyclic dependencies involving <package>org.apache.axiom.util</package>:
-                    </para>
-                    <figure>
-                        <title>Package dependencies for r939984</title>
-                        <mediaobject>
-                            <imageobject>
-                                <imagedata fileref="sonarj-939984.png" format="PNG"/>
-                            </imageobject>
-                        </mediaobject>
-                    </figure>
-                    <para>
-                        The check can also be done using <link xlink:href="http://mojo.codehaus.org/jdepend-maven-plugin/">jdepend-maven-plugin</link>.
-                        To do this, execute the following command in the <filename>axiom-api</filename>
module:
-                    </para>
-                    <screen>mvn jdepend:generate</screen>
-                    <para>
-                        Then open <filename>target/site/jdepend-report.html</filename>
and go the the "Cycles" section.
-                        The report should not show any package cycles involving <package>org.apache.axiom.mime</package>,
-                        <package>org.apache.axiom.util</package> and <package>org.apache.axiom.ext</package>.
-                    </para>
-                </listitem>
-                <listitem>
-                    <para>
                         Check that the generated Javadoc contains the appropriate set of
packages, i.e. only the public API.
                         This excludes classes from <filename>axiom-impl</filename>
and <filename>axiom-dom</filename> as well as classes
                         related to unit tests.



Mime
View raw message