Changeset 2754


Ignore:
Timestamp:
05/04/07 15:55:26 (13 years ago)
Author:
curtis
Message:

Load the default readers.txt and/or writers.txt the first time the
default constructor is called, rather than in a static initializer.

Location:
trunk/loci/formats
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/ImageReader.java

    r2701 r2754  
    4343  private static ClassList readerClasses; 
    4444 
    45   // -- Static initializer -- 
    46  
    47   static { 
    48     // load built-in reader classes from readers.txt file 
    49     try { 
    50       readerClasses = new ClassList("readers.txt", IFormatReader.class); 
     45  // -- Static helper methods -- 
     46 
     47  private static ClassList getDefaultReaderClasses() { 
     48    if (readerClasses == null) { 
     49      // load built-in reader classes from readers.txt file 
     50      try { 
     51        readerClasses = new ClassList("readers.txt", IFormatReader.class); 
     52      } 
     53      catch (IOException exc) { 
     54        exc.printStackTrace(); 
     55        readerClasses = new ClassList(IFormatReader.class); 
     56      } 
    5157    } 
    52     catch (IOException exc) { 
    53       exc.printStackTrace(); 
    54       readerClasses = new ClassList(IFormatReader.class); 
    55     } 
     58    return readerClasses; 
    5659  } 
    5760 
     
    8083   */ 
    8184  public ImageReader() { 
    82     this(readerClasses); 
     85    this(getDefaultReaderClasses()); 
    8386  } 
    8487 
  • trunk/loci/formats/ImageWriter.java

    r2712 r2754  
    4444  private static ClassList writerClasses; 
    4545 
    46   // -- Static initializer -- 
    47  
    48   static { 
    49     // load built-in writer classes from writers.txt file 
    50     try { 
    51       writerClasses = new ClassList("writers.txt", IFormatWriter.class); 
    52     } 
    53     catch (IOException exc) { 
    54       exc.printStackTrace(); 
    55       writerClasses = new ClassList(IFormatWriter.class); 
    56     } 
     46  // -- Static helper methods -- 
     47 
     48  private static ClassList getDefaultWriterClasses() { 
     49    if (writerClasses == null) { 
     50      // load built-in writer classes from writers.txt file 
     51      try { 
     52        writerClasses = new ClassList("writers.txt", IFormatWriter.class); 
     53      } 
     54      catch (IOException exc) { 
     55        exc.printStackTrace(); 
     56        writerClasses = new ClassList(IFormatWriter.class); 
     57      } 
     58    } 
     59    return writerClasses; 
    5760  } 
    5861 
     
    8790   */ 
    8891  public ImageWriter() { 
    89     this(writerClasses); 
     92    this(getDefaultWriterClasses()); 
    9093  } 
    9194 
Note: See TracChangeset for help on using the changeset viewer.