Author: keith Date: Mon Jul 27 04:59:51 2009 New Revision: 41937 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=41937
Log: Adding in a patch to Carbon that gives us the facility to have servlet filters. Fix for Mashup-1165 Modified: branches/mashup/java/2.0/product/modules/org.wso2.carbon.core/pom.xml branches/mashup/java/2.0/product/modules/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/init/CarbonServerManager.java branches/mashup/java/2.0/product/modules/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/util/MIMEType2FileExtensionMap.java branches/mashup/java/2.0/product/pom.xml Modified: branches/mashup/java/2.0/product/modules/org.wso2.carbon.core/pom.xml URL: http://wso2.org/svn/browse/wso2/branches/mashup/java/2.0/product/modules/org.wso2.carbon.core/pom.xml?rev=41937&r1=41936&r2=41937&view=diff ============================================================================== --- branches/mashup/java/2.0/product/modules/org.wso2.carbon.core/pom.xml (original) +++ branches/mashup/java/2.0/product/modules/org.wso2.carbon.core/pom.xml Mon Jul 27 04:59:51 2009 @@ -7,6 +7,7 @@ <artifactId>carbon-parent</artifactId> <version>2.0.0</version> </parent> + <version>2.0.01</version> <modelVersion>4.0.0</modelVersion> <artifactId>org.wso2.carbon.core</artifactId> <packaging>bundle</packaging> @@ -30,6 +31,11 @@ <groupId>org.eclipse.equinox</groupId> <artifactId>org.eclipse.equinox.http.servlet</artifactId> </dependency> + + <dependency> + <groupId>org.eclipse.equinox</groupId> + <artifactId>org.eclipse.equinox.http.helper</artifactId> + </dependency> <dependency> <groupId>org.eclipse.equinox</groupId> @@ -44,11 +50,13 @@ <dependency> <groupId>org.wso2.carbon</groupId> <artifactId>org.wso2.carbon.bridge</artifactId> + <version>2.0.0</version> </dependency> <dependency> <groupId>org.wso2.carbon</groupId> <artifactId>org.wso2.carbon.user.core</artifactId> + <version>2.0.0</version> <exclusions> <exclusion> <groupId>org.wso2.carbon</groupId> @@ -86,6 +94,7 @@ <dependency> <groupId>org.wso2.carbon</groupId> <artifactId>org.wso2.carbon.utils</artifactId> + <version>2.0.0</version> <exclusions> <exclusion> <groupId>org.apache.geronimo.specs</groupId> @@ -97,6 +106,7 @@ <dependency> <groupId>org.wso2.carbon</groupId> <artifactId>org.wso2.carbon.registry.core</artifactId> + <version>2.0.0</version> <exclusions> <exclusion> <groupId>org.apache.geronimo.specs</groupId> Modified: branches/mashup/java/2.0/product/modules/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/init/CarbonServerManager.java URL: http://wso2.org/svn/browse/wso2/branches/mashup/java/2.0/product/modules/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/init/CarbonServerManager.java?rev=41937&r1=41936&r2=41937&view=diff ============================================================================== --- branches/mashup/java/2.0/product/modules/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/init/CarbonServerManager.java (original) +++ branches/mashup/java/2.0/product/modules/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/init/CarbonServerManager.java Mon Jul 27 04:59:51 2009 @@ -59,12 +59,14 @@ import org.wso2.carbon.utils.ServerConstants; import org.wso2.carbon.utils.ServerException; import org.wso2.carbon.utils.deployment.Axis2ServiceRegistry; +import org.eclipse.equinox.http.helper.FilterServletAdaptor; import javax.management.MBeanServer; import javax.management.remote.JMXConnectorServer; import javax.management.remote.JMXConnectorServerFactory; import javax.management.remote.JMXServiceURL; import javax.servlet.ServletException; +import javax.servlet.Filter; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -72,13 +74,7 @@ import java.net.SocketException; import java.rmi.registry.LocateRegistry; import java.rmi.server.UnicastRemoteObject; -import java.util.Dictionary; -import java.util.HashMap; -import java.util.Map; -import java.util.Timer; -import java.util.TimerTask; -import java.util.Iterator; -import java.util.Enumeration; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -421,7 +417,13 @@ if (!servicePath.startsWith("/")) { servicePath = "/" + servicePath; } - httpService.registerServlet(servicePath, carbonServlet, null, defaultHttpContext); + ServiceReference filterServiceReference = bundleContext.getServiceReference(Filter.class.getName()); + if (filterServiceReference != null) { + Filter filter = (Filter) bundleContext.getService(filterServiceReference); + httpService.registerServlet(servicePath, new FilterServletAdaptor(filter , null, carbonServlet), null, defaultHttpContext); + } else { + httpService.registerServlet(servicePath, carbonServlet, null, defaultHttpContext); + } HTTPGetProcessorListener getProcessorListener = new HTTPGetProcessorListener(carbonServlet, bundleContext); // Check whether there are any services that expose HTTPGetRequestProcessors @@ -441,7 +443,6 @@ // expose HTTPGetRequestProcessors bundleContext.addServiceListener(getProcessorListener, "(" + CarbonConstants.HTTP_GET_REQUEST_PROCESSOR_SERVICE + "=*)"); - } } Modified: branches/mashup/java/2.0/product/modules/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/util/MIMEType2FileExtensionMap.java URL: http://wso2.org/svn/browse/wso2/branches/mashup/java/2.0/product/modules/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/util/MIMEType2FileExtensionMap.java?rev=41937&r1=41936&r2=41937&view=diff ============================================================================== --- branches/mashup/java/2.0/product/modules/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/util/MIMEType2FileExtensionMap.java (original) +++ branches/mashup/java/2.0/product/modules/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/util/MIMEType2FileExtensionMap.java Mon Jul 27 04:59:51 2009 @@ -30,7 +30,8 @@ import java.util.Map; /** - * + * @scr.component name="MIMEType2FileExtensionMap.component" + * @scr.service interface="org.wso2.carbon.core.util.MIMEType2FileExtensionMap" */ public class MIMEType2FileExtensionMap { @@ -40,21 +41,9 @@ private static Log log = LogFactory.getLog(MIMEType2FileExtensionMap.class); - public String getMIMEType(File file) { - String filename = file.getName(); - int index = filename.lastIndexOf("."); - if (index == -1 || index == filename.length() - 1) { - return "application/octet-stream"; - } else { - String extension = filename.substring(index + 1); - String contentType = extensionToMimeMap.get(extension); - return contentType != null ? contentType : "application/octet-stream"; - } - } - - public void init(BundleContext context) { + public MIMEType2FileExtensionMap() { try { - URL resource = context.getBundle().getResource(mappingFileName); + URL resource = this.getClass().getClassLoader().getResource(mappingFileName); if (resource == null) { String msg = "Unable to load all MIME Mappings"; log.error(msg); @@ -74,4 +63,24 @@ throw new RuntimeException(msg, e); } } + + public String getMIMEType(File file) { + String filename = file.getName(); + int index = filename.lastIndexOf("."); + if (index == -1 || index == filename.length() - 1) { + return "application/octet-stream"; + } else { + String extension = filename.substring(index + 1); + String contentType = extensionToMimeMap.get(extension); + return contentType != null ? contentType : "application/octet-stream"; + } + } + + /** + * @deprecated No need to call init at all + * @param context + */ + public void init(BundleContext context) { + + } } Modified: branches/mashup/java/2.0/product/pom.xml URL: http://wso2.org/svn/browse/wso2/branches/mashup/java/2.0/product/pom.xml?rev=41937&r1=41936&r2=41937&view=diff ============================================================================== --- branches/mashup/java/2.0/product/pom.xml (original) +++ branches/mashup/java/2.0/product/pom.xml Mon Jul 27 04:59:51 2009 @@ -20,7 +20,8 @@ <modules> - <module>modules/styles</module> + <module>modules/styles</module> + <module>modules/org.wso2.carbon.core</module> <module>modules/distribution</module> <!--<module>modules/integration</module>--> </modules> _______________________________________________ Mashup-dev mailing list [email protected] https://wso2.org/cgi-bin/mailman/listinfo/mashup-dev
