Author: [email protected]
Date: Tue Apr 28 12:43:30 2009
New Revision: 5295
Added:
trunk/user/src/com/google/gwt/user/linker/
trunk/user/src/com/google/gwt/user/linker/rpc/
trunk/user/src/com/google/gwt/user/linker/rpc/RpcPolicyFileArtifact.java
(contents, props changed)
trunk/user/src/com/google/gwt/user/linker/rpc/RpcPolicyManifestLinker.java
(contents, props changed)
Modified:
trunk/user/src/com/google/gwt/user/RemoteService.gwt.xml
trunk/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java
Log:
Create a manifest file mapping RPC service types to their respective
serialization policy files.
Patch by: bobv
Review by: amitmanjhi (desk)
Modified: trunk/user/src/com/google/gwt/user/RemoteService.gwt.xml
==============================================================================
--- trunk/user/src/com/google/gwt/user/RemoteService.gwt.xml (original)
+++ trunk/user/src/com/google/gwt/user/RemoteService.gwt.xml Tue Apr 28
12:43:30 2009
@@ -38,4 +38,7 @@
<generate-with
class="com.google.gwt.user.rebind.rpc.ServiceInterfaceProxyGenerator">
<when-type-assignable
class="com.google.gwt.user.client.rpc.RemoteService"/>
</generate-with>
+
+ <define-linker name="rpcPolicyManifest"
class="com.google.gwt.user.linker.rpc.RpcPolicyManifestLinker" />
+ <add-linker name="rpcPolicyManifest" />
</module>
Added:
trunk/user/src/com/google/gwt/user/linker/rpc/RpcPolicyFileArtifact.java
==============================================================================
--- (empty file)
+++
trunk/user/src/com/google/gwt/user/linker/rpc/RpcPolicyFileArtifact.java
Tue Apr 28 12:43:30 2009
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.user.linker.rpc;
+
+import com.google.gwt.core.ext.linker.Artifact;
+import com.google.gwt.core.ext.linker.EmittedArtifact;
+
+/**
+ * This artifact provides information about which proxy classes resulted in
+ * which rpc proxy files.
+ */
+public class RpcPolicyFileArtifact extends Artifact<RpcPolicyFileArtifact>
{
+
+ private final String proxyClass;
+ private final EmittedArtifact artifact;
+
+ public RpcPolicyFileArtifact(String proxyClass, EmittedArtifact
artifact) {
+ super(RpcPolicyManifestLinker.class);
+ this.proxyClass = proxyClass;
+ this.artifact = artifact;
+ }
+
+ public EmittedArtifact getEmittedArtifact() {
+ return artifact;
+ }
+
+ public String getProxyClass() {
+ return proxyClass;
+ }
+
+ @Override
+ public final int hashCode() {
+ return getProxyClass().hashCode();
+ }
+
+ @Override
+ protected final int compareToComparableArtifact(RpcPolicyFileArtifact o)
{
+ return getProxyClass().compareTo(o.getProxyClass());
+ }
+
+ @Override
+ protected final Class<RpcPolicyFileArtifact> getComparableArtifactType()
{
+ return RpcPolicyFileArtifact.class;
+ }
+}
Added:
trunk/user/src/com/google/gwt/user/linker/rpc/RpcPolicyManifestLinker.java
==============================================================================
--- (empty file)
+++
trunk/user/src/com/google/gwt/user/linker/rpc/RpcPolicyManifestLinker.java
Tue Apr 28 12:43:30 2009
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.user.linker.rpc;
+
+import com.google.gwt.core.ext.LinkerContext;
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.core.ext.linker.AbstractLinker;
+import com.google.gwt.core.ext.linker.ArtifactSet;
+import com.google.gwt.core.ext.linker.EmittedArtifact;
+import com.google.gwt.core.ext.linker.LinkerOrder;
+import com.google.gwt.core.ext.linker.LinkerOrder.Order;
+
+/**
+ * Emit a file contating a map of RPC proxy classes to the partial path of
the
+ * RPC policy file.
+ */
+...@linkerorder(Order.PRE)
+public class RpcPolicyManifestLinker extends AbstractLinker {
+
+ @Override
+ public String getDescription() {
+ return "RPC policy file manifest";
+ }
+
+ @Override
+ public ArtifactSet link(TreeLogger logger, LinkerContext context,
+ ArtifactSet artifacts) throws UnableToCompleteException {
+ artifacts = new ArtifactSet(artifacts);
+
+ StringBuilder contents = new StringBuilder();
+ contents.append("#
Module ").append(context.getModuleName()).append("\n");
+ contents.append("# RPC service class, partial path of RPC policy
file\n");
+
+ // Loop over all policy file artifacts
+ for (RpcPolicyFileArtifact artifact :
artifacts.find(RpcPolicyFileArtifact.class)) {
+ // com.foo.Service, 12345.rpc.txt
+ contents.append(artifact.getProxyClass()).append(", ").append(
+ artifact.getEmittedArtifact().getPartialPath()).append("\n");
+ }
+
+ // The name of the linker is prepended as a directory prefix
+ EmittedArtifact manifest = emitString(logger, contents.toString(),
+ "manifest.txt");
+ manifest.setPrivate(true);
+ artifacts.add(manifest);
+
+ return artifacts;
+ }
+}
Modified: trunk/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java
==============================================================================
--- trunk/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java
(original)
+++ trunk/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java Tue Apr
28 12:43:30 2009
@@ -20,6 +20,7 @@
import com.google.gwt.core.ext.GeneratorContext;
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.core.ext.linker.GeneratedResource;
import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.JMethod;
import com.google.gwt.core.ext.typeinfo.JPackage;
@@ -42,6 +43,7 @@
import com.google.gwt.user.client.rpc.impl.FailingRequestBuilder;
import com.google.gwt.user.client.rpc.impl.RemoteServiceProxy;
import
com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.ResponseReader;
+import com.google.gwt.user.linker.rpc.RpcPolicyFileArtifact;
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
import com.google.gwt.user.rebind.SourceWriter;
import com.google.gwt.user.server.rpc.SerializationPolicyLoader;
@@ -650,7 +652,14 @@
serializationPolicyFileName);
if (os != null) {
os.write(serializationPolicyFileContents);
- ctx.commitResource(logger, os);
+ GeneratedResource resource = ctx.commitResource(logger, os);
+
+ /*
+ * Record which proxy class created the resource. A manifest will
be
+ * emitted by the RpcPolicyManifestLinker.
+ */
+ ctx.commitArtifact(logger, new RpcPolicyFileArtifact(
+ serviceIntf.getQualifiedSourceName(), resource));
} else {
logger.log(TreeLogger.TRACE,
"SerializationPolicy file for RemoteService '"
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---