You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ju...@apache.org on 2010/11/08 22:47:57 UTC
svn commit: r1032750 - in /sling/trunk/contrib/extensions/gwt:
sample/pom.xml servlet/pom.xml
servlet/src/main/java/org/apache/sling/extensions/gwt/user/server/rpc/SlingRemoteServiceServlet.java
Author: justin
Date: Mon Nov 8 21:47:57 2010
New Revision: 1032750
URL: http://svn.apache.org/viewvc?rev=1032750&view=rev
Log:
SLING-1863 - upgrading GWT to 2.1.0
Modified:
sling/trunk/contrib/extensions/gwt/sample/pom.xml
sling/trunk/contrib/extensions/gwt/servlet/pom.xml
sling/trunk/contrib/extensions/gwt/servlet/src/main/java/org/apache/sling/extensions/gwt/user/server/rpc/SlingRemoteServiceServlet.java
Modified: sling/trunk/contrib/extensions/gwt/sample/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/gwt/sample/pom.xml?rev=1032750&r1=1032749&r2=1032750&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/gwt/sample/pom.xml (original)
+++ sling/trunk/contrib/extensions/gwt/sample/pom.xml Mon Nov 8 21:47:57 2010
@@ -98,7 +98,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
- <version>1.2</version>
+ <version>2.1.0</version>
<executions>
<execution>
<goals>
@@ -128,7 +128,7 @@
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
- <version>2.0.4</version>
+ <version>2.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
Modified: sling/trunk/contrib/extensions/gwt/servlet/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/gwt/servlet/pom.xml?rev=1032750&r1=1032749&r2=1032750&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/gwt/servlet/pom.xml (original)
+++ sling/trunk/contrib/extensions/gwt/servlet/pom.xml Mon Nov 8 21:47:57 2010
@@ -41,7 +41,7 @@
<properties>
<!-- The implementation of the Sling GWT Servlet Library is dependent
on this specific GWT version: 2.0.4. Do not upgrade just like that. -->
- <gwt.version>2.0.4</gwt.version>
+ <gwt.version>2.1.0</gwt.version>
</properties>
<scm>
@@ -64,7 +64,7 @@
com.google.gwt.user.server.rpc.*;version=${gwt.version},
com.google.gwt.user.client.rpc.*;version=${gwt.version}
</Export-Package>
- <Import-Package>!com.google.gwt.*,!javax.imageio.*,!junit.*,!org.w3c.*,!sun.misc,*</Import-Package>
+ <Import-Package>!com.google.gwt.*,!javax.imageio.*,!junit.*,!org.w3c.*,!sun.misc,!org.json,!javax.validation.*,*</Import-Package>
<DynamicImport-Package>
javax.imageio.*
</DynamicImport-Package>
Modified: sling/trunk/contrib/extensions/gwt/servlet/src/main/java/org/apache/sling/extensions/gwt/user/server/rpc/SlingRemoteServiceServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/gwt/servlet/src/main/java/org/apache/sling/extensions/gwt/user/server/rpc/SlingRemoteServiceServlet.java?rev=1032750&r1=1032749&r2=1032750&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/gwt/servlet/src/main/java/org/apache/sling/extensions/gwt/user/server/rpc/SlingRemoteServiceServlet.java (original)
+++ sling/trunk/contrib/extensions/gwt/servlet/src/main/java/org/apache/sling/extensions/gwt/user/server/rpc/SlingRemoteServiceServlet.java Mon Nov 8 21:47:57 2010
@@ -24,6 +24,7 @@ import com.google.gwt.user.server.rpc.Se
import com.google.gwt.user.server.rpc.SerializationPolicyLoader;
import org.osgi.framework.Bundle;
+import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
@@ -43,6 +44,101 @@ import java.text.ParseException;
* </code>
*/
public class SlingRemoteServiceServlet extends RemoteServiceServlet {
+
+ // This is a verbatim copy of the method of the same signature from
+ // RemoteServiceServlet, with one exception (noted inline) which loads
+ // the policy file from the bundle, as Sling doesn't support
+ // ServletContext.getResourceAsStream().
+ static SerializationPolicy loadSerializationPolicy(HttpServlet servlet,
+ HttpServletRequest request, String moduleBaseURL, String strongName,
+ Bundle bundle) {
+ // The request can tell you the path of the web app relative to the
+ // container root.
+ String contextPath = request.getContextPath();
+
+ String modulePath = null;
+ if (moduleBaseURL != null) {
+ try {
+ modulePath = new URL(moduleBaseURL).getPath();
+ } catch (MalformedURLException ex) {
+ // log the information, we will default
+ servlet.log("Malformed moduleBaseURL: " + moduleBaseURL, ex);
+ }
+ }
+
+ SerializationPolicy serializationPolicy = null;
+
+ /*
+ * Check that the module path must be in the same web app as the servlet
+ * itself. If you need to implement a scheme different than this, override
+ * this method.
+ */
+ if (modulePath == null || !modulePath.startsWith(contextPath)) {
+ String message = "ERROR: The module path requested, "
+ + modulePath
+ + ", is not in the same web application as this servlet, "
+ + contextPath
+ + ". Your module may not be properly configured or your client and server code maybe out of date.";
+ servlet.log(message, null);
+ } else {
+ // Strip off the context path from the module base URL. It should be a
+ // strict prefix.
+ String contextRelativePath = modulePath.substring(contextPath.length());
+
+ String serializationPolicyFilePath = SerializationPolicyLoader.getSerializationPolicyFileName(contextRelativePath
+ + strongName);
+
+ // BEGIN - REMOVE CODE
+ // Open the RPC resource file and read its contents.
+ // InputStream is = servlet.getServletContext().getResourceAsStream(
+ // serializationPolicyFilePath);
+ // END - REMOVE CODE
+
+ // BEGIN - NEW CODE
+ InputStream is = null;
+ // if the bundle was set by the extending class, load the resource from it instead of the servlet context
+ if (bundle != null) {
+ try {
+ is = bundle.getResource(serializationPolicyFilePath).openStream();
+ } catch (IOException e) {
+ //ignore
+ }
+ } else {
+ is = servlet.getServletContext().getResourceAsStream(serializationPolicyFilePath);
+ }
+ // END - NEW CODE
+
+ try {
+ if (is != null) {
+ try {
+ serializationPolicy = SerializationPolicyLoader.loadFromStream(is,
+ null);
+ } catch (ParseException e) {
+ servlet.log("ERROR: Failed to parse the policy file '"
+ + serializationPolicyFilePath + "'", e);
+ } catch (IOException e) {
+ servlet.log("ERROR: Could not read the policy file '"
+ + serializationPolicyFilePath + "'", e);
+ }
+ } else {
+ String message = "ERROR: The serialization policy file '"
+ + serializationPolicyFilePath
+ + "' was not found; did you forget to include it in this deployment?";
+ servlet.log(message);
+ }
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // Ignore this error
+ }
+ }
+ }
+ }
+
+ return serializationPolicy;
+ }
/**
* The <code>org.osgi.framework.Bundle</code> to load resources from.
@@ -97,107 +193,24 @@ public class SlingRemoteServiceServlet e
}
/**
- * Gets the {@link com.google.gwt.user.server.rpc.SerializationPolicy} for given module base URL and strong
+ * Gets the {@link SerializationPolicy} for given module base URL and strong
* name if there is one.
- * <p/>
- * Override this method to provide a {@link com.google.gwt.user.server.rpc.SerializationPolicy} using an
+ *
+ * Override this method to provide a {@link SerializationPolicy} using an
* alternative approach.
- * <p/>
- * This method has been overriden, so that the serialization policy can be properly loaded as a bundle entry,
- * as Sling does not support <code>ServletContext.getResourceAsStream()</code>.
- *
- * @param request the HTTP request being serviced
+ *
+ * @param request the HTTP request being serviced
* @param moduleBaseURL as specified in the incoming payload
- * @param strongName a strong name that uniquely identifies a serialization
- * policy file
- * @return a {@link com.google.gwt.user.server.rpc.SerializationPolicy} for the given module base URL and
+ * @param strongName a strong name that uniquely identifies a serialization
+ * policy file
+ * @return a {@link SerializationPolicy} for the given module base URL and
* strong name, or <code>null</code> if there is none
*/
- @Override
- protected SerializationPolicy doGetSerializationPolicy(HttpServletRequest request, String moduleBaseURL, String strongName) {
-
- // The request can tell you the path of the web app relative to the
- // container root.
- String contextPath = request.getContextPath();
-
- String modulePath = null;
- if (moduleBaseURL != null) {
- try {
- modulePath = new URL(moduleBaseURL).getPath();
- } catch (MalformedURLException ex) {
- // log the information, we will default
- getServletContext().log("Malformed moduleBaseURL: " + moduleBaseURL, ex);
- }
- }
-
- SerializationPolicy serializationPolicy = null;
-
- /*
- * Check that the module path must be in the same web app as the servlet
- * itself. If you need to implement a scheme different than this, override
- * this method.
- */
- if (modulePath == null || !modulePath.startsWith(contextPath)) {
- String message = "ERROR: The module path requested, "
- + modulePath
- + ", is not in the same web application as this servlet, "
- + contextPath
- + ". Your module may not be properly configured or your client and server code maybe out of date.";
- getServletContext().log(message);
- } else {
- // Strip off the context path from the module base URL. It should be a
- // strict prefix.
- String contextRelativePath = modulePath.substring(contextPath.length());
-
- String serializationPolicyFilePath = SerializationPolicyLoader.getSerializationPolicyFileName(contextRelativePath
- + strongName);
-
- // Open the RPC resource file read its contents.
- InputStream is = null;
- // if the bundle was set by the extending class, load the resource from it instead of the servlet context
- if (bundle != null) {
- try {
- is = bundle.getResource(serializationPolicyFilePath).openStream();
- } catch (IOException e) {
- //ignore
- }
- } else {
- is = getServletContext().getResourceAsStream(
- serializationPolicyFilePath);
- }
- try {
- if (is != null) {
- try {
- serializationPolicy = SerializationPolicyLoader.loadFromStream(is, null);
- } catch (ParseException e) {
- getServletContext().log(
- "ERROR: Failed to parse the policy file '"
- + serializationPolicyFilePath + "'", e);
- } catch (IOException e) {
- getServletContext().log(
- "ERROR: Could not read the policy file '"
- + serializationPolicyFilePath + "'", e);
- }
- } else {
- String message = "ERROR: The serialization policy file '"
- + serializationPolicyFilePath
- + "' was not found; did you forget to include it in this deployment?";
- getServletContext().log(message);
- }
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- // Ignore this error
- }
- }
- }
- }
-
- return serializationPolicy;
+ protected SerializationPolicy doGetSerializationPolicy(
+ HttpServletRequest request, String moduleBaseURL, String strongName) {
+ return loadSerializationPolicy(this, request, moduleBaseURL, strongName, bundle);
}
-
+
/**
* Allows the extending OSGi service to set the bundle it is part of. The bundle is used to provide access
* to the policy file otherwise loaded by <code>getServletContext().getResourceAsStream()</code> which is not