Package com.sun.javatest.exec
Class BasicSession
- java.lang.Object
-
- com.sun.javatest.exec.BasicSession
-
- All Implemented Interfaces:
Session,SessionExt
public class BasicSession extends java.lang.Object implements SessionExt
The very classic implementation of Session that encapsulates the WorkDirectory instance and InterviewParameters instance.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBasicSession.E_NewConfigEvent which is delivered when current configuration has been modified.static classBasicSession.E_NewWDEvent which is delivered when WorkDircotry has been set.static interfaceBasicSession.OrderedObserverExtension to the Observer interface for those classes which are sensitive to the order of notifying.static classBasicSession.U_NewConfigClass of update to configuration-
Nested classes/interfaces inherited from interface com.sun.javatest.exec.Session
Session.Event, Session.Fault, Session.Observer, Session.Update
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCONFIG_NAME_PROPprotected java.util.List<java.lang.String>filterNamesList of available filtersprotected java.util.List<Session.Observer>observersList of registered observersprotected java.util.List<java.lang.String>propsList of observable propertiesstatic java.lang.StringWD_PROP
-
Constructor Summary
Constructors Constructor Description BasicSession(TestSuite ts)Creates empty session for the passed test suite.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddObserver(Session.Observer obs)Registers the observer.protected voidapplyWorkDir(WorkDirectory wd)Associates session with the work dir.voiddispose()Disposes configuration.protected TestFilterfindFilter(java.lang.String name)Supposed to be overridden when extra filters addedInterviewParametersgetInterviewParameters()Returns InterviewParameters object, most likely the same object as getParamaters()ParametersgetParameters()Data required to execute tests.java.util.List<java.lang.String>getPropertyNames()Returns the config property namesTestFiltergetTestFilter(java.lang.String name)java.util.List<java.lang.String>getTestFilterNames()java.lang.StringgetValue(java.lang.String name)WorkDirectorygetWorkDirectory()Work directory assigned to the session.protected voidinitFilterList()Creates list of supported filters: ExcludeList, PriorStatus, Keyword, Relevant.protected voidinitPropertyList()Creates list of two session properties: WorkDirectory and Configuration.booleanisReady()voidloadInterviewFromFile(WorkDirectory wd, java.io.File cfgFile)Loads interview from file.voidnotifyObservers(Session.Event evn)Delivers events to the all registered observersvoidreloadInterview()Reloads interview if out of date.voidremoveObserver(Session.Observer obs)Unregisters the observer.voidrestore(java.util.Map<java.lang.String,java.lang.String> map)Restores the config state from the mapvoidsave(java.util.Map<java.lang.String,java.lang.String> map)Saves the config state to the mapvoidupdate(Session.Update u)Applies the update.voidupdate(Session.Update u, boolean updateConfig)Applies the update.protected voidupdateNewConfig(InterviewParameters ip)Method invoked as a reaction on U_NewConfig update.protected voidupdateWorkDir(WorkDirectory wd, boolean doRestoreConfig)Sets the work dir to the new specified value, inovkes applyWorkDir() method, notifies observers of the work dir change.
-
-
-
Field Detail
-
CONFIG_NAME_PROP
public static final java.lang.String CONFIG_NAME_PROP
- See Also:
- Constant Field Values
-
WD_PROP
public static final java.lang.String WD_PROP
- See Also:
- Constant Field Values
-
observers
protected final java.util.List<Session.Observer> observers
List of registered observers
-
filterNames
protected final java.util.List<java.lang.String> filterNames
List of available filters
-
props
protected final java.util.List<java.lang.String> props
List of observable properties
-
-
Constructor Detail
-
BasicSession
public BasicSession(TestSuite ts) throws Session.Fault
Creates empty session for the passed test suite.- Throws:
Session.Fault
-
-
Method Detail
-
update
public void update(Session.Update u) throws Session.Fault
Applies the update. Ignores updates of unknown type. Subclasses need override this method to support more update types.- Specified by:
updatein interfaceSession- Parameters:
u- - object encapsulating data describing the change.- Throws:
Session.Fault
-
update
public void update(Session.Update u, boolean updateConfig) throws Session.Fault
Applies the update. Ignores updates of unknown type. Subclasses need override this method to support more update types.- Specified by:
updatein interfaceSession- Parameters:
u- - object encapsulating data describing the change.updateConfig- - hint whether to reload the configuration from disk- Throws:
Session.Fault- Since:
- 4.4.1
-
addObserver
public void addObserver(Session.Observer obs)
Description copied from interface:SessionRegisters the observer. Does nothing if the observer is null or already registered.- Specified by:
addObserverin interfaceSession- Parameters:
obs- - observer
-
removeObserver
public void removeObserver(Session.Observer obs)
Description copied from interface:SessionUnregisters the observer. Does nothing if the observer is null or not registered.- Specified by:
removeObserverin interfaceSession- Parameters:
obs- - observer
-
notifyObservers
public void notifyObservers(Session.Event evn)
Delivers events to the all registered observers- Specified by:
notifyObserversin interfaceSession- Parameters:
evn- - event to be sent out.
-
getTestFilter
public TestFilter getTestFilter(java.lang.String name)
-
findFilter
protected TestFilter findFilter(java.lang.String name)
Supposed to be overridden when extra filters added- Parameters:
name-- Returns:
- found filter or null, if not found.
-
getTestFilterNames
public java.util.List<java.lang.String> getTestFilterNames()
-
save
public void save(java.util.Map<java.lang.String,java.lang.String> map)
Description copied from interface:SessionSaves the config state to the map
-
restore
public void restore(java.util.Map<java.lang.String,java.lang.String> map) throws Session.FaultDescription copied from interface:SessionRestores the config state from the map- Specified by:
restorein interfaceSession- Throws:
Session.Fault
-
loadInterviewFromFile
public void loadInterviewFromFile(WorkDirectory wd, java.io.File cfgFile) throws Session.Fault
Loads interview from file.- Specified by:
loadInterviewFromFilein interfaceSessionExt- Parameters:
wd-cfgFile-- Throws:
Session.Fault
-
dispose
public void dispose()
Description copied from interface:SessionDisposes configuration. Critical when heavy objects were used.
-
getPropertyNames
public java.util.List<java.lang.String> getPropertyNames()
Description copied from interface:SessionReturns the config property names- Specified by:
getPropertyNamesin interfaceSession- Returns:
- Configuration property name List
-
getValue
public java.lang.String getValue(java.lang.String name)
- Specified by:
getValuein interfaceSession- Returns:
- the value of property or null if unset
- See Also:
Session.getPropertyNames()
-
getWorkDirectory
public WorkDirectory getWorkDirectory()
Work directory assigned to the session.- Specified by:
getWorkDirectoryin interfaceSessionExt- Returns:
- The current wd set.
-
getInterviewParameters
public InterviewParameters getInterviewParameters()
Description copied from interface:SessionExtReturns InterviewParameters object, most likely the same object as getParamaters()According to the original idea there should not be such method in this interface, getParameters() should be enough. But JavaTest is not ready yet to not use InterviewParameters.
- Specified by:
getInterviewParametersin interfaceSessionExt- Returns:
- an instance of InterviewParameters
- See Also:
Session.getParameters()
-
getParameters
public Parameters getParameters()
Description copied from interface:SessionData required to execute tests. In future - should be replaced.- Specified by:
getParametersin interfaceSession- Returns:
- The current parameters in use.
-
isReady
public boolean isReady()
-
initFilterList
protected void initFilterList()
Creates list of supported filters: ExcludeList, PriorStatus, Keyword, Relevant.
-
initPropertyList
protected void initPropertyList()
Creates list of two session properties: WorkDirectory and Configuration.
-
updateWorkDir
protected void updateWorkDir(WorkDirectory wd, boolean doRestoreConfig)
Sets the work dir to the new specified value, inovkes applyWorkDir() method, notifies observers of the work dir change.It's not recommended to override this method.
- Parameters:
wd- - instance of WorkDirectorydoRestoreConfig- - flag to be passed via Event signaling whether restoring configuration from wd is required
-
applyWorkDir
protected void applyWorkDir(WorkDirectory wd)
Associates session with the work dir. To be overridden when wd should be applied not only to session, but template or other properties.
-
updateNewConfig
protected void updateNewConfig(InterviewParameters ip) throws Session.Fault
Method invoked as a reaction on U_NewConfig update. Checks if there are any changes in the update, if none - does nothing, Otherwise, copies new values into the main configuration instance, notifies observers with E_NewConfig event.- Throws:
Session.Fault
-
reloadInterview
public void reloadInterview() throws Session.FaultReloads interview if out of date.- Specified by:
reloadInterviewin interfaceSessionExt- Throws:
Session.Fault
-
-