From 01a57a03bfda2a27530025e0fbac4f3eb082c5b1 Mon Sep 17 00:00:00 2001 From: Charlie Groves Date: Thu, 7 Jul 2011 21:10:49 +0000 Subject: [PATCH] Parameterize InvocationService on the ClientObject type expected to call the service, and generate InvocationProviders that take that type instead of just ClientObject. Also, use the full set of import groupings no matter what. If that's the way we like it, that's the way we like it. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6682 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../bureau/data/BureauMarshaller.as | 4 +- .../crowd/chat/client/ChannelSpeakService.as | 1 + .../crowd/chat/client/ChatService.as | 3 +- .../chat/client/ChatService_TellListener.as | 3 +- .../crowd/chat/data/ChannelSpeakMarshaller.as | 4 +- .../crowd/chat/data/ChatMarshaller.as | 4 +- .../data/ChatMarshaller_TellMarshaller.as | 4 +- .../crowd/chat/data/SpeakMarshaller.as | 4 +- .../client/LocationService_MoveListener.as | 1 + .../threerings/crowd/data/BodyMarshaller.as | 4 +- .../crowd/data/LocationMarshaller.as | 4 +- .../data/LocationMarshaller_MoveMarshaller.as | 1 + .../threerings/admin/client/AdminService.java | 3 +- .../admin/data/AdminMarshaller.java | 4 +- .../admin/server/AdminProvider.java | 1 + .../bureau/client/BureauService.java | 3 +- .../bureau/data/BureauMarshaller.java | 4 +- .../bureau/server/BureauProvider.java | 1 + .../chat/client/ChannelSpeakService.java | 3 +- .../crowd/chat/client/ChatService.java | 3 +- .../crowd/chat/client/SpeakService.java | 3 +- .../chat/data/ChannelSpeakMarshaller.java | 4 +- .../crowd/chat/data/ChatMarshaller.java | 9 ++-- .../crowd/chat/data/SpeakMarshaller.java | 4 +- .../chat/server/ChannelSpeakProvider.java | 1 + .../crowd/chat/server/SpeakProvider.java | 1 + .../threerings/crowd/client/BodyService.java | 3 +- .../crowd/client/LocationService.java | 3 +- .../threerings/crowd/data/BodyMarshaller.java | 4 +- .../crowd/data/LocationMarshaller.java | 4 +- .../crowd/peer/client/CrowdPeerService.java | 3 +- .../crowd/peer/data/CrowdPeerMarshaller.java | 7 +++- .../crowd/peer/server/CrowdPeerProvider.java | 4 +- .../threerings/crowd/server/BodyProvider.java | 1 + .../crowd/server/LocationProvider.java | 1 + .../threerings/crowd/server/PlaceManager.java | 9 ++-- .../presents/client/InvocationService.java | 6 ++- .../presents/client/TimeBaseService.java | 4 +- .../presents/data/InvocationMarshaller.java | 4 +- .../presents/data/TimeBaseMarshaller.java | 2 +- .../presents/peer/client/PeerService.java | 3 +- .../presents/peer/data/PeerMarshaller.java | 3 +- .../presents/tools/GenServiceTask.java | 41 +++++++++++++------ .../threerings/presents/tools/ImportSet.java | 28 ++++++------- .../threerings/presents/tools/marshaller.tmpl | 2 +- .../threerings/presents/tools/provider.tmpl | 2 +- .../presents/client/TestService.java | 4 +- .../presents/data/TestMarshaller.java | 2 +- 48 files changed, 147 insertions(+), 74 deletions(-) diff --git a/src/main/as/com/threerings/bureau/data/BureauMarshaller.as b/src/main/as/com/threerings/bureau/data/BureauMarshaller.as index 137634b95..cf15fd5df 100644 --- a/src/main/as/com/threerings/bureau/data/BureauMarshaller.as +++ b/src/main/as/com/threerings/bureau/data/BureauMarshaller.as @@ -22,9 +22,11 @@ package com.threerings.bureau.data { import com.threerings.bureau.client.BureauService; -import com.threerings.presents.data.InvocationMarshaller; + import com.threerings.util.Integer; +import com.threerings.presents.data.InvocationMarshaller; + /** * Provides the implementation of the BureauService interface * that marshalls the arguments and delivers the request to the provider diff --git a/src/main/as/com/threerings/crowd/chat/client/ChannelSpeakService.as b/src/main/as/com/threerings/crowd/chat/client/ChannelSpeakService.as index 14eb88cb9..1253c24f4 100644 --- a/src/main/as/com/threerings/crowd/chat/client/ChannelSpeakService.as +++ b/src/main/as/com/threerings/crowd/chat/client/ChannelSpeakService.as @@ -22,6 +22,7 @@ package com.threerings.crowd.chat.client { import com.threerings.crowd.chat.data.ChatChannel; + import com.threerings.presents.client.InvocationService; /** diff --git a/src/main/as/com/threerings/crowd/chat/client/ChatService.as b/src/main/as/com/threerings/crowd/chat/client/ChatService.as index eabeceea3..9610427f6 100644 --- a/src/main/as/com/threerings/crowd/chat/client/ChatService.as +++ b/src/main/as/com/threerings/crowd/chat/client/ChatService.as @@ -21,9 +21,10 @@ package com.threerings.crowd.chat.client { +import com.threerings.util.Name; + import com.threerings.presents.client.InvocationService; import com.threerings.presents.client.InvocationService_InvocationListener; -import com.threerings.util.Name; /** * An ActionScript version of the Java ChatService interface. diff --git a/src/main/as/com/threerings/crowd/chat/client/ChatService_TellListener.as b/src/main/as/com/threerings/crowd/chat/client/ChatService_TellListener.as index 0e63d77cb..558b71617 100644 --- a/src/main/as/com/threerings/crowd/chat/client/ChatService_TellListener.as +++ b/src/main/as/com/threerings/crowd/chat/client/ChatService_TellListener.as @@ -21,9 +21,10 @@ package com.threerings.crowd.chat.client { -import com.threerings.presents.client.InvocationService_InvocationListener; import com.threerings.util.Long; +import com.threerings.presents.client.InvocationService_InvocationListener; + /** * An ActionScript version of the Java ChatService_TellListener interface. */ diff --git a/src/main/as/com/threerings/crowd/chat/data/ChannelSpeakMarshaller.as b/src/main/as/com/threerings/crowd/chat/data/ChannelSpeakMarshaller.as index 4b5993413..e57a7b8a1 100644 --- a/src/main/as/com/threerings/crowd/chat/data/ChannelSpeakMarshaller.as +++ b/src/main/as/com/threerings/crowd/chat/data/ChannelSpeakMarshaller.as @@ -22,9 +22,11 @@ package com.threerings.crowd.chat.data { import com.threerings.crowd.chat.client.ChannelSpeakService; -import com.threerings.presents.data.InvocationMarshaller; + import com.threerings.util.Byte; +import com.threerings.presents.data.InvocationMarshaller; + /** * Provides the implementation of the ChannelSpeakService interface * that marshalls the arguments and delivers the request to the provider diff --git a/src/main/as/com/threerings/crowd/chat/data/ChatMarshaller.as b/src/main/as/com/threerings/crowd/chat/data/ChatMarshaller.as index 2642dd036..a11199da4 100644 --- a/src/main/as/com/threerings/crowd/chat/data/ChatMarshaller.as +++ b/src/main/as/com/threerings/crowd/chat/data/ChatMarshaller.as @@ -23,10 +23,12 @@ package com.threerings.crowd.chat.data { import com.threerings.crowd.chat.client.ChatService; import com.threerings.crowd.chat.client.ChatService_TellListener; + +import com.threerings.util.Name; + import com.threerings.presents.client.InvocationService_InvocationListener; import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller; -import com.threerings.util.Name; /** * Provides the implementation of the ChatService interface diff --git a/src/main/as/com/threerings/crowd/chat/data/ChatMarshaller_TellMarshaller.as b/src/main/as/com/threerings/crowd/chat/data/ChatMarshaller_TellMarshaller.as index 636555405..956546f3f 100644 --- a/src/main/as/com/threerings/crowd/chat/data/ChatMarshaller_TellMarshaller.as +++ b/src/main/as/com/threerings/crowd/chat/data/ChatMarshaller_TellMarshaller.as @@ -22,9 +22,11 @@ package com.threerings.crowd.chat.data { import com.threerings.crowd.chat.client.ChatService_TellListener; -import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller; + import com.threerings.util.Long; +import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller; + /** * Marshalls instances of the ChatService_TellMarshaller interface. */ diff --git a/src/main/as/com/threerings/crowd/chat/data/SpeakMarshaller.as b/src/main/as/com/threerings/crowd/chat/data/SpeakMarshaller.as index ee05f92cd..dec4a15c1 100644 --- a/src/main/as/com/threerings/crowd/chat/data/SpeakMarshaller.as +++ b/src/main/as/com/threerings/crowd/chat/data/SpeakMarshaller.as @@ -22,9 +22,11 @@ package com.threerings.crowd.chat.data { import com.threerings.crowd.chat.client.SpeakService; -import com.threerings.presents.data.InvocationMarshaller; + import com.threerings.util.Byte; +import com.threerings.presents.data.InvocationMarshaller; + /** * Provides the implementation of the SpeakService interface * that marshalls the arguments and delivers the request to the provider diff --git a/src/main/as/com/threerings/crowd/client/LocationService_MoveListener.as b/src/main/as/com/threerings/crowd/client/LocationService_MoveListener.as index 412e7df2e..8498cca8d 100644 --- a/src/main/as/com/threerings/crowd/client/LocationService_MoveListener.as +++ b/src/main/as/com/threerings/crowd/client/LocationService_MoveListener.as @@ -22,6 +22,7 @@ package com.threerings.crowd.client { import com.threerings.crowd.data.PlaceConfig; + import com.threerings.presents.client.InvocationService_InvocationListener; /** diff --git a/src/main/as/com/threerings/crowd/data/BodyMarshaller.as b/src/main/as/com/threerings/crowd/data/BodyMarshaller.as index 11997e05e..eea71078b 100644 --- a/src/main/as/com/threerings/crowd/data/BodyMarshaller.as +++ b/src/main/as/com/threerings/crowd/data/BodyMarshaller.as @@ -22,9 +22,11 @@ package com.threerings.crowd.data { import com.threerings.crowd.client.BodyService; -import com.threerings.presents.data.InvocationMarshaller; + import com.threerings.util.langBoolean; +import com.threerings.presents.data.InvocationMarshaller; + /** * Provides the implementation of the BodyService interface * that marshalls the arguments and delivers the request to the provider diff --git a/src/main/as/com/threerings/crowd/data/LocationMarshaller.as b/src/main/as/com/threerings/crowd/data/LocationMarshaller.as index 4803bea1c..de8fbf971 100644 --- a/src/main/as/com/threerings/crowd/data/LocationMarshaller.as +++ b/src/main/as/com/threerings/crowd/data/LocationMarshaller.as @@ -23,9 +23,11 @@ package com.threerings.crowd.data { import com.threerings.crowd.client.LocationService; import com.threerings.crowd.client.LocationService_MoveListener; -import com.threerings.presents.data.InvocationMarshaller; + import com.threerings.util.Integer; +import com.threerings.presents.data.InvocationMarshaller; + /** * Provides the implementation of the LocationService interface * that marshalls the arguments and delivers the request to the provider diff --git a/src/main/as/com/threerings/crowd/data/LocationMarshaller_MoveMarshaller.as b/src/main/as/com/threerings/crowd/data/LocationMarshaller_MoveMarshaller.as index f3d710a7b..de4e06ac3 100644 --- a/src/main/as/com/threerings/crowd/data/LocationMarshaller_MoveMarshaller.as +++ b/src/main/as/com/threerings/crowd/data/LocationMarshaller_MoveMarshaller.as @@ -22,6 +22,7 @@ package com.threerings.crowd.data { import com.threerings.crowd.client.LocationService_MoveListener; + import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller; /** diff --git a/src/main/java/com/threerings/admin/client/AdminService.java b/src/main/java/com/threerings/admin/client/AdminService.java index 98497cec3..c9263d60b 100644 --- a/src/main/java/com/threerings/admin/client/AdminService.java +++ b/src/main/java/com/threerings/admin/client/AdminService.java @@ -22,11 +22,12 @@ package com.threerings.admin.client; import com.threerings.presents.client.InvocationService; +import com.threerings.presents.data.ClientObject; /** * Defines the client side of the admin invocation services. */ -public interface AdminService extends InvocationService +public interface AdminService extends InvocationService { /** * Used to communicate a response to a {@link AdminService#getConfigInfo} request. diff --git a/src/main/java/com/threerings/admin/data/AdminMarshaller.java b/src/main/java/com/threerings/admin/data/AdminMarshaller.java index 586e61f3a..fa93570cb 100644 --- a/src/main/java/com/threerings/admin/data/AdminMarshaller.java +++ b/src/main/java/com/threerings/admin/data/AdminMarshaller.java @@ -24,6 +24,8 @@ package com.threerings.admin.data; import javax.annotation.Generated; import com.threerings.admin.client.AdminService; + +import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.InvocationMarshaller; /** @@ -35,7 +37,7 @@ import com.threerings.presents.data.InvocationMarshaller; */ @Generated(value={"com.threerings.presents.tools.GenServiceTask"}, comments="Derived from AdminService.java.") -public class AdminMarshaller extends InvocationMarshaller +public class AdminMarshaller extends InvocationMarshaller implements AdminService { /** diff --git a/src/main/java/com/threerings/admin/server/AdminProvider.java b/src/main/java/com/threerings/admin/server/AdminProvider.java index 0cac48fb3..345c3390c 100644 --- a/src/main/java/com/threerings/admin/server/AdminProvider.java +++ b/src/main/java/com/threerings/admin/server/AdminProvider.java @@ -24,6 +24,7 @@ package com.threerings.admin.server; import javax.annotation.Generated; import com.threerings.admin.client.AdminService; + import com.threerings.presents.data.ClientObject; import com.threerings.presents.server.InvocationException; import com.threerings.presents.server.InvocationProvider; diff --git a/src/main/java/com/threerings/bureau/client/BureauService.java b/src/main/java/com/threerings/bureau/client/BureauService.java index ed87342e2..c3022d2be 100644 --- a/src/main/java/com/threerings/bureau/client/BureauService.java +++ b/src/main/java/com/threerings/bureau/client/BureauService.java @@ -22,11 +22,12 @@ package com.threerings.bureau.client; import com.threerings.presents.client.InvocationService; +import com.threerings.presents.data.ClientObject; /** * Interface for the bureau to communicate with the server. */ -public interface BureauService extends InvocationService +public interface BureauService extends InvocationService { /** * Notifies the server that the bureau is up and running and ready to receive diff --git a/src/main/java/com/threerings/bureau/data/BureauMarshaller.java b/src/main/java/com/threerings/bureau/data/BureauMarshaller.java index 7e2822b7b..ab789919e 100644 --- a/src/main/java/com/threerings/bureau/data/BureauMarshaller.java +++ b/src/main/java/com/threerings/bureau/data/BureauMarshaller.java @@ -24,6 +24,8 @@ package com.threerings.bureau.data; import javax.annotation.Generated; import com.threerings.bureau.client.BureauService; + +import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.InvocationMarshaller; /** @@ -35,7 +37,7 @@ import com.threerings.presents.data.InvocationMarshaller; */ @Generated(value={"com.threerings.presents.tools.GenServiceTask"}, comments="Derived from BureauService.java.") -public class BureauMarshaller extends InvocationMarshaller +public class BureauMarshaller extends InvocationMarshaller implements BureauService { /** The method id used to dispatch {@link #agentCreated} requests. */ diff --git a/src/main/java/com/threerings/bureau/server/BureauProvider.java b/src/main/java/com/threerings/bureau/server/BureauProvider.java index c369a90ee..20702b0e2 100644 --- a/src/main/java/com/threerings/bureau/server/BureauProvider.java +++ b/src/main/java/com/threerings/bureau/server/BureauProvider.java @@ -24,6 +24,7 @@ package com.threerings.bureau.server; import javax.annotation.Generated; import com.threerings.bureau.client.BureauService; + import com.threerings.presents.data.ClientObject; import com.threerings.presents.server.InvocationProvider; diff --git a/src/main/java/com/threerings/crowd/chat/client/ChannelSpeakService.java b/src/main/java/com/threerings/crowd/chat/client/ChannelSpeakService.java index 543b07118..ef21953f8 100644 --- a/src/main/java/com/threerings/crowd/chat/client/ChannelSpeakService.java +++ b/src/main/java/com/threerings/crowd/chat/client/ChannelSpeakService.java @@ -22,13 +22,14 @@ package com.threerings.crowd.chat.client; import com.threerings.presents.client.InvocationService; +import com.threerings.presents.data.ClientObject; import com.threerings.crowd.chat.data.ChatChannel; /** * Provides a way for clients to speak on chat channels. */ -public interface ChannelSpeakService extends InvocationService +public interface ChannelSpeakService extends InvocationService { /** * Requests to speak the supplied message on the specified channel. diff --git a/src/main/java/com/threerings/crowd/chat/client/ChatService.java b/src/main/java/com/threerings/crowd/chat/client/ChatService.java index ee6560719..bc9fecbbe 100644 --- a/src/main/java/com/threerings/crowd/chat/client/ChatService.java +++ b/src/main/java/com/threerings/crowd/chat/client/ChatService.java @@ -24,6 +24,7 @@ package com.threerings.crowd.chat.client; import com.threerings.util.Name; import com.threerings.presents.client.InvocationService; +import com.threerings.presents.data.ClientObject; /** * The chat services provide a mechanism by which the client can broadcast chat messages to all @@ -31,7 +32,7 @@ import com.threerings.presents.client.InvocationService; * These services should not be used directly, but instead should be accessed via the * {@link ChatDirector}. */ -public interface ChatService extends InvocationService +public interface ChatService extends InvocationService { /** * Used to communicate the response to a {@link ChatService#tell} request. diff --git a/src/main/java/com/threerings/crowd/chat/client/SpeakService.java b/src/main/java/com/threerings/crowd/chat/client/SpeakService.java index d19105b06..a7da72fcc 100644 --- a/src/main/java/com/threerings/crowd/chat/client/SpeakService.java +++ b/src/main/java/com/threerings/crowd/chat/client/SpeakService.java @@ -22,12 +22,13 @@ package com.threerings.crowd.chat.client; import com.threerings.presents.client.InvocationService; +import com.threerings.presents.data.ClientObject; /** * Provides a means by which "speaking" can be allowed among subscribers * of a particular distributed object. */ -public interface SpeakService extends InvocationService +public interface SpeakService extends InvocationService { /** * Issues a request to speak "on" the distributed object via which diff --git a/src/main/java/com/threerings/crowd/chat/data/ChannelSpeakMarshaller.java b/src/main/java/com/threerings/crowd/chat/data/ChannelSpeakMarshaller.java index 258c737db..4c01fc361 100644 --- a/src/main/java/com/threerings/crowd/chat/data/ChannelSpeakMarshaller.java +++ b/src/main/java/com/threerings/crowd/chat/data/ChannelSpeakMarshaller.java @@ -24,6 +24,8 @@ package com.threerings.crowd.chat.data; import javax.annotation.Generated; import com.threerings.crowd.chat.client.ChannelSpeakService; + +import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.InvocationMarshaller; /** @@ -35,7 +37,7 @@ import com.threerings.presents.data.InvocationMarshaller; */ @Generated(value={"com.threerings.presents.tools.GenServiceTask"}, comments="Derived from ChannelSpeakService.java.") -public class ChannelSpeakMarshaller extends InvocationMarshaller +public class ChannelSpeakMarshaller extends InvocationMarshaller implements ChannelSpeakService { /** The method id used to dispatch {@link #speak} requests. */ diff --git a/src/main/java/com/threerings/crowd/chat/data/ChatMarshaller.java b/src/main/java/com/threerings/crowd/chat/data/ChatMarshaller.java index d844554ef..a6a4ce58c 100644 --- a/src/main/java/com/threerings/crowd/chat/data/ChatMarshaller.java +++ b/src/main/java/com/threerings/crowd/chat/data/ChatMarshaller.java @@ -24,10 +24,13 @@ package com.threerings.crowd.chat.data; import javax.annotation.Generated; import com.threerings.crowd.chat.client.ChatService; -import com.threerings.presents.client.InvocationService; -import com.threerings.presents.data.InvocationMarshaller; + import com.threerings.util.Name; +import com.threerings.presents.client.InvocationService; +import com.threerings.presents.data.ClientObject; +import com.threerings.presents.data.InvocationMarshaller; + /** * Provides the implementation of the {@link ChatService} interface * that marshalls the arguments and delivers the request to the provider @@ -37,7 +40,7 @@ import com.threerings.util.Name; */ @Generated(value={"com.threerings.presents.tools.GenServiceTask"}, comments="Derived from ChatService.java.") -public class ChatMarshaller extends InvocationMarshaller +public class ChatMarshaller extends InvocationMarshaller implements ChatService { /** diff --git a/src/main/java/com/threerings/crowd/chat/data/SpeakMarshaller.java b/src/main/java/com/threerings/crowd/chat/data/SpeakMarshaller.java index 7927e3aec..afdbdf832 100644 --- a/src/main/java/com/threerings/crowd/chat/data/SpeakMarshaller.java +++ b/src/main/java/com/threerings/crowd/chat/data/SpeakMarshaller.java @@ -24,6 +24,8 @@ package com.threerings.crowd.chat.data; import javax.annotation.Generated; import com.threerings.crowd.chat.client.SpeakService; + +import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.InvocationMarshaller; /** @@ -35,7 +37,7 @@ import com.threerings.presents.data.InvocationMarshaller; */ @Generated(value={"com.threerings.presents.tools.GenServiceTask"}, comments="Derived from SpeakService.java.") -public class SpeakMarshaller extends InvocationMarshaller +public class SpeakMarshaller extends InvocationMarshaller implements SpeakService { /** The method id used to dispatch {@link #speak} requests. */ diff --git a/src/main/java/com/threerings/crowd/chat/server/ChannelSpeakProvider.java b/src/main/java/com/threerings/crowd/chat/server/ChannelSpeakProvider.java index 6162c1c76..fc0b971c5 100644 --- a/src/main/java/com/threerings/crowd/chat/server/ChannelSpeakProvider.java +++ b/src/main/java/com/threerings/crowd/chat/server/ChannelSpeakProvider.java @@ -25,6 +25,7 @@ import javax.annotation.Generated; import com.threerings.crowd.chat.client.ChannelSpeakService; import com.threerings.crowd.chat.data.ChatChannel; + import com.threerings.presents.data.ClientObject; import com.threerings.presents.server.InvocationProvider; diff --git a/src/main/java/com/threerings/crowd/chat/server/SpeakProvider.java b/src/main/java/com/threerings/crowd/chat/server/SpeakProvider.java index 036d602b5..564872e86 100644 --- a/src/main/java/com/threerings/crowd/chat/server/SpeakProvider.java +++ b/src/main/java/com/threerings/crowd/chat/server/SpeakProvider.java @@ -24,6 +24,7 @@ package com.threerings.crowd.chat.server; import javax.annotation.Generated; import com.threerings.crowd.chat.client.SpeakService; + import com.threerings.presents.data.ClientObject; import com.threerings.presents.server.InvocationProvider; diff --git a/src/main/java/com/threerings/crowd/client/BodyService.java b/src/main/java/com/threerings/crowd/client/BodyService.java index cf9b2d0d0..27016f4b8 100644 --- a/src/main/java/com/threerings/crowd/client/BodyService.java +++ b/src/main/java/com/threerings/crowd/client/BodyService.java @@ -22,11 +22,12 @@ package com.threerings.crowd.client; import com.threerings.presents.client.InvocationService; +import com.threerings.presents.data.ClientObject; /** * The client side of the body-related invocation services. */ -public interface BodyService extends InvocationService +public interface BodyService extends InvocationService { /** * Requests to set the idle state of the client to the specified diff --git a/src/main/java/com/threerings/crowd/client/LocationService.java b/src/main/java/com/threerings/crowd/client/LocationService.java index ed9ce41e1..e70dd5322 100644 --- a/src/main/java/com/threerings/crowd/client/LocationService.java +++ b/src/main/java/com/threerings/crowd/client/LocationService.java @@ -22,6 +22,7 @@ package com.threerings.crowd.client; import com.threerings.presents.client.InvocationService; +import com.threerings.presents.data.ClientObject; import com.threerings.crowd.data.PlaceConfig; @@ -30,7 +31,7 @@ import com.threerings.crowd.data.PlaceConfig; * place in the server. These services should not be used directly, but instead should be accessed * via the {@link LocationDirector}. */ -public interface LocationService extends InvocationService +public interface LocationService extends InvocationService { /** * Used to communicate responses to {@link LocationService#moveTo} requests. diff --git a/src/main/java/com/threerings/crowd/data/BodyMarshaller.java b/src/main/java/com/threerings/crowd/data/BodyMarshaller.java index 14bf2f945..7f5a10208 100644 --- a/src/main/java/com/threerings/crowd/data/BodyMarshaller.java +++ b/src/main/java/com/threerings/crowd/data/BodyMarshaller.java @@ -24,6 +24,8 @@ package com.threerings.crowd.data; import javax.annotation.Generated; import com.threerings.crowd.client.BodyService; + +import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.InvocationMarshaller; /** @@ -35,7 +37,7 @@ import com.threerings.presents.data.InvocationMarshaller; */ @Generated(value={"com.threerings.presents.tools.GenServiceTask"}, comments="Derived from BodyService.java.") -public class BodyMarshaller extends InvocationMarshaller +public class BodyMarshaller extends InvocationMarshaller implements BodyService { /** The method id used to dispatch {@link #setIdle} requests. */ diff --git a/src/main/java/com/threerings/crowd/data/LocationMarshaller.java b/src/main/java/com/threerings/crowd/data/LocationMarshaller.java index 26a31b021..a66f3b33b 100644 --- a/src/main/java/com/threerings/crowd/data/LocationMarshaller.java +++ b/src/main/java/com/threerings/crowd/data/LocationMarshaller.java @@ -24,6 +24,8 @@ package com.threerings.crowd.data; import javax.annotation.Generated; import com.threerings.crowd.client.LocationService; + +import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.InvocationMarshaller; /** @@ -35,7 +37,7 @@ import com.threerings.presents.data.InvocationMarshaller; */ @Generated(value={"com.threerings.presents.tools.GenServiceTask"}, comments="Derived from LocationService.java.") -public class LocationMarshaller extends InvocationMarshaller +public class LocationMarshaller extends InvocationMarshaller implements LocationService { /** diff --git a/src/main/java/com/threerings/crowd/peer/client/CrowdPeerService.java b/src/main/java/com/threerings/crowd/peer/client/CrowdPeerService.java index 4309dad8a..a555e35c2 100644 --- a/src/main/java/com/threerings/crowd/peer/client/CrowdPeerService.java +++ b/src/main/java/com/threerings/crowd/peer/client/CrowdPeerService.java @@ -24,6 +24,7 @@ package com.threerings.crowd.peer.client; import com.threerings.util.Name; import com.threerings.presents.client.InvocationService; +import com.threerings.presents.data.ClientObject; import com.threerings.crowd.chat.client.ChatService; import com.threerings.crowd.chat.data.UserMessage; @@ -31,7 +32,7 @@ import com.threerings.crowd.chat.data.UserMessage; /** * Bridges certain Crowd services between peers in a cluster configuration. */ -public interface CrowdPeerService extends InvocationService +public interface CrowdPeerService extends InvocationService { /** * Used to forward a tell request to the server on which the destination user actually diff --git a/src/main/java/com/threerings/crowd/peer/data/CrowdPeerMarshaller.java b/src/main/java/com/threerings/crowd/peer/data/CrowdPeerMarshaller.java index 1408b364f..049ff012f 100644 --- a/src/main/java/com/threerings/crowd/peer/data/CrowdPeerMarshaller.java +++ b/src/main/java/com/threerings/crowd/peer/data/CrowdPeerMarshaller.java @@ -27,9 +27,12 @@ import com.threerings.crowd.chat.client.ChatService; import com.threerings.crowd.chat.data.ChatMarshaller; import com.threerings.crowd.chat.data.UserMessage; import com.threerings.crowd.peer.client.CrowdPeerService; -import com.threerings.presents.data.InvocationMarshaller; + import com.threerings.util.Name; +import com.threerings.presents.data.ClientObject; +import com.threerings.presents.data.InvocationMarshaller; + /** * Provides the implementation of the {@link CrowdPeerService} interface * that marshalls the arguments and delivers the request to the provider @@ -39,7 +42,7 @@ import com.threerings.util.Name; */ @Generated(value={"com.threerings.presents.tools.GenServiceTask"}, comments="Derived from CrowdPeerService.java.") -public class CrowdPeerMarshaller extends InvocationMarshaller +public class CrowdPeerMarshaller extends InvocationMarshaller implements CrowdPeerService { /** The method id used to dispatch {@link #deliverBroadcast} requests. */ diff --git a/src/main/java/com/threerings/crowd/peer/server/CrowdPeerProvider.java b/src/main/java/com/threerings/crowd/peer/server/CrowdPeerProvider.java index 89335cd4b..89938acfb 100644 --- a/src/main/java/com/threerings/crowd/peer/server/CrowdPeerProvider.java +++ b/src/main/java/com/threerings/crowd/peer/server/CrowdPeerProvider.java @@ -26,10 +26,12 @@ import javax.annotation.Generated; import com.threerings.crowd.chat.client.ChatService; import com.threerings.crowd.chat.data.UserMessage; import com.threerings.crowd.peer.client.CrowdPeerService; + +import com.threerings.util.Name; + import com.threerings.presents.data.ClientObject; import com.threerings.presents.server.InvocationException; import com.threerings.presents.server.InvocationProvider; -import com.threerings.util.Name; /** * Defines the server-side of the {@link CrowdPeerService}. diff --git a/src/main/java/com/threerings/crowd/server/BodyProvider.java b/src/main/java/com/threerings/crowd/server/BodyProvider.java index c02f60300..dc1ee35eb 100644 --- a/src/main/java/com/threerings/crowd/server/BodyProvider.java +++ b/src/main/java/com/threerings/crowd/server/BodyProvider.java @@ -24,6 +24,7 @@ package com.threerings.crowd.server; import javax.annotation.Generated; import com.threerings.crowd.client.BodyService; + import com.threerings.presents.data.ClientObject; import com.threerings.presents.server.InvocationProvider; diff --git a/src/main/java/com/threerings/crowd/server/LocationProvider.java b/src/main/java/com/threerings/crowd/server/LocationProvider.java index e0ab284db..78d131b6f 100644 --- a/src/main/java/com/threerings/crowd/server/LocationProvider.java +++ b/src/main/java/com/threerings/crowd/server/LocationProvider.java @@ -24,6 +24,7 @@ package com.threerings.crowd.server; import javax.annotation.Generated; import com.threerings.crowd.client.LocationService; + import com.threerings.presents.data.ClientObject; import com.threerings.presents.server.InvocationException; import com.threerings.presents.server.InvocationProvider; diff --git a/src/main/java/com/threerings/crowd/server/PlaceManager.java b/src/main/java/com/threerings/crowd/server/PlaceManager.java index 789d2a32b..e956e000f 100644 --- a/src/main/java/com/threerings/crowd/server/PlaceManager.java +++ b/src/main/java/com/threerings/crowd/server/PlaceManager.java @@ -26,6 +26,8 @@ import java.util.Map; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.google.inject.Inject; +import com.google.inject.Injector; import com.samskivert.util.HashIntMap; import com.samskivert.util.Interval; @@ -63,9 +65,6 @@ import com.threerings.crowd.data.PlaceConfig; import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.server.CrowdObjectAccess.PlaceAccessController; -import com.google.inject.Inject; -import com.google.inject.Injector; - import static com.threerings.crowd.Log.log; /** @@ -567,7 +566,7 @@ public class PlaceManager * Registers an invocation provider and notes the registration such that it will be * automatically cleared when this manager shuts down. */ - protected T addProvider ( + protected > T addProvider ( InvocationProvider prov, Class mclass) { T marsh = _invmgr.registerProvider(prov, mclass); @@ -579,7 +578,7 @@ public class PlaceManager * Registers an invocation dispatcher and notes the registration such that it will be * automatically cleared when this manager shuts down. */ - protected T addDispatcher (InvocationDispatcher disp) + protected > T addDispatcher (InvocationDispatcher disp) { T marsh = _invmgr.registerDispatcher(disp); _marshallers.add(marsh); diff --git a/src/main/java/com/threerings/presents/client/InvocationService.java b/src/main/java/com/threerings/presents/client/InvocationService.java index e570dbf6f..1d309b0f8 100644 --- a/src/main/java/com/threerings/presents/client/InvocationService.java +++ b/src/main/java/com/threerings/presents/client/InvocationService.java @@ -21,13 +21,15 @@ package com.threerings.presents.client; +import com.threerings.presents.data.ClientObject; + /** * Serves as the base interface for invocation services. An invocation service can be defined by * extending this interface and defining service methods, as well as response listeners (which must * extend {@link InvocationListener}). For example: * *
- * public interface LocationService extends InvocationService
+ * public interface LocationService extends InvocationService<ClientObject>
  * {
  *
  *     // Used to communicate responses to moveTo() requests.
@@ -62,7 +64,7 @@ package com.threerings.presents.client;
  * }
  * 
*/ -public interface InvocationService +public interface InvocationService { /** * Invocation service methods that require a response should take a listener argument that can diff --git a/src/main/java/com/threerings/presents/client/TimeBaseService.java b/src/main/java/com/threerings/presents/client/TimeBaseService.java index 8f1499537..e750b59bd 100644 --- a/src/main/java/com/threerings/presents/client/TimeBaseService.java +++ b/src/main/java/com/threerings/presents/client/TimeBaseService.java @@ -21,11 +21,13 @@ package com.threerings.presents.client; +import com.threerings.presents.data.ClientObject; + /** * Provides a means by which to obtain access to a time base object which can be used to convert * delta times into absolute times. */ -public interface TimeBaseService extends InvocationService +public interface TimeBaseService extends InvocationService { /** * Used to communicated the result of a {@link TimeBaseService#getTimeOid} request. diff --git a/src/main/java/com/threerings/presents/data/InvocationMarshaller.java b/src/main/java/com/threerings/presents/data/InvocationMarshaller.java index 3cb1184ea..cf5925219 100644 --- a/src/main/java/com/threerings/presents/data/InvocationMarshaller.java +++ b/src/main/java/com/threerings/presents/data/InvocationMarshaller.java @@ -40,8 +40,8 @@ import static com.threerings.presents.Log.log; * Provides a base from which all invocation service marshallers extend. Handles functionality * common to all marshallers. */ -public class InvocationMarshaller - implements Streamable, InvocationService +public class InvocationMarshaller + implements Streamable, InvocationService { /** * Provides a base from which invocation listener marshallers extend. diff --git a/src/main/java/com/threerings/presents/data/TimeBaseMarshaller.java b/src/main/java/com/threerings/presents/data/TimeBaseMarshaller.java index 9171ce413..cb295a6e4 100644 --- a/src/main/java/com/threerings/presents/data/TimeBaseMarshaller.java +++ b/src/main/java/com/threerings/presents/data/TimeBaseMarshaller.java @@ -34,7 +34,7 @@ import com.threerings.presents.client.TimeBaseService; */ @Generated(value={"com.threerings.presents.tools.GenServiceTask"}, comments="Derived from TimeBaseService.java.") -public class TimeBaseMarshaller extends InvocationMarshaller +public class TimeBaseMarshaller extends InvocationMarshaller implements TimeBaseService { /** diff --git a/src/main/java/com/threerings/presents/peer/client/PeerService.java b/src/main/java/com/threerings/presents/peer/client/PeerService.java index a2cecd05c..4f15a901e 100644 --- a/src/main/java/com/threerings/presents/peer/client/PeerService.java +++ b/src/main/java/com/threerings/presents/peer/client/PeerService.java @@ -22,12 +22,13 @@ package com.threerings.presents.peer.client; import com.threerings.presents.client.InvocationService; +import com.threerings.presents.data.ClientObject; import com.threerings.presents.peer.data.NodeObject.Lock; /** * Defines requests made from one peer to another. */ -public interface PeerService extends InvocationService +public interface PeerService extends InvocationService { /** * Informs the node that the sending peer ratifies its acquisition or release of the specified diff --git a/src/main/java/com/threerings/presents/peer/data/PeerMarshaller.java b/src/main/java/com/threerings/presents/peer/data/PeerMarshaller.java index 4ed07defe..9aeb12d89 100644 --- a/src/main/java/com/threerings/presents/peer/data/PeerMarshaller.java +++ b/src/main/java/com/threerings/presents/peer/data/PeerMarshaller.java @@ -24,6 +24,7 @@ package com.threerings.presents.peer.data; import javax.annotation.Generated; import com.threerings.presents.client.InvocationService; +import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.peer.client.PeerService; @@ -36,7 +37,7 @@ import com.threerings.presents.peer.client.PeerService; */ @Generated(value={"com.threerings.presents.tools.GenServiceTask"}, comments="Derived from PeerService.java.") -public class PeerMarshaller extends InvocationMarshaller +public class PeerMarshaller extends InvocationMarshaller implements PeerService { /** The method id used to dispatch {@link #generateReport} requests. */ diff --git a/src/main/java/com/threerings/presents/tools/GenServiceTask.java b/src/main/java/com/threerings/presents/tools/GenServiceTask.java index 344df91b0..5b28d54aa 100644 --- a/src/main/java/com/threerings/presents/tools/GenServiceTask.java +++ b/src/main/java/com/threerings/presents/tools/GenServiceTask.java @@ -21,18 +21,17 @@ package com.threerings.presents.tools; +import java.io.File; import java.lang.reflect.Method; import java.lang.reflect.Modifier; - -import java.util.Arrays; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; -import java.io.File; - import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -249,6 +248,11 @@ public class GenServiceTask extends InvocationTask imports.add(InvocationMarshaller.class); imports.add("javax.annotation.Generated"); + // We only add a type parameter for the caller ClientObject type if the service has one + if (sdesc.callerTypeSpecified) { + imports.add(sdesc.callerType); + } + // import classes contained in arrays imports.translateClassArrays(); @@ -276,7 +280,9 @@ public class GenServiceTask extends InvocationTask ctx.put("package", mpackage); ctx.put("methods", sdesc.methods); ctx.put("listeners", sdesc.listeners); - ctx.put("importGroups", imports.toGroups(Arrays.asList("java", "com.threerings"))); + ctx.put("typeParameters", + sdesc.callerTypeSpecified ? "<" + sdesc.callerType.getSimpleName() + ">" : ""); + ctx.put("importGroups", imports.toGroups()); // determine the path to our marshaller file String mpath = source.getPath(); @@ -327,7 +333,7 @@ public class GenServiceTask extends InvocationTask // remove imports in our own package imports.removeSamePackage(mpackage); - ctx.put("importGroups", imports.toGroups(Arrays.asList("com.threerings"))); + ctx.put("importGroups", imports.toGroups()); // now generate ActionScript versions of our marshaller @@ -362,7 +368,7 @@ public class GenServiceTask extends InvocationTask // remove imports in our own package imports.removeSamePackage(mpackage); - ctx.put("importGroups", imports.toGroups(Arrays.asList("com.threerings"))); + ctx.put("importGroups", imports.toGroups()); ctx.put("listener", listener); String aslpath = _asroot + File.separator + mppath + File.separator + mname + "_" + listener.getListenerName() + "Marshaller.as"; @@ -397,7 +403,7 @@ public class GenServiceTask extends InvocationTask // remove imports in our own package imports.removeSamePackage(sdesc.spackage); - ctx.put("importGroups", imports.toGroups(Arrays.asList("com.threerings"))); + ctx.put("importGroups", imports.toGroups()); ctx.put("package", sdesc.spackage); // make sure our service directory exists @@ -429,7 +435,7 @@ public class GenServiceTask extends InvocationTask // remove imports in our own package imports.removeSamePackage(sdesc.spackage); - ctx.put("importGroups", imports.toGroups(Arrays.asList("com.threerings"))); + ctx.put("importGroups", imports.toGroups()); ctx.put("listener", listener); String aslpath = _asroot + File.separator + sppath + File.separator + @@ -463,7 +469,7 @@ public class GenServiceTask extends InvocationTask } // swap Client for ClientObject - imports.add(ClientObject.class); + imports.add(sdesc.callerType); // add some classes required for all dispatchers imports.add(InvocationDispatcher.class); @@ -514,8 +520,9 @@ public class GenServiceTask extends InvocationTask // start with imports required by service methods ImportSet imports = sdesc.imports.clone(); - // swap Client for ClientObject - imports.add(ClientObject.class); + if (!sdesc.methods.isEmpty()) { + imports.add(sdesc.callerType); + } // import superclass and service imports.add(InvocationProvider.class); @@ -552,7 +559,8 @@ public class GenServiceTask extends InvocationTask "package", mpackage, "methods", sdesc.methods, "listeners", sdesc.listeners, - "importGroups", imports.toGroups(Arrays.asList("java", "com.threerings"))); + "callerType", sdesc.callerType.getSimpleName(), + "importGroups", imports.toGroups()); } /** @@ -567,6 +575,8 @@ public class GenServiceTask extends InvocationTask /** Rolls up everything needed for the generate* methods. */ protected class ServiceDescription { + public Class callerType = ClientObject.class; + public boolean callerTypeSpecified;// True if callerType came from a type parameter public Class service; public String sname; public String spackage; @@ -578,6 +588,11 @@ public class GenServiceTask extends InvocationTask public ServiceDescription (Class serviceClass) { service = serviceClass; + Type[] genint = service.getGenericInterfaces(); + if (genint.length > 0 && genint[0] instanceof ParameterizedType) { + callerType = (Class)((ParameterizedType)genint[0]).getActualTypeArguments()[0]; + callerTypeSpecified = true; + } sname = service.getSimpleName(); spackage = service.getPackage().getName(); ActionScript asa = service.getAnnotation(ActionScript.class); diff --git a/src/main/java/com/threerings/presents/tools/ImportSet.java b/src/main/java/com/threerings/presents/tools/ImportSet.java index 80df9fe96..b2fb4401c 100644 --- a/src/main/java/com/threerings/presents/tools/ImportSet.java +++ b/src/main/java/com/threerings/presents/tools/ImportSet.java @@ -332,21 +332,12 @@ public class ImportSet * ordering and spacing. Within each group, sorting is alphabetical. */ public List> toGroups () - { - return toGroups(IMPORT_GROUPS); - } - - /** - * Converts the set of imports to groups of class names, according to the provided groups. - * Within each group, sorting is alphabetical. - */ - public List> toGroups (final List groups) { List list = Lists.newArrayList(_imports); Collections.sort(list, new Comparator() { public int compare (String class1, String class2) { return ComparisonChain.start() - .compare(findImportGroup(class1, groups), findImportGroup(class2, groups)) + .compare(findImportGroup(class1), findImportGroup(class2)) .compare(class1, class2) .result(); } @@ -355,7 +346,7 @@ public class ImportSet List current = null; int lastGroup = -2; for (String imp : list) { - int group = findImportGroup(imp, groups); + int group = findImportGroup(imp); if (group != lastGroup) { if (current == null || !current.isEmpty()) { result.add(current = Lists.newArrayList()); @@ -415,10 +406,10 @@ public class ImportSet return Pattern.compile(pattern.toString()); } - protected static int findImportGroup (String imp, List groups) + protected static int findImportGroup (String imp) { String longest = null; - for (String prefix : groups) { + for (String prefix : IMPORT_GROUPS) { if (!imp.startsWith(prefix)) { continue; } @@ -426,7 +417,7 @@ public class ImportSet longest = prefix; } } - return groups.indexOf(longest); + return IMPORT_GROUPS.indexOf(longest); } protected HashSet _imports = Sets.newHashSet(); @@ -438,17 +429,24 @@ public class ImportSet protected static List IMPORT_GROUPS = Lists.newArrayList( "flash.", "fl.", + "java", "", OOO, OOO + "io.", OOO + "util.", OOO + "presents.", + OOO + "tudey.", OOO + "orth.", OOO + "riposte.", + OOO + "riposte.", OOO + "samsara.", OOO + "flashbang.", OOO + "downtown.", OOO + "biteme.", OOO + "who.", - OOO + "blueharvest."); + OOO + "blueharvest.", + OOO + "piracy.", + OOO + "ppa.", + OOO + "yohoho.", + OOO + "projectx."); } diff --git a/src/main/resources/com/threerings/presents/tools/marshaller.tmpl b/src/main/resources/com/threerings/presents/tools/marshaller.tmpl index 8062464ff..25f5f0042 100644 --- a/src/main/resources/com/threerings/presents/tools/marshaller.tmpl +++ b/src/main/resources/com/threerings/presents/tools/marshaller.tmpl @@ -14,7 +14,7 @@ import {{this}}; * to the requesting client. */ {{generated}} -public class {{name}}Marshaller extends InvocationMarshaller +public class {{name}}Marshaller extends InvocationMarshaller{{typeParameters}} implements {{name}}Service { {{#listeners}} diff --git a/src/main/resources/com/threerings/presents/tools/provider.tmpl b/src/main/resources/com/threerings/presents/tools/provider.tmpl index 9b495f773..0f7ffc45f 100644 --- a/src/main/resources/com/threerings/presents/tools/provider.tmpl +++ b/src/main/resources/com/threerings/presents/tools/provider.tmpl @@ -19,7 +19,7 @@ public interface {{name}}Provider extends InvocationProvider /** * Handles a {@link {{name}}Service#{{method.name}}} request. */ - {{typeParams}}void {{method.name}} (ClientObject caller{{#hasArgs}}, {{/hasArgs}}{{getArgList}}){{^listenerArgs.isEmpty}} + {{typeParams}}void {{method.name}} ({{callerType}} caller{{#hasArgs}}, {{/hasArgs}}{{getArgList}}){{^listenerArgs.isEmpty}} throws InvocationException{{/listenerArgs.isEmpty}}; {{/methods}} diff --git a/src/test/java/com/threerings/presents/client/TestService.java b/src/test/java/com/threerings/presents/client/TestService.java index de2d46e8c..8942d6e59 100644 --- a/src/test/java/com/threerings/presents/client/TestService.java +++ b/src/test/java/com/threerings/presents/client/TestService.java @@ -23,10 +23,12 @@ package com.threerings.presents.client; import java.util.List; +import com.threerings.presents.data.ClientObject; + /** * A test of the invocation services. */ -public interface TestService extends InvocationService +public interface TestService extends InvocationService { /** Used to dispatch responses to {@link TestService#test} requests. */ public static interface TestFuncListener extends InvocationListener diff --git a/src/test/java/com/threerings/presents/data/TestMarshaller.java b/src/test/java/com/threerings/presents/data/TestMarshaller.java index 10a36994c..b0146364a 100644 --- a/src/test/java/com/threerings/presents/data/TestMarshaller.java +++ b/src/test/java/com/threerings/presents/data/TestMarshaller.java @@ -36,7 +36,7 @@ import com.threerings.presents.client.TestService; */ @Generated(value={"com.threerings.presents.tools.GenServiceTask"}, comments="Derived from TestService.java.") -public class TestMarshaller extends InvocationMarshaller +public class TestMarshaller extends InvocationMarshaller implements TestService { /**