You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by lr...@apache.org on 2010/02/20 09:38:48 UTC
svn commit: r912092 - in /tuscany/sca-java-2.x/trunk/modules: ./
common-http/ common-http/META-INF/ common-http/src/ common-http/src/main/
common-http/src/main/java/ common-http/src/main/java/org/
common-http/src/main/java/org/apache/ common-http/src/m...
Author: lresende
Date: Sat Feb 20 08:38:48 2010
New Revision: 912092
URL: http://svn.apache.org/viewvc?rev=912092&view=rev
Log:
Providing utility module to share common HTTP Utilities and Constants
Added:
tuscany/sca-java-2.x/trunk/modules/common-http/
tuscany/sca-java-2.x/trunk/modules/common-http/META-INF/
tuscany/sca-java-2.x/trunk/modules/common-http/META-INF/MANIFEST.MF
tuscany/sca-java-2.x/trunk/modules/common-http/pom.xml (with props)
tuscany/sca-java-2.x/trunk/modules/common-http/src/
tuscany/sca-java-2.x/trunk/modules/common-http/src/main/
tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/
tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/
tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/
tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/
tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/
tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/
tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/
tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPConstants.java (with props)
tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPContentTypeMapper.java (with props)
Modified:
tuscany/sca-java-2.x/trunk/modules/pom.xml
Added: tuscany/sca-java-2.x/trunk/modules/common-http/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/common-http/META-INF/MANIFEST.MF?rev=912092&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/common-http/META-INF/MANIFEST.MF (added)
+++ tuscany/sca-java-2.x/trunk/modules/common-http/META-INF/MANIFEST.MF Sat Feb 20 08:38:48 2010
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Common HTTP
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Common HTTP
+Bundle-SymbolicName: org.apache.tuscany.sca.common.http
+Bundle-DocURL: http://www.apache.org/
+Export-Package: org.apache.tuscany.sca.common.http;version="2.0.0"
+
+
Added: tuscany/sca-java-2.x/trunk/modules/common-http/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/common-http/pom.xml?rev=912092&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/common-http/pom.xml (added)
+++ tuscany/sca-java-2.x/trunk/modules/common-http/pom.xml Sat Feb 20 08:38:48 2010
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-common-http</artifactId>
+ <name>Apache Tuscany SCA Common HTTP</name>
+
+</project>
Propchange: tuscany/sca-java-2.x/trunk/modules/common-http/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/sca-java-2.x/trunk/modules/common-http/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: tuscany/sca-java-2.x/trunk/modules/common-http/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPConstants.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPConstants.java?rev=912092&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPConstants.java (added)
+++ tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPConstants.java Sat Feb 20 08:38:48 2010
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.tuscany.sca.common.http;
+
+public class HTTPConstants {
+ public static final String CHARACTER_ENCODING_UTF8 = "UTF-8";
+
+ public static final String HTML_CONTENT_TYPE = "text/html";
+ public static final String JAVASCRIPT_CONTENT_TYPE = "text/javascript";
+}
Propchange: tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPConstants.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPContentTypeMapper.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPContentTypeMapper.java?rev=912092&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPContentTypeMapper.java (added)
+++ tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPContentTypeMapper.java Sat Feb 20 08:38:48 2010
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.tuscany.sca.common.http;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Utility class to provide default HTTP Content-Type header
+ * based on resource type
+ */
+public class HTTPContentTypeMapper {
+ private static Map<String, String> contentTypeTable = new HashMap<String, String>();
+
+ static {
+ contentTypeTable.put("htm", HTTPConstants.HTML_CONTENT_TYPE);
+ contentTypeTable.put("html", HTTPConstants.HTML_CONTENT_TYPE);
+ contentTypeTable.put("js", "text/javascript");
+ }
+
+ /**
+ * Provided a resource path, identify default content-type based on the resource extension
+ * @param resourcePath
+ * @return
+ */
+ public static String getContentType(String resourcePath) {
+ return contentTypeTable.get(getResourceType(resourcePath));
+ }
+
+ /**
+ * Utility function to calculate file type based on its extension
+ * Useful to map HTTP content-type based on file extension
+ * @param resource the resource/file name
+ * @return the resource type/extension
+ */
+ private static String getResourceType(String resource) {
+ return resource.substring(resource.lastIndexOf(".") + 1);
+ }
+}
Propchange: tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPContentTypeMapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPContentTypeMapper.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: tuscany/sca-java-2.x/trunk/modules/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/pom.xml?rev=912092&r1=912091&r2=912092&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/pom.xml (original)
+++ tuscany/sca-java-2.x/trunk/modules/pom.xml Sat Feb 20 08:38:48 2010
@@ -58,6 +58,7 @@
<!--module>binding-ws-axis2-policy</module-->
<module>binding-ws-wsdlgen</module>
<module>builder</module>
+ <module>common-http</module>
<module>common-java</module>
<module>common-xml</module>
<module>contribution</module>