[#1472] Add a Settings.executeDebugging property, and move server-side
Console logic to core - Inline CommandMessage.{sync|async}Message. This
indirection is not needed, but obscures further refactorings
This commit is contained in:
parent
baffa39059
commit
8086066e8b
@ -52,6 +52,14 @@ import org.jooq.debug.QueryLoggingData;
|
||||
import org.jooq.debug.ResultSetLoggingData;
|
||||
import org.jooq.debug.StatementExecutor;
|
||||
import org.jooq.debug.StatementMatcher;
|
||||
import org.jooq.debug.console.remote.ServerDebugger.CMS_addBreakpoint;
|
||||
import org.jooq.debug.console.remote.ServerDebugger.CMS_isExecutionSupported;
|
||||
import org.jooq.debug.console.remote.ServerDebugger.CMS_modifyBreakpoint;
|
||||
import org.jooq.debug.console.remote.ServerDebugger.CMS_removeBreakpoint;
|
||||
import org.jooq.debug.console.remote.ServerDebugger.CMS_setBreakpointHitHandlerActive;
|
||||
import org.jooq.debug.console.remote.ServerDebugger.CMS_setBreakpoints;
|
||||
import org.jooq.debug.console.remote.ServerDebugger.CMS_setLoggingActive;
|
||||
import org.jooq.debug.console.remote.ServerDebugger.CMS_setLoggingStatementMatchers;
|
||||
import org.jooq.debug.console.remote.messaging.CommunicationInterface;
|
||||
import org.jooq.debug.console.remote.messaging.CommunicationInterfaceFactory;
|
||||
|
||||
@ -60,10 +68,10 @@ import org.jooq.debug.console.remote.messaging.CommunicationInterfaceFactory;
|
||||
*/
|
||||
public class ClientDebugger implements Debugger {
|
||||
|
||||
private CommunicationInterface communicationInterface;
|
||||
private CommunicationInterface comm;
|
||||
|
||||
public ClientDebugger(String ip, int port) throws Exception {
|
||||
communicationInterface = CommunicationInterface.openClientCommunicationChannel(new CommunicationInterfaceFactory() {
|
||||
comm = CommunicationInterface.openClientCommunicationChannel(new CommunicationInterfaceFactory() {
|
||||
@Override
|
||||
public CommunicationInterface createCommunicationInterface(int port_) {
|
||||
return new DebuggerCommmunicationInterface(ClientDebugger.this, port_);
|
||||
@ -72,7 +80,7 @@ public class ClientDebugger implements Debugger {
|
||||
}
|
||||
|
||||
CommunicationInterface getCommunicationInterface() {
|
||||
return communicationInterface;
|
||||
return comm;
|
||||
}
|
||||
|
||||
private LoggingListener loggingListener;
|
||||
@ -86,7 +94,7 @@ public class ClientDebugger implements Debugger {
|
||||
}
|
||||
this.loggingListener = loggingListener;
|
||||
}
|
||||
new ServerDebugger.CMS_setLoggingActive().asyncExec(communicationInterface, loggingListener != null);
|
||||
comm.asyncExec(new CMS_setLoggingActive(), loggingListener != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -104,7 +112,7 @@ public class ClientDebugger implements Debugger {
|
||||
synchronized (LOGGING_STATEMENT_MATCHERS_LOCK) {
|
||||
this.loggingStatementMatchers = loggingStatementMatchers;
|
||||
}
|
||||
new ServerDebugger.CMS_setLoggingStatementMatchers().asyncExec(communicationInterface, (Object)loggingStatementMatchers);
|
||||
comm.asyncExec(new CMS_setLoggingStatementMatchers(), (Serializable[]) loggingStatementMatchers);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -125,7 +133,7 @@ public class ClientDebugger implements Debugger {
|
||||
synchronized (BREAKPOINT_LOCK) {
|
||||
this.breakpoints = breakpoints;
|
||||
}
|
||||
new ServerDebugger.CMS_setBreakpoints().asyncExec(communicationInterface, (Object)breakpoints);
|
||||
comm.asyncExec(new CMS_setBreakpoints(), (Serializable[]) breakpoints);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -133,13 +141,13 @@ public class ClientDebugger implements Debugger {
|
||||
synchronized (BREAKPOINT_LOCK) {
|
||||
if(this.breakpoints == null) {
|
||||
this.breakpoints = new Breakpoint[] {breakpoint};
|
||||
new ServerDebugger.CMS_addBreakpoint().asyncExec(communicationInterface, (Object)breakpoint);
|
||||
comm.asyncExec(new CMS_addBreakpoint(), breakpoint);
|
||||
return;
|
||||
}
|
||||
for(int i=0; i<breakpoints.length; i++) {
|
||||
if(breakpoints[i].getID() == breakpoint.getID()) {
|
||||
breakpoints[i] = breakpoint;
|
||||
new ServerDebugger.CMS_modifyBreakpoint().asyncExec(communicationInterface, (Object)breakpoint);
|
||||
comm.asyncExec(new CMS_modifyBreakpoint(), breakpoint);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -148,7 +156,7 @@ public class ClientDebugger implements Debugger {
|
||||
newBreakpoints[breakpoints.length] = breakpoint;
|
||||
breakpoints = newBreakpoints;
|
||||
}
|
||||
new ServerDebugger.CMS_addBreakpoint().asyncExec(communicationInterface, (Object)breakpoint);
|
||||
comm.asyncExec(new CMS_addBreakpoint(), breakpoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -161,7 +169,7 @@ public class ClientDebugger implements Debugger {
|
||||
for(int i=0; i<breakpoints.length; i++) {
|
||||
if(breakpoints[i].getID() == breakpoint.getID()) {
|
||||
breakpoints[i] = breakpoint;
|
||||
new ServerDebugger.CMS_modifyBreakpoint().asyncExec(communicationInterface, (Object)breakpoint);
|
||||
comm.asyncExec(new CMS_modifyBreakpoint(), breakpoint);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -185,7 +193,7 @@ public class ClientDebugger implements Debugger {
|
||||
System.arraycopy(breakpoints, i + 1, newBreakpoints, i, newBreakpoints.length - i);
|
||||
breakpoints = newBreakpoints;
|
||||
}
|
||||
new ServerDebugger.CMS_removeBreakpoint().asyncExec(communicationInterface, (Object)breakpoint);
|
||||
comm.asyncExec(new CMS_removeBreakpoint(), breakpoint);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -210,7 +218,7 @@ public class ClientDebugger implements Debugger {
|
||||
}
|
||||
this.breakpointHitHandler = breakpointHitHandler;
|
||||
}
|
||||
new ServerDebugger.CMS_setBreakpointHitHandlerActive().asyncExec(communicationInterface, breakpointHitHandler != null);
|
||||
comm.asyncExec(new CMS_setBreakpointHitHandlerActive(), breakpointHitHandler != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -227,7 +235,7 @@ public class ClientDebugger implements Debugger {
|
||||
public boolean isExecutionSupported() {
|
||||
synchronized (IS_EDITION_SUPPORTED_LOCK) {
|
||||
if(isEditionSupported == null) {
|
||||
isEditionSupported = (Boolean)new ServerDebugger.CMS_isExecutionSupported().syncExec(communicationInterface);
|
||||
isEditionSupported = comm.syncExec(new CMS_isExecutionSupported());
|
||||
}
|
||||
}
|
||||
return Boolean.TRUE.equals(isEditionSupported);
|
||||
@ -241,7 +249,7 @@ public class ClientDebugger implements Debugger {
|
||||
@SuppressWarnings("serial")
|
||||
static class CMC_logQueries extends ClientDebuggerCommandMessage<Serializable> {
|
||||
@Override
|
||||
public Serializable run(Object[] args) {
|
||||
public Serializable run(Serializable... args) {
|
||||
LoggingListener loggingListener = getDebugger().getLoggingListener();
|
||||
if(loggingListener != null) {
|
||||
loggingListener.logQueries((QueryLoggingData)args[0]);
|
||||
@ -253,7 +261,7 @@ public class ClientDebugger implements Debugger {
|
||||
@SuppressWarnings("serial")
|
||||
static class CMC_logResultSet extends ClientDebuggerCommandMessage<Serializable> {
|
||||
@Override
|
||||
public Serializable run(Object[] args) {
|
||||
public Serializable run(Serializable... args) {
|
||||
LoggingListener loggingListener = getDebugger().getLoggingListener();
|
||||
if(loggingListener != null) {
|
||||
loggingListener.logResultSet((Integer)args[0], (ResultSetLoggingData)args[1]);
|
||||
@ -265,7 +273,7 @@ public class ClientDebugger implements Debugger {
|
||||
@SuppressWarnings("serial")
|
||||
static class CMC_processBreakpointBeforeExecutionHit extends ClientDebuggerCommandMessage<BreakpointHit> {
|
||||
@Override
|
||||
public BreakpointHit run(Object[] args) {
|
||||
public BreakpointHit run(Serializable... args) {
|
||||
BreakpointHitHandler breakpointHitHandler = getDebugger().getBreakpointHitHandler();
|
||||
if(breakpointHitHandler != null) {
|
||||
BreakpointHit breakpointHit = (BreakpointHit)args[0];
|
||||
@ -283,7 +291,7 @@ public class ClientDebugger implements Debugger {
|
||||
@SuppressWarnings("serial")
|
||||
static class CMC_processBreakpointAfterExecutionHit extends ClientDebuggerCommandMessage<BreakpointHit> {
|
||||
@Override
|
||||
public BreakpointHit run(Object[] args) {
|
||||
public BreakpointHit run(Serializable... args) {
|
||||
BreakpointHitHandler breakpointHitHandler = getDebugger().getBreakpointHitHandler();
|
||||
if(breakpointHitHandler != null) {
|
||||
BreakpointHit breakpointHit = (BreakpointHit)args[0];
|
||||
|
||||
@ -40,6 +40,11 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.jooq.debug.StatementExecution;
|
||||
import org.jooq.debug.StatementExecutor;
|
||||
import org.jooq.debug.console.remote.ServerDebugger.CMS_createServerStatementExecutor;
|
||||
import org.jooq.debug.console.remote.ServerDebugger.CMS_doStatementExecutorExecution;
|
||||
import org.jooq.debug.console.remote.ServerDebugger.CMS_getStatementExecutorTableColumnNames;
|
||||
import org.jooq.debug.console.remote.ServerDebugger.CMS_getStatementExecutorTableNames;
|
||||
import org.jooq.debug.console.remote.ServerDebugger.CMS_stopStatementExecutorExecution;
|
||||
|
||||
/**
|
||||
* @author Christopher Deckers
|
||||
@ -57,28 +62,28 @@ public class ClientStatementExecutor implements StatementExecutor {
|
||||
public ClientStatementExecutor(ClientDebugger debugger, Long breakpointHitThreadID) {
|
||||
id = nextID.incrementAndGet();
|
||||
this.debugger = debugger;
|
||||
new ServerDebugger.CMS_createServerStatementExecutor().asyncExec(debugger.getCommunicationInterface(), id, breakpointHitThreadID);
|
||||
debugger.getCommunicationInterface().asyncExec(new CMS_createServerStatementExecutor(), id, breakpointHitThreadID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatementExecution execute(String sql, int maxRSRowsParsing, int retainParsedRSDataRowCountThreshold) {
|
||||
return new ServerDebugger.CMS_doStatementExecutorExecution().syncExec(debugger.getCommunicationInterface(), id, sql, maxRSRowsParsing, retainParsedRSDataRowCountThreshold);
|
||||
return debugger.getCommunicationInterface().syncExec(new CMS_doStatementExecutorExecution(), id, sql, maxRSRowsParsing, retainParsedRSDataRowCountThreshold);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopExecution() {
|
||||
new ServerDebugger.CMS_stopStatementExecutorExecution().asyncExec(debugger.getCommunicationInterface(), id);
|
||||
debugger.getCommunicationInterface().asyncExec(new CMS_stopStatementExecutorExecution(), id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTableNames() {
|
||||
String[] tableNames = (String[])new ServerDebugger.CMS_getStatementExecutorTableNames().syncExec(debugger.getCommunicationInterface(), id);
|
||||
String[] tableNames = debugger.getCommunicationInterface().syncExec(new CMS_getStatementExecutorTableNames(), id);
|
||||
return tableNames == null? new String[0]: tableNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTableColumnNames() {
|
||||
String[] tableColumnNames = (String[])new ServerDebugger.CMS_getStatementExecutorTableColumnNames().syncExec(debugger.getCommunicationInterface(), id);
|
||||
String[] tableColumnNames = debugger.getCommunicationInterface().syncExec(new CMS_getStatementExecutorTableColumnNames(), id);
|
||||
return tableColumnNames == null? new String[0]: tableColumnNames;
|
||||
}
|
||||
|
||||
|
||||
@ -54,6 +54,10 @@ import org.jooq.debug.StatementExecution;
|
||||
import org.jooq.debug.StatementExecutor;
|
||||
import org.jooq.debug.StatementMatcher;
|
||||
import org.jooq.debug.console.DatabaseDescriptor;
|
||||
import org.jooq.debug.console.remote.ClientDebugger.CMC_logQueries;
|
||||
import org.jooq.debug.console.remote.ClientDebugger.CMC_logResultSet;
|
||||
import org.jooq.debug.console.remote.ClientDebugger.CMC_processBreakpointAfterExecutionHit;
|
||||
import org.jooq.debug.console.remote.ClientDebugger.CMC_processBreakpointBeforeExecutionHit;
|
||||
import org.jooq.debug.console.remote.messaging.CommunicationInterface;
|
||||
|
||||
/**
|
||||
@ -65,10 +69,10 @@ class ServerDebugger extends LocalDebugger {
|
||||
super(databaseDescriptor);
|
||||
}
|
||||
|
||||
private CommunicationInterface communicationInterface;
|
||||
private CommunicationInterface comm;
|
||||
|
||||
void setCommunicationInterface(CommunicationInterface communicationInterface) {
|
||||
this.communicationInterface = communicationInterface;
|
||||
this.comm = communicationInterface;
|
||||
}
|
||||
|
||||
private void setLoggingActive(boolean isActive) {
|
||||
@ -76,11 +80,11 @@ class ServerDebugger extends LocalDebugger {
|
||||
setLoggingListener(new LoggingListener() {
|
||||
@Override
|
||||
public void logQueries(QueryLoggingData queryLoggingData) {
|
||||
new ClientDebugger.CMC_logQueries().asyncExec(communicationInterface, queryLoggingData);
|
||||
comm.asyncExec(new CMC_logQueries(), queryLoggingData);
|
||||
}
|
||||
@Override
|
||||
public void logResultSet(int sqlQueryDebuggerDataID, ResultSetLoggingData resultSetLoggingData) {
|
||||
new ClientDebugger.CMC_logResultSet().asyncExec(communicationInterface, sqlQueryDebuggerDataID, resultSetLoggingData);
|
||||
comm.asyncExec(new CMC_logResultSet(), sqlQueryDebuggerDataID, resultSetLoggingData);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@ -91,7 +95,7 @@ class ServerDebugger extends LocalDebugger {
|
||||
@SuppressWarnings("serial")
|
||||
static class CMS_setLoggingActive extends ServerDebuggerCommandMessage<Serializable> {
|
||||
@Override
|
||||
public Serializable run(Object[] args) {
|
||||
public Serializable run(Serializable... args) {
|
||||
getDebugger().setLoggingActive((Boolean)args[0]);
|
||||
return null;
|
||||
}
|
||||
@ -102,14 +106,14 @@ class ServerDebugger extends LocalDebugger {
|
||||
setBreakpointHitHandler(new BreakpointHitHandler() {
|
||||
@Override
|
||||
public void processBreakpointBeforeExecutionHit(BreakpointHit breakpointHit) {
|
||||
BreakpointHit modifiedBreakpointHit = new ClientDebugger.CMC_processBreakpointBeforeExecutionHit().syncExec(communicationInterface, breakpointHit);
|
||||
BreakpointHit modifiedBreakpointHit = comm.syncExec(new CMC_processBreakpointBeforeExecutionHit(), breakpointHit);
|
||||
if(modifiedBreakpointHit != null) {
|
||||
breakpointHit.setExecutionType(modifiedBreakpointHit.getExecutionType(), modifiedBreakpointHit.getSql());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void processBreakpointAfterExecutionHit(BreakpointHit breakpointHit) {
|
||||
new ClientDebugger.CMC_processBreakpointAfterExecutionHit().syncExec(communicationInterface, breakpointHit);
|
||||
comm.syncExec(new CMC_processBreakpointAfterExecutionHit(), breakpointHit);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@ -120,7 +124,7 @@ class ServerDebugger extends LocalDebugger {
|
||||
@SuppressWarnings("serial")
|
||||
static class CMS_setLoggingStatementMatchers extends ServerDebuggerCommandMessage<Serializable> {
|
||||
@Override
|
||||
public Serializable run(Object[] args) {
|
||||
public Serializable run(Serializable... args) {
|
||||
getDebugger().setLoggingStatementMatchers((StatementMatcher[])args[0]);
|
||||
return null;
|
||||
}
|
||||
@ -129,7 +133,7 @@ class ServerDebugger extends LocalDebugger {
|
||||
@SuppressWarnings("serial")
|
||||
static class CMS_setBreakpoints extends ServerDebuggerCommandMessage<Serializable> {
|
||||
@Override
|
||||
public Serializable run(Object[] args) {
|
||||
public Serializable run(Serializable... args) {
|
||||
Breakpoint[] breakpoints = (Breakpoint[])args[0];
|
||||
if(breakpoints != null) {
|
||||
for(Breakpoint breakpoint: breakpoints) {
|
||||
@ -145,7 +149,7 @@ class ServerDebugger extends LocalDebugger {
|
||||
@SuppressWarnings("serial")
|
||||
static class CMS_addBreakpoint extends ServerDebuggerCommandMessage<Serializable> {
|
||||
@Override
|
||||
public Serializable run(Object[] args) {
|
||||
public Serializable run(Serializable... args) {
|
||||
Breakpoint breakpoint = (Breakpoint)args[0];
|
||||
// Serialization has a cache, assuming objects are immutable. We have to reset our internal states.
|
||||
breakpoint.reset();
|
||||
@ -157,7 +161,7 @@ class ServerDebugger extends LocalDebugger {
|
||||
@SuppressWarnings("serial")
|
||||
static class CMS_modifyBreakpoint extends ServerDebuggerCommandMessage<Serializable> {
|
||||
@Override
|
||||
public Serializable run(Object[] args) {
|
||||
public Serializable run(Serializable... args) {
|
||||
Breakpoint breakpoint = (Breakpoint)args[0];
|
||||
// Serialization has a cache, assuming objects are immutable. We have to reset our internal states.
|
||||
breakpoint.reset();
|
||||
@ -169,7 +173,7 @@ class ServerDebugger extends LocalDebugger {
|
||||
@SuppressWarnings("serial")
|
||||
static class CMS_removeBreakpoint extends ServerDebuggerCommandMessage<Serializable> {
|
||||
@Override
|
||||
public Serializable run(Object[] args) {
|
||||
public Serializable run(Serializable... args) {
|
||||
getDebugger().removeBreakpoint((Breakpoint)args[0]);
|
||||
return null;
|
||||
}
|
||||
@ -178,16 +182,16 @@ class ServerDebugger extends LocalDebugger {
|
||||
@SuppressWarnings("serial")
|
||||
static class CMS_setBreakpointHitHandlerActive extends ServerDebuggerCommandMessage<Serializable> {
|
||||
@Override
|
||||
public Serializable run(Object[] args) {
|
||||
public Serializable run(Serializable... args) {
|
||||
getDebugger().setBreakpointHitHandlerActive((Boolean)args[0]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
static class CMS_isExecutionSupported extends ServerDebuggerCommandMessage<Serializable> {
|
||||
static class CMS_isExecutionSupported extends ServerDebuggerCommandMessage<Boolean> {
|
||||
@Override
|
||||
public Serializable run(Object[] args) {
|
||||
public Boolean run(Serializable... args) {
|
||||
return getDebugger().isExecutionSupported();
|
||||
}
|
||||
}
|
||||
@ -221,7 +225,7 @@ class ServerDebugger extends LocalDebugger {
|
||||
@SuppressWarnings("serial")
|
||||
static class CMS_createServerStatementExecutor extends ServerDebuggerCommandMessage<Serializable> {
|
||||
@Override
|
||||
public Serializable run(Object[] args) {
|
||||
public Serializable run(Serializable... args) {
|
||||
int id = (Integer)args[0];
|
||||
Long breakpointHitThreadID = (Long)args[1];
|
||||
getDebugger().createStatementExecutor(id, breakpointHitThreadID);
|
||||
@ -232,7 +236,7 @@ class ServerDebugger extends LocalDebugger {
|
||||
@SuppressWarnings("serial")
|
||||
static class CMS_doStatementExecutorExecution extends ServerDebuggerCommandMessage<StatementExecution> {
|
||||
@Override
|
||||
public StatementExecution run(Object[] args) {
|
||||
public StatementExecution run(Serializable... args) {
|
||||
int id = (Integer)args[0];
|
||||
String sql = (String)args[1];
|
||||
int maxRSRowsParsing = (Integer)args[2];
|
||||
@ -245,7 +249,7 @@ class ServerDebugger extends LocalDebugger {
|
||||
@SuppressWarnings("serial")
|
||||
static class CMS_stopStatementExecutorExecution extends ServerDebuggerCommandMessage<Serializable> {
|
||||
@Override
|
||||
public Serializable run(Object[] args) {
|
||||
public Serializable run(Serializable... args) {
|
||||
int id = (Integer)args[0];
|
||||
getDebugger().removeStatementExecutor(id).stopExecution();
|
||||
return null;
|
||||
@ -253,18 +257,18 @@ class ServerDebugger extends LocalDebugger {
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
static class CMS_getStatementExecutorTableNames extends ServerDebuggerCommandMessage<Serializable> {
|
||||
static class CMS_getStatementExecutorTableNames extends ServerDebuggerCommandMessage<String[]> {
|
||||
@Override
|
||||
public Serializable run(Object[] args) {
|
||||
public String[] run(Serializable... args) {
|
||||
int id = (Integer)args[0];
|
||||
return getDebugger().getStatementExecutor(id).getTableNames();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
static class CMS_getStatementExecutorTableColumnNames extends ServerDebuggerCommandMessage<Serializable> {
|
||||
static class CMS_getStatementExecutorTableColumnNames extends ServerDebuggerCommandMessage<String[]> {
|
||||
@Override
|
||||
public Serializable run(Object[] args) {
|
||||
public String[] run(Serializable... args) {
|
||||
int id = (Integer)args[0];
|
||||
return getDebugger().getStatementExecutor(id).getTableColumnNames();
|
||||
}
|
||||
|
||||
@ -49,39 +49,21 @@ public abstract class CommandMessage<S extends Serializable> extends Message<S>
|
||||
public CommandMessage() {
|
||||
}
|
||||
|
||||
private Object[] args;
|
||||
private Serializable[] args;
|
||||
|
||||
/**
|
||||
* Set the arguments that will be used when the message is run.
|
||||
*
|
||||
* @param arguments the arguments, which must be serializable.
|
||||
*/
|
||||
void setArgs(Object... arguments) {
|
||||
if(arguments.length == 0) {
|
||||
void setArgs(Serializable... arguments) {
|
||||
if (arguments.length == 0) {
|
||||
arguments = null;
|
||||
}
|
||||
this.args = arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute that message asynchronously with the given arguments.
|
||||
* @param arguments the arguments, which must be serializable.
|
||||
*/
|
||||
public void asyncExec(CommunicationInterface communicationInterface, Object... arguments) {
|
||||
setArgs(arguments);
|
||||
communicationInterface.asyncSend(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute that message synchronously with the given arguments and return the result.
|
||||
* @param arguments the arguments, which must be serializable.
|
||||
* @return the result of the execution.
|
||||
*/
|
||||
public S syncExec(CommunicationInterface communicationInterface, Object... arguments) {
|
||||
setArgs(arguments);
|
||||
return communicationInterface.syncSend(this);
|
||||
}
|
||||
|
||||
private static final Object[] EMPTY_ARGS = new Object[0];
|
||||
private static final Serializable[] EMPTY_ARGS = new Serializable[0];
|
||||
|
||||
S runCommand() throws Exception {
|
||||
return run(args == null? EMPTY_ARGS: args);
|
||||
@ -89,11 +71,14 @@ public abstract class CommandMessage<S extends Serializable> extends Message<S>
|
||||
|
||||
/**
|
||||
* Run the message.
|
||||
* @param arguments the arguments that were specified for that command, or an empty array if none were specified.
|
||||
*
|
||||
* @param arguments the arguments that were specified for that command, or
|
||||
* an empty array if none were specified.
|
||||
* @return the result that may be passed back to the caller.
|
||||
* @throws Exception any exception that may happen, and which would be passed back if it is a synchronous execution.
|
||||
* @throws Exception any exception that may happen, and which would be
|
||||
* passed back if it is a synchronous execution.
|
||||
*/
|
||||
public abstract S run(Object[] arguments) throws Exception;
|
||||
public abstract S run(Serializable... arguments) throws Exception;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@ -130,6 +130,28 @@ public class CommunicationInterface {
|
||||
return messagingInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute that message asynchronously with the given arguments.
|
||||
*
|
||||
* @param arguments the arguments, which must be serializable.
|
||||
*/
|
||||
public void asyncExec(CommandMessage<?> message, Serializable... arguments) {
|
||||
message.setArgs(arguments);
|
||||
asyncSend(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute that message synchronously with the given arguments and return
|
||||
* the result.
|
||||
*
|
||||
* @param arguments the arguments, which must be serializable.
|
||||
* @return the result of the execution.
|
||||
*/
|
||||
public <S extends Serializable> S syncExec(CommandMessage<S> message, Serializable... arguments) {
|
||||
message.setArgs(arguments);
|
||||
return syncSend(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send that message synchronously, potentially returning a result if the
|
||||
* message type allows that.
|
||||
|
||||
@ -61,6 +61,6 @@ public abstract class LocalMessage<S extends Serializable> extends CommandMessag
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract S run(Object[] args);
|
||||
public abstract S run(Serializable... args);
|
||||
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@ class MessagingInterface {
|
||||
@SuppressWarnings("serial")
|
||||
private static class CM_asyncExecResponse extends CommandMessage<Serializable> {
|
||||
@Override
|
||||
public Serializable run(Object[] args) {
|
||||
public Serializable run(Serializable... args) {
|
||||
MessagingInterface messagingInterface = getCommunicationInterface().getMessagingInterface();
|
||||
long threadID = (Long)args[0];
|
||||
CommandResultMessage<?> commandResultMessage = (CommandResultMessage<?>)args[1];
|
||||
@ -354,7 +354,7 @@ class MessagingInterface {
|
||||
@SuppressWarnings("serial")
|
||||
private static class CM_asyncExec extends CommandMessage<Serializable> {
|
||||
@Override
|
||||
public Serializable run(Object[] args) {
|
||||
public Serializable run(Serializable... args) {
|
||||
Message<?> message = (Message<?>)args[1];
|
||||
message.setSyncExec(false);
|
||||
CommunicationInterface communicationInterface = getCommunicationInterface();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user