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 FormModifier 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, serverHost
SERVER_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.
|
rebindLocalRMIRegistry
clone, exportObject, exportObject, exportObject, unexportObject
public 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.RemoteException
protected void initialize()
public void ping() throws java.rmi.RemoteException
ping
in interface Agent
java.rmi.RemoteException
Agent.ping()
public java.rmi.server.ObjID getAgentID() throws java.rmi.RemoteException
Agent
getAgentID
in interface Agent
java.rmi.RemoteException
Agent.getAgentID()
public java.lang.String getAgentName() throws java.rmi.RemoteException
Agent
getAgentName
in interface Agent
java.rmi.RemoteException
Agent.getAgentName()
public TestRecordData process(java.lang.Object object, TestRecordData testRecordData) throws java.rmi.RemoteException, java.lang.Exception
process
in interface Agent
testRecordData
- 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.RemoteException
java.lang.Exception
Agent.process(Object,TestRecordData)
public void shutdown() throws java.rmi.RemoteException
shutdown
in interface Agent
java.rmi.RemoteException
Agent.shutdown()
public int getTopLevelCount() throws java.rmi.RemoteException, java.lang.Exception
getTopLevelCount
in interface Agent
SAFSActionUnsupportedRuntimeException("TopLevelCount
- Unsupported")java.rmi.RemoteException
java.lang.Exception
Agent.getTopLevelCount()
public java.lang.Object[] getTopLevelWindows() throws java.rmi.RemoteException, java.lang.Exception
getTopLevelWindows
in interface Agent
SAFSActionUnsupportedRuntimeException("TopLevelWindows
- Unsupported")java.rmi.RemoteException
java.lang.Exception
Agent.getTopLevelWindows()
public int getChildCount(java.lang.Object parent) throws java.rmi.RemoteException, java.lang.Exception
getChildCount
in interface Agent
SAFSActionUnsupportedRuntimeException("ChildCount
- Unsupported")java.rmi.RemoteException
java.lang.Exception
Agent.getChildCount(Object)
public java.lang.Object[] getChildren(java.lang.Object parent) throws java.rmi.RemoteException, java.lang.Exception
getChildren
in interface Agent
parent
- 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.RemoteException
java.lang.Exception
Agent.getChildren(Object)
public java.lang.String getCaption(java.lang.Object object) throws java.rmi.RemoteException, java.lang.Exception
getCaption
in interface Agent
object
- 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.RemoteException
java.lang.Exception
Agent.getCaption(Object)
public java.lang.String getName(java.lang.Object object) throws java.rmi.RemoteException, java.lang.Exception
getName
in interface Agent
object
- 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.RemoteException
java.lang.Exception
Agent.getName(Object)
public java.lang.String getID(java.lang.Object object) throws java.rmi.RemoteException, java.lang.Exception
getID
in interface Agent
object
- 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.RemoteException
java.lang.Exception
Agent.getID(Object)
public java.lang.String getText(java.lang.Object object) throws java.rmi.RemoteException, java.lang.Exception
getText
in interface Agent
object
- An object from getTopLevelWindows or from a previous call to getChildren.SAFSActionUnsupportedRuntimeException("Text
- Unsupported")java.rmi.RemoteException
java.lang.Exception
Agent.getText(Object)
public java.lang.String[] getPropertyNames(java.lang.Object object) throws java.rmi.RemoteException, java.lang.Exception
getPropertyNames
in interface Agent
object
- An object from getTopLevelWindows or from a previous call to getChildren.SAFSActionUnsupportedRuntimeException("PropertyNames
- Unsupported")java.rmi.RemoteException
java.lang.Exception
Agent.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 Agent
object
- -- 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.RemoteException
java.lang.Exception
Agent.getProperty(Object, String)
public java.lang.String getClassName(java.lang.Object object) throws java.rmi.RemoteException, java.lang.Exception
getClassName
in interface Agent
object
- An object from getTopLevelWindows or from a previous call to getChildren.SAFSActionUnsupportedRuntimeException("ClassName
- Unsupported")java.rmi.RemoteException
java.lang.Exception
Agent.getClassName(Object)
public int getLevel(java.lang.Object object) throws java.rmi.RemoteException, java.lang.Exception
getLevel
in interface Agent
object
- An object from getTopLevelWindows or from a previous call to getChildren.SAFSActionUnsupportedRuntimeException("Level
- Unsupported")java.rmi.RemoteException
java.lang.Exception
Agent.getLevel(Object)
public boolean isShowing(java.lang.Object object) throws java.rmi.RemoteException, java.lang.Exception
isShowing
in interface Agent
object
- An object from getTopLevelWindows or from a previous call to getChildren.SAFSActionUnsupportedRuntimeException("Showing
- Unsupported")java.rmi.RemoteException
java.lang.Exception
Agent.isShowing(Object)
public boolean isValid(java.lang.Object object) throws java.rmi.RemoteException, java.lang.Exception
isValid
in interface Agent
object
- An object from getTopLevelWindows or from a previous call to getChildren.SAFSActionUnsupportedRuntimeException("Valid
- Unsupported")java.rmi.RemoteException
java.lang.Exception
public java.lang.String[] getSuperClassNames(java.lang.Object object) throws java.rmi.RemoteException, java.lang.Exception
getSuperClassNames
in interface Agent
object
- An object from getTopLevelWindows or from a previous call to getChildren.SAFSActionUnsupportedRuntimeException("SuperClassNames
- Unsupported")java.rmi.RemoteException
java.lang.Exception
Agent.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 Agent
object
- 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.RemoteException
java.lang.Exception
Agent.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 Agent
getMatchingPathObject
in interface SubItemsAgent
theObject--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.RemoteException
java.lang.Exception
Agent.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 Agent
isMatchingPath
in interface SubItemsAgent
theObject--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.RemoteException
java.lang.Exception
org.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 Agent
command
- Object of a type expected by the Client implementation for this method.SAFSActionUnsupportedRuntimeException("runCommand
- Unsupported");java.rmi.RemoteException
java.lang.Exception
Agent.runCommand(Object)
public void setActiveWindow(java.lang.Object theObject) throws java.rmi.RemoteException, java.lang.Exception
setActiveWindow
in interface Agent
theObject
- Object of a type expected by the Client implementation for this method.SAFSActionUnsupportedRuntimeException("ActiveWindow
- Unsupported");java.rmi.RemoteException
java.lang.Exception
public java.lang.Object getSubItemAtIndex(java.lang.Object object, int index) throws java.rmi.RemoteException, java.lang.Exception
getSubItemAtIndex
in interface SubItemsAgent
object
- 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.RemoteException
java.lang.Exception
SubItemsAgent.getSubItemAtIndex(Object,int)
protected static void debugLogSystemProperties()
protected void finalize() throws java.lang.Exception
finalize
in class RemoteRoot
java.lang.Exception
public 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.