Package jade.core
Class GenericCommand
- java.lang.Object
-
- jade.core.GenericCommand
-
- All Implemented Interfaces:
Command,HorizontalCommand,VerticalCommand,Serializable,Serializable
public class GenericCommand extends Object implements HorizontalCommand, VerticalCommand
A generic implementation of theCommandinterface, operating at the meta-level to provide a generic transformation of method invocations. Generic commands can be used both as vertical and horizontal commands. Objects of this class can also be recycled to build command pools, since every information they hold can be rewritten.- Author:
- Giovanni Rimassa - FRAMeTech s.r.l.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description GenericCommand(String name, String service, String interaction)Creates a new generic command, with the given name and belonging to the given service and interaction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddParam(Object obj)Add a new parameter to this command object.voidclear()CredentialsgetCredentials()Get the credentials that the actor of this command wants to use while processing this command.StringgetInteraction()Query the interaction this command object is a part of.StringgetName()Query the name of this command object.ObjectgetParam(int index)Obtain the parameter list, as an array of Java objects.Object[]getParams()Obtain the parameter list, as an array of Java objects.JADEPrincipalgetPrincipal()Get the JADEPrincipal of the actor, respnsible for this Command object.ObjectgetReturnValue()Obtain the return value for this command.StringgetService()Access the service object this command belongs to.voidremoveParam(Object obj)Remove a parameter from this command object.voidsetCredentials(Credentials creds)voidsetPrincipal(JADEPrincipal p)voidsetReturnValue(Object rv)Assign a return value to this command, so that the original command issuer can retrieve it.
-
-
-
Constructor Detail
-
GenericCommand
public GenericCommand(String name, String service, String interaction)
Creates a new generic command, with the given name and belonging to the given service and interaction.- Parameters:
name- The name of this command.svc- The name of the service this command belongs to.interaction- The identifier of the service interation this command belongs to.
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:CommandQuery the name of this command object.
-
getService
public String getService()
Description copied from interface:HorizontalCommandAccess the service object this command belongs to. A command object belongs exactly to one single service.- Specified by:
getServicein interfaceCommand- Specified by:
getServicein interfaceHorizontalCommand- Returns:
- The name of a
Serviceobject, such that this command is one of the allowed commands for that service.
-
getInteraction
public String getInteraction()
Description copied from interface:HorizontalCommandQuery the interaction this command object is a part of. A command object is part of exactly one single interaction. Some services can generate interactions made by many commands, which can be grouped together because callinggetInteraction()on them yields the same result.- Specified by:
getInteractionin interfaceHorizontalCommand- Returns:
- A
Stringserving as a service-unique identifier for the interaction of this command object.
-
addParam
public void addParam(Object obj)
Add a new parameter to this command object.- Parameters:
obj- The parameter to add. The actual type ofobjmust be such that can be delivered over the network by the concrete platform IMTP.- See Also:
IMTPManager
-
removeParam
public void removeParam(Object obj)
Remove a parameter from this command object.- Parameters:
obj- The parameter to remove.
-
clear
public void clear()
-
setReturnValue
public void setReturnValue(Object rv)
Description copied from interface:CommandAssign a return value to this command, so that the original command issuer can retrieve it.- Specified by:
setReturnValuein interfaceCommand- Parameters:
rv- The desired return value for this command object.
-
getParam
public final Object getParam(int index)
Description copied from interface:CommandObtain the parameter list, as an array of Java objects.
-
getParams
public Object[] getParams()
Description copied from interface:CommandObtain the parameter list, as an array of Java objects.
-
getReturnValue
public Object getReturnValue()
Description copied from interface:CommandObtain the return value for this command.- Specified by:
getReturnValuein interfaceCommand- Returns:
- The value that is to be returned back to the issuer of
this
Commandobject.
-
getPrincipal
public JADEPrincipal getPrincipal()
Description copied from interface:CommandGet the JADEPrincipal of the actor, respnsible for this Command object.- Specified by:
getPrincipalin interfaceCommand- Returns:
-
setPrincipal
public void setPrincipal(JADEPrincipal p)
- Specified by:
setPrincipalin interfaceCommand
-
getCredentials
public Credentials getCredentials()
Description copied from interface:CommandGet the credentials that the actor of this command wants to use while processing this command.- Specified by:
getCredentialsin interfaceCommand- Returns:
-
setCredentials
public void setCredentials(Credentials creds)
- Specified by:
setCredentialsin interfaceCommand
-
-