Author: chathura
Date: Wed Jan 16 01:14:57 2008
New Revision: 12323

Log:


Implementing pluggable media type handlers.



Added:
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/MediaTypeHandlerConfiguration.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfigurationProcessor.java
      - copied, changed from r12300, 
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfiguration.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryContext.java
Removed:
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfiguration.java
Modified:
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.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/mediatypes/builtin/WSDLMediaTypeHandler.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/XSDMediaTypeHandler.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/utils/SchemaFileProcessor.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/utils/WSDLFileProcessor.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/realm/RegistryRealm.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/registry.xml
   
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/utils/AdminUtil.java

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java
  (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java
  Wed Jan 16 01:14:57 2008
@@ -34,6 +34,7 @@
 
     public static final String REGISTRY_CONFIG_PATH = "registry.config.path";
     public static final String REGISTRY_CONFIG = "registry.config";
+    public static final String REGISTRY_CONTEXT = "registry.context";
 
     /**
      * Built in user names

Added: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/MediaTypeHandlerConfiguration.java
==============================================================================
--- (empty file)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/MediaTypeHandlerConfiguration.java
       Wed Jan 16 01:14:57 2008
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2006, 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.wso2.registry.config;
+
+public class MediaTypeHandlerConfiguration {
+
+    private String mediaType;
+    private String mediaTypeHandler;
+
+    public String getMediaType() {
+        return mediaType;
+    }
+
+    public void setMediaType(String mediaType) {
+        this.mediaType = mediaType;
+    }
+
+    public String getMediaTypeHandler() {
+        return mediaTypeHandler;
+    }
+
+    public void setMediaTypeHandler(String mediaTypeHandler) {
+        this.mediaTypeHandler = mediaTypeHandler;
+    }
+}

Copied: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfigurationProcessor.java
 (from r12300, 
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfiguration.java)
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfiguration.java
       (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfigurationProcessor.java
      Wed Jan 16 01:14:57 2008
@@ -40,10 +40,7 @@
 import java.sql.Connection;
 import java.sql.SQLException;
 
-public class RegistryConfiguration {
-
-    private DataBaseConfiguration defaultDataBaseConfiguration = null;
-    private Map dbconfgigMap = new HashMap();
+public class RegistryConfigurationProcessor {
 
     /**
      * This method will read the registry.xml and using the data given in the 
file registry
@@ -55,8 +52,10 @@
      * @throws org.wso2.registry.RegistryException
      *          : if something went wrong
      */
-    public void populateRegistryConfig(String xmlLocation, ServletConfig 
servletConfig)
+    public void populateRegistryConfig(
+            String xmlLocation, ServletConfig servletConfig, RegistryContext 
registryContext)
             throws RegistryException {
+
         InputStream in;
         if (xmlLocation != null) {
             try {
@@ -152,7 +151,7 @@
                         }
                     }
 
-                    dbconfgigMap.put(dbName, dataBaseConfiguration);
+                    registryContext.getDbconfgigMap().put(dbName, 
dataBaseConfiguration);
                 }
 
                 OMElement currentConfigElement =
@@ -163,9 +162,42 @@
                 }
 
                 String currentConfigName = currentConfigElement.getText();
-                DataBaseConfiguration currentConfiguration =
-                        getDataBaseConfiguration(currentConfigName);
-                setDefaultDataBaseConfiguration(currentConfiguration);
+                DataBaseConfiguration currentConfiguration = 
(DataBaseConfiguration)
+                        
registryContext.getDbconfgigMap().get(currentConfigName);
+                
registryContext.setDefaultDataBaseConfiguration(currentConfiguration);
+
+                // process media type handler config
+                Iterator mediaTypeHandlers = configElement.
+                        getChildrenWithName(new QName("mediaTypeHandler"));
+                while (mediaTypeHandlers.hasNext()) {
+
+                    MediaTypeHandlerConfiguration 
mediaTypeHandlerConfiguration =
+                            new MediaTypeHandlerConfiguration();
+
+                    OMElement mediaTypeElement = (OMElement) 
mediaTypeHandlers.next();
+                    OMElement mediaTypeName = mediaTypeElement.
+                            getFirstChildWithName(new QName("mediaType"));
+                    if (mediaTypeName != null) {
+                        
mediaTypeHandlerConfiguration.setMediaType(mediaTypeName.getText());
+                    }
+
+                    OMElement mediaTypeHandler = mediaTypeElement.
+                            getFirstChildWithName(new QName("handler"));
+                    if (mediaTypeHandler != null) {
+                        mediaTypeHandlerConfiguration.
+                                
setMediaTypeHandler(mediaTypeHandler.getText());
+                    }
+
+                    
registryContext.addMediaTypeHandler(mediaTypeHandlerConfiguration);
+                }
+
+                // process URL handler config
+                Iterator urlHandlers = configElement.getChildrenWithName(new 
QName("urlHandler"));
+                while (urlHandlers.hasNext()) {
+
+                    OMElement urlHandler = (OMElement) urlHandlers.next();
+                    registryContext.addURLHandler(urlHandler.getText());
+                }
             }
 
         } catch (XMLStreamException e) {
@@ -173,30 +205,18 @@
         }
     }
 
-    public void addDataBaseConfiguration(DataBaseConfiguration 
dataBaseConfiguration) {
-        dbconfgigMap.put(dataBaseConfiguration.getConfigName(), 
dataBaseConfiguration);
-    }
-
-    public DataBaseConfiguration getDataBaseConfiguration(String configName) {
-        return (DataBaseConfiguration)dbconfgigMap.get(configName);
-    }
-
-    public void removeDataBaseConfiguration(String configName) {
-        dbconfgigMap.remove(configName);
-    }
-
-    public OMElement getRegistryConfigAsXML() {
+    public OMElement getRegistryConfigAsXML(RegistryContext registryContext) {
 
         OMFactory factory = OMAbstractFactory.getOMFactory();
         OMElement root = factory.createOMElement("wso2regsitry", null);
 
-        if (getDefaultDataBaseConfiguration() != null) {
+        if (registryContext.getDefaultDataBaseConfiguration() != null) {
             OMElement currrentConfigElement = 
factory.createOMElement("currentConfig", null);
-            
currrentConfigElement.setText(getDefaultDataBaseConfiguration().getConfigName());
+            
currrentConfigElement.setText(registryContext.getDefaultDataBaseConfiguration().getConfigName());
             root.addChild(currrentConfigElement);
         }
 
-        Iterator values = dbconfgigMap.values().iterator();
+        Iterator values = 
registryContext.getDbconfgigMap().values().iterator();
         while (values.hasNext()) {
             DataBaseConfiguration dataBaseConfiguration = 
(DataBaseConfiguration)values.next();
             OMElement config = factory.createOMElement("dbconfig", null);
@@ -218,18 +238,6 @@
         return root;
     }
 
-    public DataBaseConfiguration getDefaultDataBaseConfiguration() {
-        return defaultDataBaseConfiguration;
-    }
-
-    public void setDefaultDataBaseConfiguration(DataBaseConfiguration 
deafultDataBaseConfiguration) {
-        this.defaultDataBaseConfiguration = deafultDataBaseConfiguration;
-    }
-
-    public Map getDbconfgigMap() {
-        return dbconfgigMap;
-    }
-
     private String getDBURL(ServletConfig config) {
 
         String webinf = config.getServletContext().getRealPath("/WEB-INF");

Added: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryContext.java
==============================================================================
--- (empty file)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryContext.java
     Wed Jan 16 01:14:57 2008
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2006, 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.wso2.registry.config;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
+
+public class RegistryContext {
+
+    private DataBaseConfiguration defaultDataBaseConfiguration = null;
+    private Map dbconfgigMap = new HashMap();
+    private List mediaTypeHandlers = new ArrayList();
+    private List urlHandlers = new ArrayList();
+
+    public DataBaseConfiguration getDefaultDataBaseConfiguration() {
+        return defaultDataBaseConfiguration;
+    }
+
+    public void setDefaultDataBaseConfiguration(DataBaseConfiguration 
defaultDataBaseConfiguration) {
+        this.defaultDataBaseConfiguration = defaultDataBaseConfiguration;
+    }
+
+    public Map getDbconfgigMap() {
+        return dbconfgigMap;
+    }
+
+    public void setDbconfgigMap(Map dbconfgigMap) {
+        this.dbconfgigMap = dbconfgigMap;
+    }
+
+    public List getMediaTypeHandlers() {
+        return mediaTypeHandlers;
+    }
+
+    public void setMediaTypeHandlers(List mediaTypeHandlers) {
+        this.mediaTypeHandlers = mediaTypeHandlers;
+    }
+
+    public void addMediaTypeHandler(MediaTypeHandlerConfiguration 
mediaTypeHandlerConfiguration) {
+        mediaTypeHandlers.add(mediaTypeHandlerConfiguration);
+    }
+
+    public List getUrlHandlers() {
+        return urlHandlers;
+    }
+
+    public void setUrlHandlers(List urlHandlers) {
+        this.urlHandlers = urlHandlers;
+    }
+
+    public void addURLHandler(String urlHandler) {
+        urlHandlers.add(urlHandler);
+    }
+}

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 Jan 16 01:14:57 2008
@@ -21,6 +21,8 @@
 import org.wso2.registry.RegistryConstants;
 import org.wso2.registry.RegistryException;
 import org.wso2.registry.Resource;
+import org.wso2.registry.config.RegistryContext;
+import org.wso2.registry.config.MediaTypeHandlerConfiguration;
 import org.wso2.registry.exceptions.ResourceNotFoundException;
 import org.wso2.registry.i18n.Messages;
 import org.wso2.registry.jdbc.JDBCRegistry;
@@ -33,6 +35,9 @@
 import java.sql.SQLException;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.List;
+import java.util.Iterator;
+import java.lang.reflect.Constructor;
 
 /**
  * Handles the actions by delegating them to registered media type handlers. 
If a mediatype handler
@@ -42,7 +47,7 @@
  */
 public class MediaTypeManager {
 
-    private static final Log log = LogFactory.getLog(JDBCRegistry.class);
+    private static final Log log = LogFactory.getLog(MediaTypeManager.class);
 
     private DataSource dataSource = null;
 
@@ -51,7 +56,7 @@
     private Map mediaTypeHandlers = new HashMap();
     private DefaultMediaTypeHandler defaultMediaTypeHandler;
 
-    public MediaTypeManager(DataSource dataSource, Realm realm) {
+    public MediaTypeManager(DataSource dataSource, Realm realm) throws 
RegistryException {
 
         this.dataSource = dataSource;
 
@@ -62,17 +67,54 @@
                 new SQLQueryMediaTypeHandler(dataSource, realm, this);
         mediaTypeHandlers.put(RegistryConstants.SQL_QUERY_MEDIA_TYPE, 
sqlMediaTypeHandler);
 
-        MediaTypeHandler synRepoMediaTypeHandler =
-                new SynapseRepositoryMediaTypeHandler(dataSource, realm, this);
-        mediaTypeHandlers.put(
-                RegistryConstants.SYNPASE_REPOSITORY_MEDIA_TYPE, 
synRepoMediaTypeHandler);
-
-        MediaTypeHandler wsdlMediaTypeHandler =
-                new WSDLMediaTypeHandler(dataSource, realm, this);
-        mediaTypeHandlers.put(RegistryConstants.WSDL_MEDIA_TYPE, 
wsdlMediaTypeHandler);
+        RegistryContext registryContext =
+                (RegistryContext) 
System.getProperties().get(RegistryConstants.REGISTRY_CONTEXT);
 
-        MediaTypeHandler xsdMediaTypeHandler = new 
XSDMediaTypeHandler(dataSource, realm, this);
-        mediaTypeHandlers.put(RegistryConstants.XSD_MEDIA_TYPE, 
xsdMediaTypeHandler);
+        if (registryContext != null) {
+            List mediaTypeConfigs = registryContext.getMediaTypeHandlers();
+            Iterator mediaTypeIterator = mediaTypeConfigs.iterator();
+
+            while (mediaTypeIterator.hasNext()) {
+
+                MediaTypeHandlerConfiguration configuration =
+                        (MediaTypeHandlerConfiguration) 
mediaTypeIterator.next();
+
+                try {
+                    Class handlerClass = 
Class.forName(configuration.getMediaTypeHandler());
+
+                    Constructor handlerConstructor = 
handlerClass.getConstructor(
+                            new Class[] { DataSource.class, Realm.class, 
MediaTypeManager.class});
+
+                    MediaTypeHandler mediaTypeHandler = (MediaTypeHandler)
+                            handlerConstructor.newInstance(new Object[] { 
dataSource, realm, this});
+
+                    mediaTypeHandlers.put(configuration.getMediaType(), 
mediaTypeHandler);
+
+                } catch (ClassNotFoundException cnfe) {
+                    String msg = "Could not find the implementation class: " + 
configuration.getMediaTypeHandler() + " for the media type: " + 
configuration.getMediaType();
+                    log.error(msg, cnfe);
+                    throw new RegistryException(msg, cnfe);
+
+                } catch (Exception e) {
+
+                    String msg = "Could not instantiate the media type 
handler.";
+                    log.error(msg, e);
+                    throw new RegistryException(msg, e);
+                }
+            }
+        }
+
+        //MediaTypeHandler synRepoMediaTypeHandler =
+        //        new SynapseRepositoryMediaTypeHandler(dataSource, realm, 
this);
+        //mediaTypeHandlers.put(
+        //        RegistryConstants.SYNPASE_REPOSITORY_MEDIA_TYPE, 
synRepoMediaTypeHandler);
+        //
+        //MediaTypeHandler wsdlMediaTypeHandler =
+        //        new WSDLMediaTypeHandler(dataSource, realm, this);
+        //mediaTypeHandlers.put(RegistryConstants.WSDL_MEDIA_TYPE, 
wsdlMediaTypeHandler);
+        //
+        //MediaTypeHandler xsdMediaTypeHandler = new 
XSDMediaTypeHandler(dataSource, realm, this);
+        //mediaTypeHandlers.put(RegistryConstants.XSD_MEDIA_TYPE, 
xsdMediaTypeHandler);
     }
 
     public Resource get(String path) throws RegistryException {
@@ -117,7 +159,7 @@
                     boolean allowed = parentMediaTypeHandler.putChild(path, 
resource);
                     if (!allowed) {
                         String msg = "Attempted to add unrecognized resource 
in to the typed " +
-                                     "collection " + 
parentCollection.getMediaType();
+                                "collection " + 
parentCollection.getMediaType();
                         log.info(msg);
                         throw new RegistryException(msg);
                     }
@@ -155,7 +197,7 @@
                     boolean allowed = parentMediaTypeHandler.importChild(path, 
sourceURL);
                     if (!allowed) {
                         String msg = "Attempted to add unrecognized resource 
in to the typed " +
-                                     "collection " + 
parentCollection.getMediaType();
+                                "collection " + 
parentCollection.getMediaType();
                         log.info(msg);
                         throw new RegistryException(msg);
                     }

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/WSDLMediaTypeHandler.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/WSDLMediaTypeHandler.java
       (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/WSDLMediaTypeHandler.java
       Wed Jan 16 01:14:57 2008
@@ -52,7 +52,7 @@
 
     public boolean importResource(String path, String sourceURL, String 
mediaType) throws RegistryException {
 
-        wsdlFileProcessor.saveWSDLFileToRegistry(sourceURL, 
getParentPath(path));
+        wsdlFileProcessor.saveWSDLFileToRegistry(sourceURL, 
getParentPath(path), true);
         return true;
     }
 

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/XSDMediaTypeHandler.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/XSDMediaTypeHandler.java
        (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/XSDMediaTypeHandler.java
        Wed Jan 16 01:14:57 2008
@@ -52,7 +52,7 @@
 
     public boolean importResource(String path, String sourceURL, String 
mediaType) throws RegistryException {
 
-        schemaFileProcessor.saveSchemaFileToRegistry(sourceURL, 
getParentPath(path));
+        schemaFileProcessor.saveSchemaFileToRegistry(sourceURL, 
getParentPath(path), true);
         return true;
     }
 

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/utils/SchemaFileProcessor.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/utils/SchemaFileProcessor.java
  (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/utils/SchemaFileProcessor.java
  Wed Jan 16 01:14:57 2008
@@ -50,10 +50,10 @@
      * @throws FileNotFoundException
      */
 
-    public void saveSchemaFileToRegistry(String location, String 
registryBasePath)
+    public void saveSchemaFileToRegistry(String location, String 
registryBasePath,boolean processInclueds)
             throws RegistryException {
 
-        saveSchemaFileToRegistry(location, new HashMap(), registryBasePath);
+        saveSchemaFileToRegistry(location, new HashMap(), 
registryBasePath,processInclueds);
     }
 
     /**
@@ -61,7 +61,7 @@
      * @param processedSchemaMap - this map contains schema source URI vs new 
schema locaitons.
      */
     public void saveSchemaFileToRegistry(String location,
-                                         Map processedSchemaMap, String 
registryBasePath)
+                                         Map processedSchemaMap, String 
registryBasePath,boolean processInclueds)
             throws RegistryException {
 
         XmlSchemaCollection xmlSchemaCollection = new XmlSchemaCollection();
@@ -70,8 +70,8 @@
         // hence passes null to validator.
         XmlSchema xmlSchema = xmlSchemaCollection.read(inputSource, null);
         // this is not an inline wsdl schema. so pass null to change map.
-        calculateNewSchemaNames(xmlSchema, processedSchemaMap, new HashSet(), 
false);
-        saveSchemaFileToRegistry(xmlSchema, processedSchemaMap, null, new 
HashSet(), false, registryBasePath);
+        calculateNewSchemaNames(xmlSchema, processedSchemaMap, new HashSet(), 
false,processInclueds);
+        saveSchemaFileToRegistry(xmlSchema, processedSchemaMap, null, new 
HashSet(), false, registryBasePath,processInclueds);
     }
 
     /**
@@ -91,32 +91,36 @@
     public void calculateNewSchemaNames(XmlSchema xmlSchema,
                                         Map processedSchemaMap,
                                         Set visitedShemas,
-                                        boolean isWsdlInlineSchema) {
+                                        boolean isWsdlInlineSchema,
+                                        boolean processInclues) {
 
-        // first process the imports and includes
-        XmlSchemaObjectCollection includes = xmlSchema.getIncludes();
-        // set this as an visited schema to stop recursion
-        visitedShemas.add(xmlSchema.getSourceURI());
-        if (includes != null) {
-            Object externalComponet = null;
-            XmlSchemaExternal xmlSchemaExternal = null;
-            XmlSchema innerSchema = null;
-            for (Iterator iter = includes.getIterator(); iter.hasNext();) {
-                externalComponet = iter.next();
-                if (externalComponet instanceof XmlSchemaExternal) {
-                    xmlSchemaExternal = (XmlSchemaExternal)externalComponet;
-                    innerSchema = xmlSchemaExternal.getSchema();
-                    // we do not need to process it if it already process
-                    // when calling with a different import.
-                    if 
(!processedSchemaMap.containsKey(innerSchema.getSourceURI()) &&
-                            
!visitedShemas.contains(innerSchema.getSourceURI())) {
-                        calculateNewSchemaNames(xmlSchemaExternal.getSchema(),
-                                processedSchemaMap, visitedShemas, false);
+        if (processInclues) {
+            // first process the imports and includes
+            XmlSchemaObjectCollection includes = xmlSchema.getIncludes();
+            // set this as an visited schema to stop recursion
+            visitedShemas.add(xmlSchema.getSourceURI());
+            if (includes != null) {
+                Object externalComponet = null;
+                XmlSchemaExternal xmlSchemaExternal = null;
+                XmlSchema innerSchema = null;
+                for (Iterator iter = includes.getIterator(); iter.hasNext();) {
+                    externalComponet = iter.next();
+                    if (externalComponet instanceof XmlSchemaExternal) {
+                        xmlSchemaExternal = (XmlSchemaExternal) 
externalComponet;
+                        innerSchema = xmlSchemaExternal.getSchema();
+                        // we do not need to process it if it already process
+                        // when calling with a different import.
+                        if 
(!processedSchemaMap.containsKey(innerSchema.getSourceURI()) &&
+                                
!visitedShemas.contains(innerSchema.getSourceURI())) {
+                            
calculateNewSchemaNames(xmlSchemaExternal.getSchema(),
+                                    processedSchemaMap, visitedShemas, 
false,processInclues);
+                        }
                     }
                 }
             }
         }
 
+
         // after processing includes and imports save the xml schema
         if (!isWsdlInlineSchema) {
             String baseUri = xmlSchema.getSourceURI();
@@ -147,41 +151,45 @@
                                          Map changeSchemaNames,
                                          Set visitedShemas,
                                          boolean isWsdlInlineSchema,
-                                         String registryBasePath) throws 
RegistryException {
+                                         String registryBasePath,
+                                         boolean processIncludes) throws 
RegistryException {
 
-        // first process the imports and includes
-        XmlSchemaObjectCollection includes = xmlSchema.getIncludes();
-        // set this as an visited schema to stop recursion
-        visitedShemas.add(xmlSchema.getSourceURI());
-        if (includes != null) {
-            Object externalComponet = null;
-            XmlSchemaExternal xmlSchemaExternal = null;
-            XmlSchema innerSchema = null;
-            for (Iterator iter = includes.getIterator(); iter.hasNext();) {
-                externalComponet = iter.next();
-                if (externalComponet instanceof XmlSchemaExternal) {
-                    xmlSchemaExternal = (XmlSchemaExternal)externalComponet;
-                    innerSchema = xmlSchemaExternal.getSchema();
-                    if (!visitedShemas.contains(innerSchema.getSourceURI())) {
-                        saveSchemaFileToRegistry(xmlSchemaExternal.getSchema(),
-                                processedSchemaMap, null, visitedShemas, 
false, registryBasePath);
-                    }
+        if (processIncludes) {
+            // first process the imports and includes
+            XmlSchemaObjectCollection includes = xmlSchema.getIncludes();
+            // set this as an visited schema to stop recursion
+            visitedShemas.add(xmlSchema.getSourceURI());
+            if (includes != null) {
+                Object externalComponet = null;
+                XmlSchemaExternal xmlSchemaExternal = null;
+                XmlSchema innerSchema = null;
+                for (Iterator iter = includes.getIterator(); iter.hasNext();) {
+                    externalComponet = iter.next();
+                    if (externalComponet instanceof XmlSchemaExternal) {
+                        xmlSchemaExternal = (XmlSchemaExternal) 
externalComponet;
+                        innerSchema = xmlSchemaExternal.getSchema();
+                        if 
(!visitedShemas.contains(innerSchema.getSourceURI())) {
+                            
saveSchemaFileToRegistry(xmlSchemaExternal.getSchema(),
+                                    processedSchemaMap, null, visitedShemas, 
false, registryBasePath,processIncludes);
+                        }
+
+                        // add the new name to changeschema map
+                        // have to do before change the schema location
+                        if (isWsdlInlineSchema) {
+                            
changeSchemaNames.put(xmlSchemaExternal.getSchemaLocation(),
+                                    (String) processedSchemaMap.get(
+                                            innerSchema.getSourceURI()));
+                        }
+                        // set the new location
+                        xmlSchemaExternal.setSchemaLocation((String) 
processedSchemaMap.get(
+                                innerSchema.getSourceURI()));
 
-                    // add the new name to changeschema map
-                    // have to do before change the schema location
-                    if (isWsdlInlineSchema) {
-                        
changeSchemaNames.put(xmlSchemaExternal.getSchemaLocation(),
-                                (String)processedSchemaMap.get(
-                                        innerSchema.getSourceURI()));
                     }
-                    // set the new location
-                    
xmlSchemaExternal.setSchemaLocation((String)processedSchemaMap.get(
-                            innerSchema.getSourceURI()));
-
                 }
             }
         }
 
+
         // after processing includes and imports save the xml schema
         if (!isWsdlInlineSchema) {
             String fileNameToSave = 
(String)processedSchemaMap.get(xmlSchema.getSourceURI());

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/utils/WSDLFileProcessor.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/utils/WSDLFileProcessor.java
    (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/utils/WSDLFileProcessor.java
    Wed Jan 16 01:14:57 2008
@@ -58,7 +58,7 @@
      * @param location
      * @throws WSDLException
      */
-    public void saveWSDLFileToRegistry(String location, String 
registryBasePath)
+    public void saveWSDLFileToRegistry(String location, String 
registryBasePath,boolean processImports)
             throws RegistryException {
         WSDLReader wsdlReader = null;
 
@@ -82,8 +82,8 @@
 
         Map processedWSDLMap = new HashMap();
         calculateWSDLNamesAndChangeTypes(wsdlDefinition, processedWSDLMap, new 
HashMap(),
-                                         new HashSet(), registryBasePath);
-        saveWSDLFileToRegistry(wsdlDefinition, processedWSDLMap, new 
HashSet(), registryBasePath);
+                                         new HashSet(), 
registryBasePath,processImports);
+        saveWSDLFileToRegistry(wsdlDefinition, processedWSDLMap, new 
HashSet(), registryBasePath,processImports);
     }
 
     /**
@@ -99,28 +99,33 @@
                                                  Map processedWSDLMap,
                                                  Map processedScheamMap,
                                                  Set visitedWSDLs,
-                                                 String registryBasePath) 
throws RegistryException {
+                                                 String registryBasePath,
+                                                 boolean processImports) 
throws RegistryException {
         // first we have to process the imports and change the
         // schema locations suite for the registry
-        Iterator iter = wsdlDefinition.getImports().values().iterator();
-        Vector values = null;
-        Import wsdlImport = null;
-        // add this to visited list to stop recursion
-        visitedWSDLs.add(wsdlDefinition.getDocumentBaseURI());
-        for (; iter.hasNext();) {
-            values = (Vector)iter.next();
-            for (Iterator valuesIter = values.iterator(); 
valuesIter.hasNext();) {
-                wsdlImport = (Import)valuesIter.next();
-                // process the types recuresiveilt
-                Definition innerDefinition = wsdlImport.getDefinition();
-                if 
(!visitedWSDLs.contains(innerDefinition.getDocumentBaseURI())) {
-                    // we have not process this wsdl file earlier
-                    calculateWSDLNamesAndChangeTypes(
-                            innerDefinition, processedWSDLMap, 
processedScheamMap, visitedWSDLs, registryBasePath);
+
+        if (processImports) {
+            Iterator iter = wsdlDefinition.getImports().values().iterator();
+            Vector values = null;
+            Import wsdlImport = null;
+            // add this to visited list to stop recursion
+            visitedWSDLs.add(wsdlDefinition.getDocumentBaseURI());
+            for (; iter.hasNext();) {
+                values = (Vector) iter.next();
+                for (Iterator valuesIter = values.iterator(); 
valuesIter.hasNext();) {
+                    wsdlImport = (Import) valuesIter.next();
+                    // process the types recuresiveilt
+                    Definition innerDefinition = wsdlImport.getDefinition();
+                    if 
(!visitedWSDLs.contains(innerDefinition.getDocumentBaseURI())) {
+                        // we have not process this wsdl file earlier
+                        calculateWSDLNamesAndChangeTypes(
+                                innerDefinition, processedWSDLMap, 
processedScheamMap, visitedWSDLs, registryBasePath, processImports);
+                    }
                 }
             }
         }
 
+
         // change the schema names
         Types types = wsdlDefinition.getTypes();
         if (types != null) {
@@ -146,9 +151,9 @@
                     schemaFileProcessor = new 
SchemaFileProcessor(defaultMediaTypeHandler);
                     changedLocationMap = new HashMap();
                     schemaFileProcessor.calculateNewSchemaNames(
-                            xmlSchema, processedScheamMap, new HashSet(), 
true);
+                            xmlSchema, processedScheamMap, new HashSet(), 
true, processImports);
                     schemaFileProcessor.saveSchemaFileToRegistry(
-                            xmlSchema, processedScheamMap, changedLocationMap, 
new HashSet(), true, registryBasePath);
+                            xmlSchema, processedScheamMap, changedLocationMap, 
new HashSet(), true, registryBasePath,processImports);
                     // update the current schema locations with the generated 
ones.
                     changeLocations(schemaExtension.getElement(), 
changedLocationMap);
                 }
@@ -172,31 +177,36 @@
     public void saveWSDLFileToRegistry(Definition wsdlDefinition,
                                        Map processedWSDLMap,
                                        Set visitedWSDLs,
-                                       String registryBasePath) throws 
RegistryException {
-        // first we have to process the imports and change the
-        // schema locations suite for the registry
-        Iterator iter = wsdlDefinition.getImports().values().iterator();
-        Vector values = null;
-        Import wsdlImport = null;
-        // add this to visited list to stop recursion
-        visitedWSDLs.add(wsdlDefinition.getDocumentBaseURI());
-        for (; iter.hasNext();) {
-            values = (Vector)iter.next();
-            for (Iterator valuesIter = values.iterator(); 
valuesIter.hasNext();) {
-                wsdlImport = (Import)valuesIter.next();
-                // process the types recuresiveilt
-                Definition innerDefinition = wsdlImport.getDefinition();
-                if 
(!visitedWSDLs.contains(innerDefinition.getDocumentBaseURI())) {
-                    // we have not process this wsdl file earlier
-                    saveWSDLFileToRegistry(innerDefinition, processedWSDLMap, 
visitedWSDLs,
-                                           registryBasePath);
+                                       String registryBasePath,
+                                       boolean processImports) throws 
RegistryException {
+
+        if (processImports) {
+            // first we have to process the imports and change the
+            // schema locations suite for the registry
+            Iterator iter = wsdlDefinition.getImports().values().iterator();
+            Vector values = null;
+            Import wsdlImport = null;
+            // add this to visited list to stop recursion
+            visitedWSDLs.add(wsdlDefinition.getDocumentBaseURI());
+            for (; iter.hasNext();) {
+                values = (Vector) iter.next();
+                for (Iterator valuesIter = values.iterator(); 
valuesIter.hasNext();) {
+                    wsdlImport = (Import) valuesIter.next();
+                    // process the types recuresiveilt
+                    Definition innerDefinition = wsdlImport.getDefinition();
+                    if 
(!visitedWSDLs.contains(innerDefinition.getDocumentBaseURI())) {
+                        // we have not process this wsdl file earlier
+                        saveWSDLFileToRegistry(innerDefinition, 
processedWSDLMap, visitedWSDLs,
+                                registryBasePath,processImports);
+                    }
+                    // set the import location according to the new location
+                    wsdlImport.setLocationURI((String) processedWSDLMap.get(
+                            innerDefinition.getDocumentBaseURI()));
                 }
-                // set the import location according to the new location
-                wsdlImport.setLocationURI((String)processedWSDLMap.get(
-                        innerDefinition.getDocumentBaseURI()));
             }
         }
 
+
         // after processing the defintions save this to the registry
         // TODO: save this to the registry for the moment save this to the
         // folder and omit any exception occurs.

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/realm/RegistryRealm.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/realm/RegistryRealm.java
   (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/realm/RegistryRealm.java
   Wed Jan 16 01:14:57 2008
@@ -54,7 +54,7 @@
     private void init(DataSource dataSource) throws RegistryException {
 
         try {
-            DefaultRealmConfig config = 
(DefaultRealmConfig)this.getRealmConfiguration();
+            DefaultRealmConfig config = (DefaultRealmConfig) 
this.getRealmConfiguration();
             config.setDataSource(dataSource);
             this.init(config);
 

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
    Wed Jan 16 01:14:57 2008
@@ -19,7 +19,6 @@
 
 package org.wso2.registry.servlet;
 
-import org.apache.axiom.om.OMElement;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.wso2.registry.Registry;
@@ -28,7 +27,8 @@
 import org.wso2.registry.Resource;
 import org.wso2.registry.servlet.utils.Utils;
 import org.wso2.registry.config.DataBaseConfiguration;
-import org.wso2.registry.config.RegistryConfiguration;
+import org.wso2.registry.config.RegistryConfigurationProcessor;
+import org.wso2.registry.config.RegistryContext;
 import org.wso2.registry.i18n.Messages;
 import org.wso2.registry.jdbc.InMemoryJDBCRegistry;
 import org.wso2.registry.jdbc.JDBCRegistry;
@@ -46,7 +46,6 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.sql.DataSource;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.URLDecoder;
 
@@ -59,7 +58,7 @@
     //To store the context path
     private String contextRoot = null;
     private String configPath;
-    private RegistryConfiguration registryConfiguration;
+    private RegistryConfigurationProcessor registryConfigurationProcessor;
 
     public void init(ServletConfig config) throws ServletException {
         super.init(config);
@@ -69,13 +68,16 @@
             // read the registry.xml file from the configured location. if not 
configured, read the
             // default registry.xml file bundled with the webapp.
             configPath = 
config.getInitParameter(RegistryConstants.REGISTRY_CONFIG_PATH);
-            registryConfiguration = new RegistryConfiguration();
-            registryConfiguration.populateRegistryConfig(configPath, config);
+
+            RegistryContext registryContext = new RegistryContext();
+            System.getProperties().put(RegistryConstants.REGISTRY_CONTEXT, 
registryContext);
+
+            registryConfigurationProcessor = new 
RegistryConfigurationProcessor();
+            registryConfigurationProcessor.populateRegistryConfig(configPath, 
config, registryContext);
             config.getServletContext().
-                    setAttribute(RegistryConstants.REGISTRY_CONFIG, 
registryConfiguration);
+                    setAttribute(RegistryConstants.REGISTRY_CONFIG, 
registryConfigurationProcessor);
 
-            DataBaseConfiguration dbConfiguration =
-                    registryConfiguration.getDefaultDataBaseConfiguration();
+            DataBaseConfiguration dbConfiguration = 
registryContext.getDefaultDataBaseConfiguration();
 
             if (dbConfiguration.getConfigName().equals("in-memory")) {
                 registryRealm = new InMemoryRegistryRealm();
@@ -132,6 +134,7 @@
             System.getProperties().put(RegistryConstants.REGISTRY, 
coreRegistry);
             System.getProperties().put(RegistryConstants.SYSTEM_REGISTRY, 
systemRegistry);
             System.getProperties().put(RegistryConstants.REGISTRY_REALM, 
registryRealm);
+            
         } catch (RegistryException e) {
             String msg = "Registry initialization failed.";
             throw new ServletException(msg, e);
@@ -259,7 +262,7 @@
         //}
         //try {
         //    FileOutputStream fio = new FileOutputStream(configPath);
-        //    OMElement registryXml = 
registryConfiguration.getRegistryConfigAsXML();
+        //    OMElement registryXml = 
registryConfigurationProcessor.getRegistryConfigAsXML();
         //    registryXml.serialize(fio);
         //    fio.flush();
         //    fio.close();

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/registry.xml
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/registry.xml
    (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/registry.xml
    Wed Jan 16 01:14:57 2008
@@ -19,4 +19,21 @@
         <dataSource>dataSourceName</dataSource>
     </dbconfig>
 
+    <mediaTypeHandler>
+        <mediaType>synapse-repo</mediaType>
+        
<handler>org.wso2.registry.jdbc.mediatypes.builtin.SynapseRepositoryMediaTypeHandler</handler>
+    </mediaTypeHandler>
+
+    <mediaTypeHandler>
+        <mediaType>application/wsdl+xml</mediaType>
+        
<handler>org.wso2.registry.jdbc.mediatypes.builtin.WSDLMediaTypeHandler</handler>
+    </mediaTypeHandler>
+
+    <mediaTypeHandler>
+        <mediaType>application/x-xsd+xml</mediaType>
+        
<handler>org.wso2.registry.jdbc.mediatypes.builtin.XSDMediaTypeHandler</handler>
+    </mediaTypeHandler>
+
+    
<urlHandler>org.wso2.registry.jdbc.urlhandlers.CommentCollectionURLHandler</urlHandler>
+
 </wso2regsitry>
\ No newline at end of file

Modified: 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/utils/AdminUtil.java
==============================================================================
--- 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/utils/AdminUtil.java
     (original)
+++ 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/utils/AdminUtil.java
     Wed Jan 16 01:14:57 2008
@@ -18,7 +18,7 @@
 
 import org.wso2.registry.web.beans.AdminBean;
 import org.wso2.registry.web.UIConstants;
-import org.wso2.registry.config.RegistryConfiguration;
+import org.wso2.registry.config.RegistryConfigurationProcessor;
 import org.wso2.registry.config.DataBaseConfiguration;
 import org.wso2.registry.RegistryConstants;
 import org.wso2.registry.Registry;
@@ -45,19 +45,21 @@
 
     public static AdminBean getAdminBean(HttpServletRequest request) {
 
-        RegistryConfiguration regConfiguration = (RegistryConfiguration) 
request.getSession().
-                
getServletContext().getAttribute(RegistryConstants.REGISTRY_CONFIG);
-
-        Map dbConfigs = regConfiguration.getDbconfgigMap();
+        //RegistryConfigurationProcessor regConfiguration = 
(RegistryConfigurationProcessor) request.getSession().
+        //        
getServletContext().getAttribute(RegistryConstants.REGISTRY_CONFIG);
+        //
+        ////Map dbConfigs = regConfiguration.getDbconfgigMap();
+        //
+        //AdminBean adminBean = new AdminBean();
+        ////adminBean.setDbConfigs(dbConfigs);
+        //return adminBean;
 
-        AdminBean adminBean = new AdminBean();
-        adminBean.setDbConfigs(dbConfigs);
-        return adminBean;
+        return null;
     }
 
     public static void addDBURLBasedConfiguration(HttpServletRequest request, 
HttpServletResponse response) {
 
-        RegistryConfiguration regConfiguration = (RegistryConfiguration) 
request.getSession().
+        RegistryConfigurationProcessor regConfiguration = 
(RegistryConfigurationProcessor) request.getSession().
                 
getServletContext().getAttribute(RegistryConstants.REGISTRY_CONFIG);
 
         String configName = request.getParameter("configName");
@@ -73,7 +75,7 @@
         dbConfiguration.setUserName(userName);
         dbConfiguration.setPassWord(password);
 
-        regConfiguration.addDataBaseConfiguration(dbConfiguration);
+        //regConfiguration.addDataBaseConfiguration(dbConfiguration);
 
         try {
             
request.getRequestDispatcher(UIConstants.ADMIN_JSP).forward(request, response);
@@ -86,10 +88,10 @@
 
     public static void removeDBConfiguration(HttpServletRequest request, 
HttpServletResponse response) {
 
-        RegistryConfiguration regConfiguration = (RegistryConfiguration) 
request.getSession().
+        RegistryConfigurationProcessor regConfiguration = 
(RegistryConfigurationProcessor) request.getSession().
                 
getServletContext().getAttribute(RegistryConstants.REGISTRY_CONFIG);
 
-        
regConfiguration.removeDataBaseConfiguration(request.getParameter("config"));
+        
//regConfiguration.removeDataBaseConfiguration(request.getParameter("config"));
 
         try {
             
request.getRequestDispatcher(UIConstants.ADMIN_JSP).forward(request, response);
@@ -105,74 +107,74 @@
             HttpServletResponse response)
             throws RegistryException {
 
-        ServletContext servletContext = 
request.getSession().getServletContext();
-
-        RegistryConfiguration regConfiguration = (RegistryConfiguration) 
servletContext.
-                getAttribute(RegistryConstants.REGISTRY_CONFIG);
-
-        DataBaseConfiguration dbConfiguration =
-                
regConfiguration.getDataBaseConfiguration(request.getParameter("config"));
-        regConfiguration.setDefaultDataBaseConfiguration(dbConfiguration);
-
-        RegistryRealm registryRealm;
-        Registry coreRegistry;
-
-        if (dbConfiguration.getConfigName().equals("in-memory")) {
-            registryRealm = new InMemoryRegistryRealm();
-            coreRegistry = new InMemoryJDBCRegistry(registryRealm);
-
-        } else {
-
-            DataSource dataSource;
-
-            if (dbConfiguration.getDataSourceName() != null &&
-                    dbConfiguration.getDataSourceName().length() > 0) {
-                try {
-                    Context context = new InitialContext();
-                    dataSource =
-                            (DataSource) 
context.lookup(dbConfiguration.getDataSourceName());
-
-                } catch (NamingException e) {
-
-                    String msg = "Could not find the specified data source 
named: " +
-                            dbConfiguration.getDataSourceName() + ". Caused 
by: " +
-                            e.getMessage();
-                    throw new RegistryException(msg);
-                }
-
-            } else {
-
-                dataSource = new RegistryDataSource(
-                        dbConfiguration.getDbUrl(),
-                        dbConfiguration.getDriverName(),
-                        dbConfiguration.getUserName(),
-                        dbConfiguration.getPassWord());
-            }
-
-            registryRealm = new RegistryRealm(dataSource);
-            coreRegistry = new JDBCRegistry(dataSource, registryRealm);
-        }
-
-        // create a system registry and put it in the context
-        SecureRegistry systemRegistry =
-                new SecureRegistry(RegistryConstants.SYSTEM_USER,
-                        RegistryConstants.SYSTEM_PASSWORD,
-                        coreRegistry,
-                        registryRealm);
-
-        servletContext.setAttribute(RegistryConstants.REGISTRY, coreRegistry);
-        servletContext.setAttribute(RegistryConstants.REGISTRY_REALM, 
registryRealm);
-        System.getProperties().put(RegistryConstants.REGISTRY, coreRegistry);
-        System.getProperties().put(RegistryConstants.SYSTEM_REGISTRY, 
systemRegistry);
-
-        CommonUtil.invalidateAllSessions(request);
-
-        try {
-            
request.getRequestDispatcher(UIConstants.ADMIN_JSP).forward(request, response);
-        } catch (ServletException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
+        //ServletContext servletContext = 
request.getSession().getServletContext();
+        //
+        //RegistryConfiguration regConfiguration = (RegistryConfiguration) 
servletContext.
+        //        getAttribute(RegistryConstants.REGISTRY_CONFIG);
+        //
+        //DataBaseConfiguration dbConfiguration =
+        //        
regConfiguration.getDataBaseConfiguration(request.getParameter("config"));
+        //regConfiguration.setDefaultDataBaseConfiguration(dbConfiguration);
+        //
+        //RegistryRealm registryRealm;
+        //Registry coreRegistry;
+        //
+        //if (dbConfiguration.getConfigName().equals("in-memory")) {
+        //    registryRealm = new InMemoryRegistryRealm();
+        //    coreRegistry = new InMemoryJDBCRegistry(registryRealm);
+        //
+        //} else {
+        //
+        //    DataSource dataSource;
+        //
+        //    if (dbConfiguration.getDataSourceName() != null &&
+        //            dbConfiguration.getDataSourceName().length() > 0) {
+        //        try {
+        //            Context context = new InitialContext();
+        //            dataSource =
+        //                    (DataSource) 
context.lookup(dbConfiguration.getDataSourceName());
+        //
+        //        } catch (NamingException e) {
+        //
+        //            String msg = "Could not find the specified data source 
named: " +
+        //                    dbConfiguration.getDataSourceName() + ". Caused 
by: " +
+        //                    e.getMessage();
+        //            throw new RegistryException(msg);
+        //        }
+        //
+        //    } else {
+        //
+        //        dataSource = new RegistryDataSource(
+        //                dbConfiguration.getDbUrl(),
+        //                dbConfiguration.getDriverName(),
+        //                dbConfiguration.getUserName(),
+        //                dbConfiguration.getPassWord());
+        //    }
+        //
+        //    registryRealm = new RegistryRealm(dataSource);
+        //    coreRegistry = new JDBCRegistry(dataSource, registryRealm);
+        //}
+        //
+        //// create a system registry and put it in the context
+        //SecureRegistry systemRegistry =
+        //        new SecureRegistry(RegistryConstants.SYSTEM_USER,
+        //                RegistryConstants.SYSTEM_PASSWORD,
+        //                coreRegistry,
+        //                registryRealm);
+        //
+        //servletContext.setAttribute(RegistryConstants.REGISTRY, 
coreRegistry);
+        //servletContext.setAttribute(RegistryConstants.REGISTRY_REALM, 
registryRealm);
+        //System.getProperties().put(RegistryConstants.REGISTRY, coreRegistry);
+        //System.getProperties().put(RegistryConstants.SYSTEM_REGISTRY, 
systemRegistry);
+        //
+        //CommonUtil.invalidateAllSessions(request);
+        //
+        //try {
+        //    
request.getRequestDispatcher(UIConstants.ADMIN_JSP).forward(request, response);
+        //} catch (ServletException e) {
+        //    e.printStackTrace();
+        //} catch (IOException e) {
+        //    e.printStackTrace();
+        //}
     }
 }

_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev

Reply via email to