[Registry-dev] svn commit r16810 - in trunk/registry/modules/core/src: main/java/org/wso2/registry/app main/java/org/wso2/registry/config main/java/org/wso2/registry/jdbc main/java/org/wso2/registry/jdbc/handlers main/java/org/wso2/registry/jdbc/utils/creators main/java/org/wso2/registry/servlet test/java/org/wso2/registry/jdbc

svn at wso2.org svn at wso2.org
Sun May 11 19:35:50 PDT 2008


Author: glen
Date: Sun May 11 19:35:49 2008
New Revision: 16810

Log:
* Rationalize registry initialization.  Now all Registries have to have a RegistryContext at startup, so we can make sure Aspects are correctly initialized and remain consistent.  Aspects are now kept exclusively in RegistryContext.  EmbeddedRegistry uses the same RegistryContext for all created registries.

* Replace 2006 year attribution with 2008

NOTE - We need to completely finish with cleaning up the creation/factory code (i.e. EmbeddedRegistry / RegistryFactory / RegistryContext / registry.xml) the way we want it.  Need to discuss this on the list and finish ASAP.


Modified:
   trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RegistryAdapter.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RegistryProvider.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfigurationProcessor.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryContext.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/EmbeddedRegistry.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/InMemoryEmbeddedRegistry.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/NonTransactionalJDBCRegistry.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/TransactionalJDBCRegistry.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/RequestContext.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/utils/creators/DatabaseCreator.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
   trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/LifeCycleTest.java

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RegistryAdapter.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RegistryAdapter.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RegistryAdapter.java	Sun May 11 19:35:49 2008
@@ -576,7 +576,7 @@
             }
         }
         boolean recentFirst = recentParam == null || recentParam.equals("true");
-        int action = 0;
+        int action = -1;
         LogEntry [] logs;
         try {
             final Registry reg = getSecureRegistry(request);

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RegistryProvider.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RegistryProvider.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RegistryProvider.java	Sun May 11 19:35:49 2008
@@ -44,14 +44,13 @@
         if (context != null) {
             embeddedRegistry = context.getEmbeddedRegistry();
         } else {
-            RegistryContext ctx = new RegistryContext();
             InputStream is = null;
             try {
                 is = new FileInputStream("registry.xml");
             } catch (FileNotFoundException e) {
                 // no problemo
             }
-            RegistryConfigurationProcessor.populateRegistryConfig(is, ctx);
+            RegistryContext ctx = new RegistryContext(is);
             RegistryContext.setRegistryContext(ctx);
         }
 

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfigurationProcessor.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfigurationProcessor.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfigurationProcessor.java	Sun May 11 19:35:49 2008
@@ -42,15 +42,6 @@
 
     private static final Log log = LogFactory.getLog(RegistryConfigurationProcessor.class);
 
-    public static void populateRegistryConfig(String filename, RegistryContext context)
-            throws RegistryException {
-        try {
-            populateRegistryConfig(new FileInputStream(filename), context);
-        } catch (FileNotFoundException e) {
-            throw new RegistryException(e.getMessage(), e);
-        }
-    }
-
     /**
      * Read XML configuration from the passed InputStream, or from the classpath.
      *

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryContext.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryContext.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryContext.java	Sun May 11 19:35:49 2008
@@ -30,6 +30,7 @@
 
 import javax.sql.DataSource;
 import java.util.*;
+import java.io.InputStream;
 
 public class RegistryContext {
     public interface RegURLSupplier {
@@ -60,11 +61,18 @@
         registryContext = context;
     }
 
-    public RegistryContext() {
+    public RegistryContext() throws RegistryException {
+        this(null);
     }
 
-    public RegistryContext(RegURLSupplier urlSupplier) {
+    public RegistryContext(InputStream configStream) throws RegistryException {
+        RegistryConfigurationProcessor.populateRegistryConfig(configStream, this);
+    }
+
+    public RegistryContext(InputStream configStream, RegURLSupplier urlSupplier)
+            throws RegistryException {
         this.urlSupplier = urlSupplier;
+        RegistryConfigurationProcessor.populateRegistryConfig(configStream, this);
     }
 
     public Repository getRepository() {
@@ -184,7 +192,8 @@
     }
 
     public String [] getAspectNames() {
-        return (String [])aspects.keySet().toArray();
+        final Set aspectNames = aspects.keySet();
+        return (String [])aspectNames.toArray(new String[aspectNames.size()]);
     }
 
     public List getQueryProcessors() {

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/EmbeddedRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/EmbeddedRegistry.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/EmbeddedRegistry.java	Sun May 11 19:35:49 2008
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,9 +16,9 @@
 
 package org.wso2.registry.jdbc;
 
-import org.wso2.registry.Registry;
 import org.wso2.registry.RegistryException;
 import org.wso2.registry.RegistryConstants;
+import org.wso2.registry.config.RegistryContext;
 import org.wso2.registry.jdbc.realm.RegistryRealm;
 import org.wso2.registry.jdbc.utils.creators.DatabaseCreator;
 import org.wso2.registry.jdbc.utils.creators.DatabaseCreatorFactory;
@@ -31,43 +31,35 @@
 
     private JDBCRegistry jdbcRegistry;
     private UserRealm defaultRealm;
-    private DataSource dataSource;
+    protected RegistryContext registryContext;
 
-    public EmbeddedRegistry(DataSource dataSource) throws RegistryException {
-        configure(dataSource);
+    public EmbeddedRegistry(RegistryContext context) throws RegistryException {
+        this.registryContext = context;
+        configure();
     }
 
-    public EmbeddedRegistry(DataSource dataSource, UserRealm realm) throws RegistryException {
-        configure(dataSource, realm);
+    public EmbeddedRegistry(RegistryContext context, UserRealm realm) throws RegistryException {
+        this.registryContext = context;
+        configure(realm);
     }
 
-    /**
-     * Subclasses may use this constructor, which need to set datasource and realm after
-     * instantiating the registry.
-     */
-    protected EmbeddedRegistry() {}
+    protected EmbeddedRegistry() {
+    }
 
-    public void configure(DataSource dataSource) throws RegistryException {
-        this.dataSource = dataSource;
+    protected void configure() throws RegistryException {
+        DataSource dataSource = registryContext.getDataSource();
 
         DatabaseCreator databaseCreator = DatabaseCreatorFactory.getDatabaseCreator(dataSource);
         databaseCreator.createRegistryDatabase();
         databaseCreator.createUserManagerDatabase();
 
         defaultRealm = new RegistryRealm(dataSource);
-        jdbcRegistry = new JDBCRegistry(dataSource, defaultRealm);
+        jdbcRegistry = new JDBCRegistry(registryContext, defaultRealm);
     }
 
-    protected void configure(DataSource dataSource, UserRealm defaultRealm)
-            throws RegistryException {
-
-        this.dataSource = dataSource;
+    protected void configure(UserRealm defaultRealm) throws RegistryException {
         this.defaultRealm = defaultRealm;
-
-        DatabaseCreator databaseCreator = DatabaseCreatorFactory.getDatabaseCreator(dataSource);
-        databaseCreator.createRegistryDatabase();
-
-        jdbcRegistry = new JDBCRegistry(dataSource, defaultRealm);
+        configure();
     }
 
     public UserRegistry getUserRegistry() throws RegistryException {
@@ -76,7 +68,7 @@
                 RegistryConstants.ANONYMOUS_PASSWORD,
                 jdbcRegistry,
                 defaultRealm,
-                dataSource);
+                registryContext.getDataSource());
     }
 
     /**
@@ -92,14 +84,16 @@
                 RegistryConstants.SYSTEM_PASSWORD,
                 jdbcRegistry,
                 defaultRealm,
-                dataSource);
+                registryContext.getDataSource());
     }
 
     public UserRegistry getUserRegistry(String userName, String password) throws RegistryException {
-        return new UserRegistry(userName, password, jdbcRegistry, defaultRealm, dataSource);
+        return new UserRegistry(userName, password, jdbcRegistry, defaultRealm,
+                                registryContext.getDataSource());
     }
 
     public UserRegistry getUserRegistry(String userName) throws RegistryException {
-        return new UserRegistry(userName, jdbcRegistry, defaultRealm, dataSource);
+        return new UserRegistry(userName, jdbcRegistry, defaultRealm,
+                                registryContext.getDataSource());
     }
 }

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/InMemoryEmbeddedRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/InMemoryEmbeddedRegistry.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/InMemoryEmbeddedRegistry.java	Sun May 11 19:35:49 2008
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
 
 import org.wso2.registry.jdbc.utils.RegistryDataSource;
 import org.wso2.registry.RegistryException;
+import org.wso2.registry.config.RegistryContext;
 import org.wso2.registry.users.UserRealm;
 
 public class InMemoryEmbeddedRegistry extends EmbeddedRegistry {
@@ -28,29 +29,22 @@
     public static final String INMEMORY_DB_PASSWORD = "";
 
     public InMemoryEmbeddedRegistry() throws RegistryException {
-
+        registryContext = new RegistryContext();
         RegistryDataSource dataSource = new RegistryDataSource(INMEMORY_DB_URL,
                                                                INMEMORY_DB_DRIVER_NAME,
                                                                INMEMORY_DB_USER_NAME,
                                                                INMEMORY_DB_PASSWORD);
-
-        // create registry database tables
-        //DatabaseCreator.createDatabase(dataSource);
-
-        //UserRealm realm = new InMemoryRegistryRealm();
-
-        super.configure(dataSource);
+        registryContext.setDataSource(dataSource);
+        super.configure();
     }
 
     public InMemoryEmbeddedRegistry(UserRealm defaultRealm) throws RegistryException {
-
+        registryContext = new RegistryContext();
         RegistryDataSource dataSource = new RegistryDataSource(INMEMORY_DB_URL,
                                                                INMEMORY_DB_DRIVER_NAME,
                                                                INMEMORY_DB_USER_NAME,
                                                                INMEMORY_DB_PASSWORD);
-
-        //DatabaseCreator.createDatabase(dataSource);
-
-        super.configure(dataSource, defaultRealm);
+        registryContext.setDataSource(dataSource);
+        super.configure(defaultRealm);
     }
 }

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	Sun May 11 19:35:49 2008
@@ -47,8 +47,6 @@
 import java.sql.SQLException;
 import java.util.Map;
 import java.util.Date;
-import java.util.HashMap;
-import java.util.Set;
 
 /**
  * JDBC based implementation of the Registry. This will be used mostly as the back-end by other
@@ -68,7 +66,6 @@
     protected HandlerManager handlerManager;
     protected Repository repository;
     protected VersionRepository versionRepository;
-    private Map<String, Aspect> aspects = new HashMap<String, Aspect>();
 
     private UserRealm defaultRealm = null;
     protected RegistryContext registryContext;
@@ -83,32 +80,20 @@
     }
 
     /**
-     * Constructs a JDBC registry to be used without any security (authorizations on actions). JDBC
-     * registry instances created using this constructor should not be used with SecureRegistry
-     * instances.
-     *
-     * @param dataSource Data source to be used to store resources and metadata.
-     * @throws RegistryException : If something went wrong while init
-     */
-    public JDBCRegistry(DataSource dataSource) throws RegistryException {
-        this.dataSource = dataSource;
-        init(null);
-    }
-
-    /**
      * Constructs a JDBC registry to be used with secure registries. Default authorizations will be
      * applied on the resources created using this registry.
      *
-     * @param dataSource Data source to be used to store resources and metadata. Note that the same
-     *                   data source may or may not be used as the data source of user manager.
+     * @param registryContext RegistryContext containing our configuration and DataSource.  Note
+     *                        that this may or may not be the same data source as the UserManager
      * @param realm      User manager realm to handle authorizations. It is strongly recommended to
      *                   use a realm instance constructed using the RegistryRealmFactory. All
      *                   initial users, roles and authorizations will be set on realms obtained
      *                   using the RegistryRealmFactory.
      * @throws RegistryException : If something went wrong
      */
-    public JDBCRegistry(DataSource dataSource, UserRealm realm) throws RegistryException {
-        this.dataSource = dataSource;
+    public JDBCRegistry(RegistryContext registryContext, UserRealm realm) throws RegistryException {
+        this.registryContext = registryContext;
+        this.dataSource = registryContext.getDataSource();
         init(realm);
     }
 
@@ -129,7 +114,7 @@
 
         FileManager.init();
 
-                defaultRealm = realm;
+        defaultRealm = realm;
 
         try {
             systemUserRealm = new AuthorizingRealm();
@@ -153,10 +138,6 @@
         QueryProcessorManager queryProcessorManager =
                 new QueryProcessorManager(dataSource, realm, this);
 
-        RegistryContext registryContext = RegistryContext.getRegistryContext();
-        //RegistryContext registryContext = (RegistryContext)System.
-        //        getProperties().get(RegistryConstants.REGISTRY_CONTEXT);
-
         if (registryContext == null) {
             registryContext = new RegistryContext();
             RegistryContext.setRegistryContext(registryContext);
@@ -172,7 +153,7 @@
 
         transactionalRegistry =
                 new TransactionalJDBCRegistry(registryContext, handlerManager, repository,
-                                              versionRepository, queryProcessorManager, aspects);
+                                              versionRepository, queryProcessorManager);
 
         nonTransactionalRegistry = new NonTransactionalJDBCRegistry(
                 transactionalRegistry, dataSource);
@@ -630,12 +611,12 @@
     }
 
     public String[] getAvailableAspects() {
-        final Set<String> keys = aspects.keySet();
-        return keys.toArray(new String[keys.size()]);
+        return registryContext.getAspectNames();
     }
 
     public void addAspect(String name, Aspect aspect) throws RegistryException {
-        aspects.put(name, aspect);
+        aspect.setName(name);
+        registryContext.addAspect(aspect);
     }
 
     public void associateAspect(String resourcePath, String aspect) throws RegistryException {

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/NonTransactionalJDBCRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/NonTransactionalJDBCRegistry.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/NonTransactionalJDBCRegistry.java	Sun May 11 19:35:49 2008
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,27 +16,19 @@
 
 package org.wso2.registry.jdbc;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.wso2.registry.*;
-import org.wso2.registry.Collection;
 import org.wso2.registry.config.RegistryContext;
-import org.wso2.registry.utils.RegistryUtils;
-import org.wso2.registry.session.CurrentSession;
-import org.wso2.registry.i18n.Messages;
-import org.wso2.registry.exceptions.ResourceNotFoundException;
-import org.wso2.registry.jdbc.handlers.RequestContext;
 import org.wso2.registry.jdbc.handlers.Handler;
-import org.wso2.registry.jdbc.handlers.HandlerManager;
 import org.wso2.registry.jdbc.handlers.filters.Filter;
-import org.wso2.registry.jdbc.dao.*;
 import org.wso2.registry.jdbc.utils.Transaction;
-import org.wso2.registry.jdbc.queries.QueryProcessorManager;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 import javax.sql.DataSource;
 import java.sql.Connection;
 import java.sql.SQLException;
-import java.util.*;
+import java.util.Date;
+import java.util.Map;
 
 public class NonTransactionalJDBCRegistry implements Registry {
 
@@ -218,7 +210,7 @@
 
     public boolean resourceExists(String path) throws RegistryException {
 
-        boolean exists = false;
+        boolean exists;
 
         try {
             beginTransaction();
@@ -606,7 +598,7 @@
 
     public Association[] getAllAssociations(String resourcePath) throws RegistryException {
 
-        Association[] associations = null;
+        Association[] associations;
         try {
 
             beginTransaction();
@@ -654,7 +646,7 @@
     public Association[] getAssociations(String resourcePath, String associationType)
             throws RegistryException {
 
-        Association[] associations = null;
+        Association[] associations;
         try {
 
             beginTransaction();

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/TransactionalJDBCRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/TransactionalJDBCRegistry.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/TransactionalJDBCRegistry.java	Sun May 11 19:35:49 2008
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,7 +46,6 @@
     private HandlerManager handlerManager;
     private Repository repository;
     private QueryProcessorManager queryProcessorManager;
-    private Map<String, Aspect> aspects;
     private VersionRepository versionRepository;
 
     private ResourceDAO resourceDAO = new ResourceDAO();
@@ -60,14 +59,12 @@
                                      HandlerManager handlerManager,
                                      Repository repository,
                                      VersionRepository versionRepository,
-                                     QueryProcessorManager queryProcessorManager,
-                                     Map<String, Aspect> aspects) {
+                                     QueryProcessorManager queryProcessorManager) {
         this.registryContext = registryContext;
         this.handlerManager = handlerManager;
         this.repository = repository;
         this.versionRepository = versionRepository;
         this.queryProcessorManager = queryProcessorManager;
-        this.aspects = aspects;
     }
 
     public void beginTransaction() throws RegistryException {
@@ -837,8 +834,7 @@
     }
 
     public String[] getAvailableAspects() {
-        final Set<String> keys = aspects.keySet(); // TODO - which aspects, here or context?
-        return keys.toArray(new String[keys.size()]);
+        return registryContext.getAspectNames();
     }
 
     public void addAspect(String name, Aspect aspect) throws RegistryException {
@@ -851,20 +847,16 @@
         //TODO need to do the security validation here
         Resource resource = get(resourcePath);
         Aspect aspect = getAspect(name);
+        if (aspect == null) {
+            throw new RegistryException("Couldn't find aspect '" + name + "'");
+        }
         aspect.associate(resource, this);
         resource.addAspect(name);
         put(resource.getPath(), resource);
     }
 
     private Aspect getAspect(String name) throws RegistryException {
-        Aspect aspect = aspects.get(name);
-        if (aspect == null) {
-            aspect = registryContext.getAspect(name);
-        }
-        if (aspect == null) {
-            throw new RegistryException(" No aspect object found for the name :"  + name);
-        }
-        return aspect;
+        return registryContext.getAspect(name);
     }
 
     //public void addAspect(String name, Aspect aspect) {

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/RequestContext.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/RequestContext.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/RequestContext.java	Sun May 11 19:35:49 2008
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/utils/creators/DatabaseCreator.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/utils/creators/DatabaseCreator.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/utils/creators/DatabaseCreator.java	Sun May 11 19:35:49 2008
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -225,4 +225,4 @@
     public abstract String getUserPermissionTable();
 
     public abstract String getUserRolesTable();
-}
\ No newline at end of file
+}

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java	Sun May 11 19:35:49 2008
@@ -24,7 +24,6 @@
 import org.wso2.registry.*;
 import org.wso2.registry.session.UserRegistry;
 import org.wso2.registry.config.DataBaseConfiguration;
-import org.wso2.registry.config.RegistryConfigurationProcessor;
 import org.wso2.registry.config.RegistryContext;
 import org.wso2.registry.config.HandlerConfiguration;
 import org.wso2.registry.i18n.Messages;
@@ -47,6 +46,9 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.sql.DataSource;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.net.URLDecoder;
 import java.util.Iterator;
 
@@ -67,21 +69,27 @@
             // read the registry.xml file from the configured location. if not configured, read the
             // default registry.xml file bundled with the webapp.
             String configPath = config.getInitParameter(RegistryConstants.REGISTRY_CONFIG_PATH);
+            InputStream configStream;
+            if (configPath != null) {
+                try {
+                    configStream = new FileInputStream(configPath);
+                } catch (FileNotFoundException e) {
+                    throw new ServletException("Couldn't find specified config file '" +
+                                               configPath + "'", e);
+                }
+            } else {
+                configStream =
+                        config.getServletContext().getResourceAsStream("/WEB-INF/registry.xml");
+            }
 
-            RegistryContext registryContext = new RegistryContext(
+            RegistryContext registryContext = new RegistryContext(configStream,
                     new RegistryContext.RegURLSupplier() {
                         public String getURL() {
                             return config.getServletContext().getRealPath("/WEB-INF");
                         }
                     });
+
             RegistryContext.setRegistryContext(registryContext);
-            if (configPath != null) {
-                RegistryConfigurationProcessor.populateRegistryConfig(configPath, registryContext);
-            } else {
-                RegistryConfigurationProcessor.populateRegistryConfig(
-                        config.getServletContext().getResourceAsStream("/WEB-INF/registry.xml"),
-                        registryContext);
-            }
 
             DataBaseConfiguration dbConfiguration =
                     registryContext.getDefaultDataBaseConfiguration();
@@ -119,7 +127,7 @@
                 //coreRegistry = new JDBCRegistry(dataSource, registryRealm);
                 //coreRegistry.setRegistryContext(registryContext);
 
-                embeddedRegistry = new EmbeddedRegistry(dataSource);
+                embeddedRegistry = new EmbeddedRegistry(registryContext);
             }
 
             // create a system registry and put it in the context

Modified: trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/LifeCycleTest.java
==============================================================================
--- trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/LifeCycleTest.java	(original)
+++ trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/LifeCycleTest.java	Sun May 11 19:35:49 2008
@@ -18,15 +18,10 @@
 
 import junit.framework.TestCase;
 import org.wso2.registry.*;
-import org.wso2.registry.jdbc.realm.RegistryRealm;
-import org.wso2.registry.jdbc.realm.InMemoryRegistryRealm;
-import org.wso2.registry.secure.SecureRegistry;
 import org.wso2.registry.config.RegistryContext;
-import org.wso2.registry.config.RegistryConfigurationProcessor;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.io.InputStream;
 
 public class LifeCycleTest extends TestCase {
 
@@ -42,7 +37,6 @@
             EmbeddedRegistry embeddedRegistry = new InMemoryEmbeddedRegistry();
             registry = embeddedRegistry.getSystemRegistry();
             RegistryContext ctx = new RegistryContext();
-            RegistryConfigurationProcessor.populateRegistryConfig((InputStream)null, ctx);
             registry.setRegistryContext(ctx);
             
             //registry = RegistryFactory.newInstance().getRegistry();



More information about the Registry-dev mailing list