db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/metadata MetadataManager.java
Date Thu, 27 May 2004 21:04:42 GMT
tomdz       2004/05/27 14:04:42

  Modified:    src/java/org/apache/ojb/broker/metadata MetadataManager.java
  Log:
  It is no longer required to provide an (empty) repository.xml; if no such file has been
found, OJB starts now with empy descriptor and connection repositories
  Also loading is now lazy, i.e. only when OJB is first accessed
  
  Revision  Changes    Path
  1.17      +16 -13    db-ojb/src/java/org/apache/ojb/broker/metadata/MetadataManager.java
  
  Index: MetadataManager.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/MetadataManager.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- MetadataManager.java	4 Apr 2004 23:53:34 -0000	1.16
  +++ MetadataManager.java	27 May 2004 21:04:41 -0000	1.17
  @@ -22,6 +22,7 @@
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   import org.apache.ojb.broker.PBKey;
   
  +import java.io.FileNotFoundException;
   import java.io.InputStream;
   import java.util.Hashtable;
   import java.util.Iterator;
  @@ -124,7 +125,7 @@
       private static final String MSG_STR = "* Can't find DescriptorRepository for current
thread, use default one *";
   
       private static ThreadLocal threadedRepository = new ThreadLocal();
  -    private static MetadataManager singleton = new MetadataManager();
  +    private static MetadataManager singleton = null;
   
       private Hashtable metadataProfiles;
       private DescriptorRepository globalRepository;
  @@ -145,21 +146,18 @@
                   .getConfigurationFor(null)).getRepositoryFilename();
           try
           {
  -            globalRepository = new RepositoryPersistor().readDescriptorRepository(repository);
  +            globalRepository     = new RepositoryPersistor().readDescriptorRepository(repository);
  +            connectionRepository = new RepositoryPersistor().readConnectionRepository(repository);
           }
  -        catch (Exception e)
  +        catch (FileNotFoundException ex)
           {
  -            throw new MetadataException(
  -                    "Can not read repository class descriptor data, using repository: "
+ repository, e);
  +            globalRepository     = new DescriptorRepository();
  +            connectionRepository = new ConnectionRepository();
  +            log.info("No repository.xml file found, starting with empty metadata and connection
configuration");
           }
  -        try
  +        catch (Exception ex)
           {
  -            connectionRepository = new RepositoryPersistor().readConnectionRepository(repository);
  -        }
  -        catch (Exception e)
  -        {
  -            throw new MetadataException(
  -                    "Can not read jdbc-connection-descriptor data, using repository: "
+ repository, e);
  +            throw new MetadataException("Could not read repository file" + repository,
ex);
           }
           this.defaultPBKey = buildDefaultKey();
       }
  @@ -169,6 +167,11 @@
        */
       public static MetadataManager getInstance()
       {
  +        // lazy initialization
  +        if (singleton == null)
  +        {
  +            singleton = new MetadataManager();
  +        }
           return singleton;
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message