Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
oniseijin committed Apr 4, 2015
1 parent 176d52c commit 60f0956
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 8 deletions.
2 changes: 1 addition & 1 deletion GwtGrailsPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.codehaus.groovy.grails.plugins.gwt.DefaultGwtServiceInterfaceGenerato
import org.codehaus.groovy.grails.web.plugins.support.WebMetaUtils

class GwtGrailsPlugin {
def version = "1.0.3"
def version = "1.0.4"
def grailsVersion = "2.0 > *"
def title = "The Google Web Toolkit for Grails."
def description = """\
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ plugins {
transitive=false
}
}
setProperty('gwt.codeserver.port', '9876')
```
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import com.google.gwt.user.client.rpc.SerializationException
import com.google.gwt.user.server.rpc.RPC
import com.google.gwt.user.server.rpc.RPCRequest
import com.google.gwt.user.server.rpc.RemoteServiceServlet
import com.google.gwt.user.server.rpc.SerializationPolicy

import javax.servlet.http.HttpServletRequest
import java.lang.reflect.UndeclaredThrowableException
import javax.servlet.ServletContext
import java.net.URL;
import org.codehaus.groovy.grails.commons.GrailsApplication
import org.codehaus.groovy.grails.commons.GrailsClassUtils as GCU
import org.codehaus.groovy.grails.web.context.ServletContextHolder
Expand Down
4 changes: 2 additions & 2 deletions src/docs/guide/1. Introduction.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Jan Ehrhardt has kindly created a simple "tutorial":http://code.google.com/p/der
You can also join in the discussions about the plugin and ask questions on the "Google Group for GWT/Grails integration":http://groups.google.com/group/grails-gwt/

The plugin host page is at http://grails.org/plugin/gwt
The source code is at https://github.com/dawsonsystems/grails-gwt
Documentation can be found at http://dawsonsystems.github.com/grails-gwt/guide/
The source code is at https://github.com/simplicityitself/grails-gwt
Documentation can be found at http://simplicityitself.github.com/grails-gwt/guide/
The Google Group can be found at https://groups.google.com/group/grails-gwt
7 changes: 7 additions & 0 deletions src/docs/guide/2. Getting Started.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ Starting the GWT hosted mode client. …
[java] Listening for transport dt_socket at address: 5006
{code}

However, since 2.5.1, a JavaScript based code server method has been implemented, and has become mandatory in 2.7
{code}
grails run-gwt-codeserver
{code}

Note: in your BuildConfig.groovy, you must set an the property gwt.codeserver.port for RPC to work properly if you are using the resource plugin

Then, create a launch config in STS:

{code}
Expand Down
7 changes: 7 additions & 0 deletions src/docs/guide/3. Server RPC.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,10 @@ into:
{code}
MyServiceAsync myService = GWT.create(MyService.class);
{code}

h3. For existing Java RPC RemoteServiceServlet implementations

Because of the resource plugin, the location that GWT is looking for the resource policy is different from the URL. To resolve, GrailsRemoteServiceServlet was create. Extend this instead of RemoteServiceServlet, or provide a custom doGetSerializationPolicy.



4 changes: 2 additions & 2 deletions src/docs/guide/5. Configuration.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ It will use any repositories that you set up in the main BuildConfig.groovy
It *does not* use the dependencies block from BuildConfig, instead you must use the options below.

The following options control dependency management
* gwt.version - Set a version number (eg "2.4.0") of GWT to use.
* gwt.version - Set a version number (eg "2.5.1") of GWT to use.
* gwt.home (prefer to set a version have have it downloaded) - use the gwt version installed at the given location
* gwt.gin.version - download gin and any necessary libraries

Expand All @@ -19,7 +19,7 @@ gwt {
version="2.3.0"
gin.version="1.5.0"
}

setProperty("gwt.codeserver.port", "9876") //needed for run-app and run-gwt-codeserver
{code}

h3. GWT Modules
Expand Down
2 changes: 1 addition & 1 deletion src/docs/ref/Command Line/run-gwt-client.gdoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
h1. run-gwt-client

Run the GWT Development Mode client.
Run the GWT Development Mode client (2.5.1 -> 2.6.1; for 2.7.0, see run-gwt-codeserver)

This hosts your GWT code and executes it as Java. You will need the GWT plugin installed in your browser of choice.

Expand Down
4 changes: 3 additions & 1 deletion src/docs/ref/Command Line/run-gwt-codeserver.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ Run the GWT Super Dev Mode client.
This hosts your GWT code and compiles it to Javascript, in draft mode, on demand.
This removes the need to have a browser plugin, and speeds up page refreshes if the code hasn't changed.

See https://developers.google.com/web-toolkit/articles/superdevmode
See https://developers.google.com/web-toolkit/articles/superdevmode

You also need to set gwt.codeserver.port in BuildConfig.groovy for RPC to work properly.
62 changes: 62 additions & 0 deletions src/java/grails/plugins/gwt/server/GrailsRemoteServiceServlet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package grails.plugins.gwt.server;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.google.gwt.user.server.rpc.SerializationPolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.HttpServletRequest;
import java.net.URL;

/**
* Used to overcome the problem with grails resource plugin conflict with GWT
*
* GWT will use the URL to find resources, but the url has /static in it.
*
* issue#62 https://github.com/simplicityitself/grails-gwt/issues/62
*
* Created by ryan on 15-04-04.
*/
public class GrailsRemoteServiceServlet extends RemoteServiceServlet {
Logger logger = LoggerFactory.getLogger(GrailsRemoteServiceServlet.class);
/**
* Strip off the /static from the beginning of a module url, then pass to the super's implementation
*
* issue#62
*
* Does not affect other uses of static
*
* Borrow's from loadSerializationPolicy
*
* @param request
* @param moduleBaseURL
* @param strongName
* @return
*/
@Override
protected SerializationPolicy doGetSerializationPolicy(
HttpServletRequest request, String moduleBaseURL, String strongName) {
//moduleBaseURL.replace("/static", "") is so much easy(lazy)
String returnURL = moduleBaseURL;
logger.debug("doGetSerializationPolicy url:" + moduleBaseURL);
try{
URL url = new URL(moduleBaseURL);
String host = url.getHost();
int port = url.getPort();
String protocol = url.getProtocol();
String basePath = url.getPath();
logger.debug("basePath:" + basePath);
if(basePath.startsWith("/static")){
logger.debug("found static!");
basePath = basePath.replaceFirst("/static", "");
URL newUrl = new URL(protocol, host, port, basePath);
returnURL = newUrl.toString();
}

} catch(Exception e) { // default implementation will handle this
logger.error("Exception in GrailsRemoteService Servlet parsing url" + e.getMessage());
}
return super.doGetSerializationPolicy(request, returnURL, strongName);

}
}
2 changes: 1 addition & 1 deletion test/projects/aether/grails-app/conf/BuildConfig.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ grails.project.dependency.resolution = {
compile ':cache:1.1.1'

build ":extended-dependency-manager:0.5.2"
compile ":gwt:1.0-SNAPSHOT", {
compile ":gwt:1.0.3", {
transitive=false
}

Expand Down

0 comments on commit 60f0956

Please sign in to comment.