incubator-nmaven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r559383 - in /incubator/nmaven/branches/SI_GAC/components/dotnet-registry/src/main/java/org/apache/maven/dotnet/registry: ConnectionsRepository.java impl/DataAccessObjectRegistryImpl.java impl/RepositoryRegistryImpl.java
Date Wed, 25 Jul 2007 10:04:14 GMT
Author: sisbell
Date: Wed Jul 25 03:04:11 2007
New Revision: 559383

URL: http://svn.apache.org/viewvc?view=rev&rev=559383
Log:
Improved performance of registry by lazy loading the daos (and rdf repo).

Modified:
    incubator/nmaven/branches/SI_GAC/components/dotnet-registry/src/main/java/org/apache/maven/dotnet/registry/ConnectionsRepository.java
    incubator/nmaven/branches/SI_GAC/components/dotnet-registry/src/main/java/org/apache/maven/dotnet/registry/impl/DataAccessObjectRegistryImpl.java
    incubator/nmaven/branches/SI_GAC/components/dotnet-registry/src/main/java/org/apache/maven/dotnet/registry/impl/RepositoryRegistryImpl.java

Modified: incubator/nmaven/branches/SI_GAC/components/dotnet-registry/src/main/java/org/apache/maven/dotnet/registry/ConnectionsRepository.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_GAC/components/dotnet-registry/src/main/java/org/apache/maven/dotnet/registry/ConnectionsRepository.java?view=diff&rev=559383&r1=559382&r2=559383
==============================================================================
--- incubator/nmaven/branches/SI_GAC/components/dotnet-registry/src/main/java/org/apache/maven/dotnet/registry/ConnectionsRepository.java
(original)
+++ incubator/nmaven/branches/SI_GAC/components/dotnet-registry/src/main/java/org/apache/maven/dotnet/registry/ConnectionsRepository.java
Wed Jul 25 03:04:11 2007
@@ -22,23 +22,19 @@
 
     private RepositoryRegistry registry;
 
-    //Dangerous but performance is worth it
-    private static Set<DataAccessObject> daos = new HashSet<DataAccessObject>();
+    private Set<DataAccessObject> daos = new HashSet<DataAccessObject>();
 
-    public void load( InputStream inputStream, Hashtable properties )
-        throws IOException
+    private Hashtable properties;
+
+    public void lazyLoad() throws IOException
     {
-        if ( daos.size() > 0 )
-        {
-            return;
-        }
         long start = System.currentTimeMillis();
 
-        File dataDir = new File( System.getProperty( "user.home"), ".m2/uac/rdfRepository"
);
+        File dataDir = new File( System.getProperty( "user.home" ), ".m2/uac/rdfRepository"
);
         MemoryStore store = new MemoryStore( dataDir );
         store.setPersist( true );
         store.setSyncDelay( 0 );
-        org.openrdf.repository.Repository rdfRepository = new SailRepository( new MemoryStoreRDFSInferencer(
store ) );
+        org.openrdf.repository.Repository rdfRepository = new SailRepository( store );
         try
         {
             rdfRepository.initialize();
@@ -84,6 +80,12 @@
             }
         }
         logger.info( "Connection Start Up: Time = " + ( System.currentTimeMillis() - start
) );
+    }
+
+    public void load( InputStream inputStream, Hashtable properties )
+        throws IOException
+    {
+        this.properties = properties;
     }
 
     public void setRepositoryRegistry( RepositoryRegistry repositoryRegistry )

Modified: incubator/nmaven/branches/SI_GAC/components/dotnet-registry/src/main/java/org/apache/maven/dotnet/registry/impl/DataAccessObjectRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_GAC/components/dotnet-registry/src/main/java/org/apache/maven/dotnet/registry/impl/DataAccessObjectRegistryImpl.java?view=diff&rev=559383&r1=559382&r2=559383
==============================================================================
--- incubator/nmaven/branches/SI_GAC/components/dotnet-registry/src/main/java/org/apache/maven/dotnet/registry/impl/DataAccessObjectRegistryImpl.java
(original)
+++ incubator/nmaven/branches/SI_GAC/components/dotnet-registry/src/main/java/org/apache/maven/dotnet/registry/impl/DataAccessObjectRegistryImpl.java
Wed Jul 25 03:04:11 2007
@@ -10,14 +10,18 @@
 import java.util.HashSet;
 import java.util.Collections;
 import java.util.logging.Logger;
+import java.io.IOException;
 
-public class DataAccessObjectRegistryImpl implements DataAccessObjectRegistry
+public class DataAccessObjectRegistryImpl
+    implements DataAccessObjectRegistry
 {
 
     private RepositoryRegistry repositoryRegistry;
 
     private static Logger logger = Logger.getAnonymousLogger();
 
+    private boolean isConnectionsRepoLoaded = false;
+
     public Set<DataAccessObject> findAll()
     {
         Set<DataAccessObject> daos = new HashSet<DataAccessObject>();
@@ -31,6 +35,19 @@
             Repository repository = repositoryRegistry.find( name );
             if ( repository instanceof ConnectionsRepository )
             {
+                ConnectionsRepository connectionsRepository = (ConnectionsRepository) repository;
+                if ( !isConnectionsRepoLoaded )
+                {
+                    try
+                    {
+                        connectionsRepository.lazyLoad();
+                        isConnectionsRepoLoaded = true;
+                    }
+                    catch ( IOException e )
+                    {
+                        return daos;
+                    }
+                }
                 daos.addAll( ( (ConnectionsRepository) repository ).getDataAccessObjects()
);
             }
         }
@@ -49,7 +66,20 @@
             Repository repository = repositoryRegistry.find( name );
             if ( repository instanceof ConnectionsRepository )
             {
-                for ( DataAccessObject dao : ( (ConnectionsRepository) repository ).getDataAccessObjects()
)
+                ConnectionsRepository connectionsRepository = (ConnectionsRepository) repository;
+                if ( !isConnectionsRepoLoaded )
+                {
+                    try
+                    {
+                        connectionsRepository.lazyLoad();
+                        isConnectionsRepoLoaded = true;
+                    }
+                    catch ( IOException e )
+                    {
+                        return null;
+                    }
+                }
+                for ( DataAccessObject dao : ( connectionsRepository ).getDataAccessObjects()
)
                 {
                     if ( dao.getID().trim().equals( daoId ) )
                     {
@@ -74,6 +104,19 @@
             Repository repository = repositoryRegistry.find( name );
             if ( repository instanceof ConnectionsRepository )
             {
+                ConnectionsRepository connectionsRepository = (ConnectionsRepository) repository;
+                if ( !isConnectionsRepoLoaded )
+                {
+                    try
+                    {
+                        connectionsRepository.lazyLoad();
+                        isConnectionsRepoLoaded = true;
+                    }
+                    catch ( IOException e )
+                    {
+                        return Collections.unmodifiableSet( daoIds );
+                    }
+                }
                 for ( DataAccessObject dao : ( (ConnectionsRepository) repository ).getDataAccessObjects()
)
                 {
                     daoIds.add( dao.getID() );

Modified: incubator/nmaven/branches/SI_GAC/components/dotnet-registry/src/main/java/org/apache/maven/dotnet/registry/impl/RepositoryRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_GAC/components/dotnet-registry/src/main/java/org/apache/maven/dotnet/registry/impl/RepositoryRegistryImpl.java?view=diff&rev=559383&r1=559382&r2=559383
==============================================================================
--- incubator/nmaven/branches/SI_GAC/components/dotnet-registry/src/main/java/org/apache/maven/dotnet/registry/impl/RepositoryRegistryImpl.java
(original)
+++ incubator/nmaven/branches/SI_GAC/components/dotnet-registry/src/main/java/org/apache/maven/dotnet/registry/impl/RepositoryRegistryImpl.java
Wed Jul 25 03:04:11 2007
@@ -50,7 +50,7 @@
 
 
     /**
-     * @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable#initialize()

+     * @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable#initialize()
      */
     public void initialize()
         throws InitializationException



Mime
View raw message