xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject cvs commit: xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider CompositeClassInitializer.java DefaultCommentProcessor.java DefaultJServiceFactory.java ElementProcessor.java ElementWalker.java CompositeClassBuilder.java EClassInitializer.java JServiceParamsImpl.java JStoreParams.java NewJServiceFactory.java DefaultJResultFactory.java
Date Wed, 03 Mar 2004 03:57:50 GMT
pcal        2004/03/02 19:57:50

  Modified:    v2/src/jam/org/apache/xmlbeans/impl/jam JElement.java
                        JServiceFactory.java JServiceParams.java
               v2/src/jam/org/apache/xmlbeans/impl/jam/editable EClass.java
                        EElement.java
               v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl
                        EAnnotationImpl.java EAnnotationMemberImpl.java
                        EClassImpl.java EConstructorImpl.java
                        EElementImpl.java EFieldImpl.java
                        EInvokableImpl.java EMethodImpl.java
                        EParameterImpl.java
               v2/src/jam/org/apache/xmlbeans/impl/jam/internal
                        JClassLoaderImpl.java
               v2/src/jam/org/apache/xmlbeans/impl/jam/provider
                        CompositeClassBuilder.java EClassInitializer.java
                        JServiceParamsImpl.java JStoreParams.java
                        NewJServiceFactory.java
  Added:       v2/src/jam/org/apache/xmlbeans/impl/jam/editable
                        EElementVisitor.java
               v2/src/jam/org/apache/xmlbeans/impl/jam/provider
                        CompositeClassInitializer.java
                        DefaultCommentProcessor.java
                        DefaultJServiceFactory.java ElementProcessor.java
                        ElementWalker.java
  Removed:     v2/src/jam/org/apache/xmlbeans/impl/jam/provider
                        DefaultJResultFactory.java
  Log:
  jam: add EElementVisitor, lay groundwork for javadoc tag transformers
  
  Revision  Changes    Path
  1.5       +35 -12    xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JElement.java
  
  Index: JElement.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JElement.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JElement.java	12 Feb 2004 20:06:09 -0000	1.4
  +++ JElement.java	3 Mar 2004 03:57:49 -0000	1.5
  @@ -37,18 +37,16 @@
     public JAnnotation[] getAnnotations();
   
     /**
  -   * <p>Returns the set of annotations associated with this
  -   * abstraction which have the given name.  Returns an empty array if
  -   * there are no such annotations.</p>
  +   * <p>Returns the annotation of the named annotation class.  The
  +   * named class must be loadable by the JClassLoader which loaded
  +   * this JElement.</p>
  +   *
  +   * NOTE: The following additional behavior is still supported
  +   * in the case where the annotation takes the form of javadoc tags,
  +   * but it is deprecated.
      *
  -   * @deprecated I don't think we should encourage people to support
  -   * multiple annotations with the same name as that does not work once
  -   * we get to 175-land.
  -   */
  -  public JAnnotation[] getAnnotations(String named);
  -
  -  /**
  -   * <p>Returns the annotation on this abstraction which has the given
  +   * <p>Returns the annotation on this abstraction of the given
  +   * annotation type.  which has the given
      * name.  If more than one such annotation exists, returns the first
      * one in document order.  If none exists, returns null.</p>
      *
  @@ -65,7 +63,16 @@
      * return null.</p>
      *
      */
  -  public JAnnotation getAnnotation(String named);
  +  public JAnnotation getAnnotation(String qualifiedAnnotationClassname);
  +
  +  /**
  +   * <p>Returns the annotation on this abstraction of the given
  +   * annotation type.</p>
  +   */
  +  //public JAnnotation getAnnotation(JAnnotationDefinition annType);
  +
  +
  +
   
     /**
      * <p>Returns the parent of this abstraction, or null if this
  @@ -116,4 +123,20 @@
      * element, or null if the position is unknown on not applicable.
      */
     public JSourcePosition getSourcePosition();
  +
  +
  +  // ========================================================================
  +  // Deprecated methods
  +
  +  /**
  +   * <p>Returns the set of annotations associated with this
  +   * abstraction which have the given name.  Returns an empty array if
  +   * there are no such annotations.</p>
  +   *
  +   * @deprecated I don't think we should encourage people to support
  +   * multiple annotations with the same name as that does not work once
  +   * we get to 175-land.
  +   */
  +  public JAnnotation[] getAnnotations(String named);
  +
   }
  
  
  
  1.6       +2 -2      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JServiceFactory.java
  
  Index: JServiceFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JServiceFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JServiceFactory.java	2 Mar 2004 08:28:19 -0000	1.5
  +++ JServiceFactory.java	3 Mar 2004 03:57:49 -0000	1.6
  @@ -16,7 +16,7 @@
   package org.apache.xmlbeans.impl.jam;
   
   import org.apache.xmlbeans.impl.jam.internal.JamPrinter;
  -import org.apache.xmlbeans.impl.jam.provider.DefaultJResultFactory;
  +import org.apache.xmlbeans.impl.jam.provider.DefaultJServiceFactory;
   
   import java.io.IOException;
   import java.io.File;
  @@ -42,7 +42,7 @@
     // ========================================================================
     // Constants
   
  -  private static final JServiceFactory DEFAULT = new DefaultJResultFactory();
  +  private static final JServiceFactory DEFAULT = new DefaultJServiceFactory();
   
     // ========================================================================
     // Singleton
  
  
  
  1.6       +7 -0      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JServiceParams.java
  
  Index: JServiceParams.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JServiceParams.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JServiceParams.java	2 Mar 2004 06:32:13 -0000	1.5
  +++ JServiceParams.java	3 Mar 2004 03:57:49 -0000	1.6
  @@ -15,6 +15,8 @@
   
   package org.apache.xmlbeans.impl.jam;
   
  +import org.apache.xmlbeans.impl.jam.provider.EClassInitializer;
  +
   import java.io.File;
   import java.io.PrintWriter;
   
  @@ -245,4 +247,9 @@
      * @throws IllegalArgumentException if either argument is null.
      */
     public File getRootForFile(File[] sourceRoots, File sourceFile);
  +
  +
  +  public void setCommentInitializer(EClassInitializer init);
  +
  +  public void addCustomInitializer(EClassInitializer init);
   }
  
  
  
  1.7       +3 -3      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/EClass.java
  
  Index: EClass.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/EClass.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- EClass.java	3 Mar 2004 00:01:42 -0000	1.6
  +++ EClass.java	3 Mar 2004 03:57:49 -0000	1.7
  @@ -150,9 +150,9 @@
     public void removeMethod(EMethod method);
   
     /**
  -   * Returns the EditableMethods declared on this class.  This does not include
  -   * methods from any base class or interface.  This is simply a more
  -   * strongly-typed version of getDeclaredMethods().
  +   * Returns the EditableMethods declared on this class.  This does not
  +   * include methods inherited from any base class or interface.  This is
  +   * simply a more strongly-typed version of getDeclaredMethods().
      */
     public EMethod[] getEditableMethods();
   
  
  
  
  1.5       +28 -0     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/EElement.java
  
  Index: EElement.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/EElement.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EElement.java	2 Mar 2004 04:26:18 -0000	1.4
  +++ EElement.java	3 Mar 2004 03:57:49 -0000	1.5
  @@ -23,6 +23,7 @@
    */
   public interface EElement extends JElement {
   
  +
     public void setSimpleName(String name);
   
     public ESourcePosition createSourcePosition();
  @@ -34,4 +35,31 @@
     public EAnnotation addNewAnnotation();
   
     public void removeAnnotation(EAnnotation ann);
  +
  +  /**
  +   * <p>Accepts the given visitor.</p>
  +   */
  +  public void accept(EElementVisitor visitor);
  +
  +  /**
  +   * <p>Calls accept() with the given visitor, and then recursively calls
  +   * acceptAndWalk for all of our component elements.  Calling this on
  +   * an EClass will cause the EClass to accept the visitor, and then
  +   * all of it's declared fields constructors, and methods.  The parameter
  +   * for each constructor and method will also in turn be accepted.
  +   * Any annotations for each of these element types will also be visited
  +   * after their other children have been visited.  Note that inherited
  +   * members are never visited, nor are referenced classes (e.g. referenced
  +   * via inheritance or member types).  </p>
  +   *
  +   * Class
  +   *   Field
  +   *   Method
  +   *     Parameter
  +   *   Constructor
  +   *     Parameter
  +   *
  +   * </p>
  +   */
  +  public void acceptAndWalk(EElementVisitor visitor);
   }
  
  
  
  1.1                  xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/EElementVisitor.java
  
  Index: EElementVisitor.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed 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.xmlbeans.impl.jam.editable;
  
  /**
   *
   * @author Patrick Calahan <pcal@bea.com>
   */
  public interface EElementVisitor {
  
    public void visit(EClass clazz);
  
    public void visit(EConstructor ctor);
  
    public void visit(EField field);
  
    public void visit(EMethod method);
  
    public void visit(EParameter param);
  
    //REVIEW i'm not sure we want to visit annotations and their members,
    //but we have little choice as long as they are elements.  Maybe that
    //needs to change.
    public void visit(EAnnotation param);
  
    public void visit(EAnnotationMember member);
  
  }
  
  
  
  1.3       +12 -0     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EAnnotationImpl.java
  
  Index: EAnnotationImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EAnnotationImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EAnnotationImpl.java	2 Mar 2004 04:26:18 -0000	1.2
  +++ EAnnotationImpl.java	3 Mar 2004 03:57:49 -0000	1.3
  @@ -166,4 +166,16 @@
       return 0;
     }
   
  +  // ========================================================================
  +  // EElement implementation
  +
  +  public void accept(EElementVisitor visitor) {
  +    visitor.visit(this);
  +  }
  +
  +  public void acceptAndWalk(EElementVisitor visitor) {
  +    accept(visitor);
  +    acceptAndWalkAll(visitor,getEditableMembers());
  +  }
  +
   }
  
  
  
  1.2       +17 -1     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EAnnotationMemberImpl.java
  
  Index: EAnnotationMemberImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EAnnotationMemberImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EAnnotationMemberImpl.java	1 Mar 2004 00:10:18 -0000	1.1
  +++ EAnnotationMemberImpl.java	3 Mar 2004 03:57:49 -0000	1.2
  @@ -15,6 +15,7 @@
   package org.apache.xmlbeans.impl.jam.editable.impl;
   
   import org.apache.xmlbeans.impl.jam.editable.EAnnotationMember;
  +import org.apache.xmlbeans.impl.jam.editable.EElementVisitor;
   import org.apache.xmlbeans.impl.jam.editable.impl.ref.DirectJClassRef;
   import org.apache.xmlbeans.impl.jam.editable.impl.ref.QualifiedJClassRef;
   import org.apache.xmlbeans.impl.jam.JAnnotation;
  @@ -239,4 +240,19 @@
     public char[] getValueAsCharArray() throws IllegalArgumentException {
       return new char[0];
     }
  -}
  +
  +
  +  // ========================================================================
  +  // EElement implementation
  +
  +  public void accept(EElementVisitor visitor) {
  +    visitor.visit(this);
  +  }
  +
  +  public void acceptAndWalk(EElementVisitor visitor) {
  +    accept(visitor);
  +    if (mValue instanceof EAnnotationMember) {
  +      ((EAnnotationMember)mValue).acceptAndWalk(visitor); //REVIEW is ok???
  +    }
  +  }
  +}
  \ No newline at end of file
  
  
  
  1.8       +12 -0     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EClassImpl.java
  
  Index: EClassImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EClassImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- EClassImpl.java	3 Mar 2004 00:01:42 -0000	1.7
  +++ EClassImpl.java	3 Mar 2004 03:57:49 -0000	1.8
  @@ -412,4 +412,16 @@
       }
     }
   
  +  public void accept(EElementVisitor visitor) {
  +    visitor.visit(this);
  +  }
  +
  +  public void acceptAndWalk(EElementVisitor visitor) {
  +    accept(visitor);
  +    acceptAndWalkAll(visitor,getEditableFields());
  +    acceptAndWalkAll(visitor,getEditableConstructors());
  +    acceptAndWalkAll(visitor,getEditableMethods());
  +    acceptAndWalkAll(visitor,getEditableAnnotations());
  +  }
  +
   }
  
  
  
  1.4       +15 -0     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EConstructorImpl.java
  
  Index: EConstructorImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EConstructorImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EConstructorImpl.java	25 Feb 2004 18:56:49 -0000	1.3
  +++ EConstructorImpl.java	3 Mar 2004 03:57:49 -0000	1.4
  @@ -17,6 +17,7 @@
   
   import org.apache.xmlbeans.impl.jam.editable.EConstructor;
   import org.apache.xmlbeans.impl.jam.editable.EParameter;
  +import org.apache.xmlbeans.impl.jam.editable.EElementVisitor;
   import org.apache.xmlbeans.impl.jam.JClass;
   import org.apache.xmlbeans.impl.jam.JParameter;
   
  @@ -36,5 +37,19 @@
     /*package*/ EConstructorImpl(EClassImpl containingClass) {
       super(containingClass.getSimpleName(),containingClass);
     }
  +
  +  // ========================================================================
  +  // EElement implementation
  +
  +  public void accept(EElementVisitor visitor) {
  +    visitor.visit(this);
  +  }
  +
  +  public void acceptAndWalk(EElementVisitor visitor) {
  +    accept(visitor);
  +    acceptAndWalkAll(visitor,getEditableParameters());
  +    acceptAndWalkAll(visitor,getEditableAnnotations());
  +  }
  +
   
   }
  
  
  
  1.7       +8 -0      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EElementImpl.java
  
  Index: EElementImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EElementImpl.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- EElementImpl.java	2 Mar 2004 22:03:04 -0000	1.6
  +++ EElementImpl.java	3 Mar 2004 03:57:49 -0000	1.7
  @@ -18,6 +18,7 @@
   import org.apache.xmlbeans.impl.jam.editable.EElement;
   import org.apache.xmlbeans.impl.jam.editable.ESourcePosition;
   import org.apache.xmlbeans.impl.jam.editable.EAnnotation;
  +import org.apache.xmlbeans.impl.jam.editable.EElementVisitor;
   import org.apache.xmlbeans.impl.jam.*;
   
   import java.util.List;
  @@ -152,6 +153,13 @@
     public int hashCode() {
       String qn = getQualifiedName();
       return (qn == null) ? 0 : qn.hashCode();
  +  }
  +
  +  // ========================================================================
  +  // Protected methods
  +
  +  protected void acceptAndWalkAll(EElementVisitor v, EElement[] elems) {
  +    for(int i=0; i<elems.length; i++) elems[i].acceptAndWalk(v);
     }
   
   
  
  
  
  1.4       +15 -0     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EFieldImpl.java
  
  Index: EFieldImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EFieldImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EFieldImpl.java	25 Feb 2004 18:56:49 -0000	1.3
  +++ EFieldImpl.java	3 Mar 2004 03:57:49 -0000	1.4
  @@ -16,6 +16,7 @@
   package org.apache.xmlbeans.impl.jam.editable.impl;
   
   import org.apache.xmlbeans.impl.jam.editable.EField;
  +import org.apache.xmlbeans.impl.jam.editable.EElementVisitor;
   import org.apache.xmlbeans.impl.jam.editable.impl.ref.JClassRef;
   import org.apache.xmlbeans.impl.jam.editable.impl.ref.QualifiedJClassRef;
   import org.apache.xmlbeans.impl.jam.editable.impl.ref.UnqualifiedJClassRef;
  @@ -55,6 +56,7 @@
       return getContainingClass().getQualifiedName()+"."+getSimpleName();
     }
   
  +
     // ========================================================================
     // EField implementation
   
  @@ -98,4 +100,17 @@
     public boolean isTransient() {
       return Modifier.isTransient(getModifiers());
     }
  +
  +  // ========================================================================
  +  // EElement implementation
  +
  +  public void accept(EElementVisitor visitor) {
  +    visitor.visit(this);
  +  }
  +
  +  public void acceptAndWalk(EElementVisitor visitor) {
  +    accept(visitor);
  +    acceptAndWalkAll(visitor,getEditableAnnotations());
  +  }
  +
   }
  
  
  
  1.6       +1 -1      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EInvokableImpl.java
  
  Index: EInvokableImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EInvokableImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- EInvokableImpl.java	3 Mar 2004 00:01:42 -0000	1.5
  +++ EInvokableImpl.java	3 Mar 2004 03:57:49 -0000	1.6
  @@ -32,7 +32,7 @@
    *
    * @author Patrick Calahan <pcal@bea.com>
    */
  -public class EInvokableImpl extends EMemberImpl implements EInvokable {
  +public abstract class EInvokableImpl extends EMemberImpl implements EInvokable {
   
     // ========================================================================
     // Variables
  
  
  
  1.5       +15 -0     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EMethodImpl.java
  
  Index: EMethodImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EMethodImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EMethodImpl.java	3 Mar 2004 00:01:42 -0000	1.4
  +++ EMethodImpl.java	3 Mar 2004 03:57:49 -0000	1.5
  @@ -16,6 +16,7 @@
   package org.apache.xmlbeans.impl.jam.editable.impl;
   
   import org.apache.xmlbeans.impl.jam.editable.EMethod;
  +import org.apache.xmlbeans.impl.jam.editable.EElementVisitor;
   import org.apache.xmlbeans.impl.jam.editable.impl.ref.UnqualifiedJClassRef;
   import org.apache.xmlbeans.impl.jam.editable.impl.ref.JClassRef;
   import org.apache.xmlbeans.impl.jam.editable.impl.ref.QualifiedJClassRef;
  @@ -94,4 +95,18 @@
     public boolean isSynchronized() {
       return Modifier.isSynchronized(getModifiers());
     }
  +
  +  // ========================================================================
  +  // EElement implementation
  +
  +  public void accept(EElementVisitor visitor) {
  +    visitor.visit(this);
  +  }
  +
  +  public void acceptAndWalk(EElementVisitor visitor) {
  +    accept(visitor);
  +    acceptAndWalkAll(visitor,getEditableParameters());
  +    acceptAndWalkAll(visitor,getEditableAnnotations());
  +  }
  +
   }
  
  
  
  1.6       +12 -0     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EParameterImpl.java
  
  Index: EParameterImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EParameterImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- EParameterImpl.java	3 Mar 2004 00:01:42 -0000	1.5
  +++ EParameterImpl.java	3 Mar 2004 03:57:49 -0000	1.6
  @@ -16,6 +16,7 @@
   package org.apache.xmlbeans.impl.jam.editable.impl;
   
   import org.apache.xmlbeans.impl.jam.editable.EParameter;
  +import org.apache.xmlbeans.impl.jam.editable.EElementVisitor;
   import org.apache.xmlbeans.impl.jam.editable.impl.ref.JClassRef;
   import org.apache.xmlbeans.impl.jam.editable.impl.ref.QualifiedJClassRef;
   import org.apache.xmlbeans.impl.jam.editable.impl.ref.DirectJClassRef;
  @@ -79,4 +80,15 @@
       return mTypeClassRef.getRefClass();
     }
   
  +  // ========================================================================
  +  // EElement implementation
  +
  +  public void accept(EElementVisitor visitor) {
  +    visitor.visit(this);
  +  }
  +
  +  public void acceptAndWalk(EElementVisitor visitor) {
  +    accept(visitor);
  +    acceptAndWalkAll(visitor,getEditableAnnotations());
  +  }
   }
  
  
  
  1.3       +10 -3     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/JClassLoaderImpl.java
  
  Index: JClassLoaderImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/JClassLoaderImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JClassLoaderImpl.java	3 Mar 2004 00:01:42 -0000	1.2
  +++ JClassLoaderImpl.java	3 Mar 2004 03:57:49 -0000	1.3
  @@ -54,10 +54,17 @@
     public JClassLoaderImpl(EClassBuilder builder,
                             EClassInitializer initializer) {
       if (builder == null) throw new IllegalArgumentException("null builder");
  +    if (initializer == null) throw new IllegalArgumentException("null initializer");
       mBuilder = builder;
       mInitializer = initializer;
     }
   
  +  public JClassLoaderImpl(EClassBuilder builder) {
  +    if (builder == null) throw new IllegalArgumentException("null builder");
  +    mBuilder = builder;
  +    mInitializer = null;
  +  }
  +
     // ========================================================================
     // JClassLoader implementation
   
  @@ -90,11 +97,11 @@
       if (out == null) {
         out = new EClassImpl(pkg,name,this,null);
         ((EClassImpl)out).setIsUnresolved(true);
  -      if (mVerbose) System.out.println("[JClassLoaderImpl] unresolve class '"+
  +      if (mVerbose) System.out.println("[JClassLoaderImpl] unresolved class '"+
                                          pkg+" "+name+"'!!");
       }
  -    if (out instanceof EClassImpl) {
  -      if (mInitializer != null) mInitializer.initialize((EClassImpl)out);
  +    if (mInitializer != null && out instanceof EClassImpl) {
  +      mInitializer.initialize((EClassImpl)out);
       }
       mFd2ClassCache.put(fd,out);
       return out;
  
  
  
  1.2       +3 -0      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/CompositeClassBuilder.java
  
  Index: CompositeClassBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/CompositeClassBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CompositeClassBuilder.java	2 Mar 2004 04:26:18 -0000	1.1
  +++ CompositeClassBuilder.java	3 Mar 2004 03:57:49 -0000	1.2
  @@ -23,6 +23,9 @@
    */
   public class CompositeClassBuilder implements EClassBuilder {
   
  +  // ========================================================================
  +  // Variables
  +
     private EClassBuilder[] mBuilders;
   
     // ========================================================================
  
  
  
  1.2       +1 -2      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/EClassInitializer.java
  
  Index: EClassInitializer.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/EClassInitializer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EClassInitializer.java	2 Mar 2004 04:26:18 -0000	1.1
  +++ EClassInitializer.java	3 Mar 2004 03:57:49 -0000	1.2
  @@ -30,8 +30,7 @@
      * <p>Note that the type to be initialized will never be an array type,
      * a primitive, 'void', or 'java.lang.Object'.</p>
      *
  -   * @return
      */
  -  public boolean initialize(EClass clazz);
  +  public void initialize(EClass clazz);
   
   }
  
  
  
  1.2       +25 -0     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/JServiceParamsImpl.java
  
  Index: JServiceParamsImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/JServiceParamsImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JServiceParamsImpl.java	2 Mar 2004 06:32:13 -0000	1.1
  +++ JServiceParamsImpl.java	3 Mar 2004 03:57:49 -0000	1.2
  @@ -51,6 +51,8 @@
     private boolean mUseSystemClasspath = true;
     private boolean mVerbose = false;
     private JClassLoader mParentClassloader = null;
  +  private EClassInitializer mCommentInitializer = null;
  +  private List mOtherInitializers = null;
   
     // ========================================================================
     // Constructors
  @@ -206,6 +208,15 @@
       mUseSystemClasspath = use;
     }
   
  +  public void setCommentInitializer(EClassInitializer init) {
  +    mCommentInitializer = init;
  +  }
  +
  +  public void addCustomInitializer(EClassInitializer init) {
  +    if (mOtherInitializers == null) mOtherInitializers = new ArrayList();
  +    mOtherInitializers.add(init);
  +  }
  +
     // ========================================================================
     // JStoreParams implementation
   
  @@ -243,6 +254,20 @@
         }
       }
       return null;
  +  }
  +
  +  public EClassInitializer getInitializer() {
  +    List initers = new ArrayList();
  +    if (mCommentInitializer != null) {
  +      initers.add(mCommentInitializer);
  +    } else {
  +      //FIXME initers.add(new DefaultCommentInitializer());
  +    }
  +    if (mOtherInitializers != null) initers.addAll(mOtherInitializers);
  +    // now go
  +    EClassInitializer[] inits = new EClassInitializer[initers.size()];
  +    initers.toArray(inits);
  +    return new CompositeClassInitializer(inits);
     }
   
   
  
  
  
  1.4       +2 -0      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/JStoreParams.java
  
  Index: JStoreParams.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/JStoreParams.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JStoreParams.java	2 Mar 2004 06:32:13 -0000	1.3
  +++ JStoreParams.java	3 Mar 2004 03:57:49 -0000	1.4
  @@ -109,4 +109,6 @@
     public Properties getProperties();
   
     public JClassLoader getParentClassLoader();
  +
  +  public EClassInitializer getInitializer();
   }
  
  
  
  1.3       +2 -2      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/NewJServiceFactory.java
  
  Index: NewJServiceFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/NewJServiceFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NewJServiceFactory.java	3 Mar 2004 00:01:42 -0000	1.2
  +++ NewJServiceFactory.java	3 Mar 2004 03:57:49 -0000	1.3
  @@ -24,7 +24,7 @@
    *
    * @author Patrick Calahan <pcal@bea.com>
    */
  -public class NewJServiceFactory extends DefaultJResultFactory {
  +public class NewJServiceFactory extends DefaultJServiceFactory {
   
     /**
      * <p>Creates the sourcefile classloader to be used given the input params.
  @@ -40,7 +40,7 @@
       // FIXME this is a temporary hack - we shouldnt have to do this
       builders[1] = ReflectionClassBuilder.getSystemClassBuilder();
       CompositeClassBuilder ccb = new CompositeClassBuilder(builders);
  -    return new JClassLoaderImpl(ccb,null);
  +    return new JClassLoaderImpl(ccb,params.getInitializer());
     }
   
   }
  
  
  
  1.1                  xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/CompositeClassInitializer.java
  
  Index: CompositeClassInitializer.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed 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.xmlbeans.impl.jam.provider;
  
  import org.apache.xmlbeans.impl.jam.editable.EClass;
  
  /**
   *
   * @author Patrick Calahan <pcal@bea.com>
   */
  public class CompositeClassInitializer implements EClassInitializer {
  
    // ========================================================================
    // Variables
  
    private EClassInitializer[] mIniters;
  
    // ========================================================================
    // Constructors
  
    public CompositeClassInitializer(EClassInitializer[] initers) {
      if (initers == null) throw new IllegalArgumentException("null initers");
      mIniters = initers;
    }
  
    // ========================================================================
    // EClassBuilder implementation
  
    public void initialize(EClass clazz) {
      for(int i=0; i<mIniters.length; i++) mIniters[i].initialize(clazz);
    }
  
  }
  
  
  1.1                  xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/DefaultCommentProcessor.java
  
  Index: DefaultCommentProcessor.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed 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.xmlbeans.impl.jam.provider;
  
  import org.apache.xmlbeans.impl.jam.editable.*;
  import org.apache.xmlbeans.impl.jam.JComment;
  
  import java.io.*;
  
  /**
   *
   * @author Patrick Calahan <pcal@bea.com>
   */
  public class DefaultCommentProcessor
          implements EClassInitializer, EElementVisitor {
  
    // ========================================================================
    // Singleton
  
    public static EClassInitializer getInstance() { return INSTANCE; }
  
    private static EClassInitializer INSTANCE = new DefaultCommentProcessor();
  
    private DefaultCommentProcessor() {}
  
    // ========================================================================
    // EClassInitializer implementation
  
    public void initialize(EClass clazz) {
      clazz.acceptAndWalk(this);
    }
  
    // ========================================================================
    // EElementVisitor implementation - nothing to see here
  
    public void visit(EClass clazz)             { visit((EElement)clazz); }
    public void visit(EConstructor ctor)        { visit((EElement)ctor); }
    public void visit(EField field)             { visit((EElement)field); }
    public void visit(EMethod method)           { visit((EElement)method); }
    public void visit(EParameter param)         { visit((EElement)param); }
    public void visit(EAnnotation ann)          { visit((EElement)ann); }
    public void visit(EAnnotationMember member) { visit((EElement)member); }
  
    // ========================================================================
    // Protected methods
  
    protected void visit(EElement element) {
      /*
      EComment[] comments = element.getEditableComments();
      if (comments == null || comments.length == 0) return;
      for(int i=0; i<comments.length; i++) {
        String text = comments[i].getText().trim();
        if (!text.startsWith("/*")) {
          element.removeComment(comments[i]);
        } else {
          StringWriter sw = new StringWriter();
          BufferedWriter out = new BufferedWriter(sw);
          BufferedReader in = new BufferedReader(new StringReader(text));
          String line;
          try {
            while((line = in.readLine()) != null) {
              line = line.trim();
              if (line.equalsxxxfixme("* /")) continue;
              int offset = line.indexOf('*');
              if (offset == line.length()) continue;
              out.write(line.substring(offset+1));
            }
            comments[i].setText(sw.toString());
          } catch(IOException veryUnexpected) {
            veryUnexpected.printStackTrace();
          }
        }
        }
  */
    }
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/DefaultJServiceFactory.java
  
  Index: DefaultJServiceFactory.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed 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.xmlbeans.impl.jam.provider;
  
  import org.apache.xmlbeans.impl.jam.JServiceFactory;
  import org.apache.xmlbeans.impl.jam.JServiceParams;
  import org.apache.xmlbeans.impl.jam.JService;
  import org.apache.xmlbeans.impl.jam.JClassLoader;
  import org.apache.xmlbeans.impl.jam.internal.RootJClassLoader;
  import org.apache.xmlbeans.impl.jam.internal.javadoc.JDClassLoaderFactory;
  
  import java.io.IOException;
  import java.io.File;
  import java.net.URL;
  import java.net.URLClassLoader;
  
  /**
   * <p>Default implementation of JServiceFactory.  It currently uses javadoc
   * for inspecting sources and reflection for inspecting classes.</p>
   *
   * <p>Note that this class can be used as a base class for custom factories.
   * </p>
   *
   * @author Patrick Calahan <pcal@bea.com>
   */
  public class DefaultJServiceFactory extends JServiceFactory {
  
    // ========================================================================
    // Constructors
  
    public DefaultJServiceFactory() {}
  
    // ========================================================================
    // JServiceFactory implementation
  
    public JServiceParams createServiceParams() {
      return new JServiceParamsImpl();
    }
  
    public JService createService(JServiceParams jsps) throws IOException {
      //assert that they aren't implementing JServiceParams themselves or
      //getting them from somewhere else
      if (!(jsps instanceof JServiceParamsImpl)) {
        throw new IllegalArgumentException
                ("JServiceParams must be instantiated by this JServiceFactory.");
      }
      //create and return the service
      return new JServiceImpl(createClassLoader((JServiceParamsImpl)jsps),
                             getSpecifiedClasses((JServiceParamsImpl)jsps));
    }
  
    // ========================================================================
    // Protected methods - override at your own risk
  
    /**
     * <p>Returns the set of classes to be included in a JService to be
     * created by the given params.  You should not override this
     * unless you really know what you're doing.</p>
     */
    protected String[] getSpecifiedClasses(JServiceParamsImpl params)
            throws IOException
    {
      return params.getAllClassnames();
    }
  
    /**
     * <p>Creates the main classloader to be used given the input params.
     * This is usually a composite of the source classloader and a
     * classfile classloader.  Subclasses may override to change the behavior.
     * </p>
     */
    protected JClassLoader createClassLoader(JServiceParamsImpl params)
            throws IOException
    {
      // Build up the clasloader chain.  Note that each loader we create is
      // used as a parent of the next.
      //
      // The root classloader deals with Object, void, primitives, arrays...
      JClassLoader loader = new RootJClassLoader();
      // Usually they will also want the system classloader in there, but this
      // is optional
      if (params.isUseSystemClasspath()) {
        loader = ReflectionClassBuilder.createRClassLoader
                (ClassLoader.getSystemClassLoader());
      }
      // Now create a loader for any classfile loading they specified
      JClassLoader classfileLoader = createClassfileLoader(params,loader);
      if (classfileLoader != null) loader = classfileLoader;
      // Finally check for sources
      JClassLoader sourceLoader = createSourceLoader(params,loader);
      if (sourceLoader != null) loader = sourceLoader;
      //
      return loader;
    }
  
  
    /**
     * <p>Creates the sourcefile classloader to be used given the input params.
     * Returns null if no source files are specified in the params.  Subclasses
     * may override to change the way in which java sources are loaded.</p>
     */
    protected JClassLoader createSourceLoader(JServiceParamsImpl params,
                                              JClassLoader parent)
            throws IOException
    {
      //FIXME someday should make the name of the service class to use here
      //settable via a system property
      File[] files = params.getSourceFiles();
      if (files == null || files.length == 0) return null;
      String sourcePath = (params.getInputSourcepath() == null) ? null :
              params.getInputSourcepath().toString();
      String classPath = (params.getInputClasspath() == null) ? null :
              params.getInputClasspath().toString();
      return JDClassLoaderFactory.getInstance().
              create(files,
                     parent,
                     params.getAnnotationLoader(),
                     params.getOut(),
                     sourcePath,
                     classPath,
                     null);//FIXME get javadoc args from param props
    }
  
    /**
     * <p>Creates the sourcefile classloader to be used given the input params.
     * If no class files or classloaders are specified in the params, this
     * source files are specified in the params, this just returns null.
     * Subclasses may override to change the way in which java classes
     * are loaded.</p>
     */
    protected JClassLoader createClassfileLoader(JStoreParams jp,
                                                 JClassLoader parent)
            throws IOException
    {
  
      //FIXME someday should make the name of the service class to use here
      //settable via a system property
      JPath cp = jp.getInputClasspath();
      if (cp == null) {
        return null;
      } else {
        URL[] urls = cp.toUrlPath();
        ClassLoader cl = new URLClassLoader(urls);
        return ReflectionClassBuilder.createRClassLoader(cl);
      //  return new RClassLoader(,parent);
      }
    }
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/ElementProcessor.java
  
  Index: ElementProcessor.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed 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.xmlbeans.impl.jam.provider;
  
  import org.apache.xmlbeans.impl.jam.editable.EElement;
  
  /**
   *
   * @author Patrick Calahan <pcal@bea.com>
   */
  public interface ElementProcessor {
  
    public void process(EElement e);
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/ElementWalker.java
  
  Index: ElementWalker.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed 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.xmlbeans.impl.jam.provider;
  
  import org.apache.xmlbeans.impl.jam.editable.EClass;
  
  /**
   *
   * @author Patrick Calahan <pcal@bea.com>
   */
  public class ElementWalker {
  
    // ========================================================================
    // Variables
  
    private ElementProcessor mProcessor;
  
    // ========================================================================
    // Constructors
  
    public ElementWalker(ElementProcessor p) {
      mProcessor = p;
    }
  
    // ========================================================================
    // Public methods
  
    public void walk(EClass clazz) {
      mProcessor.process(clazz);
    }
  
  
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org


Mime
View raw message