dear all!

what we do is at compilation time, with ant, to move the policy files
to the package of the server side implementation of the service, and
to use following loader:

    /**
     * We do not want that the server goes to fetch files from the
servlet context, so we keep the .gwt.prc files in the class
     * path together with the service implementation.<p>
     *
     * @see
com.google.gwt.user.server.rpc.RemoteServiceServlet#doGetSerializationPolicy(javax.servlet.http.HttpServletRequest,
java.lang.String, java.lang.String)
     */
    @Override
    protected SerializationPolicy doGetSerializationPolicy(
        HttpServletRequest request,
        String moduleBaseURL,
        String strongName) {

        // locate the serialization policy file in the class path
        String serializationPolicyFilePath =
getClass().getPackage().getName().replace('.', '/') + "/";
        serializationPolicyFilePath +=
SerializationPolicyLoader.getSerializationPolicyFileName(strongName);

        SerializationPolicy serializationPolicy = null;

        // Open the RPC resource file and read its contents.
        InputStream is =
getClass().getClassLoader().getResourceAsStream(serializationPolicyFilePath);
        try {
            if (is != null) {
                try {
                    serializationPolicy =
SerializationPolicyLoader.loadFromStream(is, null);
                } catch (ParseException e) {
                    this.log("ERROR: Failed to parse the policy file
'" + serializationPolicyFilePath + "'", e);
                } catch (IOException e) {
                    this.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?";
                this.log(message);
            }
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                    // Ignore this error
                }
            }
        }

        return serializationPolicy;
    }

HTH
Michael

On Feb 24, 11:56 pm, Ed <post2edb...@hotmail.com> wrote:
> Thanks for your thoughts Alex.
> The solution is a bit like discussed above with Ladislav.
> I am still not so happy about retrieving this rpc files from different
> locations in different environments and also having to configure a
> HTTP context in the build/dev environment to be able to retrieve the
> policy files....
>
> I still think this should be more simple for "just" dealing with a
> "few" policy files.
>
> I think my best option, to make handling the policy files easy, is to
> implement my own SerializationPolicy class. But, I have no idea if
> that is correct way to go as I can't find correct information about
> it :(.
> Any idea's on how to do this are more then welcome?
>
> Ed

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to