[Registry-dev] svn commit r14522 - in trunk/registry/modules/core/src/main/java/org/wso2/registry: . jdbc jdbc/dao jdbc/handlers jdbc/handlers/builtin jdbc/mediatypes jdbc/queries jdbc/urlhandlers

svn at wso2.org svn at wso2.org
Wed Mar 5 02:08:14 PST 2008


Author: chathura
Date: Wed Mar  5 02:07:51 2008
New Revision: 14522

Log:


Implemented on demand content fetching for resources.
Now the input streams for contents of resources are created only if the getContent() or getContentStream() methods are invoked.
registry.get(...) returns a Resource instance filled with resource metadata, but without any content.
But the registry users will not experience any difference as content will be fetched as soon as getContent is called.
This will increase the performance as in most cases only the resource metadata is needed, not the content (e.g. Registry and mashup UIs).



Modified:
   trunk/registry/modules/core/src/main/java/org/wso2/registry/Resource.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImpl.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/DatabaseConstants.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/Repository.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/LogsDAO.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/TagsDAO.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/Handler.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/builtin/TagURLHandler.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeHandler.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeManager.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/queries/SQLQueryProcessor.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/urlhandlers/TagURLHandler.java

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/Resource.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/Resource.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/Resource.java	Wed Mar  5 02:07:51 2008
@@ -66,7 +66,7 @@
 
     void addDependency(String dependencyPath);
 
-    InputStream getContentStream();
+    InputStream getContentStream() throws RegistryException;
 
     void setContentStream(InputStream contentStream);
 }

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImpl.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImpl.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImpl.java	Wed Mar  5 02:07:51 2008
@@ -21,8 +21,12 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.wso2.registry.jdbc.dao.VersionedResourceDAO;
 
+import javax.sql.DataSource;
 import java.sql.Timestamp;
+import java.sql.Connection;
+import java.sql.SQLException;
 import java.util.*;
 import java.io.*;
 
@@ -46,6 +50,12 @@
     private long id;
 
     /**
+     * Version of this instance of the resource. Versioned attributes (e.g. content,
+     * last modified date) can be accessed by using the combination of id and versionNumber.
+     */
+    private long versionNumber;
+
+    /**
      * Username of the user who added the resource to the registry.
      */
     private String authorUserName;
@@ -148,9 +158,28 @@
      */
     private InputStream contentStream;
 
+    /**
+     * Registry datasource. This is to be used only by the resource implemetation and users of the
+     * resource are not needed to use this. Some attributes of the resource (e.g. content) is
+     * fetched upon the first request to optimize the response time. Getters of such attributes use
+     * this datasource to fetch the values from the database.
+     */
+    private DataSource dataSource;
+
+    /**
+     * Resource DAO instance to access the database directly. Note that the VersionedResourceDAO is
+     * thread safe, so it is possible to keep a single instance for the resource.
+     */
+    private VersionedResourceDAO resourceDAO;
+
     public ResourceImpl() {
     }
 
+    public void setDataSource(DataSource dataSource) {
+        this.dataSource = dataSource;
+        resourceDAO = new VersionedResourceDAO(dataSource);
+    }
+
     public long getId() {
         return id;
     }
@@ -159,6 +188,14 @@
         this.id = id;
     }
 
+    public long getVersionNumber() {
+        return versionNumber;
+    }
+
+    public void setVersionNumber(long versionNumber) {
+        this.versionNumber = versionNumber;
+    }
+
     public String getAuthorUserName() {
         return authorUserName;
     }
@@ -239,18 +276,44 @@
         this.properties = properties;
     }
 
-    public InputStream getContentStream() {
+    public InputStream getContentStream() throws RegistryException {
+
+        if (contentStream == null) {
+            if (content != null) {
+
+                if (content instanceof byte[]) {
+                    this.contentStream =
+                            new BufferedInputStream(new ByteArrayInputStream((byte[]) content));
+
+                } else if (content instanceof String) {
+                    byte[] contentBytes = ((String) content).getBytes();
+                    this.contentStream =
+                            new BufferedInputStream(new ByteArrayInputStream(contentBytes));
+                }
+                
+            } else if (dataSource != null) {
+
+                Connection conn = null;
 
-        if (contentStream == null && content != null) {
+                try {
+                    conn = dataSource.getConnection();
+                    contentStream = resourceDAO.getResourceContentStream(id, versionNumber, conn);
 
-            if (content instanceof byte[]) {
-                this.contentStream =
-                        new BufferedInputStream(new ByteArrayInputStream((byte[]) content));
-
-            } else if (content instanceof String) {
-                byte[] contentBytes = ((String) content).getBytes();
-                this.contentStream =
-                        new BufferedInputStream(new ByteArrayInputStream(contentBytes));
+                } catch (Exception e) {
+                    String msg =
+                            "Failed to get the input stream for the content of resource: " + path;
+                    log.error(msg, e);
+                    throw new RegistryException(msg, e);
+
+                } finally {
+                    if (conn != null) {
+                        try {
+                            conn.close();
+                        } catch (SQLException e) {
+                            log.error("Failed to close the database connection.", e);
+                        }
+                    }
+                }
             }
         }
 
@@ -270,30 +333,34 @@
     }
 
     public Object getContent() throws RegistryException {
-        if (content == null && contentStream != null) {
-            BufferedInputStream bufferedInputStream = new BufferedInputStream(contentStream);
-            ByteArrayOutputStream out = new ByteArrayOutputStream();
-            try {
-                byte[] contentChunk = new byte[1024];
-                int byteCount;
-                while ((byteCount = bufferedInputStream.read(contentChunk)) != -1) {
-                    out.write(contentChunk, 0, byteCount);
-                }
-                content = out.toByteArray();
-            } catch (IOException e) {
-                String msg = "Failed to generate byte array from the resource content stream.";
-                log.error(msg, e);
-                throw new RegistryException(msg, e);
-            } finally {
+        if (content == null) {
+
+            contentStream = getContentStream();
+            if (contentStream != null) {
+                BufferedInputStream bufferedInputStream = new BufferedInputStream(contentStream);
+                ByteArrayOutputStream out = new ByteArrayOutputStream();
                 try {
-                    bufferedInputStream.close();
-                    out.close();
+                    byte[] contentChunk = new byte[1024];
+                    int byteCount;
+                    while ((byteCount = bufferedInputStream.read(contentChunk)) != -1) {
+                        out.write(contentChunk, 0, byteCount);
+                    }
+                    content = out.toByteArray();
                 } catch (IOException e) {
-                    log.error("Could not close the input stream of the content.", e);
+                    String msg = "Failed to generate byte array from the resource content stream.";
+                    log.error(msg, e);
+                    throw new RegistryException(msg, e);
+                } finally {
+                    try {
+                        bufferedInputStream.close();
+                        out.close();
+                    } catch (IOException e) {
+                        log.error("Could not close the input stream of the content.", e);
+                    }
                 }
             }
         }
-        
+
         return content;
     }
 

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/DatabaseConstants.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/DatabaseConstants.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/DatabaseConstants.java	Wed Mar  5 02:07:51 2008
@@ -45,6 +45,7 @@
     public static final String CHILD_ID_FIELD = "CHILD_ID";
 
     // Field names of Versions table
+    public static final String VERSION_NUMBER_FIELD = "VN";
     public static final String VERSION_CONTENT_FIELD = "CONTENT";
     public static final String VERSION_AUTHOR_FIELD = "AUTHOR";
     public static final String VERSION_UPDATED_TIME = "UPDATED_TIME";

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java	Wed Mar  5 02:07:51 2008
@@ -132,11 +132,11 @@
         //mediaTypeManager = new MediaTypeManager(dataSource, realm, this);
         queryProcessorManager = new QueryProcessorManager(dataSource, realm);
 
-        resourceDAO = new VersionedResourceDAO();
-        tagsDAO = new TagsDAO();
+        resourceDAO = new VersionedResourceDAO(dataSource);
+        tagsDAO = new TagsDAO(dataSource);
         commentsDAO = new CommentsDAO();
         ratingsDAO = new RatingsDAO();
-        logsDAO = new LogsDAO();
+        logsDAO = new LogsDAO(dataSource);
 
         // check if root is added. if not add it.
         Connection conn = getConnection();

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/Repository.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/Repository.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/Repository.java	Wed Mar  5 02:07:51 2008
@@ -54,7 +54,7 @@
     protected UserRealm realm;
 
     /** ResourceDAO for directly accessing resources. */
-    private VersionedResourceDAO resourceDAO = new VersionedResourceDAO();
+    private VersionedResourceDAO resourceDAO = new VersionedResourceDAO(dataSource);
 
     public Repository(DataSource dataSource, UserRealm userRealm) {
         this.dataSource = dataSource;
@@ -63,7 +63,7 @@
 
     public Resource get(String path) throws RegistryException {
 
-        Resource resource;
+        ResourceImpl resourceImpl;
 
         String plainPath = path;
         long versionNumber = -1;
@@ -81,17 +81,21 @@
         } catch (SQLException e) {
             throw new RegistryException(e.getMessage());
         }
-        //if we uncomment following three lines then , no onc access a deleted resource
+        //if we uncomment following three lines then , no onc access a deleted resourceImpl
 //        if (!resourceDAO.isResourceActive(plainPath,conn)) {
-//             throw new RegistryException("Trying to access a deleted resource");
+//             throw new RegistryException("Trying to access a deleted resourceImpl");
 //        }
         try {
-            //resource = resourceDAO.get(path, conn);
+            //resourceImpl = resourceDAO.get(path, conn);
             if (versionNumber == -1) {
-                resource = resourceDAO.getLatestVersion(plainPath, conn);
+                resourceImpl = resourceDAO.getLatestVersion(plainPath, conn);
 
             } else {
-                resource = resourceDAO.get(plainPath, versionNumber, conn);
+                resourceImpl = resourceDAO.get(plainPath, versionNumber, conn);
+            }
+
+            if (resourceImpl != null) {
+                resourceImpl.setDataSource(dataSource);
             }
 
         } catch (Exception e) {
@@ -109,11 +113,11 @@
         }
 
         // we are just getting the content from the database. not a content modification.
-        if (resource != null && resource instanceof ResourceImpl) {
-            ((ResourceImpl) resource).setContentModified(false);
+        if (resourceImpl != null && resourceImpl instanceof ResourceImpl) {
+            ((ResourceImpl) resourceImpl).setContentModified(false);
         }
 
-        return resource;
+        return resourceImpl;
     }
 
     public boolean put(String path, Resource resource) throws RegistryException {

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/LogsDAO.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/LogsDAO.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/LogsDAO.java	Wed Mar  5 02:07:51 2008
@@ -19,6 +19,7 @@
 import org.wso2.registry.LogEntry;
 import org.wso2.registry.jdbc.DatabaseConstants;
 
+import javax.sql.DataSource;
 import java.sql.*;
 import java.util.ArrayList;
 import java.util.Date;
@@ -26,6 +27,12 @@
 
 public class LogsDAO {
 
+    private DataSource dataSource;
+
+    public LogsDAO(DataSource dataSource) {
+        this.dataSource = dataSource;
+    }
+
     public void addLog(long resourceID,
                        String userName,
                        int action,
@@ -50,7 +57,7 @@
                         String userName, Date from, Date to, boolean descending, Connection conn)
             throws SQLException {
 
-        VersionedResourceDAO resourceDAO = new VersionedResourceDAO();
+        VersionedResourceDAO resourceDAO = new VersionedResourceDAO(dataSource);
 
         long aid = -1;
         if (resourcePath != null) {

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/TagsDAO.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/TagsDAO.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/TagsDAO.java	Wed Mar  5 02:07:51 2008
@@ -25,12 +25,19 @@
 import org.wso2.registry.jdbc.DatabaseConstants;
 import org.wso2.registry.jdbc.dataobjects.TaggingDO;
 
+import javax.sql.DataSource;
 import java.sql.*;
 import java.util.ArrayList;
 import java.util.List;
 
 public class TagsDAO {
 
+    private DataSource dataSource;
+
+    public TagsDAO(DataSource dataSource) {
+        this.dataSource = dataSource;
+    }
+
     public void addTagging(String tagName, long resourceID, String userID, Connection conn)
             throws SQLException {
 
@@ -100,7 +107,7 @@
     public void removeTag(String path, String tag, Connection conn)
             throws SQLException {
 
-        VersionedResourceDAO resourceDAO = new VersionedResourceDAO();
+        VersionedResourceDAO resourceDAO = new VersionedResourceDAO(dataSource);
         long resourceID = resourceDAO.getResourceID(path, conn);
 
         String sql = "DELETE FROM TAGS WHERE AID=? AND TAG_NAME=?";
@@ -115,7 +122,7 @@
     public void removeTag(String path, String tag, String userName, Connection conn)
             throws SQLException {
 
-        VersionedResourceDAO resourceDAO = new VersionedResourceDAO();
+        VersionedResourceDAO resourceDAO = new VersionedResourceDAO(dataSource);
         long resourceID = resourceDAO.getResourceID(path, conn);
 
         String sql = "DELETE FROM TAGS WHERE AID=? AND TAG_NAME=?";
@@ -260,7 +267,7 @@
     public TaggingDO getTagging(String path, String tagName, String userName, Connection conn)
             throws SQLException {
 
-        VersionedResourceDAO resourceDAO = new VersionedResourceDAO();
+        VersionedResourceDAO resourceDAO = new VersionedResourceDAO(dataSource);
         long aid = resourceDAO.getResourceID(path, conn);
 
         String sql =

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java	Wed Mar  5 02:07:51 2008
@@ -26,6 +26,7 @@
 import org.wso2.registry.utils.VersionedPath;
 
 import javax.activation.DataHandler;
+import javax.sql.DataSource;
 import java.io.*;
 import java.sql.*;
 import java.util.ArrayList;
@@ -37,6 +38,12 @@
 
     private static final Log log = LogFactory.getLog(VersionedResourceDAO.class);
 
+    private DataSource dataSource;
+
+    public VersionedResourceDAO(DataSource dataSource) {
+        this.dataSource = dataSource;
+    }
+
     /**
      * Returns the given version of the artifact. If artifact is a collection all child paths will
      * be added as versioned paths in the form /a/b?v=12
@@ -88,12 +95,18 @@
         ResultSet versionResults = versionQuery.executeQuery();
 
         if (versionResults.next()) {
+            resource.setVersionNumber(
+                    versionResults.getLong(DatabaseConstants.VERSION_NUMBER_FIELD));
             resource.setLastUpdaterUserName(
                     versionResults.getString(DatabaseConstants.VERSION_AUTHOR_FIELD));
             resource.setLastModified(
                     versionResults.getTimestamp(DatabaseConstants.VERSION_UPDATED_TIME));
-            resource.setContentStream(getDisconnectedStream(
-                    versionResults.getBinaryStream(DatabaseConstants.VERSION_CONTENT_FIELD)));
+
+            // set the datasource to fetch the content.
+            resource.setDataSource(dataSource);
+            
+            //resource.setContentStream(getDisconnectedStream(
+            //        versionResults.getBinaryStream(DatabaseConstants.VERSION_CONTENT_FIELD)));
         }
 
         // get resource children
@@ -110,7 +123,8 @@
         return getResourceWithProperties(conn, resource);
     }
 
-    public ResourceImpl getResourceByID(long artifactID, long versionNumber, Connection conn)
+    public ResourceImpl getResourceByID(
+            long artifactID, long versionNumber, Connection conn)
             throws SQLException, IOException {
 
         ResourceImpl resource = null;
@@ -155,12 +169,18 @@
         ResultSet versionResults = versionQuery.executeQuery();
 
         if (versionResults.next()) {
+            resource.setVersionNumber(
+                    versionResults.getLong(DatabaseConstants.VERSION_NUMBER_FIELD));
             resource.setLastUpdaterUserName(
                     versionResults.getString(DatabaseConstants.VERSION_AUTHOR_FIELD));
             resource.setLastModified(
                     versionResults.getTimestamp(DatabaseConstants.VERSION_UPDATED_TIME));
-            resource.setContentStream(getDisconnectedStream(
-                    versionResults.getBinaryStream(DatabaseConstants.VERSION_CONTENT_FIELD)));
+
+            // set the datasource to fetch the content.
+            resource.setDataSource(dataSource);
+
+            //resource.setContentStream(getDisconnectedStream(
+            //        versionResults.getBinaryStream(DatabaseConstants.VERSION_CONTENT_FIELD)));
         }
 
         // get resource children
@@ -177,6 +197,30 @@
         return getResourceWithProperties(conn, resource);
     }
 
+    public InputStream getResourceContentStream(
+            long resourceID, long versionNumber, Connection conn)
+            throws SQLException, IOException {
+
+        if (versionNumber == -1) {
+            versionNumber = getLatestVersionNumber(resourceID, conn);
+        }
+        
+        String sqlVersionedFields = "SELECT * FROM VERSIONS WHERE AID=? AND VN=?";
+        PreparedStatement versionQuery = conn.prepareStatement(sqlVersionedFields);
+        versionQuery.setLong(1, resourceID);
+        versionQuery.setLong(2, versionNumber);
+
+        ResultSet versionResults = versionQuery.executeQuery();
+
+        InputStream contentStream = null;
+        if (versionResults.next()) {
+            contentStream = getDisconnectedStream(
+                    versionResults.getBinaryStream(DatabaseConstants.VERSION_CONTENT_FIELD));
+        }
+
+        return contentStream;
+    }
+
     private ResourceImpl getResourceWithProperties(Connection conn, ResourceImpl resource)
             throws SQLException {
         String propSQL = "SELECT P.PKEY, P.PVALUE FROM PROPERTIES P WHERE P.AID=?";
@@ -402,13 +446,20 @@
         ResultSet versionResults = versionQuery.executeQuery();
 
         if (versionResults.next()) {
+            resource.setVersionNumber(
+                    versionResults.getLong(DatabaseConstants.VERSION_NUMBER_FIELD));
             resource.setLastUpdaterUserName(
                     versionResults.getString(DatabaseConstants.VERSION_AUTHOR_FIELD));
             resource.setLastModified(
                     versionResults.getTimestamp(DatabaseConstants.VERSION_UPDATED_TIME));
-            if (!isDirectory)
-                resource.setContentStream(getDisconnectedStream(
-                        versionResults.getBinaryStream(DatabaseConstants.VERSION_CONTENT_FIELD)));
+
+            // set the datasource to fetch the content.
+            resource.setDataSource(dataSource);
+            
+            //if (!isDirectory) {
+            //    resource.setContentStream(getDisconnectedStream(
+            //            versionResults.getBinaryStream(DatabaseConstants.VERSION_CONTENT_FIELD)));
+            //}
         }
 
         // get resource children
@@ -928,6 +979,11 @@
             throws SQLException, IOException, RegistryException {
 
         ResourceImpl resource = getLatestVersion(oldPath, conn);
+
+        // calling the getContentStream loads the input stream to the resource. so we can
+        // access it even after changing the original resource.
+        resource.setContentStream(resource.getContentStream());
+        
         String resourcePath = resource.getPath();
         long resourceID = resource.getId();
         //to see whether the patent node is there in the table , if not need to add that
@@ -959,10 +1015,11 @@
             CommentsDAO commentsDAO = new CommentsDAO();
             commentsDAO.copyComments(oldPath, resourceID, conn);
             //coping the tags
-            TagsDAO tags = new TagsDAO();
+            TagsDAO tags = new TagsDAO(dataSource);
             tags.copyTags(fromResourceId, resourceID, conn);
 
-            // copy ratings
+            // copy ratings// set the datasource to fetch the content.
+            resource.setDataSource(dataSource);
             RatingsDAO ratingsDAO = new RatingsDAO();
             ratingsDAO.copyRatings(fromResourceId, resourceID, conn);
 
@@ -1021,7 +1078,7 @@
                 CommentsDAO commentsDAO = new CommentsDAO();
                 commentsDAO.copyComments(fromPath, resourceId, conn);
                 //coping the tags
-                TagsDAO tags = new TagsDAO();
+                TagsDAO tags = new TagsDAO(dataSource);
                 tags.copyTags(fromResourceId, resourceId, conn);
 
                 // copy ratings

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/Handler.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/Handler.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/Handler.java	Wed Mar  5 02:07:51 2008
@@ -70,7 +70,7 @@
     protected Registry registry;
 
     /** ResourceDAO for directly accessing resources. */
-    protected VersionedResourceDAO resourceDAO = new VersionedResourceDAO();
+    protected VersionedResourceDAO resourceDAO = new VersionedResourceDAO(dataSource);
 
     /** Some common authorization tasks are implemented in this util. */
     protected AuthorizationUtil authorizationUtil = new AuthorizationUtil();

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/builtin/TagURLHandler.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/builtin/TagURLHandler.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/builtin/TagURLHandler.java	Wed Mar  5 02:07:51 2008
@@ -66,7 +66,7 @@
         }
 
         try {
-            TagsDAO tagsDAO = new TagsDAO();
+            TagsDAO tagsDAO = new TagsDAO(dataSource);
             TaggingDO taggingDO = tagsDAO.getTagging(resourcePath, tagName, userName, conn);
 
             ResourceImpl resource = new ResourceImpl();

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeHandler.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeHandler.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeHandler.java	Wed Mar  5 02:07:51 2008
@@ -73,7 +73,7 @@
     protected Registry registry;
 
     /** ResourceDAO for directly accessing resources. */
-    protected VersionedResourceDAO resourceDAO = new VersionedResourceDAO();
+    protected VersionedResourceDAO resourceDAO = new VersionedResourceDAO(dataSource);
 
     /** Some common authorization tasks are implemented in this util. */
     protected AuthorizationUtil authorizationUtil = new AuthorizationUtil();

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeManager.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeManager.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeManager.java	Wed Mar  5 02:07:51 2008
@@ -49,7 +49,7 @@
 
     private DataSource dataSource = null;
 
-    private VersionedResourceDAO resourceDAO = new VersionedResourceDAO();
+    private VersionedResourceDAO resourceDAO = new VersionedResourceDAO(dataSource);
 
     private Map mediaTypeHandlers = new HashMap();
     private DefaultMediaTypeHandler defaultMediaTypeHandler;

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/queries/SQLQueryProcessor.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/queries/SQLQueryProcessor.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/queries/SQLQueryProcessor.java	Wed Mar  5 02:07:51 2008
@@ -217,7 +217,7 @@
 
             long taggingID = results.getLong(DatabaseConstants.TAGGING_ID_FIELD);
 
-            TagsDAO tagsDAO = new TagsDAO();
+            TagsDAO tagsDAO = new TagsDAO(dataSource);
             TaggingDO taggingDO = tagsDAO.getTagging(taggingID, conn);
 
             //String userName = results.getString(DatabaseConstants.USER_ID_FIELD);

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/urlhandlers/TagURLHandler.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/urlhandlers/TagURLHandler.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/urlhandlers/TagURLHandler.java	Wed Mar  5 02:07:51 2008
@@ -75,7 +75,7 @@
         }
 
         try {
-            TagsDAO tagsDAO = new TagsDAO();
+            TagsDAO tagsDAO = new TagsDAO(dataSource);
             TaggingDO taggingDO = tagsDAO.getTagging(resourcePath, tagName, userName, conn);
 
             ResourceImpl resource = new ResourceImpl();



More information about the Registry-dev mailing list