Here are code fragments for you. It would be good if something like this could
be built in to GWT rather than having everybody implement similar code.
private static final String CODE_SERVER_URL_KEY = "CodeServerURL";
public void init(ServletConfig config) throws ServletException
{
m_codeServerURL = config.getInitParameter(CODE_SERVER_URL_KEY);
if (m_codeServerURL != null &&
m_codeServerURL.charAt(m_codeServerURL.length()-1) != '/')
m_codeServerURL = m_codeServerURL + "/";
}
Then, I override doGetSerializationPolicy and the part of the code that loads
from the code server looks like this:
boolean endsWithSlash =
moduleBaseURL.charAt(moduleBaseURL.length()-1) == '/';
String tmp = moduleBaseURL;
if (endsWithSlash)
tmp = tmp.substring(0, tmp.length()-1);
int lastSlash = tmp.lastIndexOf('/');
String moduleName = lastSlash < 0 ? tmp :
tmp.substring(lastSlash+1, tmp.length());
try
{
url = new URL(m_codeServerURL + moduleName + "/"
+
SerializationPolicyLoader.getSerializationPolicyFileName(strongName));
}
catch (MalformedURLException mue)
{
s_logger.debug("Could not read the policy file '" + url + "'",
ioe);
return null; // null return is then converted into throwing an
exception
}
InputStream is = null;
try
{
is = url.openStream();
s_logger.debug("Loading serialization policy from code server");
}
catch (IOException ioe2)
{
s_logger.debug("Could not read the policy file '" + url + "'",
ioe);
return null; // null return is then converted into throwing an
exception
}
Paul
On 14/06/12 22:15, Stefano Ciccarelli wrote:
Great idea!
It should work on GAE too using UrlFetch api to talk with the code server.
Could you share some pieces of code, please?
--
Inviato con Sparrow <http://www.sparrowmailapp.com/?sig>
Il giorno giovedÄ› 14 giugno 2012, alle ore 11:33, Paul Robinson ha scritto:
On 13/06/12 18:53, Andrea Boscolo wrote:
I can confirm that copying the CodeServer's .gwt.rpc files in the local war
dir, works but it's a pain: every time they change, they need to be copied.
There's an alternative to copying gwt.rpc files. I've changed my app so that
when it looks for the serialization policy, and it can't find it, it will ask
the code server for it. You just need to parse the module base URL to get the
module name, and then use the strong name provided to generate the appropriate
URL, something like:
http://localhost:9876/modulename/strongname.gwt.rpc
All I need to do now is to add the codeserver URL as a parameter in web.xml
<http://web.xml> so that this feature can be enabled/disabled so it doesn't
happen in production.
I don't know whether this technique would work on GAE as well.
Paul
--
You received this message because you are subscribed to the Google Groups "Google
Web Toolkit" group.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
To unsubscribe from this group, send email to
[email protected]
<mailto:[email protected]>.
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.
--
You received this message because you are subscribed to the Google Groups "Google
Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.
--
You received this message because you are subscribed to the Google Groups "Google
Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.