public class ServerImpl extends RemoteRoot implements Server, LocalServer, LocalSubItemsAgent
The server communicates with remote Agents on the local machine acting as Java Enablers. The security policy for the JVM running this RMI server may need the additional permissions specified in:
SAFS\lib\java.policy
Normally this RMI Server would be instanced in a JVM we control -- like the TID or a SAFS Engine. Thus, these settings do not impact any AUT security policy since the AUT is running in a different JVM.
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.ServerImpl
Note: For consistent operation the java.rmi.server.hostname
needs to be set in code or
on the command line before launching an RMI Server:
System.setProperty("java.rmi.server.hostname", "<rmi server ip>");
-Djava.rmi.server.hostname=<rmi server ip>
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"; permission java.util.PropertyPermission "safs.*", "write,read"; permission java.util.PropertyPermission "java.rmi.server.hostname", "write,read";
RemoteRoot.ShutdownHook
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_RMI_SERVER
'SAFS/RMIEngineServer'
|
protected java.lang.String |
serverName
Name of Server object in rmi Naming registry.
|
DEFAULT_RMI_SERVER_HOST, PROPERTY_REGISTRY_PORT, PROPERTY_SERVER_PORT, registryPort, remoteType, serverHost
JAVA_RMI_SERVER_HOSTNAME_PROPERTY, SERVER_SYSTEM_PROPERTY
Constructor and Description |
---|
ServerImpl()
Constructor for ServerImpl.
|
Modifier and Type | Method and Description |
---|---|
protected void |
finalize()
Remove this server object from the RMI registry.
|
java.lang.String |
getCaption(java.lang.Object object)
Retrieve the Caption of the object if one exits.
|
int |
getChildCount(java.lang.Object parent)
Return the number of children available in the remote parent (AgentWindow).
|
java.lang.Object[] |
getChildren(java.lang.Object parent)
Return an array representing the children of the provided parent AgentWindow.
|
java.lang.String |
getClassName(java.lang.Object object)
Return the Class name of the object.
|
java.lang.String |
getID(java.lang.Object object)
Retrieve the ID of the object if the object has an ID.
|
int |
getLevel(java.lang.Object object)
Return the Z-Order level of the object (generally for a top level window).
|
java.lang.Object |
getMatchingPathObject(java.lang.Object object,
java.lang.String path)
Mechanism to retrieve a subitem/object identified
by the provided Path.
|
java.lang.String |
getName(java.lang.Object object)
Retrieve the name of the object if the object is named.
|
java.lang.String |
getProperty(java.lang.Object object,
java.lang.String property)
Retrieve the property value of the object if the object has the property.
|
java.lang.String[] |
getPropertyNames(java.lang.Object object)
Retrieve the list of available properties for the object.
|
java.lang.String[][] |
getStringData(java.lang.Object object,
java.lang.Object dataInfo)
Return whatever data is extractable (normally visible) from the object.
|
java.lang.Object |
getSubItemAtIndex(java.lang.Object object,
int index)
Return the subitem at the specified index from the given object.
|
java.lang.String[] |
getSuperClassNames(java.lang.Object object)
Return the array of all superclass names for the object.
|
java.lang.String |
getText(java.lang.Object object)
Retrieve the displayed text value of the object if the object has a text value.
|
int |
getTopLevelCount()
Return the number of currently active Top Level Windows from
all known Agents.
|
java.lang.Object[] |
getTopLevelWindows()
Return an AgentWindow array representing the TopLevel windows from all known Agents.
|
boolean |
isMatchingPath(java.lang.Object object,
java.lang.String path)
Mechanism to determine if the object contains a subitem/object identified
by the provided Path.
|
boolean |
isShowing(java.lang.Object object)
Return true if the object is showing/visible.
|
boolean |
isValid(java.lang.Object object)
Return true if the object is still valid/finadable in the Remote JVM.
|
static void |
main(java.lang.String[] args)
Primarily a test entry point.
|
protected void |
pingAgents()
Simple routine to ping each registered agent to see if it is actually still there.
|
TestRecordData |
process(java.lang.Object object,
TestRecordData testRecordData)
Process the action provided in the testRecordData.
|
void |
register(Agent anAgent)
A JVM Agent will register with the RMI Server after it has become available in
the RMI Naming registry.
|
java.lang.Object |
runCommand(java.lang.Object command)
Default implementation throws SAFSActionUnsupportedRuntimeException("runCommand Unsupported").
|
void |
setActiveWindow(java.lang.Object object)
Make the provided object the "active" object or window (bring it forward).
|
void |
unRegister(Agent anAgent)
Uses a separate Thread to unRegister the Agent and perform other internal checks after
the Agent is unregistered.
|
init, rebindLocalRMIRegistry
clone, exportObject, exportObject, exportObject, unexportObject
public static final java.lang.String DEFAULT_RMI_SERVER
protected java.lang.String serverName
public ServerImpl() throws java.rmi.RemoteException
java.rmi.RemoteException
public void register(Agent anAgent) throws java.rmi.RemoteException
Server
Registering with the Server makes that remote JVM available for testing through the controlling SAFS Engine.
register
in interface Server
java.rmi.RemoteException
Server.register(Agent)
public void unRegister(Agent anAgent) throws java.rmi.RemoteException
unRegister
in interface Server
java.rmi.RemoteException
Server.unRegister(Agent)
protected void pingAgents()
public int getTopLevelCount()
getTopLevelCount
in interface LocalServer
LocalServer.getTopLevelCount()
public java.lang.Object[] getTopLevelWindows()
getTopLevelWindows
in interface LocalServer
LocalServer.getTopLevelWindows()
public int getChildCount(java.lang.Object parent)
getChildCount
in interface LocalAgent
SAFSObjectNotFoundRuntimeException("Invalid
- parent") if the provided parent cannot be located.SAFSActionErrorRuntimeException(x.getMessage(),
- x) if an unexpected Exception is thrown fromLocalAgent.getChildCount(Object)
public java.lang.Object[] getChildren(java.lang.Object parent)
getChildren
in interface LocalAgent
parent
- An object (AgentWindow) 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.SAFSObjectNotFoundRuntimeException("Invalid
- parent") if the provided parent cannot be located.SAFSActionErrorRuntimeException(x.getMessage(),
- x) if an unexpected Exception is thrown fromLocalAgent.getChildren(Object)
public void setActiveWindow(java.lang.Object object)
setActiveWindow
in interface LocalServer
object
- An object from getTopLevelWindows or from a previous call to getChildren.SAFSObjectNotFoundRuntimeException("Invalid
- object") if the provided parent cannot be located.SAFSActionErrorRuntimeException(x.getMessage(),
- x) if an unexpected Exception is thrown frompublic java.lang.String getClassName(java.lang.Object object)
getClassName
in interface LocalAgent
object
- An object from getTopLevelWindows or from a previous call to getChildren.SAFSObjectNotFoundRuntimeException("Invalid
- object") if the provided parent cannot be located.SAFSActionErrorRuntimeException(x.getMessage(),
- x) if an unexpected Exception is thrown fromLocalAgent.getClassName(Object)
public java.lang.String[] getSuperClassNames(java.lang.Object object)
getSuperClassNames
in interface LocalAgent
object
- An object from getTopLevelWindows or from a previous call to getChildren.SAFSObjectNotFoundRuntimeException("Invalid
- object") if the provided parent cannot be located.SAFSActionErrorRuntimeException(x.getMessage(),
- x) if an unexpected Exception is thrown fromLocalAgent.getSuperClassNames(Object)
public java.lang.String[] getPropertyNames(java.lang.Object object)
getPropertyNames
in interface LocalAgent
object
- An object from getTopLevelWindows or from a previous call to getChildren.SAFSObjectNotFoundRuntimeException("Invalid
- object") if the provided parent cannot be located.SAFSActionErrorRuntimeException(x.getMessage(),
- x) if an unexpected Exception is thrown fromLocalAgent.getPropertyNames(Object)
public java.lang.String getProperty(java.lang.Object object, java.lang.String property)
getProperty
in interface LocalAgent
object
- -- An object from getTopLevelWindows or from a previous call to getChildren.property
- -- the case-sensitive name of the property to seek.SAFSObjectNotFoundRuntimeException("Invalid
- object") if the provided parent cannot be located.SAFSInvalidActionArgumentRuntimeException(property)
SAFSActionErrorRuntimeException(x.getMessage(),
- x) if an unexpected Exception is thrown fromLocalAgent.getProperty(Object,String)
public java.lang.String getCaption(java.lang.Object object)
getCaption
in interface LocalAgent
object
- An object from getTopLevelWindows or from a previous call to getChildren.SAFSObjectNotFoundRuntimeException("Invalid
- object") if the provided parent cannot be located.SAFSActionUnsupportedRuntimeException("Caption
- Unsupported") if the object does not provide a caption.SAFSActionErrorRuntimeException(x.getMessage(),
- x) if an unexpected Exception is thrown fromLocalAgent.getCaption(Object)
public java.lang.String getName(java.lang.Object object)
getName
in interface LocalAgent
object
- An object from getTopLevelWindows or from a previous call to getChildren.SAFSObjectNotFoundRuntimeException("Invalid
- object") if the provided parent cannot be located.SAFSActionUnsupportedRuntimeException("Name
- Unsupported") if the object does not provide a caption.SAFSActionErrorRuntimeException(x.getMessage(),
- x) if an unexpected Exception is thrown fromLocalAgent.getName(Object)
public java.lang.String getID(java.lang.Object object)
getID
in interface LocalAgent
object
- An object from getTopLevelWindows or from a previous call to getChildren.SAFSObjectNotFoundRuntimeException("Invalid
- object") if the provided parent cannot be located.SAFSActionUnsupportedRuntimeException("ID
- Unsupported") if the object does not provide a caption.SAFSActionErrorRuntimeException(x.getMessage(),
- x) if an unexpected Exception is thrown fromLocalAgent.getID(Object)
public java.lang.String getText(java.lang.Object object)
getText
in interface LocalAgent
object
- An object from getTopLevelWindows or from a previous call to getChildren.SAFSObjectNotFoundRuntimeException("Invalid
- object") if the provided parent cannot be located.SAFSActionUnsupportedRuntimeException("Text
- Unsupported") if the object does not provide a caption.SAFSActionErrorRuntimeException(x.getMessage(),
- x) if an unexpected Exception is thrown fromLocalAgent.getText(Object)
public int getLevel(java.lang.Object object)
getLevel
in interface LocalAgent
object
- An object from getTopLevelWindows or from a previous call to getChildren.SAFSObjectNotFoundRuntimeException("Invalid
- object") if the provided parent cannot be located.SAFSActionUnsupportedRuntimeException("Level
- Unsupported") if the level cannot be determined.SAFSActionErrorRuntimeException
- if an unexpected (design?) problem occurs.LocalAgent.getLevel(Object)
public boolean isShowing(java.lang.Object object)
isShowing
in interface LocalAgent
object
- An object from getTopLevelWindows or from a previous call to getChildren.SAFSObjectNotFoundRuntimeException("Invalid
- object") if the provided parent cannot be located.SAFSActionUnsupportedRuntimeException("Showing
- Unsupported") if the level cannot be determined.SAFSActionErrorRuntimeException
- if an unexpected (design?) problem occurs.LocalAgent.isShowing(Object)
public boolean isValid(java.lang.Object object)
isValid
in interface LocalAgent
object
- An object from getTopLevelWindows or from a previous call to getChildren.SAFSActionErrorRuntimeException
- if an unexpected (design?) problem occurs.LocalAgent.isValid(Object)
public java.lang.String[][] getStringData(java.lang.Object object, java.lang.Object dataInfo)
getStringData
in interface LocalAgent
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.SAFSObjectNotFoundRuntimeException("Invalid
- object") if the provided parent cannot be located.SAFSActionUnsupportedRuntimeException("StringData
- Unsupported") if action is not supported.SAFSInvalidActionArgumentRuntimeException(dataInfo)
- if specified dataInfo is not supported.SAFSActionErrorRuntimeException
- if an unexpected (design?) problem occurs.LocalAgent.getStringData(Object,Object)
public TestRecordData process(java.lang.Object object, TestRecordData testRecordData)
process
in interface LocalAgent
object
- must be serializable.testRecordData
- provides all the information needed by the Agent to perform the action. This must
be a serializable version of testRecordData.SAFSObjectNotFoundRuntimeException("Invalid
- object") if the provided parent cannot be located.SAFSRuntimeException
- subclasses from the various Agents.SAFSActionErrorRuntimeException
- if an unexpected (design?) problem occurs.public java.lang.Object getSubItemAtIndex(java.lang.Object object, int index) throws java.lang.Exception
LocalSubItemsAgent
getSubItemAtIndex
in interface LocalSubItemsAgent
object
- reference AgentWindow from which to locate the subitem.index
- of the subitem to retrieve.SAFSObjectNotFoundRuntimeException("Invalid
- object") if the provided parent cannot be located.SAFSSubItemsAgentUnsupportedRuntimeException
- as necessay.java.lang.IndexOutOfBoundsException
- if index is invalidSAFSObjectNotFoundException("Invalid
- SubItem") if subitem at index cannot be retrieved.SAFSActionErrorRuntimeException
- if an unexpected (design?) problem occurs.java.lang.Exception
SubItemsAgent.getSubItemAtIndex(Object,int)
public java.lang.Object getMatchingPathObject(java.lang.Object object, java.lang.String path)
Ex:
File->Exit
Root->Branch->Leaf
getMatchingPathObject
in interface LocalAgent
getMatchingPathObject
in interface LocalSubItemsAgent
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.SAFSObjectNotFoundRuntimeException("Invalid
- object") if the provided parent cannot be located.SAFSSubItemsAgentUnsupportedRuntimeException
- as necessay.SAFSObjectNotFoundException("Invalid
- SubItem") if subitem at index cannot be retrieved.SAFSActionErrorRuntimeException
- if an unexpected (design?) problem occurs.LocalAgent.getMatchingPathObject(Object,String)
public boolean isMatchingPath(java.lang.Object object, java.lang.String path)
Ex:
File->Exit
Root->Branch->Leaf
isMatchingPath
in interface LocalAgent
isMatchingPath
in interface LocalSubItemsAgent
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.SAFSObjectNotFoundRuntimeException("Invalid
- object") if the provided parent cannot be located.SAFSSubItemsAgentUnsupportedRuntimeException
- as necessay.SAFSActionErrorRuntimeException
- if an unexpected (design?) problem occurs.LocalAgent.isMatchingPath(Object,String)
public java.lang.Object runCommand(java.lang.Object command) throws java.rmi.RemoteException, java.lang.Exception
runCommand
in interface Server
command
- Object of a type expected by the Server implementation for this method.SAFSActionUnsupportedRuntimeException("runCommand
- Unsupported");java.rmi.RemoteException
java.lang.Exception
Server.runCommand(Object)
protected void finalize() throws java.lang.Exception
finalize
in class RemoteRoot
java.lang.Exception
public static void main(java.lang.String[] args) throws java.lang.Exception
Example command-line invocation:
java -cp %CLASSPATH% -Djava.security.policy=%SAFSDIR%\lib\java.policy
-Djava.rmi.server.hostname="thishost.internal.net"
org.safs.rmi.engine.ServerImpl
args
- -- nonejava.lang.Exception
Copyright © SAS Institute. All Rights Reserved.