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

Modified Files:
        Plugin.java PluginFactory.java XDoclet.java 
Log Message:
Added Java Beans support. This is in order to make it possible for Bean containers 
(such as IDEs) to configure XDoclet. We're generating BeanInfo and MANIFEST.MF files 
that provide metadata about XDoclet. This is in fact the Metadata API for the 
configuration part of XDoclet.

Index: Plugin.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/Plugin.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** Plugin.java 7 Mar 2003 09:15:09 -0000       1.6
--- Plugin.java 8 Mar 2003 14:21:09 -0000       1.7
***************
*** 11,14 ****
--- 11,15 ----
  
  import java.io.File;
+ import java.io.Serializable;
  
  import java.text.MessageFormat;
***************
*** 39,43 ****
   * @version   $Revision$
   */
! public class Plugin {
      private final List _dynamicProperties = new ArrayList();
  
--- 40,44 ----
   * @version   $Revision$
   */
! public abstract class Plugin implements Serializable {
      private final List _dynamicProperties = new ArrayList();
  
***************
*** 50,57 ****
      private List _packageSubstitutions = new ArrayList();
  
!     /**
!      * DON'T access this variable directly. Use the getFileName() method
!      */
!     private String _fileName;
  
      /** The name. */
--- 51,55 ----
      private List _packageSubstitutions = new ArrayList();
  
!     private String _fileName = "";
  
      /** The name. */
***************
*** 253,256 ****
--- 251,258 ----
      }
  
+     public final String getFileName() {
+         return _fileName;
+     }
+ 
      /**
       * Sets the package name of the generated files. This will be converted
***************
*** 264,268 ****
      }
  
!     private final String getPackageName() {
          return (_packageName != null) ? _packageName : "";
      }
--- 266,270 ----
      }
  
!     public final String getPackageName() {
          return (_packageName != null) ? _packageName : "";
      }
***************
*** 333,355 ****
      }
  
-     public final String getFileName() {
-         return _fileName;
-     }
- 
      /**
!      * Generates one file for all objects. Must be overridden if this plugin
!      * 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();
!     }
  
      /**
!      * Generates one file for each objects. Must be overridden if this plugin
!      * is intended to be used with "{0}" in the fileName.
       *
       * @param object the object to generate for.
--- 335,350 ----
      }
  
      /**
!      * Generates one file for all objects. Will be called if this plugin
!      * is used without "{0}" in the fileName.
       *
       * @param file where the generated content will be written.
       * @throws XDocletException if generation fails.
       */
!     protected abstract void generateOneFileForAll(File file) throws XDocletException;
  
      /**
!      * Generates one file for each objects. Will be called if this plugin
!      * is used with "{0}" in the fileName.
       *
       * @param object the object to generate for.
***************
*** 357,364 ****
       * @throws XDocletException if generation fails.
       */
!     protected void generateOneFileForEach(File file, Object object)
!             throws XDocletException {
!         throw new UnsupportedOperationException();
!     }
  
      /**
--- 352,356 ----
       * @throws XDocletException if generation fails.
       */
!     protected abstract void generateOneFileForEach(File file, Object object) throws 
XDocletException;
  
      /**

Index: PluginFactory.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/PluginFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** PluginFactory.java  5 Mar 2003 22:27:10 -0000       1.4
--- PluginFactory.java  8 Mar 2003 14:21:09 -0000       1.5
***************
*** 17,20 ****
--- 17,21 ----
  
  import java.util.*;
+ import java.beans.Beans;
  
  /**
***************
*** 71,74 ****
--- 72,77 ----
              throw new IllegalArgumentException("xdoclet cannot be null");
          }
+         // plugin names are case insensitive
+         pluginName = pluginName.toLowerCase(Locale.US);
  
          // Look up the plugin class.
***************
*** 90,94 ****
  
              // Instantiate, initialise and add the plugin
!             Plugin plugin = (Plugin) pluginClass.newInstance();
  
              LogFactory.getLog(getClass()).debug("Creating plugin " + 
pluginClass.getName());
--- 93,99 ----
  
              // Instantiate, initialise and add the plugin
! //            Plugin plugin = (Plugin) pluginClass.newInstance();
!             System.out.println("Instantiating bean with " + 
_classpathManager.getClassLoader());
!             Plugin plugin = (Plugin) 
Beans.instantiate(_classpathManager.getClassLoader(), pluginClass.getName(), 
xdoclet.getPlugins());
  
              LogFactory.getLog(getClass()).debug("Creating plugin " + 
pluginClass.getName());
***************
*** 99,108 ****
  
              return plugin;
-         } catch (InstantiationException e) {
-             LogFactory.getLog(getClass()).error(e.getMessage(), e);
-             throw new XDocletException(e.getMessage(), e);
-         } catch (IllegalAccessException e) {
-             LogFactory.getLog(getClass()).error(e.getMessage(), e);
-             throw new XDocletException(e.getMessage(), e);
          } catch (NoClassDefFoundError e) {
              LogFactory.getLog(getClass()).error(e.getMessage(), e);
--- 104,107 ----
***************
*** 125,128 ****
--- 124,129 ----
       */
      private void registerPlugin(String pluginName, String pluginClassName, String 
xdocletClassName) {
+         // plugin names are case insensitive
+           pluginName = pluginName.toLowerCase(Locale.US);
          LogFactory.getLog(getClass()).debug("Registered plugin: " + pluginName);
          _nameToPluginClassNameMap.put(pluginName, pluginClassName);

Index: XDoclet.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/XDoclet.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** XDoclet.java        5 Mar 2003 22:27:10 -0000       1.6
--- XDoclet.java        8 Mar 2003 14:21:09 -0000       1.7
***************
*** 7,14 ****
  import org.apache.commons.logging.LogFactory;
  
- import xdoclet.metadata.ConfigMeta;
  import xdoclet.util.ClasspathManager;
  
  import java.util.*;
  
  /**
--- 7,16 ----
  import org.apache.commons.logging.LogFactory;
  
  import xdoclet.util.ClasspathManager;
  
  import java.util.*;
+ import java.io.Serializable;
+ import java.beans.beancontext.BeanContext;
+ import java.beans.beancontext.BeanContextSupport;
  
  /**
***************
*** 17,20 ****
--- 19,25 ----
   * core environment agnostic.
   *
+  * @bean.class locale="en"
+  *             displayName="Simple XDoclet"
+  *             shortDescription="This is a simple XDoclet that can be used as a 
container by generic Plugins"
   * @see Plugin
   * @see ClasspathManager
***************
*** 25,31 ****
   * @version   $Revision$
   */
! public class XDoclet {
!     /** The ClasspathManager finds directories and jars/zips on the classpath. */
!     private static ClasspathManager _classpathManager;
  
      /** The PluginFactory registers and creates plugins found on the classpath. */
--- 30,40 ----
   * @version   $Revision$
   */
! public class XDoclet implements Serializable {
!     /**
!      * The ClasspathManager finds directories and jars/zips on the classpath.
!      * As default we use the system classpath, but a new one will be created
!      * when/if setClasspath is called.
!      */
!     private static ClasspathManager _classpathManager = new 
ClasspathManager(System.getProperty("java.class.path"));
  
      /** The PluginFactory registers and creates plugins found on the classpath. */
***************
*** 33,43 ****
  
      /** Collection of all configured plugins. */
!     private final Map _plugins = new HashMap();
  
      /** Provides us with metadata. */
!     private MetadataProvider _metadataProvider;
  
      // A cache of the collection created by _metadataProvider. */
!     private Collection _collection;
  
      /** The name. */
--- 42,52 ----
  
      /** Collection of all configured plugins. */
!     private final BeanContext _plugins = new BeanContextSupport();
  
      /** Provides us with metadata. */
!     private transient MetadataProvider _metadataProvider;
  
      // A cache of the collection created by _metadataProvider. */
!     private transient Collection _collection;
  
      /** The name. */
***************
*** 49,53 ****
       * a ref here, so we can fail the build ourself.
       */
!     private Throwable _failure;
  
      /**
--- 58,62 ----
       * a ref here, so we can fail the build ourself.
       */
!     private transient Throwable _failure;
  
      /**
***************
*** 70,73 ****
--- 79,83 ----
       * Gets the name of the xdoclet.
       * @return the name of the plugin.
+      * @bean.ignore
       */
      public final String getName() {
***************
*** 78,81 ****
--- 88,92 ----
       * Sets the name of the xdoclet.
       * @param name the name of the plugin.
+      * @bean.ignore
       */
      public final void setName(String name) {
***************
*** 83,88 ****
      }
  
!     public final Collection getPlugins() {
!         return Collections.unmodifiableCollection(_plugins.values());
      }
  
--- 94,99 ----
      }
  
!     public final BeanContext getPlugins() {
!         return _plugins;
      }
  
***************
*** 90,93 ****
--- 101,105 ----
       * Sets the classpath under which XDoclet is run.
       * @param classpath the classpath under which XDoclet is run
+      * @bean.ignore
       */
      public static void setClasspath(String classpath) {
***************
*** 99,102 ****
--- 111,115 ----
       * Gets the ClasspathManager.
       * @return the ClasspathManager
+      * @bean.ignore
       */
      public static ClasspathManager getClasspathManager() {
***************
*** 107,116 ****
       * Sets the CollectionFactory. If no CollectionFactory is set,
       * XJavadocCollectionFactory will be used.
!      * @param collectionFactory
       */
!     protected void setCollectionFactory(MetadataProvider collectionFactory) {
!         _metadataProvider = collectionFactory;
      }
  
      public Collection getCollection()
          throws XDocletException {
--- 120,140 ----
       * Sets the CollectionFactory. If no CollectionFactory is set,
       * XJavadocCollectionFactory will be used.
!      * @param metadataProvider
!      * @bean.ignore
       */
!     protected void setMetadataProvider(MetadataProvider metadataProvider) {
!         _metadataProvider = metadataProvider;
      }
  
+     /**
+      * Gets a Collection of objects containing metadata. This will be
+      * a Collection of [EMAIL PROTECTED] xjavadoc.XClass} unless a different
+      * MetaDataProvider has been set.
+      *
+      * @see #setMetadataProvider
+      * @return a Collection of objects representing metadata.
+      * @throws XDocletException
+      * @bean.ignore
+      */
      public Collection getCollection()
          throws XDocletException {
***************
*** 164,168 ****
      }
  
!     private static void printVersion() {
          // This should really be a System.out.print[ln], as we want this to be 
printed
          // every time XDoclet is run. The version string will be substituted by 
maven.xml
--- 188,192 ----
      }
  
!     private static final void printVersion() {
          // This should really be a System.out.print[ln], as we want this to be 
printed
          // every time XDoclet is run. The version string will be substituted by 
maven.xml
***************
*** 206,210 ****
      public Plugin createPlugin(String name)
          throws XDocletException {
!         return _pluginFactory.createPlugin(name, this);
      }
  
--- 230,234 ----
      public Plugin createPlugin(String name)
          throws XDocletException {
!         return _pluginFactory.createPlugin(name,this);
      }
  
***************
*** 232,240 ****
      public void addPlugin(Plugin plugin) {
          plugin.setXDoclet(this);
!         _plugins.put(plugin.getName(), plugin);
!     }
! 
!     public static ConfigMeta getConfigMeta() {
!         return null;
      }
  }
--- 256,260 ----
      public void addPlugin(Plugin plugin) {
          plugin.setXDoclet(this);
!         _plugins.add(plugin);
      }
  }



-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger 
for complex code. Debugging C/C++ programs can leave you feeling lost and 
disoriented. TotalView can help you find your way. Available on major UNIX 
and Linux platforms. Try it free. www.etnus.com
_______________________________________________
xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to