Package jadex.bridge.component.impl
Class RemoteExecutionComponentFeature
- java.lang.Object
-
- jadex.bridge.component.impl.AbstractComponentFeature
-
- jadex.bridge.component.impl.RemoteExecutionComponentFeature
-
- All Implemented Interfaces:
IComponentFeature
,IInternalRemoteExecutionFeature
,IRemoteExecutionFeature
public class RemoteExecutionComponentFeature extends AbstractComponentFeature implements IRemoteExecutionFeature, IInternalRemoteExecutionFeature
Feature for securely sending and handling remote execution commands.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
RemoteExecutionComponentFeature.OutCommand
Command that has been sent to a remote component.protected class
RemoteExecutionComponentFeature.RxHandler
Handle RX Messages.
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEBUG
Put string representation of command in message header.static IComponentFeatureFactory
FACTORY
The factory.protected java.util.Map<java.lang.String,jadex.commons.future.IFuture<?>>
incommands
Commands that have been received to be executed locally.protected java.util.Map<java.lang.String,RemoteExecutionComponentFeature.OutCommand>
outcommands
Commands that have been sent to a remote component.static java.lang.String
RX_DEBUG
Debug info of the remote execution command.static java.lang.String
RX_ID
ID of the remote execution command in progress.protected static java.util.Set<java.lang.Class<?>>
SAFE_COMMANDS
Commands safe to use with untrusted clients.-
Fields inherited from class jadex.bridge.component.impl.AbstractComponentFeature
cinfo, component, guesser
-
-
Constructor Summary
Constructors Constructor Description RemoteExecutionComponentFeature(IInternalAccess component, ComponentCreationInfo cinfo)
Create the feature.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> jadex.commons.future.IFuture<T>
execute(IComponentIdentifier target, IRemoteCommand<T> command, java.lang.Class<? extends jadex.commons.future.IFuture<T>> clazz, java.lang.Long timeout)
Execute a command on a remote agent.<T> jadex.commons.future.IFuture<T>
executeRemoteMethod(RemoteReference ref, java.lang.reflect.Method method, java.lang.Object[] args)
Invoke a method on a remote object.boolean
hasUserBody()
Has no user body.jadex.commons.future.IFuture<java.lang.Void>
init()
Initialize the feature.protected jadex.commons.future.IFuture<java.lang.Void>
sendRxMessage(IComponentIdentifier receiver, java.lang.String rxid, java.lang.Object msg)
Sends RX message.-
Methods inherited from class jadex.bridge.component.impl.AbstractComponentFeature
body, getClockService, getComponent, getExecutionService, getExternalFacade, getExternalFacadeType, getInternalAccess, getParameterGuesser, getValueFetcher, kill, shutdown
-
-
-
-
Field Detail
-
DEBUG
public static final boolean DEBUG
Put string representation of command in message header.- See Also:
- Constant Field Values
-
FACTORY
public static final IComponentFeatureFactory FACTORY
The factory.
-
RX_ID
public static final java.lang.String RX_ID
ID of the remote execution command in progress.- See Also:
- Constant Field Values
-
RX_DEBUG
public static final java.lang.String RX_DEBUG
Debug info of the remote execution command.- See Also:
- Constant Field Values
-
SAFE_COMMANDS
protected static final java.util.Set<java.lang.Class<?>> SAFE_COMMANDS
Commands safe to use with untrusted clients.
-
outcommands
protected java.util.Map<java.lang.String,RemoteExecutionComponentFeature.OutCommand> outcommands
Commands that have been sent to a remote component. Stored to set return value etc.
-
incommands
protected java.util.Map<java.lang.String,jadex.commons.future.IFuture<?>> incommands
Commands that have been received to be executed locally. Stored to allow termination etc.
-
-
Constructor Detail
-
RemoteExecutionComponentFeature
public RemoteExecutionComponentFeature(IInternalAccess component, ComponentCreationInfo cinfo)
Create the feature.
-
-
Method Detail
-
init
public jadex.commons.future.IFuture<java.lang.Void> init()
Initialize the feature.- Specified by:
init
in interfaceIComponentFeature
- Overrides:
init
in classAbstractComponentFeature
-
hasUserBody
public boolean hasUserBody()
Has no user body.- Specified by:
hasUserBody
in interfaceIComponentFeature
- Overrides:
hasUserBody
in classAbstractComponentFeature
-
execute
public <T> jadex.commons.future.IFuture<T> execute(IComponentIdentifier target, IRemoteCommand<T> command, java.lang.Class<? extends jadex.commons.future.IFuture<T>> clazz, java.lang.Long timeout)
Execute a command on a remote agent.- Specified by:
execute
in interfaceIRemoteExecutionFeature
- Parameters:
target
- The component to send the command to.command
- The command to be executed.clazz
- The return type.timeout
- Custom timeout or null for default.- Returns:
- The result(s) of the command, if any.
-
executeRemoteMethod
public <T> jadex.commons.future.IFuture<T> executeRemoteMethod(RemoteReference ref, java.lang.reflect.Method method, java.lang.Object[] args)
Invoke a method on a remote object.- Specified by:
executeRemoteMethod
in interfaceIInternalRemoteExecutionFeature
- Parameters:
ref
- The target reference.method
- The method to be executed.args
- The arguments.- Returns:
- The result(s) of the method invocation, if any. Connects any futures involved.
-
sendRxMessage
protected jadex.commons.future.IFuture<java.lang.Void> sendRxMessage(IComponentIdentifier receiver, java.lang.String rxid, java.lang.Object msg)
Sends RX message.- Parameters:
receiver
- The receiver.rxid
- The remote execution ID.msg
- The message.- Returns:
- Null, when sent.
-
-