[jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/sword s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Tue Mar 22 19:05:40 MST 2005


Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword
In directory www.crosswire.org:/tmp/cvs-serv26577/java/jsword/org/crosswire/jsword/book/sword

Modified Files:
	SwordBookDriver.java 
Log Message:
Made BookDriver a singleton with an instance() method which is used by reflection in Books to get an instance of a particular BookDriver.
Made registerDriver also re-register the driver.

Index: SwordBookDriver.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/SwordBookDriver.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** SwordBookDriver.java	20 Mar 2005 02:34:44 -0000	1.38
--- SwordBookDriver.java	23 Mar 2005 02:05:38 -0000	1.39
***************
*** 54,58 ****
      public SwordBookDriver()
      {
!         log.debug("Starting Sword drivers"); //$NON-NLS-1$
      }
  
--- 54,65 ----
      public SwordBookDriver()
      {
!     }
! 
!     /* (non-Javadoc)
!      * @see org.crosswire.jsword.book.BookDriver#getName()
!      */
!     public String getDriverName()
!     {
!         return "Sword"; //$NON-NLS-1$
      }
  
***************
*** 73,77 ****
              {
                  String[] bookdirs = mods.list(new CustomFilenameFilter());
-                 //String[] bookdirs = NetUtil.listByFile(mods, new CustomURLFilter());
  
                  // Loop through the entries in this mods.d directory
--- 80,83 ----
***************
*** 179,210 ****
  
      /**
!      * Default windows installation directory
!      */
!     private static final String DIR_WINDOWS_DEFAULT = "C:\\Program Files\\CrossWire\\The SWORD Project"; //$NON-NLS-1$
! 
!     /**
!      * Users config directory for Sword in Unix
!      */
!     private static final String DIR_SWORD_CONF = ".sword"; //$NON-NLS-1$
! 
!     /**
!      * Sword global config file
!      */
!     private static final String DIR_UNIX_GLOBAL_CONF = "/etc/sword.conf"; //$NON-NLS-1$
! 
!     /**
!      * System property for sword home directory
!      */
!     private static final String PROPERTY_SWORD_HOME = "sword.home"; //$NON-NLS-1$
! 
!     /**
!      * Java system property for users home directory
!      */
!     private static final String PROPERTY_USER_HOME = "user.home"; //$NON-NLS-1$
! 
!     /**
!      * File prefix for config file
       */
!     private static final String PREFIX_GLOBALS = "globals."; //$NON-NLS-1$
  
      /**
--- 185,195 ----
  
      /**
!      * Get the singleton instance of this driver.
!      * @return this driver instance
       */
!     public static BookDriver instance()
!     {
!         return INSTANCE;
!     }
  
      /**
***************
*** 258,272 ****
          }
  
-         // First we need to unregister any registered books from ourselves
-         BookDriver[] matches = Books.installed().getDriversByClass(SwordBookDriver.class);
-         for (int i = 0; i < matches.length; i++)
-         {
-             Books.installed().unregisterDriver(matches[i]);
-         }
- 
          SwordBookDriver.dirs = newDirs;
  
!         // Now we need to register ourselves
!         Books.installed().registerDriver(new SwordBookDriver());
      }
  
--- 243,250 ----
          }
  
          SwordBookDriver.dirs = newDirs;
  
!         // Now we need to (re)register ourselves
!         Books.installed().registerDriver(INSTANCE);
      }
  
***************
*** 435,448 ****
  
      /**
-      * The directory URL
-      */
-     private static File[] dirs = getDefaultPaths();
- 
-     /**
-      * The log stream
-      */
-     private static final Logger log = Logger.getLogger(SwordBookDriver.class);
- 
-     /**
       * Check that the directories in the version directory really
       * represent versions.
--- 413,416 ----
***************
*** 459,468 ****
      }
  
!     /* (non-Javadoc)
!      * @see org.crosswire.jsword.book.BookDriver#getName()
       */
!     public String getDriverName()
!     {
!         return "Sword"; //$NON-NLS-1$
!     }
  }
--- 427,474 ----
      }
  
!     /**
!      * Default windows installation directory
       */
!     private static final String DIR_WINDOWS_DEFAULT = "C:\\Program Files\\CrossWire\\The SWORD Project"; //$NON-NLS-1$
! 
!     /**
!      * Users config directory for Sword in Unix
!      */
!     private static final String DIR_SWORD_CONF = ".sword"; //$NON-NLS-1$
! 
!     /**
!      * Sword global config file
!      */
!     private static final String DIR_UNIX_GLOBAL_CONF = "/etc/sword.conf"; //$NON-NLS-1$
! 
!     /**
!      * System property for sword home directory
!      */
!     private static final String PROPERTY_SWORD_HOME = "sword.home"; //$NON-NLS-1$
! 
!     /**
!      * Java system property for users home directory
!      */
!     private static final String PROPERTY_USER_HOME = "user.home"; //$NON-NLS-1$
! 
!     /**
!      * File prefix for config file
!      */
!     private static final String PREFIX_GLOBALS = "globals."; //$NON-NLS-1$
! 
!     /**
!      * A shared instance of this driver.
!      */
!     private static final BookDriver INSTANCE = new SwordBookDriver();
! 
!     /**
!      * The directory URL
!      */
!     private static File[] dirs = getDefaultPaths();
! 
!     /**
!      * The log stream
!      */
!     private static final Logger log = Logger.getLogger(SwordBookDriver.class);
! 
  }



More information about the jsword-svn mailing list