Author: deepal
Date: Tue Dec 18 02:00:17 2007
New Revision: 11368
Log:
removed a set of unwanted files
- Fix the configuration loading NPE
Added:
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/registry.xml
- copied, changed from r11353,
trunk/registry/modules/core/src/main/resources/registry.xml
Removed:
trunk/registry/modules/core/src/main/resources/registry.xml
trunk/registry/modules/webapps/conf/package.properties
trunk/registry/modules/webapps/conf/registry.xml
trunk/registry/modules/webapps/conf/struts.xml
trunk/registry/modules/webapps/conf/tiles.xml
trunk/registry/modules/webapps/src/main/webapp/rest/
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfiguration.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
trunk/registry/modules/webapps/conf/web.xml
trunk/registry/modules/webapps/pom.xml
Modified:
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/RegistryConfiguration.java
Tue Dec 18 02:00:17 2007
@@ -57,9 +57,9 @@
throw new RegistryException(e.getMessage());
}
} else {
- in =
Thread.currentThread().getContextClassLoader().getResourceAsStream("registry.xml");
+ in =
Thread.currentThread().getContextClassLoader().getResourceAsStream("org/wso2/servlet/registry.xml");
if (in == null) {
- throw new
RegistryException(Messages.getMessage("inputstream.null", "registry.xml"));
+ throw new
RegistryException(Messages.getMessage("inputstream.null",
"org/wso2/servlet/registry.xml"));
}
}
try {
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
Tue Dec 18 02:00:17 2007
@@ -25,28 +25,32 @@
import org.wso2.registry.RegistryConstants;
import org.wso2.registry.RegistryException;
import org.wso2.registry.Resource;
-import org.wso2.registry.config.RegistryConfiguration;
import org.wso2.registry.config.DataBaseConfiguration;
+import org.wso2.registry.config.RegistryConfiguration;
import org.wso2.registry.i18n.Messages;
import org.wso2.registry.jdbc.InMemoryJDBCRegistry;
import org.wso2.registry.jdbc.JDBCRegistry;
-import org.wso2.registry.jdbc.utils.RegistryDataSource;
import org.wso2.registry.jdbc.realm.InMemoryRegistryRealm;
import org.wso2.registry.jdbc.realm.RegistryRealm;
+import org.wso2.registry.jdbc.utils.RegistryDataSource;
import org.wso2.registry.secure.SecureRegistry;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
-/** Servlet for providing REST API for the registry. */
+/**
+ * Servlet for providing REST API for the registry.
+ */
public class RegistryServlet extends HttpServlet {
private static final Log log = LogFactory.getLog(RegistryServlet.class);
@@ -58,16 +62,17 @@
public void init(ServletConfig config) throws ServletException {
super.init(config);
-
+ servletConfig = config;
RegistryRealm registryRealm;
- Registry coreRegistry = null;
-
+ Registry coreRegistry;
try {
-
// 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);
RegistryConfiguration registryConfiguration = new
RegistryConfiguration();
+ if (configPath == null) {
+ configPath = getRegistryConfigPath(config);
+ }
registryConfiguration.populateRegistryConfig(configPath);
config.getServletContext().
setAttribute(RegistryConstants.REGISTRY_CONFIG,
registryConfiguration);
@@ -79,12 +84,9 @@
registryRealm = new InMemoryRegistryRealm();
coreRegistry = new InMemoryJDBCRegistry(registryRealm);
} else {
-
- DataSource dataSource = null;
-
+ DataSource dataSource;
if (dbConfiguration.getDataSourceName() != null &&
dbConfiguration.getDataSourceName().length() > 0) {
-
try {
Context context = new InitialContext();
dataSource =
@@ -98,9 +100,7 @@
log.fatal(msg, e);
throw new ServletException(msg);
}
-
} else {
-
dataSource = new RegistryDataSource(
dbConfiguration.getDbUrl(),
dbConfiguration.getDriverName(),
@@ -124,21 +124,7 @@
.setAttribute(RegistryConstants.REGISTRY_REALM,
registryRealm);
System.getProperties().put(RegistryConstants.REGISTRY,
coreRegistry);
System.getProperties().put(RegistryConstants.SYSTEM_REGISTRY,
systemRegistry);
-
-
- //String coreRegistryTypeParam =
- //
config.getInitParameter(RegistryConstants.REGISTRY_TYPE_PARAMTER);
- //
- //if (coreRegistryTypeParam == null ||
- //
coreRegistryTypeParam.equals(RegistryConstants.JDBC_REGISTRY_TYPE)) {
- //
- //
- //} else if
(coreRegistryTypeParam.equals(RegistryConstants.REMOTE_REGISTRY_TYPE)) {
- // // todo: initialize core registry with a remote registry
instance.
- //}
-
} catch (RegistryException e) {
- e.printStackTrace();
throw new ServletException(e.getMessage());
}
@@ -146,9 +132,20 @@
}
public void init() throws ServletException {
- if (this.servletConfig != null) {
- init(this.servletConfig);
+ super.init();
+ if (servletConfig == null) {
+ init(getServletConfig());
+ }
+ }
+
+ private String getRegistryConfigPath(ServletConfig config) {
+ try {
+ URL url =
config.getServletContext().getResource("/WEB-INF/registry.xml");
+ return url.toString();
+ } catch (MalformedURLException e) {
+ log.debug(e);
}
+ return null;
}
protected void doPost(HttpServletRequest httpServletRequest,
Copied:
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/registry.xml
(from r11353, trunk/registry/modules/core/src/main/resources/registry.xml)
==============================================================================
Modified: trunk/registry/modules/webapps/conf/web.xml
==============================================================================
--- trunk/registry/modules/webapps/conf/web.xml (original)
+++ trunk/registry/modules/webapps/conf/web.xml Tue Dec 18 02:00:17 2007
@@ -40,35 +40,11 @@
<servlet-name>WebServlet</servlet-name>
<url-pattern>/system/*</url-pattern>
</servlet-mapping>
-
- <servlet-mapping>
- <servlet-name>RegistryServlet</servlet-name>
- <url-pattern>/edit/*</url-pattern>
- </servlet-mapping>
-
- <servlet-mapping>
- <servlet-name>RegistryServlet</servlet-name>
- <url-pattern>/view/*</url-pattern>
- </servlet-mapping>
-
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
- <!--<filter>-->
- <!--<filter-name>struts2</filter-name>-->
-
<!--<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>-->
- <!--</filter>-->
- <!--<filter-mapping>-->
- <!--<filter-name>struts2</filter-name>-->
- <!--<url-pattern>/admin/*</url-pattern>-->
- <!--</filter-mapping>-->
-
- <!--<listener>-->
-
<!--<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>-->
- <!--</listener>-->
-
<!-- resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/WSO2RegistryDB</res-ref-name>
Modified: trunk/registry/modules/webapps/pom.xml
==============================================================================
--- trunk/registry/modules/webapps/pom.xml (original)
+++ trunk/registry/modules/webapps/pom.xml Tue Dec 18 02:00:17 2007
@@ -47,7 +47,6 @@
<targetPath>WEB-INF</targetPath>
<includes>
<include>web.xml</include>
- <include>tiles.xml</include>
<include>um.sql</include>
<include>mime.types</include>
<include>collection-media-types.conf</include>
@@ -60,13 +59,11 @@
<include>*.properties</include>
</includes>
</resource>
- <resource>
- <directory>${basedir}/conf</directory>
- <targetPath>WEB-INF/classes</targetPath>
+ <resource>
+
<directory>${basedir}/../core/src/main/java/org/wso2/registry/servlet</directory>
+ <targetPath>WEB-INF/</targetPath>
<includes>
- <include>registry.xml</include>
- <include>struts.xml</include>
- <include>package.properties</include>
+ <include>*.xml</include>
</includes>
</resource>
</webResources>
_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev