Class BasicSession

java.lang.Object
com.sun.javatest.exec.BasicSession
All Implemented Interfaces:
Session, SessionExt

public class BasicSession extends Object implements SessionExt
The very classic implementation of Session that encapsulates the WorkDirectory instance and InterviewParameters instance.
  • Field Details

  • Constructor Details

  • Method Details

    • 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:
      update in interface Session
      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:
      update in interface Session
      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: Session
      Registers the observer. Does nothing if the observer is null or already registered.
      Specified by:
      addObserver in interface Session
      Parameters:
      obs - - observer
    • removeObserver

      public void removeObserver(Session.Observer obs)
      Description copied from interface: Session
      Unregisters the observer. Does nothing if the observer is null or not registered.
      Specified by:
      removeObserver in interface Session
      Parameters:
      obs - - observer
    • notifyObservers

      public void notifyObservers(Session.Event evn)
      Delivers events to the all registered observers
      Specified by:
      notifyObservers in interface Session
      Parameters:
      evn - - event to be sent out.
    • getTestFilter

      public TestFilter getTestFilter(String name)
    • findFilter

      protected TestFilter findFilter(String name)
      Supposed to be overridden when extra filters added
      Parameters:
      name -
      Returns:
      found filter or null, if not found.
    • getTestFilterNames

      public List<String> getTestFilterNames()
    • save

      public void save(Map<String,String> map)
      Description copied from interface: Session
      Saves the config state to the map
      Specified by:
      save in interface Session
    • restore

      public void restore(Map<String,String> map) throws Session.Fault
      Description copied from interface: Session
      Restores the config state from the map
      Specified by:
      restore in interface Session
      Parameters:
      map -
      Throws:
      Session.Fault
    • loadInterviewFromFile

      public void loadInterviewFromFile(WorkDirectory wd, File cfgFile) throws Session.Fault
      Loads interview from file.
      Specified by:
      loadInterviewFromFile in interface SessionExt
      Parameters:
      wd -
      cfgFile -
      Throws:
      Session.Fault
    • dispose

      public void dispose()
      Description copied from interface: Session
      Disposes configuration. Critical when heavy objects were used.
      Specified by:
      dispose in interface Session
    • getPropertyNames

      public List<String> getPropertyNames()
      Description copied from interface: Session
      Returns the config property names
      Specified by:
      getPropertyNames in interface Session
      Returns:
      Configuration property name List
    • getValue

      public String getValue(String name)
      Specified by:
      getValue in interface Session
      Returns:
      the value of property or null if unset
      See Also:
    • getWorkDirectory

      public WorkDirectory getWorkDirectory()
      Work directory assigned to the session.
      Specified by:
      getWorkDirectory in interface SessionExt
      Returns:
      The current wd set.
    • getInterviewParameters

      public InterviewParameters getInterviewParameters()
      Description copied from interface: SessionExt
      Returns 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:
      getInterviewParameters in interface SessionExt
      Returns:
      an instance of InterviewParameters
      See Also:
    • getParameters

      public Parameters getParameters()
      Description copied from interface: Session
      Data required to execute tests. In future - should be replaced.
      Specified by:
      getParameters in interface Session
      Returns:
      The current parameters in use.
    • isReady

      public boolean isReady()
      Specified by:
      isReady in interface Session
      Returns:
      true if configuration is ready for test execution
    • 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 WorkDirectory
      doRestoreConfig - - 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.Fault
      Reloads interview if out of date.
      Specified by:
      reloadInterview in interface SessionExt
      Throws:
      Session.Fault