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
This commit is contained in:
Charlie Groves
2011-07-07 21:10:49 +00:00
parent d57521996c
commit 01a57a03bf
48 changed files with 147 additions and 74 deletions
@@ -22,9 +22,11 @@
package com.threerings.bureau.data { package com.threerings.bureau.data {
import com.threerings.bureau.client.BureauService; import com.threerings.bureau.client.BureauService;
import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.util.Integer; import com.threerings.util.Integer;
import com.threerings.presents.data.InvocationMarshaller;
/** /**
* Provides the implementation of the <code>BureauService</code> interface * Provides the implementation of the <code>BureauService</code> interface
* that marshalls the arguments and delivers the request to the provider * that marshalls the arguments and delivers the request to the provider
@@ -22,6 +22,7 @@
package com.threerings.crowd.chat.client { package com.threerings.crowd.chat.client {
import com.threerings.crowd.chat.data.ChatChannel; import com.threerings.crowd.chat.data.ChatChannel;
import com.threerings.presents.client.InvocationService; import com.threerings.presents.client.InvocationService;
/** /**
@@ -21,9 +21,10 @@
package com.threerings.crowd.chat.client { package com.threerings.crowd.chat.client {
import com.threerings.util.Name;
import com.threerings.presents.client.InvocationService; import com.threerings.presents.client.InvocationService;
import com.threerings.presents.client.InvocationService_InvocationListener; import com.threerings.presents.client.InvocationService_InvocationListener;
import com.threerings.util.Name;
/** /**
* An ActionScript version of the Java ChatService interface. * An ActionScript version of the Java ChatService interface.
@@ -21,9 +21,10 @@
package com.threerings.crowd.chat.client { package com.threerings.crowd.chat.client {
import com.threerings.presents.client.InvocationService_InvocationListener;
import com.threerings.util.Long; import com.threerings.util.Long;
import com.threerings.presents.client.InvocationService_InvocationListener;
/** /**
* An ActionScript version of the Java ChatService_TellListener interface. * An ActionScript version of the Java ChatService_TellListener interface.
*/ */
@@ -22,9 +22,11 @@
package com.threerings.crowd.chat.data { package com.threerings.crowd.chat.data {
import com.threerings.crowd.chat.client.ChannelSpeakService; import com.threerings.crowd.chat.client.ChannelSpeakService;
import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.util.Byte; import com.threerings.util.Byte;
import com.threerings.presents.data.InvocationMarshaller;
/** /**
* Provides the implementation of the <code>ChannelSpeakService</code> interface * Provides the implementation of the <code>ChannelSpeakService</code> interface
* that marshalls the arguments and delivers the request to the provider * that marshalls the arguments and delivers the request to the provider
@@ -23,10 +23,12 @@ package com.threerings.crowd.chat.data {
import com.threerings.crowd.chat.client.ChatService; import com.threerings.crowd.chat.client.ChatService;
import com.threerings.crowd.chat.client.ChatService_TellListener; import com.threerings.crowd.chat.client.ChatService_TellListener;
import com.threerings.util.Name;
import com.threerings.presents.client.InvocationService_InvocationListener; import com.threerings.presents.client.InvocationService_InvocationListener;
import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller; import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller;
import com.threerings.util.Name;
/** /**
* Provides the implementation of the <code>ChatService</code> interface * Provides the implementation of the <code>ChatService</code> interface
@@ -22,9 +22,11 @@
package com.threerings.crowd.chat.data { package com.threerings.crowd.chat.data {
import com.threerings.crowd.chat.client.ChatService_TellListener; import com.threerings.crowd.chat.client.ChatService_TellListener;
import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller;
import com.threerings.util.Long; import com.threerings.util.Long;
import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller;
/** /**
* Marshalls instances of the ChatService_TellMarshaller interface. * Marshalls instances of the ChatService_TellMarshaller interface.
*/ */
@@ -22,9 +22,11 @@
package com.threerings.crowd.chat.data { package com.threerings.crowd.chat.data {
import com.threerings.crowd.chat.client.SpeakService; import com.threerings.crowd.chat.client.SpeakService;
import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.util.Byte; import com.threerings.util.Byte;
import com.threerings.presents.data.InvocationMarshaller;
/** /**
* Provides the implementation of the <code>SpeakService</code> interface * Provides the implementation of the <code>SpeakService</code> interface
* that marshalls the arguments and delivers the request to the provider * that marshalls the arguments and delivers the request to the provider
@@ -22,6 +22,7 @@
package com.threerings.crowd.client { package com.threerings.crowd.client {
import com.threerings.crowd.data.PlaceConfig; import com.threerings.crowd.data.PlaceConfig;
import com.threerings.presents.client.InvocationService_InvocationListener; import com.threerings.presents.client.InvocationService_InvocationListener;
/** /**
@@ -22,9 +22,11 @@
package com.threerings.crowd.data { package com.threerings.crowd.data {
import com.threerings.crowd.client.BodyService; import com.threerings.crowd.client.BodyService;
import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.util.langBoolean; import com.threerings.util.langBoolean;
import com.threerings.presents.data.InvocationMarshaller;
/** /**
* Provides the implementation of the <code>BodyService</code> interface * Provides the implementation of the <code>BodyService</code> interface
* that marshalls the arguments and delivers the request to the provider * that marshalls the arguments and delivers the request to the provider
@@ -23,9 +23,11 @@ package com.threerings.crowd.data {
import com.threerings.crowd.client.LocationService; import com.threerings.crowd.client.LocationService;
import com.threerings.crowd.client.LocationService_MoveListener; import com.threerings.crowd.client.LocationService_MoveListener;
import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.util.Integer; import com.threerings.util.Integer;
import com.threerings.presents.data.InvocationMarshaller;
/** /**
* Provides the implementation of the <code>LocationService</code> interface * Provides the implementation of the <code>LocationService</code> interface
* that marshalls the arguments and delivers the request to the provider * that marshalls the arguments and delivers the request to the provider
@@ -22,6 +22,7 @@
package com.threerings.crowd.data { package com.threerings.crowd.data {
import com.threerings.crowd.client.LocationService_MoveListener; import com.threerings.crowd.client.LocationService_MoveListener;
import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller; import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller;
/** /**
@@ -22,11 +22,12 @@
package com.threerings.admin.client; package com.threerings.admin.client;
import com.threerings.presents.client.InvocationService; import com.threerings.presents.client.InvocationService;
import com.threerings.presents.data.ClientObject;
/** /**
* Defines the client side of the admin invocation services. * Defines the client side of the admin invocation services.
*/ */
public interface AdminService extends InvocationService public interface AdminService extends InvocationService<ClientObject>
{ {
/** /**
* Used to communicate a response to a {@link AdminService#getConfigInfo} request. * Used to communicate a response to a {@link AdminService#getConfigInfo} request.
@@ -24,6 +24,8 @@ package com.threerings.admin.data;
import javax.annotation.Generated; import javax.annotation.Generated;
import com.threerings.admin.client.AdminService; import com.threerings.admin.client.AdminService;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.data.InvocationMarshaller;
/** /**
@@ -35,7 +37,7 @@ import com.threerings.presents.data.InvocationMarshaller;
*/ */
@Generated(value={"com.threerings.presents.tools.GenServiceTask"}, @Generated(value={"com.threerings.presents.tools.GenServiceTask"},
comments="Derived from AdminService.java.") comments="Derived from AdminService.java.")
public class AdminMarshaller extends InvocationMarshaller public class AdminMarshaller extends InvocationMarshaller<ClientObject>
implements AdminService implements AdminService
{ {
/** /**
@@ -24,6 +24,7 @@ package com.threerings.admin.server;
import javax.annotation.Generated; import javax.annotation.Generated;
import com.threerings.admin.client.AdminService; import com.threerings.admin.client.AdminService;
import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.ClientObject;
import com.threerings.presents.server.InvocationException; import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.InvocationProvider; import com.threerings.presents.server.InvocationProvider;
@@ -22,11 +22,12 @@
package com.threerings.bureau.client; package com.threerings.bureau.client;
import com.threerings.presents.client.InvocationService; import com.threerings.presents.client.InvocationService;
import com.threerings.presents.data.ClientObject;
/** /**
* Interface for the bureau to communicate with the server. * Interface for the bureau to communicate with the server.
*/ */
public interface BureauService extends InvocationService public interface BureauService extends InvocationService<ClientObject>
{ {
/** /**
* Notifies the server that the bureau is up and running and ready to receive * Notifies the server that the bureau is up and running and ready to receive
@@ -24,6 +24,8 @@ package com.threerings.bureau.data;
import javax.annotation.Generated; import javax.annotation.Generated;
import com.threerings.bureau.client.BureauService; import com.threerings.bureau.client.BureauService;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.data.InvocationMarshaller;
/** /**
@@ -35,7 +37,7 @@ import com.threerings.presents.data.InvocationMarshaller;
*/ */
@Generated(value={"com.threerings.presents.tools.GenServiceTask"}, @Generated(value={"com.threerings.presents.tools.GenServiceTask"},
comments="Derived from BureauService.java.") comments="Derived from BureauService.java.")
public class BureauMarshaller extends InvocationMarshaller public class BureauMarshaller extends InvocationMarshaller<ClientObject>
implements BureauService implements BureauService
{ {
/** The method id used to dispatch {@link #agentCreated} requests. */ /** The method id used to dispatch {@link #agentCreated} requests. */
@@ -24,6 +24,7 @@ package com.threerings.bureau.server;
import javax.annotation.Generated; import javax.annotation.Generated;
import com.threerings.bureau.client.BureauService; import com.threerings.bureau.client.BureauService;
import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.ClientObject;
import com.threerings.presents.server.InvocationProvider; import com.threerings.presents.server.InvocationProvider;
@@ -22,13 +22,14 @@
package com.threerings.crowd.chat.client; package com.threerings.crowd.chat.client;
import com.threerings.presents.client.InvocationService; import com.threerings.presents.client.InvocationService;
import com.threerings.presents.data.ClientObject;
import com.threerings.crowd.chat.data.ChatChannel; import com.threerings.crowd.chat.data.ChatChannel;
/** /**
* Provides a way for clients to speak on chat channels. * Provides a way for clients to speak on chat channels.
*/ */
public interface ChannelSpeakService extends InvocationService public interface ChannelSpeakService extends InvocationService<ClientObject>
{ {
/** /**
* Requests to speak the supplied message on the specified channel. * Requests to speak the supplied message on the specified channel.
@@ -24,6 +24,7 @@ package com.threerings.crowd.chat.client;
import com.threerings.util.Name; import com.threerings.util.Name;
import com.threerings.presents.client.InvocationService; 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 * 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 * These services should not be used directly, but instead should be accessed via the
* {@link ChatDirector}. * {@link ChatDirector}.
*/ */
public interface ChatService extends InvocationService public interface ChatService extends InvocationService<ClientObject>
{ {
/** /**
* Used to communicate the response to a {@link ChatService#tell} request. * Used to communicate the response to a {@link ChatService#tell} request.
@@ -22,12 +22,13 @@
package com.threerings.crowd.chat.client; package com.threerings.crowd.chat.client;
import com.threerings.presents.client.InvocationService; import com.threerings.presents.client.InvocationService;
import com.threerings.presents.data.ClientObject;
/** /**
* Provides a means by which "speaking" can be allowed among subscribers * Provides a means by which "speaking" can be allowed among subscribers
* of a particular distributed object. * of a particular distributed object.
*/ */
public interface SpeakService extends InvocationService public interface SpeakService extends InvocationService<ClientObject>
{ {
/** /**
* Issues a request to speak "on" the distributed object via which * Issues a request to speak "on" the distributed object via which
@@ -24,6 +24,8 @@ package com.threerings.crowd.chat.data;
import javax.annotation.Generated; import javax.annotation.Generated;
import com.threerings.crowd.chat.client.ChannelSpeakService; import com.threerings.crowd.chat.client.ChannelSpeakService;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.data.InvocationMarshaller;
/** /**
@@ -35,7 +37,7 @@ import com.threerings.presents.data.InvocationMarshaller;
*/ */
@Generated(value={"com.threerings.presents.tools.GenServiceTask"}, @Generated(value={"com.threerings.presents.tools.GenServiceTask"},
comments="Derived from ChannelSpeakService.java.") comments="Derived from ChannelSpeakService.java.")
public class ChannelSpeakMarshaller extends InvocationMarshaller public class ChannelSpeakMarshaller extends InvocationMarshaller<ClientObject>
implements ChannelSpeakService implements ChannelSpeakService
{ {
/** The method id used to dispatch {@link #speak} requests. */ /** The method id used to dispatch {@link #speak} requests. */
@@ -24,10 +24,13 @@ package com.threerings.crowd.chat.data;
import javax.annotation.Generated; import javax.annotation.Generated;
import com.threerings.crowd.chat.client.ChatService; 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.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 * Provides the implementation of the {@link ChatService} interface
* that marshalls the arguments and delivers the request to the provider * 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"}, @Generated(value={"com.threerings.presents.tools.GenServiceTask"},
comments="Derived from ChatService.java.") comments="Derived from ChatService.java.")
public class ChatMarshaller extends InvocationMarshaller public class ChatMarshaller extends InvocationMarshaller<ClientObject>
implements ChatService implements ChatService
{ {
/** /**
@@ -24,6 +24,8 @@ package com.threerings.crowd.chat.data;
import javax.annotation.Generated; import javax.annotation.Generated;
import com.threerings.crowd.chat.client.SpeakService; import com.threerings.crowd.chat.client.SpeakService;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.data.InvocationMarshaller;
/** /**
@@ -35,7 +37,7 @@ import com.threerings.presents.data.InvocationMarshaller;
*/ */
@Generated(value={"com.threerings.presents.tools.GenServiceTask"}, @Generated(value={"com.threerings.presents.tools.GenServiceTask"},
comments="Derived from SpeakService.java.") comments="Derived from SpeakService.java.")
public class SpeakMarshaller extends InvocationMarshaller public class SpeakMarshaller extends InvocationMarshaller<ClientObject>
implements SpeakService implements SpeakService
{ {
/** The method id used to dispatch {@link #speak} requests. */ /** The method id used to dispatch {@link #speak} requests. */
@@ -25,6 +25,7 @@ import javax.annotation.Generated;
import com.threerings.crowd.chat.client.ChannelSpeakService; import com.threerings.crowd.chat.client.ChannelSpeakService;
import com.threerings.crowd.chat.data.ChatChannel; import com.threerings.crowd.chat.data.ChatChannel;
import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.ClientObject;
import com.threerings.presents.server.InvocationProvider; import com.threerings.presents.server.InvocationProvider;
@@ -24,6 +24,7 @@ package com.threerings.crowd.chat.server;
import javax.annotation.Generated; import javax.annotation.Generated;
import com.threerings.crowd.chat.client.SpeakService; import com.threerings.crowd.chat.client.SpeakService;
import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.ClientObject;
import com.threerings.presents.server.InvocationProvider; import com.threerings.presents.server.InvocationProvider;
@@ -22,11 +22,12 @@
package com.threerings.crowd.client; package com.threerings.crowd.client;
import com.threerings.presents.client.InvocationService; import com.threerings.presents.client.InvocationService;
import com.threerings.presents.data.ClientObject;
/** /**
* The client side of the body-related invocation services. * The client side of the body-related invocation services.
*/ */
public interface BodyService extends InvocationService public interface BodyService extends InvocationService<ClientObject>
{ {
/** /**
* Requests to set the idle state of the client to the specified * Requests to set the idle state of the client to the specified
@@ -22,6 +22,7 @@
package com.threerings.crowd.client; package com.threerings.crowd.client;
import com.threerings.presents.client.InvocationService; import com.threerings.presents.client.InvocationService;
import com.threerings.presents.data.ClientObject;
import com.threerings.crowd.data.PlaceConfig; 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 * place in the server. These services should not be used directly, but instead should be accessed
* via the {@link LocationDirector}. * via the {@link LocationDirector}.
*/ */
public interface LocationService extends InvocationService public interface LocationService extends InvocationService<ClientObject>
{ {
/** /**
* Used to communicate responses to {@link LocationService#moveTo} requests. * Used to communicate responses to {@link LocationService#moveTo} requests.
@@ -24,6 +24,8 @@ package com.threerings.crowd.data;
import javax.annotation.Generated; import javax.annotation.Generated;
import com.threerings.crowd.client.BodyService; import com.threerings.crowd.client.BodyService;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.data.InvocationMarshaller;
/** /**
@@ -35,7 +37,7 @@ import com.threerings.presents.data.InvocationMarshaller;
*/ */
@Generated(value={"com.threerings.presents.tools.GenServiceTask"}, @Generated(value={"com.threerings.presents.tools.GenServiceTask"},
comments="Derived from BodyService.java.") comments="Derived from BodyService.java.")
public class BodyMarshaller extends InvocationMarshaller public class BodyMarshaller extends InvocationMarshaller<ClientObject>
implements BodyService implements BodyService
{ {
/** The method id used to dispatch {@link #setIdle} requests. */ /** The method id used to dispatch {@link #setIdle} requests. */
@@ -24,6 +24,8 @@ package com.threerings.crowd.data;
import javax.annotation.Generated; import javax.annotation.Generated;
import com.threerings.crowd.client.LocationService; import com.threerings.crowd.client.LocationService;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.data.InvocationMarshaller;
/** /**
@@ -35,7 +37,7 @@ import com.threerings.presents.data.InvocationMarshaller;
*/ */
@Generated(value={"com.threerings.presents.tools.GenServiceTask"}, @Generated(value={"com.threerings.presents.tools.GenServiceTask"},
comments="Derived from LocationService.java.") comments="Derived from LocationService.java.")
public class LocationMarshaller extends InvocationMarshaller public class LocationMarshaller extends InvocationMarshaller<ClientObject>
implements LocationService implements LocationService
{ {
/** /**
@@ -24,6 +24,7 @@ package com.threerings.crowd.peer.client;
import com.threerings.util.Name; import com.threerings.util.Name;
import com.threerings.presents.client.InvocationService; import com.threerings.presents.client.InvocationService;
import com.threerings.presents.data.ClientObject;
import com.threerings.crowd.chat.client.ChatService; import com.threerings.crowd.chat.client.ChatService;
import com.threerings.crowd.chat.data.UserMessage; 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. * Bridges certain Crowd services between peers in a cluster configuration.
*/ */
public interface CrowdPeerService extends InvocationService public interface CrowdPeerService extends InvocationService<ClientObject>
{ {
/** /**
* Used to forward a tell request to the server on which the destination user actually * Used to forward a tell request to the server on which the destination user actually
@@ -27,9 +27,12 @@ import com.threerings.crowd.chat.client.ChatService;
import com.threerings.crowd.chat.data.ChatMarshaller; import com.threerings.crowd.chat.data.ChatMarshaller;
import com.threerings.crowd.chat.data.UserMessage; import com.threerings.crowd.chat.data.UserMessage;
import com.threerings.crowd.peer.client.CrowdPeerService; import com.threerings.crowd.peer.client.CrowdPeerService;
import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.util.Name; 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 * Provides the implementation of the {@link CrowdPeerService} interface
* that marshalls the arguments and delivers the request to the provider * 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"}, @Generated(value={"com.threerings.presents.tools.GenServiceTask"},
comments="Derived from CrowdPeerService.java.") comments="Derived from CrowdPeerService.java.")
public class CrowdPeerMarshaller extends InvocationMarshaller public class CrowdPeerMarshaller extends InvocationMarshaller<ClientObject>
implements CrowdPeerService implements CrowdPeerService
{ {
/** The method id used to dispatch {@link #deliverBroadcast} requests. */ /** The method id used to dispatch {@link #deliverBroadcast} requests. */
@@ -26,10 +26,12 @@ import javax.annotation.Generated;
import com.threerings.crowd.chat.client.ChatService; import com.threerings.crowd.chat.client.ChatService;
import com.threerings.crowd.chat.data.UserMessage; import com.threerings.crowd.chat.data.UserMessage;
import com.threerings.crowd.peer.client.CrowdPeerService; import com.threerings.crowd.peer.client.CrowdPeerService;
import com.threerings.util.Name;
import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.ClientObject;
import com.threerings.presents.server.InvocationException; import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.InvocationProvider; import com.threerings.presents.server.InvocationProvider;
import com.threerings.util.Name;
/** /**
* Defines the server-side of the {@link CrowdPeerService}. * Defines the server-side of the {@link CrowdPeerService}.
@@ -24,6 +24,7 @@ package com.threerings.crowd.server;
import javax.annotation.Generated; import javax.annotation.Generated;
import com.threerings.crowd.client.BodyService; import com.threerings.crowd.client.BodyService;
import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.ClientObject;
import com.threerings.presents.server.InvocationProvider; import com.threerings.presents.server.InvocationProvider;
@@ -24,6 +24,7 @@ package com.threerings.crowd.server;
import javax.annotation.Generated; import javax.annotation.Generated;
import com.threerings.crowd.client.LocationService; import com.threerings.crowd.client.LocationService;
import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.ClientObject;
import com.threerings.presents.server.InvocationException; import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.InvocationProvider; import com.threerings.presents.server.InvocationProvider;
@@ -26,6 +26,8 @@ import java.util.Map;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; 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.HashIntMap;
import com.samskivert.util.Interval; 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.data.PlaceObject;
import com.threerings.crowd.server.CrowdObjectAccess.PlaceAccessController; import com.threerings.crowd.server.CrowdObjectAccess.PlaceAccessController;
import com.google.inject.Inject;
import com.google.inject.Injector;
import static com.threerings.crowd.Log.log; 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 * Registers an invocation provider and notes the registration such that it will be
* automatically cleared when this manager shuts down. * automatically cleared when this manager shuts down.
*/ */
protected <T extends InvocationMarshaller> T addProvider ( protected <T extends InvocationMarshaller<?>> T addProvider (
InvocationProvider prov, Class<T> mclass) InvocationProvider prov, Class<T> mclass)
{ {
T marsh = _invmgr.registerProvider(prov, 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 * Registers an invocation dispatcher and notes the registration such that it will be
* automatically cleared when this manager shuts down. * automatically cleared when this manager shuts down.
*/ */
protected <T extends InvocationMarshaller> T addDispatcher (InvocationDispatcher<T> disp) protected <T extends InvocationMarshaller<?>> T addDispatcher (InvocationDispatcher<T> disp)
{ {
T marsh = _invmgr.registerDispatcher(disp); T marsh = _invmgr.registerDispatcher(disp);
_marshallers.add(marsh); _marshallers.add(marsh);
@@ -21,13 +21,15 @@
package com.threerings.presents.client; 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 * 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 * extending this interface and defining service methods, as well as response listeners (which must
* extend {@link InvocationListener}). For example: * extend {@link InvocationListener}). For example:
* *
* <pre> * <pre>
* public interface LocationService extends InvocationService * public interface LocationService extends InvocationService&lt;ClientObject>
* { * {
* *
* // Used to communicate responses to moveTo() requests. * // Used to communicate responses to moveTo() requests.
@@ -62,7 +64,7 @@ package com.threerings.presents.client;
* } * }
* </pre> * </pre>
*/ */
public interface InvocationService public interface InvocationService<T extends ClientObject>
{ {
/** /**
* Invocation service methods that require a response should take a listener argument that can * Invocation service methods that require a response should take a listener argument that can
@@ -21,11 +21,13 @@
package com.threerings.presents.client; 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 * Provides a means by which to obtain access to a time base object which can be used to convert
* delta times into absolute times. * delta times into absolute times.
*/ */
public interface TimeBaseService extends InvocationService public interface TimeBaseService extends InvocationService<ClientObject>
{ {
/** /**
* Used to communicated the result of a {@link TimeBaseService#getTimeOid} request. * Used to communicated the result of a {@link TimeBaseService#getTimeOid} request.
@@ -40,8 +40,8 @@ import static com.threerings.presents.Log.log;
* Provides a base from which all invocation service marshallers extend. Handles functionality * Provides a base from which all invocation service marshallers extend. Handles functionality
* common to all marshallers. * common to all marshallers.
*/ */
public class InvocationMarshaller public class InvocationMarshaller<T extends ClientObject>
implements Streamable, InvocationService implements Streamable, InvocationService<T>
{ {
/** /**
* Provides a base from which invocation listener marshallers extend. * Provides a base from which invocation listener marshallers extend.
@@ -34,7 +34,7 @@ import com.threerings.presents.client.TimeBaseService;
*/ */
@Generated(value={"com.threerings.presents.tools.GenServiceTask"}, @Generated(value={"com.threerings.presents.tools.GenServiceTask"},
comments="Derived from TimeBaseService.java.") comments="Derived from TimeBaseService.java.")
public class TimeBaseMarshaller extends InvocationMarshaller public class TimeBaseMarshaller extends InvocationMarshaller<ClientObject>
implements TimeBaseService implements TimeBaseService
{ {
/** /**
@@ -22,12 +22,13 @@
package com.threerings.presents.peer.client; package com.threerings.presents.peer.client;
import com.threerings.presents.client.InvocationService; import com.threerings.presents.client.InvocationService;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.peer.data.NodeObject.Lock; import com.threerings.presents.peer.data.NodeObject.Lock;
/** /**
* Defines requests made from one peer to another. * Defines requests made from one peer to another.
*/ */
public interface PeerService extends InvocationService public interface PeerService extends InvocationService<ClientObject>
{ {
/** /**
* Informs the node that the sending peer ratifies its acquisition or release of the specified * Informs the node that the sending peer ratifies its acquisition or release of the specified
@@ -24,6 +24,7 @@ package com.threerings.presents.peer.data;
import javax.annotation.Generated; import javax.annotation.Generated;
import com.threerings.presents.client.InvocationService; import com.threerings.presents.client.InvocationService;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.presents.peer.client.PeerService; 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"}, @Generated(value={"com.threerings.presents.tools.GenServiceTask"},
comments="Derived from PeerService.java.") comments="Derived from PeerService.java.")
public class PeerMarshaller extends InvocationMarshaller public class PeerMarshaller extends InvocationMarshaller<ClientObject>
implements PeerService implements PeerService
{ {
/** The method id used to dispatch {@link #generateReport} requests. */ /** The method id used to dispatch {@link #generateReport} requests. */
@@ -21,18 +21,17 @@
package com.threerings.presents.tools; package com.threerings.presents.tools;
import java.io.File;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.util.Arrays; import java.lang.reflect.Type;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.io.File;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@@ -249,6 +248,11 @@ public class GenServiceTask extends InvocationTask
imports.add(InvocationMarshaller.class); imports.add(InvocationMarshaller.class);
imports.add("javax.annotation.Generated"); 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 // import classes contained in arrays
imports.translateClassArrays(); imports.translateClassArrays();
@@ -276,7 +280,9 @@ public class GenServiceTask extends InvocationTask
ctx.put("package", mpackage); ctx.put("package", mpackage);
ctx.put("methods", sdesc.methods); ctx.put("methods", sdesc.methods);
ctx.put("listeners", sdesc.listeners); 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 // determine the path to our marshaller file
String mpath = source.getPath(); String mpath = source.getPath();
@@ -327,7 +333,7 @@ public class GenServiceTask extends InvocationTask
// remove imports in our own package // remove imports in our own package
imports.removeSamePackage(mpackage); imports.removeSamePackage(mpackage);
ctx.put("importGroups", imports.toGroups(Arrays.asList("com.threerings"))); ctx.put("importGroups", imports.toGroups());
// now generate ActionScript versions of our marshaller // now generate ActionScript versions of our marshaller
@@ -362,7 +368,7 @@ public class GenServiceTask extends InvocationTask
// remove imports in our own package // remove imports in our own package
imports.removeSamePackage(mpackage); imports.removeSamePackage(mpackage);
ctx.put("importGroups", imports.toGroups(Arrays.asList("com.threerings"))); ctx.put("importGroups", imports.toGroups());
ctx.put("listener", listener); ctx.put("listener", listener);
String aslpath = _asroot + File.separator + mppath + String aslpath = _asroot + File.separator + mppath +
File.separator + mname + "_" + listener.getListenerName() + "Marshaller.as"; File.separator + mname + "_" + listener.getListenerName() + "Marshaller.as";
@@ -397,7 +403,7 @@ public class GenServiceTask extends InvocationTask
// remove imports in our own package // remove imports in our own package
imports.removeSamePackage(sdesc.spackage); imports.removeSamePackage(sdesc.spackage);
ctx.put("importGroups", imports.toGroups(Arrays.asList("com.threerings"))); ctx.put("importGroups", imports.toGroups());
ctx.put("package", sdesc.spackage); ctx.put("package", sdesc.spackage);
// make sure our service directory exists // make sure our service directory exists
@@ -429,7 +435,7 @@ public class GenServiceTask extends InvocationTask
// remove imports in our own package // remove imports in our own package
imports.removeSamePackage(sdesc.spackage); imports.removeSamePackage(sdesc.spackage);
ctx.put("importGroups", imports.toGroups(Arrays.asList("com.threerings"))); ctx.put("importGroups", imports.toGroups());
ctx.put("listener", listener); ctx.put("listener", listener);
String aslpath = _asroot + File.separator + sppath + File.separator + String aslpath = _asroot + File.separator + sppath + File.separator +
@@ -463,7 +469,7 @@ public class GenServiceTask extends InvocationTask
} }
// swap Client for ClientObject // swap Client for ClientObject
imports.add(ClientObject.class); imports.add(sdesc.callerType);
// add some classes required for all dispatchers // add some classes required for all dispatchers
imports.add(InvocationDispatcher.class); imports.add(InvocationDispatcher.class);
@@ -514,8 +520,9 @@ public class GenServiceTask extends InvocationTask
// start with imports required by service methods // start with imports required by service methods
ImportSet imports = sdesc.imports.clone(); ImportSet imports = sdesc.imports.clone();
// swap Client for ClientObject if (!sdesc.methods.isEmpty()) {
imports.add(ClientObject.class); imports.add(sdesc.callerType);
}
// import superclass and service // import superclass and service
imports.add(InvocationProvider.class); imports.add(InvocationProvider.class);
@@ -552,7 +559,8 @@ public class GenServiceTask extends InvocationTask
"package", mpackage, "package", mpackage,
"methods", sdesc.methods, "methods", sdesc.methods,
"listeners", sdesc.listeners, "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. */ /** Rolls up everything needed for the generate* methods. */
protected class ServiceDescription protected class ServiceDescription
{ {
public Class<?> callerType = ClientObject.class;
public boolean callerTypeSpecified;// True if callerType came from a type parameter
public Class<?> service; public Class<?> service;
public String sname; public String sname;
public String spackage; public String spackage;
@@ -578,6 +588,11 @@ public class GenServiceTask extends InvocationTask
public ServiceDescription (Class<?> serviceClass) public ServiceDescription (Class<?> serviceClass)
{ {
service = 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(); sname = service.getSimpleName();
spackage = service.getPackage().getName(); spackage = service.getPackage().getName();
ActionScript asa = service.getAnnotation(ActionScript.class); ActionScript asa = service.getAnnotation(ActionScript.class);
@@ -332,21 +332,12 @@ public class ImportSet
* ordering and spacing. Within each group, sorting is alphabetical. * ordering and spacing. Within each group, sorting is alphabetical.
*/ */
public List<List<String>> toGroups () public List<List<String>> 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<List<String>> toGroups (final List<String> groups)
{ {
List<String> list = Lists.newArrayList(_imports); List<String> list = Lists.newArrayList(_imports);
Collections.sort(list, new Comparator<String>() { Collections.sort(list, new Comparator<String>() {
public int compare (String class1, String class2) { public int compare (String class1, String class2) {
return ComparisonChain.start() return ComparisonChain.start()
.compare(findImportGroup(class1, groups), findImportGroup(class2, groups)) .compare(findImportGroup(class1), findImportGroup(class2))
.compare(class1, class2) .compare(class1, class2)
.result(); .result();
} }
@@ -355,7 +346,7 @@ public class ImportSet
List<String> current = null; List<String> current = null;
int lastGroup = -2; int lastGroup = -2;
for (String imp : list) { for (String imp : list) {
int group = findImportGroup(imp, groups); int group = findImportGroup(imp);
if (group != lastGroup) { if (group != lastGroup) {
if (current == null || !current.isEmpty()) { if (current == null || !current.isEmpty()) {
result.add(current = Lists.<String>newArrayList()); result.add(current = Lists.<String>newArrayList());
@@ -415,10 +406,10 @@ public class ImportSet
return Pattern.compile(pattern.toString()); return Pattern.compile(pattern.toString());
} }
protected static int findImportGroup (String imp, List<String> groups) protected static int findImportGroup (String imp)
{ {
String longest = null; String longest = null;
for (String prefix : groups) { for (String prefix : IMPORT_GROUPS) {
if (!imp.startsWith(prefix)) { if (!imp.startsWith(prefix)) {
continue; continue;
} }
@@ -426,7 +417,7 @@ public class ImportSet
longest = prefix; longest = prefix;
} }
} }
return groups.indexOf(longest); return IMPORT_GROUPS.indexOf(longest);
} }
protected HashSet<String> _imports = Sets.newHashSet(); protected HashSet<String> _imports = Sets.newHashSet();
@@ -438,17 +429,24 @@ public class ImportSet
protected static List<String> IMPORT_GROUPS = Lists.newArrayList( protected static List<String> IMPORT_GROUPS = Lists.newArrayList(
"flash.", "flash.",
"fl.", "fl.",
"java",
"", "",
OOO, OOO,
OOO + "io.", OOO + "io.",
OOO + "util.", OOO + "util.",
OOO + "presents.", OOO + "presents.",
OOO + "tudey.",
OOO + "orth.", OOO + "orth.",
OOO + "riposte.", OOO + "riposte.",
OOO + "riposte.",
OOO + "samsara.", OOO + "samsara.",
OOO + "flashbang.", OOO + "flashbang.",
OOO + "downtown.", OOO + "downtown.",
OOO + "biteme.", OOO + "biteme.",
OOO + "who.", OOO + "who.",
OOO + "blueharvest."); OOO + "blueharvest.",
OOO + "piracy.",
OOO + "ppa.",
OOO + "yohoho.",
OOO + "projectx.");
} }
@@ -14,7 +14,7 @@ import {{this}};
* to the requesting client. * to the requesting client.
*/ */
{{generated}} {{generated}}
public class {{name}}Marshaller extends InvocationMarshaller public class {{name}}Marshaller extends InvocationMarshaller{{typeParameters}}
implements {{name}}Service implements {{name}}Service
{ {
{{#listeners}} {{#listeners}}
@@ -19,7 +19,7 @@ public interface {{name}}Provider extends InvocationProvider
/** /**
* Handles a {@link {{name}}Service#{{method.name}}} request. * 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}}; throws InvocationException{{/listenerArgs.isEmpty}};
{{/methods}} {{/methods}}
@@ -23,10 +23,12 @@ package com.threerings.presents.client;
import java.util.List; import java.util.List;
import com.threerings.presents.data.ClientObject;
/** /**
* A test of the invocation services. * A test of the invocation services.
*/ */
public interface TestService extends InvocationService public interface TestService extends InvocationService<ClientObject>
{ {
/** Used to dispatch responses to {@link TestService#test} requests. */ /** Used to dispatch responses to {@link TestService#test} requests. */
public static interface TestFuncListener extends InvocationListener public static interface TestFuncListener extends InvocationListener
@@ -36,7 +36,7 @@ import com.threerings.presents.client.TestService;
*/ */
@Generated(value={"com.threerings.presents.tools.GenServiceTask"}, @Generated(value={"com.threerings.presents.tools.GenServiceTask"},
comments="Derived from TestService.java.") comments="Derived from TestService.java.")
public class TestMarshaller extends InvocationMarshaller public class TestMarshaller extends InvocationMarshaller<ClientObject>
implements TestService implements TestService
{ {
/** /**