jni
Class GenericJNIActor

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.InstantiableNamedObj
          extended by ptolemy.kernel.Entity
              extended by ptolemy.kernel.ComponentEntity
                  extended by ptolemy.actor.AtomicActor
                      extended by ptolemy.actor.TypedAtomicActor
                          extended by jni.GenericJNIActor
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

Deprecated. This code is old, hard to use and unmaintained. See EmbeddedCActor for a more recent implementation.

public class GenericJNIActor
extends TypedAtomicActor

Use the Java Native Interface to execute a native method. To use this actor, first configure the arguments of the native method by right clicking on the actor and selecting 'Configure Arguments', then configure the library name and location, then create the JNI files.

Note that under Windows, your path needs to include the directory named by the libraryDirectory Parameter. For further details, see JNIUtilities.

Since:
Ptolemy II 2.2
Version:
$Id: GenericJNIActor.java 56152 2009-11-14 17:42:22Z cxh $
Author:
Vincent Arnould (vincent.arnould@thalesgroup.com), Contributor: Christopher Hylands
See Also:
JNIUtilities, Serialized Form
Accepted Rating:
Red (vincent.arnould)
Proposed Rating:
Red (vincent.arnould)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
private  NamedList _argumentsList
          Deprecated.  
private  java.lang.Class _class
          Deprecated.  
private  int _methodIndex
          Deprecated.  
private  java.lang.reflect.Method[] _methods
          Deprecated.  
 Parameter libraryDirectory
          Deprecated. The directory that contains the native library, which under Windows should include a dll, an h file and a lib file.
 Parameter nativeFunction
          Deprecated. The name of the native library.
 Parameter nativeLibrary
          Deprecated. The name of the native library.
 
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
GenericJNIActor()
          Deprecated. Construct an entity in the default workspace with an empty string as its name.
GenericJNIActor(CompositeEntity container, java.lang.String name)
          Deprecated. Construct an entity in the given workspace with the given name.
GenericJNIActor(Workspace workspace)
          Deprecated. Construct an entity in the given workspace with an empty string as a name.
 
Method Summary
protected  void _addArgument(Argument arg)
          Deprecated. Add an argument to this entity.
 void addArgumentReturn()
          Deprecated. Add a return argument to this entity.
 java.util.List argumentsList()
          Deprecated. Get the arguments belonging to this entity.
 void attributeChanged(Attribute attribute)
          Deprecated. If the getDirector() returns something other than null, then invalidate the resolved types.
 java.lang.Object clone(Workspace workspace)
          Deprecated. Clone the object into the specified workspace.
 void createPorts()
          Deprecated. For each Argument, a port of the same name is created, belonging to this argument.
 void fire()
          Deprecated. Read the argument of the function from the ports, call the native method throw the generated interface, and put the results on the corresponding ports.
 Argument getArgument(java.lang.String name)
          Deprecated. Return the argument contained by this entity that has the specified name.
 Argument getArgumentReturn()
          Deprecated. Return the argument contained by this entity that is return.
 void initialize()
          Deprecated. Load the generated class and search for its fire method.
 void removeAllPorts()
          Deprecated. Remove all ports by setting their container to null.
 void removeArgument(Argument arg)
          Deprecated. Remove an argument from this entity.
 void updatePorts()
          Deprecated. Update the ports to match the arguments.
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, _fireAt, _fireAt, attributeTypeChanged, clone, newPort, typeConstraintList, typeConstraints
 
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, setClassDefinition, uniqueName
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable, wrapup
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 

Field Detail

libraryDirectory

public Parameter libraryDirectory
Deprecated. 
The directory that contains the native library, which under Windows should include a dll, an h file and a lib file. The default value of thie parameter is the string "jni" + File.separator + "lib"


nativeFunction

public Parameter nativeFunction
Deprecated. 
The name of the native library. The default value of this parameter is the String "nativeFunction"


nativeLibrary

public Parameter nativeLibrary
Deprecated. 
The name of the native library. The default value of this parameter is the String "nativeLibrary"


_argumentsList

private NamedList _argumentsList
Deprecated. 

_class

private java.lang.Class _class
Deprecated. 

_methodIndex

private int _methodIndex
Deprecated. 

_methods

private java.lang.reflect.Method[] _methods
Deprecated. 
Constructor Detail

GenericJNIActor

public GenericJNIActor()
Deprecated. 
Construct an entity in the default workspace with an empty string as its name. The object is added to the workspace directory. Increment the version number of the workspace.


GenericJNIActor

public GenericJNIActor(Workspace workspace)
Deprecated. 
Construct an entity in the given workspace with an empty string as a name. If the workspace argument is null, use the default workspace. The object is added to the workspace directory. Increment the version of the workspace.

Parameters:
workspace - The workspace for synchronization and version tracking.

GenericJNIActor

public GenericJNIActor(CompositeEntity container,
                       java.lang.String name)
                throws NameDuplicationException,
                       IllegalActionException
Deprecated. 
Construct an entity in the given workspace with the given name. If the workspace argument is null, use the default workspace. If the name argument is null, then the name is set to the empty string. The object is added to the workspace directory. Increment the version of the workspace.

Parameters:
container - The container.
name - The name of this object.
Throws:
IllegalActionException - If the attribute is not of an acceptable class for the container, or if the name contains a period.
NameDuplicationException - If the name coincides with an attribute already in the container.
Method Detail

addArgumentReturn

public void addArgumentReturn()
                       throws IllegalActionException,
                              NameDuplicationException
Deprecated. 
Add a return argument to this entity.

Throws:
IllegalActionException - If the argument with the name "return" is not of an acceptable class for the container.
NameDuplicationException - If there is already an argument with the name "return"

argumentsList

public java.util.List argumentsList()
Deprecated. 
Get the arguments belonging to this entity. The order is the order in which they became contained by this entity. This method is read-synchronized on the workspace.

Returns:
An unmodifiable list of Port objects.

attributeChanged

public void attributeChanged(Attribute attribute)
                      throws IllegalActionException
Deprecated. 
If the getDirector() returns something other than null, then invalidate the resolved types.

Overrides:
attributeChanged in class NamedObj
Parameters:
attribute - The attribute that has changed.
Throws:
IllegalActionException - If the parameters are out of range.

clone

public java.lang.Object clone(Workspace workspace)
                       throws java.lang.CloneNotSupportedException
Deprecated. 
Clone the object into the specified workspace. The new object is not added to the directory of that workspace (you must do this yourself if you want it there). The result is a new entity with clones of the ports of the original entity. The ports are set to the ports of the new entity.

Overrides:
clone in class AtomicActor
Parameters:
workspace - The workspace for the cloned object.
Returns:
The new Entity.
Throws:
java.lang.CloneNotSupportedException - If cloned ports cannot have as their container the cloned entity (this should not occur), or if one of the attributes cannot be cloned.
See Also:
NamedObj.exportMoML(Writer, int, String), NamedObj.setDeferringChangeRequests(boolean)

createPorts

public void createPorts()
                 throws IllegalActionException
Deprecated. 
For each Argument, a port of the same name is created, belonging to this argument.

Throws:
IllegalActionException - If there is a problem creating the ports.

fire

public void fire()
          throws IllegalActionException
Deprecated. 
Read the argument of the function from the ports, call the native method throw the generated interface, and put the results on the corresponding ports.

Specified by:
fire in interface Executable
Overrides:
fire in class AtomicActor
Throws:
IllegalActionException - If a exception occured

getArgument

public Argument getArgument(java.lang.String name)
Deprecated. 
Return the argument contained by this entity that has the specified name. If there is no such port, return null. This method is read-synchronized on the workspace.

Parameters:
name - The name of the desired argument.
Returns:
A argument with the given name, or null if none exists.

getArgumentReturn

public Argument getArgumentReturn()
Deprecated. 
Return the argument contained by this entity that is return. If there is no such argument, return null. This method is read-synchronized on the workspace.

Returns:
the argument return, or null if none exists.

initialize

public void initialize()
                throws IllegalActionException
Deprecated. 
Load the generated class and search for its fire method.

Specified by:
initialize in interface Initializable
Overrides:
initialize in class AtomicActor
Throws:
IllegalActionException - If a derived class throws it.

removeAllPorts

public void removeAllPorts()
Deprecated. 
Remove all ports by setting their container to null. As a side effect, the ports will be unlinked from all relations. This method is write-synchronized on the workspace, and increments its version number.

Overrides:
removeAllPorts in class Entity

removeArgument

public void removeArgument(Argument arg)
                    throws IllegalActionException
Deprecated. 
Remove an argument from this entity.

Parameters:
arg - The argument to be removed.
Throws:
IllegalActionException - If there is a problem removing the argument.

updatePorts

public void updatePorts()
                 throws IllegalActionException
Deprecated. 
Update the ports to match the arguments. If an Argument has no corresponding port, a Port is added. If a Port does not have a corresponding Argument, then the Port is removed. If a input and/or output nature of a Port does not match the Argument with the same name, then the Port is adjusted.

Throws:
IllegalActionException - If there is a problem updating the ports.

_addArgument

protected void _addArgument(Argument arg)
                     throws IllegalActionException,
                            NameDuplicationException
Deprecated. 
Add an argument to this entity.

Parameters:
arg - The argument to be added.
Throws:
IllegalActionException - If the argument is not of an acceptable class for the container or the name contains a period.
NameDuplicationException - If there is already an argument with the same name.