Update of /cvsroot/xdoclet/xdoclet2/core/src/java/xdoclet
In directory sc8-pr-cvs1:/tmp/cvs-serv31722/core/src/java/xdoclet

Modified Files:
        Accept.java Generator.java Plugin.java PluginFactory.java 
        XDoclet.java 
Added Files:
        AntElementContainer.java CollectionFactory.java 
Log Message:
-Refactored out xjavadoc, so XDoclet can now be used with a different source (like JDT)
-Refactored some functionality from Plugin down to Generator


--- NEW FILE: AntElementContainer.java ---
package xdoclet;

/**
 * Classes that implement this interface will be able to have sub elements if
 * used from within Ant. This makes it possible to keep XDoclet Ant aware
 * without any compile-time or run-time dependencies to Ant.
 *
 * @author <a href="mailto:aslak.hellesoy at bekk.no">Aslak Helles&oslash;y</a>
 * @version $Revision: 1.1 $
 */
public interface AntElementContainer
{
    public Object createElement(String name) throws XDocletException;
}

--- NEW FILE: CollectionFactory.java ---
package xdoclet;

import java.util.Collection;

/**
 * A factory for creation of a Collection of objects to use during code generation.
 * This is a delegator for Plugin. It abstracts away the generation source,
 * making it possible to use XDoclet with other sources than XJavadoc.
 *
 * @author <a href="mailto:aslak.hellesoy at bekk.no">Aslak Helles&oslash;y</a>
 * @version $Revision: 1.1 $
 */
public interface CollectionFactory {
    /**
     * Returns a Collection of objects that should be used as basis for code 
generation.
     * It's up to the Generators to handle this Collection. Special Generators
     * will expect the elements in the Collection to be of a certain type.
     *
     * @return Collection of arbitrary objects
     */
    Collection getCollection();
}

Index: Accept.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/core/src/java/xdoclet/Accept.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Accept.java 10 Feb 2003 13:22:59 -0000      1.3
--- Accept.java 18 Feb 2003 00:05:07 -0000      1.4
***************
*** 15,19 ****
   * @version $Revision$
   */
! public class Accept implements Predicate
  {
      private Predicate _predicate = null;
--- 15,19 ----
   * @version $Revision$
   */
! public class Accept implements Predicate, AntElementContainer
  {
      private Predicate _predicate = null;
***************
*** 29,33 ****
       * @throws XDocletException
       */
!     public Object createElement(String predicateType) throws PredicateException, 
XDocletException
      {
          if (_predicate != null) {
--- 29,33 ----
       * @throws XDocletException
       */
!     public Object createElement(String predicateType) throws XDocletException
      {
          if (_predicate != null) {
***************
*** 39,43 ****
      }
  
!     public void setPredicate(Predicate predicate) throws XDocletException
      {
          _predicate = predicate;
--- 39,43 ----
      }
  
!     public void setPredicate(Predicate predicate)
      {
          _predicate = predicate;

Index: Generator.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/core/src/java/xdoclet/Generator.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -r1.23 -r1.24
*** Generator.java      11 Feb 2003 08:45:51 -0000      1.23
--- Generator.java      18 Feb 2003 00:05:07 -0000      1.24
***************
*** 6,11 ****
  
  import xjavadoc.XClass;
- import xjavadoc.ClassIterator;
- import xjavadoc.XCollections;
  
  import java.io.*;
--- 6,9 ----
***************
*** 14,24 ****
  
  import org.apache.commons.logging.LogFactory;
  
  /**
!  * A generator is responsible for generating a particular kind of file. It is
   * also an abstraction of underlying generation mechanisms such as Velocity,
   * Castor, Zeus, Jelly and possibly others. A generator instance will typically
!  * be used to generate one kind of file. It can operate in three different modes:
!  * {@link #MODE_PER_CLASS}, {@link #MODE_FOR_ALL_CLASSES} and {@link #MODE_CUSTOM}.
   * <p>
   * You might wonder why this class isn't abstract. It's because it uses a simplified
--- 12,26 ----
  
  import org.apache.commons.logging.LogFactory;
+ import org.apache.commons.collections.CollectionUtils;
  
  /**
!  * The main responsabilitiy of a a Generator is to generate a particular kind of 
file. It is
   * also an abstraction of underlying generation mechanisms such as Velocity,
   * Castor, Zeus, Jelly and possibly others. A generator instance will typically
!  * be used to generate one kind of file. It can operate in two different modes,
!  * depending on the value of the fileName. If there is a "{0}" in the fileName,
!  * one file will be generated for each object returned by {@link #getCollection}.
!  * If there is no "{0}" in the fileName, one file will be generated for each object
!  * returned by {@link #getCollection}.
   * <p>
   * You might wonder why this class isn't abstract. It's because it uses a simplified
***************
*** 31,35 ****
   * This is why Generator is concrete; So that adaptees can be made easily without 
having to subclass.
   *
-  * @see #getGenerationMode
   *
   * @author    <a href="mailto:aslak.hellesoy at netcom.no">Aslak Helles&oslash;y</a>
--- 33,36 ----
***************
*** 38,41 ****
--- 39,46 ----
  public class Generator extends Plugin
  {
+     public static final String ACCEPT = "accept";
+     public static final String PROPERTY = "property";
+ 
+ 
      private Plugin _plugin;
  
***************
*** 48,60 ****
      private String _encoding = "ISO-8859-1";
  
!     /**
!      * Subclasses can call this method prior to generation to put additional objects 
on the context.
!      *
!      * @return a Map that will be put on Velocity's context.
!      */
!     protected final Map getContextObjects()
!     {
!         return _contextObjects;
!     }
  
      /**
--- 53,57 ----
      private String _encoding = "ISO-8859-1";
  
!     private Accept _accept = null;
  
      /**
***************
*** 63,68 ****
      private String _packageName = null;
  
      /**
!      * DON'T access this variable directly. Use the getPackageName() method
       */
      private String _fileName;
--- 60,68 ----
      private String _packageName = null;
  
+     /** Delegate that provides us with a Collection of objects. */
+     private CollectionFactory _collectionFactory;
+ 
      /**
!      * DON'T access this variable directly. Use the getFileName() method
       */
      private String _fileName;
***************
*** 74,97 ****
      private Generator _adaptee;
  
-     private int _generationMode = -1;
- 
-     /**
-      * This generation mode should be used when exactly one file should be generated 
per class.
-      * See {@link xdoclet.generators.XMLGenerator} for an example.
-      */
-     protected static final int MODE_PER_CLASS = 0;
- 
-     /**
-      * This generation mode should be used when exactly one file should be generated 
per class.
-      */
-     protected static final int MODE_FOR_ALL_CLASSES = 1;
- 
-     /**
-      * This generation mode should be used when the number of files to generate does 
not match
-      * the number of classes or is equal to one. See {@link 
xdoclet.plugins.xmlFacade.InterfaceGenerator}
-      * for an example.
-      */
-     protected static final int MODE_CUSTOM = 2;
- 
      public Generator()
      {
--- 74,77 ----
***************
*** 110,113 ****
--- 90,103 ----
  
      /**
+      * Subclasses can call this method prior to generation to put additional objects 
+on the context.
+      *
+      * @return a Map that will be put on Velocity's context.
+      */
+     protected final Map getContextObjects()
+     {
+         return _contextObjects;
+     }
+ 
+     /**
       * Sets the owner plugin.
       *
***************
*** 156,159 ****
--- 146,158 ----
      }
  
+     public final Accept createAccept()
+     {
+         if (_accept != null) {
+             throw new IllegalStateException("Only one accept is allowed");
+         }
+         _accept = new Accept();
+         return _accept;
+     }
+ 
      private final void setDynamicProperties()
      {
***************
*** 171,210 ****
      final void generate() throws XDocletException
      {
          setDynamicProperties();
          setStandardContextObjects();
  
          File destinationFile;
!         switch (getGenerationMode()) {
!             case MODE_PER_CLASS:
!                 if (getPlugin().getAcceptedClasses().isEmpty()) {
!                     LogFactory.getLog(Generator.class).warn("WARNING: No sources 
matched for " + getPlugin().getName() + "#" + getName());
!                 }
!                 // Generate one file for each class.
!                 for (ClassIterator classIterator = 
XCollections.classIterator(getPlugin().getAcceptedClasses());
!                      classIterator.hasNext();) {
!                     XClass clazz = classIterator.next();
!                     destinationFile = getDestinationFileForClass(clazz);
!                     printGenerationInfo(destinationFile);
!                     generateForClass(destinationFile, clazz);
!                 }
!                 break;
! 
!             case MODE_FOR_ALL_CLASSES:
!                 // Only generateForClasses one file for all classes.
!                 destinationFile = getDestinationFileForClasses();
!                 printGenerationInfo(destinationFile);
!                 generateForClasses(destinationFile);
!                 break;
! 
!             case MODE_CUSTOM:
!                 for (Iterator i = getCustomObjects().iterator(); i.hasNext();) {
!                     Object o = i.next();
!                     destinationFile = getDestinationFileForCustom(o);
!                     printGenerationInfo(destinationFile);
!                     generateForCustom(destinationFile, o);
!                 }
!                 break;
!             default:
!                 throw new IllegalStateException("Illegal generation mode: " + 
getGenerationMode() + " (generator=" + Generator.class.getName() + ") You must set the 
generationMode.");
          }
      }
--- 170,193 ----
      final void generate() throws XDocletException
      {
+         if (getCollection().isEmpty()) {
+             LogFactory.getLog(Generator.class).warn("WARNING: No objects matched for 
+" + getPlugin().getName());
+         }
+ 
          setDynamicProperties();
          setStandardContextObjects();
  
          File destinationFile;
!         if (getFileName().indexOf("{0}") != -1) {
!             LogFactory.getLog(Generator.class).info("Generating " + getFileName() + 
"...");
!             for (Iterator i = getFilteredCollection().iterator(); i.hasNext();) {
!                 Object o = i.next();
!                 destinationFile = getDestinationFileForOne(o);
!                 LogFactory.getLog(Generator.class).info("Generating " + 
destinationFile.getAbsolutePath());
!                 generateOneFileForEach(destinationFile, o);
!             }
!         } else {
!                 destinationFile = getDestinationFileForAll();
!                 LogFactory.getLog(Generator.class).info("Generating " + 
destinationFile.getAbsolutePath());
!                 generateOneFileForAll(destinationFile);
          }
      }
***************
*** 219,223 ****
      }
  
!     public final String getFileNamePattern() throws XDocletException
      {
          assert getAdaptee() != null : "getAdaptee() is null";
--- 202,250 ----
      }
  
!     /**
!      * Gets all accepted objects. Subclasses can control what's accepted
!      * by calling {@link #createAccept} and call setPredicate on it, using
!      * a predicate from the xdoclet.util.predicates package. If no predicate
!      * is set, all classes that were parsed will be returned.
!      *
!      * @return all accepted classes.
!      */
!     protected final Collection getFilteredCollection()
!     {
!         // Get all the classes including inner classes.
!         Collection classes = getCollection();
! 
!         if (_accept != null) {
!             // Filter out the classes we want. Depends on accept( XClass )
!             return CollectionUtils.select(classes, _accept);
!         }
!         else {
!             return classes;
!         }
!     }
! 
!     /**
!      * Sets the CollectionFactory. If no CollectionFactory is set,
!      * XJavadocCollectionFactory will be used.
!      * @param collectionFactory
!      */
!     protected void setCollectionFactory(CollectionFactory collectionFactory) {
!         _collectionFactory = collectionFactory;
!     }
! 
!     public Collection getCollection() {
!         if(_collectionFactory == null) {
!             // Use xdoclet.xjavadoc.XJavadocCollectionFactory as default.
!             try {
!                 _collectionFactory = (CollectionFactory) 
Class.forName("xdoclet.xjavadoc.XJavadocCollectionFactory").newInstance();
!             } catch( Exception e ) {
!                 // This should never happen
!                 throw new IllegalStateException(e.getMessage());
!             }
!         }
!         return _collectionFactory.getCollection();
!     }
! 
!     public final String getFileName() throws XDocletException
      {
          assert getAdaptee() != null : "getAdaptee() is null";
***************
*** 234,275 ****
      }
  
-     private static final void printGenerationInfo(File file)
-     {
-         LogFactory.getLog(Generator.class).debug("Generating " + 
file.getAbsolutePath());
-     }
- 
-     /**
-      * Sets the generation mode. Legal values are {@link #MODE_PER_CLASS},
-      * {@link #MODE_FOR_ALL_CLASSES} and {@link #MODE_CUSTOM}. Subclases must
-      * implement this method and return one of the legal values.
-      * Depending on what this method returns, one of the following methods must be 
implemented:
-      * <ul>
-      *     <li>MODE_PER_CLASS -> {@link #generateForClass(File,XClass)}</li>
-      *     <li>MODE_FOR_ALL_CLASSES -> {@link #generateForClasses(File)}</li>
-      *     <li>MODE_CUSTOM -> {@link #generateForCustom(File,Object)} and </li>
-      * </ul>
-      * The owner plugin will call this method to figure out whether a generator
-      * should be invoked only once or several times.
-      *
-      * @param generationMode the generation mode
-      */
-     public void setGenerationMode(int generationMode)
-     {
-         _generationMode = generationMode;
-     }
- 
-     protected final int getGenerationMode()
-     {
-         return _generationMode;
-     }
- 
      /**
!      * Generates for all classes. Must be overridden if {@link #getGenerationMode()}
!      * is implemented to return {@link #MODE_PER_CLASS}.
       *
       * @param file where the generated content will be written.
       * @throws XDocletException if generation fails.
       */
!     protected void generateForClasses(File file) throws XDocletException
      {
          throw new UnsupportedOperationException();
--- 261,272 ----
      }
  
      /**
!      * Generates one file for all objects. Must be overridden if this generator
!      * is intended to be used without "{0}" in the fileName.
       *
       * @param file where the generated content will be written.
       * @throws XDocletException if generation fails.
       */
!     protected void generateOneFileForAll(File file) throws XDocletException
      {
          throw new UnsupportedOperationException();
***************
*** 277,313 ****
  
      /**
!      * Generates for one class. Must be overridden if {@link #getGenerationMode()}
!      * is implemented to return {@link #MODE_FOR_ALL_CLASSES}.
       *
!      * @param clazz the class to generate for.
       * @param file where the generated content will be written.
       * @throws XDocletException if generation fails.
       */
!     protected void generateForClass(File file, XClass clazz) throws XDocletException
!     {
!         throw new UnsupportedOperationException();
!     }
! 
!     /**
!      * Generates for one class. Must be overridden if {@link #getGenerationMode()}
!      * is implemented to return {@link #MODE_CUSTOM}.
!      *
!      * @param custom the custom object to generate for.
!      * @param file where the generated content will be written.
!      * @throws XDocletException if generation fails.
!      */
!     protected void generateForCustom(File file, Object custom) throws 
XDocletException
!     {
!         throw new UnsupportedOperationException();
!     }
! 
!     /**
!      * Returns a Collection of custom objects to generate for. Must be overridden if 
{@link #getGenerationMode()}
!      * is implemented to return {@link #MODE_CUSTOM}. One file will be generated for 
each object in this collection.
!      *
!      * @return a Collection of some custom type.
!      * @throws XDocletException
!      */
!     protected Collection getCustomObjects() throws XDocletException
      {
          throw new UnsupportedOperationException();
--- 274,285 ----
  
      /**
!      * Generates one file for each objects. Must be overridden if this generator
!      * is intended to be used with "{0}" in the fileName.
       *
!      * @param object the object to generate for.
       * @param file where the generated content will be written.
       * @throws XDocletException if generation fails.
       */
!     protected void generateOneFileForEach(File file, Object object) throws 
XDocletException
      {
          throw new UnsupportedOperationException();
***************
*** 335,340 ****
  
      /**
!      * Returns the destination file derived from a particular class. Will be called 
if
!      * {@link #getGenerationMode} returns {@link #MODE_PER_CLASS}
       *
       * @param clazz the class the generated file is derived from
--- 307,312 ----
  
      /**
!      * Returns the destination file derived from a particular object. Will be
!      * called if fileName has "{0}" in it.
       *
       * @param clazz the class the generated file is derived from
***************
*** 348,389 ****
  
          // get the resulting file name
!         String fileName = MessageFormat.format(getFileNamePattern(), new 
String[]{clazz.getName()});
  
-         // Here we do a trick. If packageName is not set, we set it to that of the 
class.
-         // We need some more fancy package substiturion here, maybe using regexp
-         if (getPackageName().equals("")) {
-             assert clazz.getContainingPackage() != null : "the containing package 
for clazz " + clazz.getName() + " is null";
-             setPackageName(clazz.getContainingPackage().getName());
-         }
  
          return new File(getAndCreateRealDestDir(), fileName);
      }
  
      /**
!      * Returns the destination file derived from all classes. Will be called if
!      * {@link #getGenerationMode} returns {@link #MODE_FOR_ALL_CLASSES}
       *
       * @return the File where content will be written
       * @throws XDocletException
       */
!     public final File getDestinationFileForClasses() throws XDocletException
      {
!         return new File(getAndCreateRealDestDir(), getFileNamePattern());
      }
  
      /**
!      * Returns the destination file derived from a custom object. Will be called if
!      * {@link #getGenerationMode} returns {@link #MODE_CUSTOM}
       *
!      * @param custom the object the generated file is derived from
       * @return the File where content will be written
       * @throws XDocletException
       */
!     public final File getDestinationFileForCustom(Object custom) throws 
XDocletException
      {
!         if (custom == null)
!             throw new IllegalArgumentException("custom cannot be null");
  
!         String fileName = MessageFormat.format(getFileNamePattern(), new 
String[]{getFileNameSubstitutionValue(custom)});
          return new File(getAndCreateRealDestDir(), fileName);
      }
--- 320,369 ----
  
          // get the resulting file name
!         String fileName = MessageFormat.format(getFileName(), new 
String[]{clazz.getName()});
  
  
          return new File(getAndCreateRealDestDir(), fileName);
      }
  
+ 
+ 
      /**
!      * Returns the destination file derived from a particular object. Will be
!      * called if fileName does not have "{0}" in it.
       *
       * @return the File where content will be written
       * @throws XDocletException
       */
!     public final File getDestinationFileForAll() throws XDocletException
      {
!         return new File(getAndCreateRealDestDir(), getFileName());
      }
  
      /**
!      * Returns the destination file derived from a particular object. Will be
!      * called if fileName has "{0}" in it.
       *
!      * @param object the object the generated file is derived from
       * @return the File where content will be written
       * @throws XDocletException
       */
!     public final File getDestinationFileForOne(Object object) throws XDocletException
      {
!         String fileNameSubstitutionValue;
!         if( object instanceof XClass ) {
!             XClass clazz = (XClass) object;
!             fileNameSubstitutionValue = clazz.getName();
! 
!             // Here we do a trick. If packageName is not set, we set it to that of 
the class.
!             // We need some more fancy package substiturion here, maybe using regexp
!             if (getPackageName().equals("")) {
!                 assert clazz.getContainingPackage() != null : "the containing 
package for clazz " + clazz.getName() + " is null";
!                 setPackageName(clazz.getContainingPackage().getName());
!             }
!         } else {
!             fileNameSubstitutionValue = getFileNameSubstitutionValue(object);
!         }
  
!         String fileName = MessageFormat.format(getFileName(), new 
String[]{fileNameSubstitutionValue});
          return new File(getAndCreateRealDestDir(), fileName);
      }
***************
*** 393,400 ****
       * name.
       *
!      * @param custom the object the substitution string should be derived from.
       * @return the substitution string.
       */
!     protected String getFileNameSubstitutionValue(Object custom)
      {
          throw new UnsupportedOperationException();
--- 373,380 ----
       * name.
       *
!      * @param object the object the substitution string should be derived from.
       * @return the substitution string.
       */
!     protected String getFileNameSubstitutionValue(Object object)
      {
          throw new UnsupportedOperationException();
***************
*** 405,420 ****
       * Currently only <property> is allowed.
       *
!      * @param type
       * @return
       */
!     public Object createElement(String type)
      {
!         if ("property".equalsIgnoreCase(type)) {
              Property property = new Property();
              _dynamicProperties.add(property);
              return property;
          }
          else {
!             throw new IllegalArgumentException("Only property is allowed here, not " 
+ type);
          }
      }
--- 385,402 ----
       * Currently only <property> is allowed.
       *
!      * @param elementType
       * @return
       */
!     public Object createElement(String elementType) throws XDocletException
      {
!         if (PROPERTY.equals(elementType)) {
              Property property = new Property();
              _dynamicProperties.add(property);
              return property;
+         } else if (ACCEPT.equals(elementType)) {
+             return createAccept();
          }
          else {
!             throw new XDocletException("Only <property> and <accept> is allowed 
here, not <" + elementType + ">");
          }
      }

Index: Plugin.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/core/src/java/xdoclet/Plugin.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** Plugin.java 11 Feb 2003 11:29:54 -0000      1.19
--- Plugin.java 18 Feb 2003 00:05:08 -0000      1.20
***************
*** 9,18 ****
  import java.util.*;
  
- import org.apache.commons.collections.CollectionUtils;
  import org.apache.commons.logging.LogFactory;
  
  import xdoclet.generators.VelocityGenerator;
! 
! import xjavadoc.XJavaDoc;
  
  /**
--- 9,16 ----
  import java.util.*;
  
  import org.apache.commons.logging.LogFactory;
  
  import xdoclet.generators.VelocityGenerator;
! import xdoclet.generators.JellyGenerator;
  
  /**
***************
*** 29,34 ****
  public class Plugin extends XDoclet
  {
-     public static final String ACCEPT = "accept";
- 
      public static final String GENERATOR = "generator";
      public static final String VELOCITY_GENERATOR = "velocitygenerator";
--- 27,30 ----
***************
*** 38,41 ****
--- 34,40 ----
      private File _destination;
  
+     /** The directory where merge files will be retrieved from. */
+     private File _mergedir;
+ 
      /** The instance of XDoclet we're under. Set by XDoclet when we're added to it. 
*/
      private XDoclet _xdoclet;
***************
*** 52,57 ****
      private List _dynamicGenerators = new ArrayList();
  
-     private Accept _accept = null;
- 
      public Plugin()
      {
--- 51,54 ----
***************
*** 90,94 ****
      {
          _destination = new File(destination);
!         LogFactory.getLog(getClass()).debug("Destination:" + 
_destination.getAbsolutePath());
      }
  
--- 87,104 ----
      {
          _destination = new File(destination);
!     }
! 
!     public void setMergedir(String mergedir)
!     {
!         _mergedir = new File(mergedir);
!     }
! 
!     /**
!      * Gets the Mergedir attribute of the Entity20Plugin object
!      *
!      * @return The Mergedir value
!      */
!     public File getMergedir() {
!        return _mergedir;
      }
  
***************
*** 102,113 ****
      }
  
-     public Accept createAccept() throws XDocletException
-     {
-         if (_accept != null) {
-             throw new XDocletException("Only one accept is allowed");
-         }
-         _accept = new Accept();
-         return _accept;
-     }
  
      /**
--- 112,115 ----
***************
*** 122,137 ****
      {
          Object result = null;
!         if (ACCEPT.equals(elementType)) {
!             return createAccept();
!         }
!         else if (VELOCITY_GENERATOR.equals(elementType)) {
              result = new VelocityGenerator();
          }
          else if (GENERATOR.equals(elementType)) {
              result = new Generator();
          }
-         else {
-             throw new XDocletException("Unknown result type: " + elementType);
-         }
          _dynamicGenerators.add(result);
          return result;
--- 124,136 ----
      {
          Object result = null;
!         if (VELOCITY_GENERATOR.equals(elementType)) {
              result = new VelocityGenerator();
          }
+         else if (JELLY_GENERATOR.equals(elementType)) {
+             result = new JellyGenerator();
+         }
          else if (GENERATOR.equals(elementType)) {
              result = new Generator();
          }
          _dynamicGenerators.add(result);
          return result;
***************
*** 168,202 ****
      {
          return (Generator) _generatorMap.get(name);
-     }
- 
-     /**
-      * Gets all accepted classes. Subclasses can control what's accepted
-      * by calling {@link #createAccept} and call setPredicate on it, using
-      * a predicate from the xdoclet.util.predicates package. If no predicate
-      * is set, all classes that were parsed will be returned.
-      *
-      * @return all accepted classes.
-      */
-     public final Collection getAcceptedClasses()
-     {
-         // Get all the classes including inner classes.
-         Collection classes = getSourceClasses();
- 
-         if (_accept != null) {
-             // Filter out the classes we want. Depends on accept( XClass )
-             return CollectionUtils.select(classes, _accept);
-         }
-         else {
-             return classes;
-         }
-     }
- 
-     /**
-      * Convenience method. Equal to calling 
<code>XJavaDoc.getInstance().getSourceClasses();</code>.
-      * @return all source classes including inner classes.
-      */
-     public static final Collection getSourceClasses()
-     {
-         return XJavaDoc.getInstance().getSourceClasses();
      }
  
--- 167,170 ----

Index: PluginFactory.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/core/src/java/xdoclet/PluginFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** PluginFactory.java  11 Feb 2003 11:12:04 -0000      1.1
--- PluginFactory.java  18 Feb 2003 00:05:08 -0000      1.2
***************
*** 18,21 ****
--- 18,22 ----
  import xdoclet.util.ClasspathManager;
  import xdoclet.util.FileUtils;
+ import xdoclet.xjavadoc.XJavadocCollectionFactory;
  
  /**
***************
*** 107,110 ****
--- 108,115 ----
              throw new XDocletException(e.getMessage(), e);
          }
+         catch (ClassCastException e) {
+             e.printStackTrace();
+             throw new XDocletException("Couldn't cast " + pluginClass.getName() + " 
+to " + Plugin.class.getName(), e);
+         }
          catch (Throwable e) {
              e.printStackTrace();
***************
*** 133,137 ****
      {
          LogFactory.getLog(getClass()).debug("Registering plugins available on the 
classpath...");
!         for (Iterator classpathFiles = 
_classpathManager.getClasspathFiles().iterator(); classpathFiles.hasNext();) {
              File file = (File) classpathFiles.next();
              parse(file);
--- 138,142 ----
      {
          LogFactory.getLog(getClass()).debug("Registering plugins available on the 
classpath...");
!         for (Iterator classpathFiles = _classpathManager.getFiles().iterator(); 
classpathFiles.hasNext();) {
              File file = (File) classpathFiles.next();
              parse(file);

Index: XDoclet.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/core/src/java/xdoclet/XDoclet.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** XDoclet.java        11 Feb 2003 11:12:04 -0000      1.20
--- XDoclet.java        18 Feb 2003 00:05:08 -0000      1.21
***************
*** 6,14 ****
  
  import xdoclet.util.ClasspathManager;
- import xdoclet.generators.ScriptGenerator;
  
  import java.util.Collection;
  import java.util.ArrayList;
  import java.util.Iterator;
  
  import xjavadoc.XTagFactory;
--- 6,14 ----
  
  import xdoclet.util.ClasspathManager;
  
  import java.util.Collection;
  import java.util.ArrayList;
  import java.util.Iterator;
+ import java.util.Collections;
  
  import xjavadoc.XTagFactory;
***************
*** 29,33 ****
   * @version   $Revision$
   */
! public class XDoclet
  {
      /** Collection of all configured plugins. */
--- 29,33 ----
   * @version   $Revision$
   */
! public class XDoclet implements AntElementContainer
  {
      /** Collection of all configured plugins. */
***************
*** 35,42 ****
  
      /** The ClasspathManager finds directories and jars/zips on the classpath. */
!     private ClasspathManager _classpathManager;
  
      /** The PluginFactory registers and creates plugins found on the classpath. */
!     private PluginFactory _pluginFactory;
  
      /** The name. */
--- 35,42 ----
  
      /** The ClasspathManager finds directories and jars/zips on the classpath. */
!     private static ClasspathManager _classpathManager;
  
      /** The PluginFactory registers and creates plugins found on the classpath. */
!     private static PluginFactory _pluginFactory;
  
      /** The name. */
***************
*** 63,77 ****
      }
  
      /**
       * Sets the classpath under which XDoclet is run.
       * @param classpath the classpath under which XDoclet is run
       */
!     public void setClasspath(String classpath)
      {
          _classpathManager = new ClasspathManager(classpath);
          _pluginFactory = new PluginFactory(_classpathManager);
- 
-         // initialise ScriptGenerator
-         ScriptGenerator.init(_classpathManager);
      }
  
--- 63,78 ----
      }
  
+     public final Collection getPlugins() {
+         return Collections.unmodifiableCollection(_plugins);
+     }
+ 
      /**
       * Sets the classpath under which XDoclet is run.
       * @param classpath the classpath under which XDoclet is run
       */
!     public static void setClasspath(String classpath)
      {
          _classpathManager = new ClasspathManager(classpath);
          _pluginFactory = new PluginFactory(_classpathManager);
      }
  
***************
*** 80,84 ****
       * @return the ClasspathManager
       */
!     public ClasspathManager getClasspathManager()
      {
          return _classpathManager;
--- 81,85 ----
       * @return the ClasspathManager
       */
!     public static ClasspathManager getClasspathManager()
      {
          return _classpathManager;



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to