public class AgentImpl extends RemoteRoot implements Agent, SubItemsAgent
To insert this class via the AgentClassLoader the following minimum settings must appear in the safsjvmagent.properties file:
safsjvmagent.properties:
To seek a remote SAFS RMI Server the System Property 'sas.server.hostname' must be set and contain the hostname of the machine expected to contain the RMI Server.
Because this is an RMI implementation, an additional Java rmic build process is necessary prior to creating the JAR file containing all classes. The Java rmic program creates the Skeletons and Stubs needed by Java RMI.
Execute Java rmic from the root directory of the Java project:
rmic -d . org.safs.rmi.engine.AgentImpl
Minimum java.policy permissions needed for successful execution:
// Allow RMI server objects to receive requests on this machine on port 1024 or higher.
permission java.net.SocketPermission "*:1024-", "connect,accept,resolve";
permission java.lang.RuntimePermission "shutdownHooks";
Agent,
Server,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
protected class |
AgentImpl.ServerMonitor
Polls the server host for a Java Registry every few seconds until one with the proper
server object is found.
|
protected class |
AgentImpl.STAFMonitor
Polls for the existence of STAF every few seconds until found.
|
RemoteRoot.ShutdownHook| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_RMI_AGENT
'Agent':Subclasses will override to provide unique Agent remoteType.
|
static java.lang.String |
DEFAULT_RMI_SERVER |
protected AgentImpl.ServerMonitor |
monitor |
protected boolean |
no_staf |
protected java.rmi.server.ObjID |
objID |
protected Server |
server |
protected java.lang.String |
serverName
Subclasses will override to seek out different RMI Server Objects.
|
protected boolean |
shutdown |
protected STAFHelper |
stafHelper |
protected AgentImpl.STAFMonitor |
stafmonitor |
protected boolean |
stafshutdown |
DEFAULT_RMI_SERVER_HOST, remoteType, serverHostSERVER_HOSTNAME_SYSTEM_PROPERTY| Constructor and Description |
|---|
AgentImpl()
Constructor for AgentImpl.
|
| Modifier and Type | Method and Description |
|---|---|
protected static void |
debugLogSystemProperties()
Log.debug all available Java System Properties.
|
protected void |
finalize()
If we have registered with a RMI Server object then unRegister with that object.
|
java.rmi.server.ObjID |
getAgentID()
Returns an ObjID to uniquely identify the JVM Agent.
|
java.lang.String |
getAgentName()
Returns the name or remoteType of the JVM Agent.
|
java.lang.String |
getCaption(java.lang.Object object)
Default implementation throws SAFSActionUnsupportedRuntimeException("Caption Unsupported").
|
int |
getChildCount(java.lang.Object parent)
Default implementation simply throws SAFSActionUnsupportedRuntimeException("ChildCount Unsupported").
|
java.lang.Object[] |
getChildren(java.lang.Object parent)
Default implementation simply throws SAFSActionUnsupportedRuntimeException("Children Unsupported").
|
java.lang.String |
getClassName(java.lang.Object object)
Default implementation throws SAFSActionUnsupportedRuntimeException("ClassName Unsupported").
|
java.lang.String |
getID(java.lang.Object object)
Default implementation throws SAFSActionUnsupportedRuntimeException("ID Unsupported").
|
int |
getLevel(java.lang.Object object)
Default implementation throws SAFSActionUnsupportedRuntimeException("Levelv").
|
java.lang.Object |
getMatchingPathObject(java.lang.Object theObject,
java.lang.String thePath)
Mechanism to retrieve a subitem/object identified
by the provided Path.
|
java.lang.String |
getName(java.lang.Object object)
Default implementation throws SAFSActionUnsupportedRuntimeException("Name Unsupported").
|
java.lang.String |
getProperty(java.lang.Object object,
java.lang.String property)
Default implementation throws SAFSActionUnsupportedRuntimeException("Property Unsupported").
|
java.lang.String[] |
getPropertyNames(java.lang.Object object)
Default implementation throws SAFSActionUnsupportedRuntimeException("PropertyNames Unsupported").
|
java.lang.String[][] |
getStringData(java.lang.Object object,
java.lang.Object dataInfo)
Default implementation throws SAFSActionUnsupportedRuntimeException("StringData Unsupported").
|
java.lang.Object |
getSubItemAtIndex(java.lang.Object object,
int index)
Default no-op simply throws SAFSSubItemsAgentUnsupportedRuntimeException("SubItemAtIndex Unsupported").
|
java.lang.String[] |
getSuperClassNames(java.lang.Object object)
Default implementation throws SAFSActionUnsupportedRuntimeException("SuperClassNames Unsupported").
|
java.lang.String |
getText(java.lang.Object object)
Default implementation throws SAFSActionUnsupportedRuntimeException("Text Unsupported").
|
int |
getTopLevelCount()
Default implementation simply throws SAFSActionUnsupportedRuntimeException("TopLevelCount Unsupported").
|
java.lang.Object[] |
getTopLevelWindows()
Default implementation simply throws SAFSActionUnsupportedRuntimeException("TopLevelWindows Unsupported").
|
protected void |
initialize()
MUST be called by subclasses after object creation
|
boolean |
isMatchingPath(java.lang.Object theObject,
java.lang.String thePath)
Mechanism to determine if the object contains a subitem/object identified
by the provided Path.
|
boolean |
isShowing(java.lang.Object object)
Default implementation throws SAFSActionUnsupportedRuntimeException("Showing Unsupported").
|
boolean |
isValid(java.lang.Object object)
Default implementation throws SAFSActionUnsupportedRuntimeException("Valid Unsupported").
|
static void |
main(java.lang.String[] args)
Primarily just a test instantiation to seek an RMI server.
|
void |
ping()
Does nothing but verify the integrity of the RMI connection and log entry.
|
TestRecordData |
process(java.lang.Object object,
TestRecordData testRecordData)
Default implementation simply throws a SAFSActionUnsupportedRuntimeException("process Unsupported").
|
java.lang.Object |
runCommand(java.lang.Object command)
Default implementation throws SAFSActionUnsupportedRuntimeException("runCommand Unsupported").
|
void |
setActiveWindow(java.lang.Object theObject)
Attempts to set theObject as the active (topmost?) Window or Component in the JVM.
|
void |
shutdown()
Removes any RMI server reference we might already have and restarts a new
ServerMonitor to watch for a new RMI server object.
|
rebindLocalRMIRegistryclone, exportObject, exportObject, exportObject, unexportObjectpublic static final java.lang.String DEFAULT_RMI_SERVER
public static final java.lang.String DEFAULT_RMI_AGENT
protected java.lang.String serverName
protected Server server
protected boolean shutdown
protected boolean stafshutdown
protected AgentImpl.ServerMonitor monitor
protected AgentImpl.STAFMonitor stafmonitor
protected java.rmi.server.ObjID objID
protected boolean no_staf
protected STAFHelper stafHelper
public AgentImpl()
throws java.rmi.RemoteException
Some web browsers launching a JVM may allow us to register a shutdown hook but may not actually execute the hook upon JVM shutdown.
java.rmi.RemoteExceptionprotected void initialize()
public void ping()
throws java.rmi.RemoteException
ping in interface Agentjava.rmi.RemoteExceptionAgent.ping()public java.rmi.server.ObjID getAgentID()
throws java.rmi.RemoteException
AgentgetAgentID in interface Agentjava.rmi.RemoteExceptionAgent.getAgentID()public java.lang.String getAgentName()
throws java.rmi.RemoteException
AgentgetAgentName in interface Agentjava.rmi.RemoteExceptionAgent.getAgentName()public TestRecordData process(java.lang.Object object, TestRecordData testRecordData) throws java.rmi.RemoteException, java.lang.Exception
process in interface AgenttestRecordData - provides all the information needed by the Agent to perform an action.
The RMI version of TestRecordData is likely going to be much sparser than the
typical TestRecordHelper. It will also be pretty specific to the concrete
implementations for the Server and Agent.SAFSActionUnsupportedRuntimeException("process - Unsupported")java.rmi.RemoteExceptionjava.lang.ExceptionAgent.process(Object,TestRecordData)public void shutdown()
throws java.rmi.RemoteException
shutdown in interface Agentjava.rmi.RemoteExceptionAgent.shutdown()public int getTopLevelCount()
throws java.rmi.RemoteException,
java.lang.Exception
getTopLevelCount in interface AgentSAFSActionUnsupportedRuntimeException("TopLevelCount - Unsupported")java.rmi.RemoteExceptionjava.lang.ExceptionAgent.getTopLevelCount()public java.lang.Object[] getTopLevelWindows()
throws java.rmi.RemoteException,
java.lang.Exception
getTopLevelWindows in interface AgentSAFSActionUnsupportedRuntimeException("TopLevelWindows - Unsupported")java.rmi.RemoteExceptionjava.lang.ExceptionAgent.getTopLevelWindows()public int getChildCount(java.lang.Object parent)
throws java.rmi.RemoteException,
java.lang.Exception
getChildCount in interface AgentSAFSActionUnsupportedRuntimeException("ChildCount - Unsupported")java.rmi.RemoteExceptionjava.lang.ExceptionAgent.getChildCount(Object)public java.lang.Object[] getChildren(java.lang.Object parent)
throws java.rmi.RemoteException,
java.lang.Exception
getChildren in interface Agentparent - An object from getTopLevelWindows or from a previous call to getChildren.
The parent is often one of the elements of the TopLevelWindow array or somewhere
lower in that same hierarchy.SAFSActionUnsupportedRuntimeException("Children - Unsupported")java.rmi.RemoteExceptionjava.lang.ExceptionAgent.getChildren(Object)public java.lang.String getCaption(java.lang.Object object)
throws java.rmi.RemoteException,
java.lang.Exception
getCaption in interface Agentobject - An object from getTopLevelWindows or from a previous call to getChildren.SAFSActionUnsupportedRuntimeException("Caption - Unsupported")java.lang.NoSuchFieldException - if the object does not provide a caption.java.rmi.RemoteExceptionjava.lang.ExceptionAgent.getCaption(Object)public java.lang.String getName(java.lang.Object object)
throws java.rmi.RemoteException,
java.lang.Exception
getName in interface Agentobject - An object from getTopLevelWindows or from a previous call to getChildren.SAFSActionUnsupportedRuntimeException("Name - Unsupported")java.lang.NoSuchFieldException - if the object does not provide a name.java.rmi.RemoteExceptionjava.lang.ExceptionAgent.getName(Object)public java.lang.String getID(java.lang.Object object)
throws java.rmi.RemoteException,
java.lang.Exception
getID in interface Agentobject - An object from getTopLevelWindows or from a previous call to getChildren.SAFSActionUnsupportedRuntimeException("ID - Unsupported")java.lang.NoSuchFieldException - if the object does not provide an ID.java.rmi.RemoteExceptionjava.lang.ExceptionAgent.getID(Object)public java.lang.String getText(java.lang.Object object)
throws java.rmi.RemoteException,
java.lang.Exception
getText in interface Agentobject - An object from getTopLevelWindows or from a previous call to getChildren.SAFSActionUnsupportedRuntimeException("Text - Unsupported")java.rmi.RemoteExceptionjava.lang.ExceptionAgent.getText(Object)public java.lang.String[] getPropertyNames(java.lang.Object object)
throws java.rmi.RemoteException,
java.lang.Exception
getPropertyNames in interface Agentobject - An object from getTopLevelWindows or from a previous call to getChildren.SAFSActionUnsupportedRuntimeException("PropertyNames - Unsupported")java.rmi.RemoteExceptionjava.lang.ExceptionAgent.getProperty(Object, String)public java.lang.String getProperty(java.lang.Object object,
java.lang.String property)
throws java.rmi.RemoteException,
java.lang.Exception
getProperty in interface Agentobject - -- An object from getTopLevelWindows or from a previous call to getChildren.property - -- the case-sensitive name of the property to seek.SAFSActionUnsupportedRuntimeException("Property - Unsupported")java.rmi.RemoteExceptionjava.lang.ExceptionAgent.getProperty(Object, String)public java.lang.String getClassName(java.lang.Object object)
throws java.rmi.RemoteException,
java.lang.Exception
getClassName in interface Agentobject - An object from getTopLevelWindows or from a previous call to getChildren.SAFSActionUnsupportedRuntimeException("ClassName - Unsupported")java.rmi.RemoteExceptionjava.lang.ExceptionAgent.getClassName(Object)public int getLevel(java.lang.Object object)
throws java.rmi.RemoteException,
java.lang.Exception
getLevel in interface Agentobject - An object from getTopLevelWindows or from a previous call to getChildren.SAFSActionUnsupportedRuntimeException("Level - Unsupported")java.rmi.RemoteExceptionjava.lang.ExceptionAgent.getLevel(Object)public boolean isShowing(java.lang.Object object)
throws java.rmi.RemoteException,
java.lang.Exception
isShowing in interface Agentobject - An object from getTopLevelWindows or from a previous call to getChildren.SAFSActionUnsupportedRuntimeException("Showing - Unsupported")java.rmi.RemoteExceptionjava.lang.ExceptionAgent.isShowing(Object)public boolean isValid(java.lang.Object object)
throws java.rmi.RemoteException,
java.lang.Exception
isValid in interface Agentobject - An object from getTopLevelWindows or from a previous call to getChildren.SAFSActionUnsupportedRuntimeException("Valid - Unsupported")java.rmi.RemoteExceptionjava.lang.Exceptionpublic java.lang.String[] getSuperClassNames(java.lang.Object object)
throws java.rmi.RemoteException,
java.lang.Exception
getSuperClassNames in interface Agentobject - An object from getTopLevelWindows or from a previous call to getChildren.SAFSActionUnsupportedRuntimeException("SuperClassNames - Unsupported")java.rmi.RemoteExceptionjava.lang.ExceptionAgent.getSuperClassNames(Object)public java.lang.String[][] getStringData(java.lang.Object object,
java.lang.Object dataInfo)
throws java.rmi.RemoteException,
java.lang.NoSuchMethodException,
java.lang.Exception
getStringData in interface Agentobject - An object from getTopLevelWindows or from a previous call to getChildren.dataInfo - Allows us to specify what type of data we want returned. This will be
specific to the types of objects from which we extract data. For example, Tables might
provide "Contents" or "Headers" or other different types of data.SAFSActionUnsupportedRuntimeException("StringData - Unsupported")java.lang.NoSuchMethodException - if the object type does not support the extraction of data
or the specific type of data requested.java.rmi.RemoteExceptionjava.lang.ExceptionAgent.getStringData(Object, Object)public java.lang.Object getMatchingPathObject(java.lang.Object theObject,
java.lang.String thePath)
throws java.rmi.RemoteException,
java.lang.Exception
Ex:
File->Exit
Root->Branch->Leaf
Default implementation throws SAFSSubItemsAgentUnsupportedRuntimeException("MatchingPathObject Unsupported").
getMatchingPathObject in interface AgentgetMatchingPathObject in interface SubItemsAgenttheObject--Object - proxy for the object to be evaluated.thePath - information to locate another object or subitem relative to theObject.
this is usually something like a menuitem or tree node where supported.SAFSSubItemsAgentUnsupportedRuntimeException("MatchingPathObject - Unsupported")java.rmi.RemoteExceptionjava.lang.ExceptionAgent.getMatchingPathObject(Object, String)public boolean isMatchingPath(java.lang.Object theObject,
java.lang.String thePath)
throws java.rmi.RemoteException,
java.lang.Exception
Ex:
File->Exit
Root->Branch->Leaf
Default implementation throws SAFSSubItemsAgentUnsupportedRuntimeException("MatchingPath Unsupported").
isMatchingPath in interface AgentisMatchingPath in interface SubItemsAgenttheObject--Object - proxy for the object to be evaluated.thePath - information to locate another object or subitem relative to theObject.
this is usually something like a menuitem or tree node where supported.SAFSSubItemsAgentUnsupportedRuntimeException("MatchingPath - Unsupported")java.rmi.RemoteExceptionjava.lang.Exceptionorg.safs.rmi.engine.Agent#getMatchingPath(Object, String)public java.lang.Object runCommand(java.lang.Object command)
throws java.rmi.RemoteException,
java.lang.Exception
runCommand in interface Agentcommand - Object of a type expected by the Client implementation for this method.SAFSActionUnsupportedRuntimeException("runCommand - Unsupported");java.rmi.RemoteExceptionjava.lang.ExceptionAgent.runCommand(Object)public void setActiveWindow(java.lang.Object theObject)
throws java.rmi.RemoteException,
java.lang.Exception
setActiveWindow in interface AgenttheObject - Object of a type expected by the Client implementation for this method.SAFSActionUnsupportedRuntimeException("ActiveWindow - Unsupported");java.rmi.RemoteExceptionjava.lang.Exceptionpublic java.lang.Object getSubItemAtIndex(java.lang.Object object,
int index)
throws java.rmi.RemoteException,
java.lang.Exception
getSubItemAtIndex in interface SubItemsAgentobject - reference from which to locate the subitem.index - of the subitem to retrieve.java.lang.IndexOutOfBoundsException - if index is invalidSAFSObjectNotFoundException - if subitem at index cannot be retrievedSAFSSubItemsAgentUnsupportedRuntimeException("SubItemAtIndex - Unsupported") as necessay.java.rmi.RemoteExceptionjava.lang.ExceptionSubItemsAgent.getSubItemAtIndex(Object,int)protected static void debugLogSystemProperties()
protected void finalize()
throws java.lang.Exception
finalize in class RemoteRootjava.lang.Exceptionpublic static void main(java.lang.String[] args)
java -cp %CLASSPATH% -Djava.security.policy=%SAFSDIR%\lib\java.policy
-Dsafs.server.hostname="hostname.internal.net"
org.safs.rmi.engine.AgentImpl
args - -- noneCopyright © SAS Institute. All Rights Reserved.