Skip to content

Commit

Permalink
Small formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
qtc-de committed Jan 21, 2024
1 parent 72fda63 commit 0abe94c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/eu/tneitzel/rmg/Starter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
10 changes: 10 additions & 0 deletions src/eu/tneitzel/rmg/internal/ArgumentHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}

Expand Down
2 changes: 1 addition & 1 deletion src/eu/tneitzel/rmg/operations/Dispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ else if (boundName != null)

else
{
ExceptionHandler.missingTarget(p.getAction().name());
ExceptionHandler.missingTarget(p.getAction().getName());
return null;
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/eu/tneitzel/rmg/operations/RemoteObjectClient.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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> T createProxy(Class<T> 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,
Expand Down
10 changes: 10 additions & 0 deletions src/eu/tneitzel/rmg/plugin/PluginSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 0abe94c

Please sign in to comment.