Class StatisticsModule

  • All Implemented Interfaces:
    CRXModule

    public class StatisticsModule
    extends java.lang.Object
    implements CRXModule
    StatisticsModule implements a CRXModule that writes statistical data to a given workspace and runs reports on that data.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addEntry​(Entry entry)
      Adds an entry to the statistics workspace.
      java.lang.String getName()
      Returns the name of this module.
      java.lang.String getWorkspaceName()  
      java.util.Iterator runReport​(Report report)
      Runs a report and returns the result of the report.
      void setWorkspaceName​(java.lang.String wspName)  
      void start​(CRXSession session)
      Starts this module and makes it ready for use.
      void stop()
      Stops this module.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StatisticsModule

        public StatisticsModule()
    • Method Detail

      • getName

        public java.lang.String getName()
        Returns the name of this module.

        This name is expected to be unique amongst the registered modules and is just used to identify the module. Other than to register the module under this name, the repository does not use it for anything else.

        Specified by:
        getName in interface CRXModule
        Returns:
        The non-null, non-empty module name.
      • start

        public void start​(CRXSession session)
                   throws RepositoryException
        Starts this module and makes it ready for use.

        This method is called by the repository before registering the module internally. This means, that while this method is active, this module is not yet visible by the CRXRepository.getModule(String) and CRXRepository.getModules() method.

        If this method fails by throwing a RepositoryException, any resources already acquired must be released. A module failing to start is also not registered and thus visible. Finally a module failing to start will never be stopped, that is the CRXModule.stop() method will not be called.

        This method should only throw a RepositoryException if failing to start. Notably, the implementation should prevent throwing a RuntimeException.

        NOTE:

        • The module MUST NOT call the logout() method on this session. Otherwise the repository may behave unexpectedly.
        • The session is a shared Session. This means, the Session is not thread safe and may at most be used for concurrent read operations but MUST NOT be used to write to the repository. If the module requires writing to the repository, a new Session MUST be acquired calling the CRXSession.getSession(String) method on the session. Such session SHOULD of course be logged out when the module is stopped}.
        Specified by:
        start in interface CRXModule
        Parameters:
        session - The CRXSession to access the system workspace of the repository. This session is shared and MUST NOT be used to write to the repository. Use the CRXSession.getSession(String) method to get a session to write to the repository.
        Throws:
        RepositoryException - May be thrown if the module fails to start.
      • stop

        public void stop()
        Stops this module.

        This method is called after the module has been unregistered. If the module failed to start, this method is never called.

        This method is not excpected to throw any exception. Care must be taken to prevent RuntimeExceptions from occurring.

        Specified by:
        stop in interface CRXModule
      • runReport

        public java.util.Iterator runReport​(Report report)
                                     throws RepositoryException
        Runs a report and returns the result of the report.
        Parameters:
        report - the report to run.
        Returns:
        the result of the report.
        Throws:
        RepositoryException - if an error occurs while reading from the workspace.
      • addEntry

        public void addEntry​(Entry entry)
                      throws RepositoryException
        Adds an entry to the statistics workspace.
        Parameters:
        entry - the entry to add.
        Throws:
        RepositoryException - if an error occurs while writing to the workspace.
      • getWorkspaceName

        public java.lang.String getWorkspaceName()
        Returns:
        the name of the statistics workspace.
      • setWorkspaceName

        public void setWorkspaceName​(java.lang.String wspName)
        Parameters:
        wspName - the name of the statistics workspace.