diff --git a/src/eu/tneitzel/rmg/Starter.java b/src/eu/tneitzel/rmg/Starter.java index 7279dd0..d01c6b2 100644 --- a/src/eu/tneitzel/rmg/Starter.java +++ b/src/eu/tneitzel/rmg/Starter.java @@ -25,13 +25,17 @@ public static void main(String[] argv) PluginSystem.init(pluginPath); ArgumentHandler handler = new ArgumentHandler(argv); - Operation operation = handler.getAction(); RMGUtils.init(); RMGUtils.disableWarning(); RMGUtils.enableCodebaseCollector(); + + Operation operation = handler.getAction(); Dispatcher dispatcher = new Dispatcher(handler); - operation.invoke(dispatcher); + if (operation != null) + { + operation.invoke(dispatcher); + } } } diff --git a/src/eu/tneitzel/rmg/internal/ArgumentHandler.java b/src/eu/tneitzel/rmg/internal/ArgumentHandler.java index 6f5add6..b81a8cc 100644 --- a/src/eu/tneitzel/rmg/internal/ArgumentHandler.java +++ b/src/eu/tneitzel/rmg/internal/ArgumentHandler.java @@ -13,6 +13,7 @@ import eu.tneitzel.argparse4j.ArgumentParsers; import eu.tneitzel.argparse4j.global.ActionContext; import eu.tneitzel.argparse4j.global.GlobalOption; +import eu.tneitzel.argparse4j.global.IAction; import eu.tneitzel.argparse4j.global.exceptions.RequirementException; import eu.tneitzel.argparse4j.inf.ArgumentParser; import eu.tneitzel.argparse4j.inf.ArgumentParserException; @@ -163,6 +164,15 @@ public Operation getAction() if (action == null) { + for (IAction action : PluginSystem.getPluginActions()) + { + if (action.getName() == args.getString("action")) + { + PluginSystem.dispatchPluginAction(action); + return null; + } + } + ExceptionHandler.internalError("ArgumentHandler.getAction", "Invalid action was specified"); } diff --git a/src/eu/tneitzel/rmg/operations/Dispatcher.java b/src/eu/tneitzel/rmg/operations/Dispatcher.java index be9974a..9d6d29a 100644 --- a/src/eu/tneitzel/rmg/operations/Dispatcher.java +++ b/src/eu/tneitzel/rmg/operations/Dispatcher.java @@ -246,7 +246,7 @@ else if (boundName != null) else { - ExceptionHandler.missingTarget(p.getAction().name()); + ExceptionHandler.missingTarget(p.getAction().getName()); return null; } } diff --git a/src/eu/tneitzel/rmg/operations/RemoteObjectClient.java b/src/eu/tneitzel/rmg/operations/RemoteObjectClient.java index ba82098..3ffe458 100644 --- a/src/eu/tneitzel/rmg/operations/RemoteObjectClient.java +++ b/src/eu/tneitzel/rmg/operations/RemoteObjectClient.java @@ -1,6 +1,8 @@ package eu.tneitzel.rmg.operations; +import java.lang.reflect.Proxy; import java.rmi.server.ObjID; +import java.rmi.server.RemoteObjectInvocationHandler; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -98,6 +100,18 @@ public RemoteObjectClient(UnicastWrapper remoteObject) remoteRef = remoteObject.unicastRef; } + /** + * Create a proxy for the RemoteObjectClient. + * + * @return proxy implementing the specified interface + */ + @SuppressWarnings("unchecked") + public T createProxy(Class intf) + { + RemoteObjectInvocationHandler invo = new RemoteObjectInvocationHandler(remoteRef); + return (T)Proxy.newProxyInstance(intf.getClassLoader(), new Class[] { intf }, invo); + } + /** * When a RemoteObjectClient was obtained using an ObjID, it has no assigned UnicastWrapper. * remote-method-guesser only creates a UnicastRef using the endpoint information and the ObjID, diff --git a/src/eu/tneitzel/rmg/plugin/PluginSystem.java b/src/eu/tneitzel/rmg/plugin/PluginSystem.java index d36f105..f394735 100644 --- a/src/eu/tneitzel/rmg/plugin/PluginSystem.java +++ b/src/eu/tneitzel/rmg/plugin/PluginSystem.java @@ -335,4 +335,14 @@ public static void addPluginActions(Subparsers parser) action.addSuparser(container); } } + + /** + * Dispatch an action that was provided by a plugin. + * + * @param pluginAction the plugin action to dispatch + */ + public static void dispatchPluginAction(IAction pluginAction) + { + actionProvider.dispatch(pluginAction); + } }