The great invocation services rethink of 2002! Rearchitected the remote
method invocation services and converted everything to the new style. Could this be my biggest checkin ever? git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1642 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,34 +1,32 @@
|
||||
//
|
||||
// $Id: AdminService.java,v 1.1 2002/06/07 06:22:24 mdb Exp $
|
||||
// $Id: AdminService.java,v 1.2 2002/08/14 19:07:48 mdb Exp $
|
||||
|
||||
package com.threerings.admin.client;
|
||||
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.InvocationDirector;
|
||||
import com.threerings.presents.client.InvocationService;
|
||||
|
||||
import com.threerings.admin.Log;
|
||||
import com.threerings.admin.data.AdminCodes;
|
||||
|
||||
/**
|
||||
* Handles the client side of the admin invocation services.
|
||||
* Defines the client side of the admin invocation services.
|
||||
*/
|
||||
public class AdminService
|
||||
implements AdminCodes
|
||||
public interface AdminService extends InvocationService
|
||||
{
|
||||
/**
|
||||
* Requests the list of config objects. This will result in a call to
|
||||
*
|
||||
* <pre>
|
||||
* public void handleConfigInfoResponse (int invid, String[] keys,
|
||||
* int[] oids)
|
||||
* </pre>
|
||||
*
|
||||
* on the response target.
|
||||
* Used to communicate a response to a {@link #getConfigInfo} request.
|
||||
*/
|
||||
public static void getConfigInfo (Client client, Object rsptarget)
|
||||
public static interface ConfigInfoListener extends InvocationListener
|
||||
{
|
||||
InvocationDirector invdir = client.getInvocationDirector();
|
||||
invdir.invoke(MODULE_NAME, GET_CONFIG_INFO_REQUEST, null, rsptarget);
|
||||
Log.debug("Sent getConfigInfo request.");
|
||||
/**
|
||||
* Delivers a successful response to a {@link #getConfigInfo}
|
||||
* request.
|
||||
*/
|
||||
public void gotConfigInfo (String[] keys, int[] oids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests the list of config objects.
|
||||
*/
|
||||
public void getConfigInfo (Client client, ConfigInfoListener listener);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ConfigEditorPanel.java,v 1.3 2002/07/09 21:13:20 ray Exp $
|
||||
// $Id: ConfigEditorPanel.java,v 1.4 2002/08/14 19:07:48 mdb Exp $
|
||||
|
||||
package com.threerings.admin.client;
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.threerings.admin.Log;
|
||||
* displays their fields in a tree widget to be viewed and edited.
|
||||
*/
|
||||
public class ConfigEditorPanel extends JTabbedPane
|
||||
implements AdminService.ConfigInfoListener
|
||||
{
|
||||
/**
|
||||
* Constructs an editor panel which will use the supplied context to
|
||||
@@ -39,8 +40,11 @@ public class ConfigEditorPanel extends JTabbedPane
|
||||
// if we have no children, ship off a getConfigInfo request to
|
||||
// find out what config objects are available for editing
|
||||
if (getComponentCount() == 0) {
|
||||
// locate our admin service and use it to make a request
|
||||
AdminService service = (AdminService)
|
||||
_ctx.getClient().requireService(AdminService.class);
|
||||
Log.info("Sending get config info.");
|
||||
AdminService.getConfigInfo(_ctx.getClient(), this);
|
||||
service.getConfigInfo(_ctx.getClient(), this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +52,7 @@ public class ConfigEditorPanel extends JTabbedPane
|
||||
* Called in response to our getConfigInfo server-side service
|
||||
* request.
|
||||
*/
|
||||
public void handleConfigInfo (int invid, String[] keys, int[] oids)
|
||||
public void gotConfigInfo (String[] keys, int[] oids)
|
||||
{
|
||||
Log.info("Got config info: " + StringUtil.toString(keys));
|
||||
// create object editor panels for each of the categories
|
||||
@@ -60,6 +64,12 @@ public class ConfigEditorPanel extends JTabbedPane
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public void requestFailed (String reason)
|
||||
{
|
||||
Log.warning("Failed to get config info [reason=" + reason + "].");
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the panel is hidden; this instructs all of our object
|
||||
* editors to clear out their subscriptions.
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// $Id: AdminCodes.java,v 1.1 2002/06/07 06:22:24 mdb Exp $
|
||||
|
||||
package com.threerings.admin.data;
|
||||
|
||||
import com.threerings.presents.data.InvocationCodes;
|
||||
|
||||
/**
|
||||
* Contains codes used by the admin invocation services.
|
||||
*/
|
||||
public interface AdminCodes extends InvocationCodes
|
||||
{
|
||||
/** The module name for the admin services. */
|
||||
public static final String MODULE_NAME = "admin";
|
||||
|
||||
/** The message identifier for a getConfigInfo request. */
|
||||
public static final String GET_CONFIG_INFO_REQUEST = "GetConfigInfo";
|
||||
|
||||
/** The response identifier for a successful getConfigInfo request. */
|
||||
public static final String CONFIG_INFO_RESPONSE = "ConfigInfo";
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// $Id: AdminMarshaller.java,v 1.1 2002/08/14 19:07:48 mdb Exp $
|
||||
|
||||
package com.threerings.admin.data;
|
||||
|
||||
import com.threerings.admin.client.AdminService;
|
||||
import com.threerings.admin.client.AdminService.ConfigInfoListener;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.data.InvocationMarshaller;
|
||||
import com.threerings.presents.dobj.InvocationResponseEvent;
|
||||
|
||||
/**
|
||||
* Provides the implementation of the {@link AdminService} interface
|
||||
* that marshalls the arguments and delivers the request to the provider
|
||||
* on the server. Also provides an implementation of the response listener
|
||||
* interfaces that marshall the response arguments and deliver them back
|
||||
* to the requesting client.
|
||||
*/
|
||||
public class AdminMarshaller extends InvocationMarshaller
|
||||
implements AdminService
|
||||
{
|
||||
// documentation inherited
|
||||
public static class ConfigInfoMarshaller extends ListenerMarshaller
|
||||
implements ConfigInfoListener
|
||||
{
|
||||
/** The method id used to dispatch {@link #gotConfigInfo}
|
||||
* responses. */
|
||||
public static final int GOT_CONFIG_INFO = 0;
|
||||
|
||||
// documentation inherited from interface
|
||||
public void gotConfigInfo (String[] arg1, int[] arg2)
|
||||
{
|
||||
omgr.postEvent(new InvocationResponseEvent(
|
||||
callerOid, requestId, GOT_CONFIG_INFO,
|
||||
new Object[] { arg1, arg2 }));
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void dispatchResponse (int methodId, Object[] args)
|
||||
{
|
||||
switch (methodId) {
|
||||
case GOT_CONFIG_INFO:
|
||||
((ConfigInfoListener)listener).gotConfigInfo(
|
||||
(String[])args[0], (int[])args[1]);
|
||||
return;
|
||||
|
||||
default:
|
||||
super.dispatchResponse(methodId, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #getConfigInfo} requests. */
|
||||
public static final int GET_CONFIG_INFO = 1;
|
||||
|
||||
// documentation inherited from interface
|
||||
public void getConfigInfo (Client arg1, ConfigInfoListener arg2)
|
||||
{
|
||||
ConfigInfoMarshaller listener2 = new ConfigInfoMarshaller();
|
||||
listener2.listener = arg2;
|
||||
sendRequest(arg1, GET_CONFIG_INFO, new Object[] {
|
||||
listener2
|
||||
});
|
||||
}
|
||||
|
||||
// Class file generated on 00:25:58 08/11/02.
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// $Id: AdminDispatcher.java,v 1.1 2002/08/14 19:07:48 mdb Exp $
|
||||
|
||||
package com.threerings.admin.server;
|
||||
|
||||
import com.threerings.admin.client.AdminService;
|
||||
import com.threerings.admin.client.AdminService.ConfigInfoListener;
|
||||
import com.threerings.admin.data.AdminMarshaller;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.data.InvocationMarshaller;
|
||||
import com.threerings.presents.server.InvocationDispatcher;
|
||||
import com.threerings.presents.server.InvocationException;
|
||||
|
||||
/**
|
||||
* Dispatches requests to the {@link AdminProvider}.
|
||||
*/
|
||||
public class AdminDispatcher extends InvocationDispatcher
|
||||
{
|
||||
/**
|
||||
* Creates a dispatcher that may be registered to dispatch invocation
|
||||
* service requests for the specified provider.
|
||||
*/
|
||||
public AdminDispatcher (AdminProvider provider)
|
||||
{
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public InvocationMarshaller createMarshaller ()
|
||||
{
|
||||
return new AdminMarshaller();
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void dispatchRequest (
|
||||
ClientObject source, int methodId, Object[] args)
|
||||
throws InvocationException
|
||||
{
|
||||
switch (methodId) {
|
||||
case AdminMarshaller.GET_CONFIG_INFO:
|
||||
((AdminProvider)provider).getConfigInfo(
|
||||
source,
|
||||
(ConfigInfoListener)args[0]
|
||||
);
|
||||
return;
|
||||
|
||||
default:
|
||||
super.dispatchRequest(source, methodId, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,20 @@
|
||||
//
|
||||
// $Id: AdminProvider.java,v 1.1 2002/06/07 06:22:24 mdb Exp $
|
||||
// $Id: AdminProvider.java,v 1.2 2002/08/14 19:07:48 mdb Exp $
|
||||
|
||||
package com.threerings.admin.server;
|
||||
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.server.InvocationManager;
|
||||
import com.threerings.presents.server.InvocationProvider;
|
||||
import com.threerings.presents.server.ServiceFailedException;
|
||||
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
|
||||
import com.threerings.admin.Log;
|
||||
import com.threerings.admin.data.AdminCodes;
|
||||
import com.threerings.admin.client.AdminService;
|
||||
|
||||
/**
|
||||
* Provides the server-side interface to various administrator services.
|
||||
* Provides the server-side implementation of various administrator
|
||||
* services.
|
||||
*/
|
||||
public class AdminProvider extends InvocationProvider
|
||||
implements AdminCodes
|
||||
public class AdminProvider implements InvocationProvider
|
||||
{
|
||||
/**
|
||||
* Constructs an admin provider and registers it with the invocation
|
||||
@@ -25,15 +23,15 @@ public class AdminProvider extends InvocationProvider
|
||||
*/
|
||||
public static void init (InvocationManager invmgr)
|
||||
{
|
||||
invmgr.registerProvider(MODULE_NAME, new AdminProvider());
|
||||
invmgr.registerDispatcher(
|
||||
new AdminDispatcher(new AdminProvider()), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a request from a client to obtain the configuration keys
|
||||
* and oids for all registered configuration objects.
|
||||
* Handles a request for the list of config objects.
|
||||
*/
|
||||
public void handleGetConfigInfoRequest (BodyObject source, int invid)
|
||||
throws ServiceFailedException
|
||||
public void getConfigInfo (
|
||||
ClientObject caller, AdminService.ConfigInfoListener listener)
|
||||
{
|
||||
// we don't have to validate the request because the user can't do
|
||||
// anything with the keys or oids unless they're an admin (we put
|
||||
@@ -46,6 +44,6 @@ public class AdminProvider extends InvocationProvider
|
||||
for (int ii = 0; ii < keys.length; ii++) {
|
||||
oids[ii] = ConfObjRegistry.getObject(keys[ii]).getOid();
|
||||
}
|
||||
sendResponse(source, invid, CONFIG_INFO_RESPONSE, keys, oids);
|
||||
listener.gotConfigInfo(keys, oids);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user