gov.nasa.arc.brahms.vm.data
Class VMMethodInvocation

java.lang.Object
  extended by gov.nasa.arc.brahms.common.data.BrahmsObject
      extended by gov.nasa.arc.brahms.common.data.ModelElement
          extended by gov.nasa.arc.brahms.common.data.Invocation
              extended by gov.nasa.arc.brahms.common.data.MethodInvocation
                  extended by gov.nasa.arc.brahms.vm.data.VMMethodInvocation
All Implemented Interfaces:
IExpression, gov.nasa.arc.brahms.common.IConstants, IVMExpression, java.io.Serializable

public class VMMethodInvocation
extends MethodInvocation
implements IVMExpression

The VMMethodInvocation is a MethodInvocation with extensions for use in the virtual machine.

Version:
$Revision: 1.1 $ $Date: 2009/11/23 20:41:40 $ $Author: rnado $
Author:
Bob Nado
See Also:
MethodInvocation, Serialized Form

Field Summary
static org.apache.log4j.Logger LOGGER
          The logger used to log messages
 
Fields inherited from interface gov.nasa.arc.brahms.common.IConstants
ABORT, ACTIVECLASS, ACTIVECONCEPT, ACTIVEINSTANCE, AGENT, ANONYMOUS, ANYAGENT, AREA, AREADEF, ASSIGNED, ATTRIBUTE, BASEAREADEF, BASECLASS, BASECONCEPTUALCLASS, BASEGROUP, BASELIBRARY, BOOLEAN, BROADCAST, BUILDING, BYTE, CCLOCK, CDATE, CHAR, CITY, CLASS, CLOCK, COLLECTALL, COMMUNICATE, COMPLETE, COMPOSITE, COMPUTER, CONCEPT, CONCEPTUALCLASS, CONCEPTUALCONCEPT, CONCEPTUALOBJECT, CONTINUE, COPY, CREATEAGENT, CREATEAREA, CREATEOBJECT, current, CURRENT, DATAFRAME, DATE, DB, DETECTABLE, DIV, DOUBLE, EMAIL, EMPTY_STRING, END, ENDACTIVITY, ENTAGENT, EQ, EXCEPTION, EXPR, FACE2FACE, FACTFRAME, FALSE, FAX, FLOAT, FOREACH, FORONE, G2, GE, GEOGRAPHYCONCEPT, GESTURE, GET, GROUP, GT, IMPASSE, INT, INVALID, JAVA, JAVA_TYPE, KNOWN_MODIFIER, KNOWNVAL_MODIFIER, LE, LOCAL, LONG, LT, MAP, MINUS, MOD, MOVE, MULT, NE, NEW, NONE, NOT_MODIFIER, NOWORK, O, OA, OBJECT, ONTOLOGY, PAGER, PARAMETER, PATH, PHONE, PLUS, PRIMITIVE, PRIVATE, PROAGENT, PROTECTED, PRSAGENT, PUBLIC, PUT, RECEIVE, RELATION, sACTIVECLASS, sACTIVECONCEPT, sACTIVEINSTANCE, sAGENT, sARCHIVE, sAREA, sAREADEF, sBOOLEAN, sBYTE, sBYTECODEEXT, sCHAR, sCLASS, sCOMPUTER, sCONCEPT, sCONCEPTUALCLASS, sCONCEPTUALCONCEPT, sCONCEPTUALOBJECT, sCOPY, sCURRENT, sDETECTABLE, sDOUBLE, sEMAIL, sEND, SEND, sFACE2FACE, sFAX, sFILEEXT, sFLOAT, sGEOGRAPHYCONCEPT, sGROUP, SHORT, SIMAGENT, sINT, sJAVA_TYPE, sLONG, sMAP, sNEW, sNONE, sNOWORK, sOBJECT, SOURCECODE, sPAGER, sPARAMETER, sPATH, sPHONE, sPRIVATE, sPROJECTEXT, sPROTECTED, sPUBLIC, sSHORT, sSTART, sSTRING, sSYMBOL, START, STRING, sUNKNOWN, sVOID, SYMBOL, TRUE, UDT, UML, UNASSIGNED, UNDEFINED, unknown, UNKNOWN, UNKNOWN_MODIFIER, V, VARIABLE, VOID, WHENEVER, WORKFRAME, WORLD, XML
 
Constructor Summary
VMMethodInvocation()
          Constructor, creates a new VMMethodInvocation for use in the virtual machine.
VMMethodInvocation(java.lang.String file, int line)
          Constructor, creates a new VMMethodInvocation operation which is located as brahms source code in the given file at the given line number.
VMMethodInvocation(java.lang.String name, java.lang.String file, int line)
          Constructor, creates a new VMMethodInvocation operation which is located as brahms source code in the given file at the given line number.
 
Method Summary
 VMMethodInvocationCtx createContext()
          Creates a new context for this method invocation.
 java.util.List<java.lang.Object> evaluate(VMActiveInstanceCtx agent, VMFrameCtx frame)
          Evaluates the method invocation to produce a list of values.
 java.util.List<java.lang.Object> evaluate(VMActiveInstanceCtx agent, VMFrameCtx frame, boolean results)
          Evaluates the method invocation to produce a list of values.
 void invokeMethod(java.lang.String methodName, java.lang.Object target, java.lang.Class<?> targetClass, java.lang.Class<?>[] parameterTypes, java.lang.Object[] argumentTuple, java.util.List<java.lang.Object> results)
          Uses Java reflection to look up a java.reflect.Method and then to invoke the method on each argument tuple in a given list of tuples.
 
Methods inherited from class gov.nasa.arc.brahms.common.data.MethodInvocation
delete, getCollectType, getMethodDescriptor, getMethodName, getOwnerType, getTarget, setCollectType, setID, setMethodDescriptor, setMethodName, setOwnerType, setTarget, toString
 
Methods inherited from class gov.nasa.arc.brahms.common.data.Invocation
addArgument, getArgumentNumber, getArguments, getBrahmsParameterTypes, getOwner, getParameterNumber, getParameters, getParameterTypes, getVariables, hasArguments, isVarArgs, parseParameterTypes, setBrahmsParameterTypes, setOwner, setParameterTypes, setVarArgs
 
Methods inherited from class gov.nasa.arc.brahms.common.data.BrahmsObject
export, getFile, getID, getLine, getSerialNumber, isBCC, isDynamic, isLoaded, isResolved, setBCC, setDynamic, setFile, setID, setLine, setLoaded, setResolved, setSerialNumber
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.nasa.arc.brahms.common.data.IExpression
export
 

Field Detail

LOGGER

public static final org.apache.log4j.Logger LOGGER
The logger used to log messages

Constructor Detail

VMMethodInvocation

public VMMethodInvocation()
Constructor, creates a new VMMethodInvocation for use in the virtual machine.


VMMethodInvocation

public VMMethodInvocation(java.lang.String file,
                          int line)
Constructor, creates a new VMMethodInvocation operation which is located as brahms source code in the given file at the given line number.

Parameters:
file - the name of the file
line - the line number in the file

VMMethodInvocation

public VMMethodInvocation(java.lang.String name,
                          java.lang.String file,
                          int line)
Constructor, creates a new VMMethodInvocation operation which is located as brahms source code in the given file at the given line number.

Parameters:
name - the name of the method to be invoked
file - the name of the file
line - the line number in the file
Method Detail

createContext

public VMMethodInvocationCtx createContext()
Creates a new context for this method invocation.

Note: This method always returns a new instance and does not verify whether one is already created.

Returns:
VMMethodInvocationCtx a context for the method invocation

evaluate

public java.util.List<java.lang.Object> evaluate(VMActiveInstanceCtx agent,
                                                 VMFrameCtx frame)
                                          throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Evaluates the method invocation to produce a list of values. Multiple values are possible as the expression may contain collectall variables with multiple values. The list may also be empty if the method invoked has a void return type.

Specified by:
evaluate in interface IVMExpression
Parameters:
agent - the VMActiveInstanceCtx for the agent performing the expression evaluation
frame - the VMFrameCtx for the frame that is being executed -- contains variable contexts for variables used in the evaluation
Returns:
List<Object> the list of values resulting from the expression evaluation
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an error occurs during the expression evaluation

evaluate

public java.util.List<java.lang.Object> evaluate(VMActiveInstanceCtx agent,
                                                 VMFrameCtx frame,
                                                 boolean results)
                                          throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Evaluates the method invocation to produce a list of values. Multiple values are possible as the target expression may be a collectall variable with multiple values. The list may also be empty if the method invoked has a void return type. Accumulation of return values may be suppressed by giving a value of false to the results parameter. The method returns null in that case.

Parameters:
agent - the VMActiveInstanceCtx for the agent performing the expression evaluation
frame - the VMFrameCtx for the frame that is being executed -- contains variable contexts for variables used in the evaluation
results - true if the expression evaluation should return a list of resulting values, false if it should return null
Returns:
List<Object> the list of values resulting from the expression evaluation
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an error occurs during the expression evaluation

invokeMethod

public void invokeMethod(java.lang.String methodName,
                         java.lang.Object target,
                         java.lang.Class<?> targetClass,
                         java.lang.Class<?>[] parameterTypes,
                         java.lang.Object[] argumentTuple,
                         java.util.List<java.lang.Object> results)
                  throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Uses Java reflection to look up a java.reflect.Method and then to invoke the method on each argument tuple in a given list of tuples. If a non-null results list is supplied as an argument, the results of the method invocations are added to that list.

Parameters:
methodName - the name of the method to be invoked
target - the target Object of the method invocation for an instance method
targetClass - the target Class with respect to which the method is looked up
parameterTypes - an array of Class objects specifying the method's parameter types
argumentTuple - an Object array on which the method will be invoked
results - if non-null, an accumulator list for the return values of the method invocations
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an error occurs looking up or invoking the method


Copyright © 1997-2012 All Rights Reserved.