org.opensubsystems.core.application
Class ThickClient

java.lang.Object
  extended by org.opensubsystems.core.application.Server
      extended by org.opensubsystems.core.application.ThickClient

public class ThickClient
extends Server

The main class which represents application that executes on a client computer. It provides framework for various modules to coexists together on the client computer. It's responsibility is to instantiate, coordinate and destroy these modules. Modules are specified in the configuration files using numbered properties, such as oss.thickclient.module.0=full classname for module 0 oss.thickclient.module.1=full classname for module 1 ... This class is independent of any GUI technology (such as SWT or AWT) used to actually construct the thick client. It defers all methods, which may depend of any GUI technology to the ThickClientGui interface. On the other hand this class is not an interface just because there has to be a class, which implements main method which launches the application. The application which will be started must be specified in te configuration files, using property [full classname for ThickClient class]=full classname for application to start Thick client embeds by default server since most modern enterprise applications require some kind of support for inter-application communication and therefore act both as clients and servers.

Version:
$Id: ThickClient.java,v 1.20 2007/03/08 05:17:15 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
1.17 2006/04/05 04:56:57 bastafidli

Field Summary
static java.lang.String GUI_MODULE_PREFIX
          This is used to name parameters such as oss.thickclient.module.0, oss.thickclient.module.1.
protected  boolean m_bFixedSize
          If true then the window will be displayed with fixed size and cannot be resized.
protected  boolean m_bHideCursor
          If true then hide cursor.
protected  boolean m_bModulesCreated
          This flag is set after modules are created.
protected  boolean m_bStoppingGui
          This flag is true when gui is being stopped.
protected  ThickClientGui m_gui
          Gui representing the thick client application.
protected  int m_iScreenPosition
          Position where to display GUI on the screen.
protected  java.util.Map m_modules
          Map where key is the module name (String) and value is the module (ThickClientModule) itself.
protected  java.lang.String m_strActiveModuleName
          Name of the module from m_modules, which is currently active.
protected  java.util.Set m_strPreviouslyActiveModules
          Collection of module names, which were previously at least once active.
protected static java.lang.Class s_clsDefaultThickClient
          Default thick client class to instantiate
protected static java.lang.String s_strDefaultGUITechnology
          Default GUI technology to use for instantiation of thick client.
 
Fields inherited from class org.opensubsystems.core.application.Server
m_bStarted, m_hsServer, m_iWebServerPort, s_iMaxServerStartRetry, SERVER_START_RETRYCOUNT, SERVER_START_RETRYCOUNT_DEFAULT
 
Constructor Summary
ThickClient()
          Construct instance of the thick client application.
ThickClient(ProductInfo product)
          Construct instance of the thick client application.
 
Method Summary
 void activateModule(java.lang.String strModuleName)
          Activate specified module.
protected  boolean activateModule(ThickClientModule module, boolean bReactivate)
          Activate specified module so that it is available for user interaction.
protected  void addWebApplications(org.mortbay.http.HttpServer hsServer)
          Install web applications which should be run on the server.
 boolean canStopGUI()
          Check if it is OK to stop the gui.
protected  void createModules()
          Create modules, which should be available in the thick client application.
protected  void destroyModules()
          Destroy modules, which were created for the thick client application.
protected  void displayGUI()
          Display the gui using previously initialized resources.
 ThickClientGui getGui()
          Get gui for this client.
 int getScreenPosition()
          Position where to display GUI on the screen.
protected static ThickClient getThickClientInstance()
          Get instance of thick client application to start.
 void init()
          Initialize the server.
protected  void initScreenOptions(int iScreenPosition, boolean bFixedSize, boolean bHideCursor)
          Initialize position and size related parameters.
 boolean isFixedSize()
          If true then the window will be displayed with fixed size and cannot be resized.
static void main(java.lang.String[] args)
          The defaul implementation of the main method.
protected  void pasivateModule(ThickClientModule module)
          Pasivate the specified module so that it is not available for user interaction anymore.
 void start()
          Start the server.
protected  void startGui()
          Start the GUI portion of the thick client application.
protected  void startThickClient()
          Start the thick client.
 void stop()
          Stop the server.
 boolean stopGUI()
          Call this method to stop the GUI.
protected  void stopThickClient()
          Stop the thick client.
 
Methods inherited from class org.opensubsystems.core.application.Server
generateNewWebPort, getWebServerPort, initContext, isStarted, setWebServerPort, startServer, stopServer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GUI_MODULE_PREFIX

public static final java.lang.String GUI_MODULE_PREFIX
This is used to name parameters such as oss.thickclient.module.0, oss.thickclient.module.1. These parameters are used to specify modules which are running inside of this thick client.

See Also:
Constant Field Values

s_strDefaultGUITechnology

protected static java.lang.String s_strDefaultGUITechnology
Default GUI technology to use for instantiation of thick client. TODO: Configure: Allow to specify this variable from the command line.


m_iScreenPosition

protected int m_iScreenPosition
Position where to display GUI on the screen. It should be one of the GUI_XXX constants.


m_bFixedSize

protected boolean m_bFixedSize
If true then the window will be displayed with fixed size and cannot be resized. The default fixed size is 1024x768. TODO: Configure: Make this fixed size configurable.


m_bHideCursor

protected boolean m_bHideCursor
If true then hide cursor. (e.g. if we are on the touchscreen).


m_bStoppingGui

protected boolean m_bStoppingGui
This flag is true when gui is being stopped.


m_modules

protected java.util.Map m_modules
Map where key is the module name (String) and value is the module (ThickClientModule) itself.


m_strActiveModuleName

protected java.lang.String m_strActiveModuleName
Name of the module from m_modules, which is currently active.


m_strPreviouslyActiveModules

protected java.util.Set m_strPreviouslyActiveModules
Collection of module names, which were previously at least once active.


m_bModulesCreated

protected boolean m_bModulesCreated
This flag is set after modules are created.


m_gui

protected ThickClientGui m_gui
Gui representing the thick client application.


s_clsDefaultThickClient

protected static java.lang.Class s_clsDefaultThickClient
Default thick client class to instantiate

Constructor Detail

ThickClient

public ThickClient()
Construct instance of the thick client application.


ThickClient

public ThickClient(ProductInfo product)
Construct instance of the thick client application.

Parameters:
product - - information about product which is running this application, this way we will force every application to create and publish this information in uniform way
Method Detail

main

public static void main(java.lang.String[] args)
The defaul implementation of the main method. It doesn't do anything much, just starts the application.

Parameters:
args - - arguments passed from command line

getGui

public ThickClientGui getGui()
Get gui for this client.

Returns:
ThinkClientGui

isFixedSize

public boolean isFixedSize()
If true then the window will be displayed with fixed size and cannot be resized. The default fixed size is 1024x768.

Returns:
boolean

getScreenPosition

public int getScreenPosition()
Position where to display GUI on the screen. It should be one of the GUI_XXX constants.

Returns:
int

init

public void init()
          throws OSSException,
                 java.io.IOException
Initialize the server. All initializeation should be done in this method so that we can call it repetitevely with changed parameters if initialization fails.

Overrides:
init in class Server
Throws:
OSSException - - if there was an error starting persistance store
java.io.IOException - - if there was an error accessing database properties

start

public void start()
           throws org.mortbay.util.MultiException,
                  OSSException
Start the server.

Overrides:
start in class Server
Throws:
org.mortbay.util.MultiException - - if there was an error starting the server
OSSException - - if there was an error starting the server

stop

public void stop()
          throws OSSException,
                 java.lang.InterruptedException
Stop the server.

Overrides:
stop in class Server
Throws:
OSSException - - if there was en error stopping persistance store
java.lang.InterruptedException - - if the server was stopped

activateModule

public void activateModule(java.lang.String strModuleName)
Activate specified module.

Parameters:
strModuleName - - name of the module to activate.

canStopGUI

public boolean canStopGUI()
Check if it is OK to stop the gui. This is abstract since the way we ask user is usually implementation specific.

Returns:
boolean - true - the gui can be stopped false - the gui cannot be stopped at this time

stopGUI

public boolean stopGUI()
Call this method to stop the GUI. Derived classes may perform some activities which require the GUI to be present but must be execute them only after user confirmed that he really wants to stop or exit the application.

Returns:
boolean - true - the gui was sucessfully stopped false - an error has occured while stopping gui

addWebApplications

protected void addWebApplications(org.mortbay.http.HttpServer hsServer)
Install web applications which should be run on the server.

Specified by:
addWebApplications in class Server
Parameters:
hsServer - - HTTP server to install the applications to

getThickClientInstance

protected static ThickClient getThickClientInstance()
                                             throws OSSException
Get instance of thick client application to start. The instance is determined dynamically by looking at class, which is configured as implementor of ThickClient.

Returns:
ThickClient - thick client to start
Throws:
OSSException - - an error has occured

initScreenOptions

protected void initScreenOptions(int iScreenPosition,
                                 boolean bFixedSize,
                                 boolean bHideCursor)
Initialize position and size related parameters.

Parameters:
iScreenPosition - - position where to display GUI on the screen, one of the GUI_XXX constants
bFixedSize - - if true then the window will be displayed with fixed size 1024x768
bHideCursor - - hide cursor (e.g. if we are on the touchscreen)

startThickClient

protected void startThickClient()
                         throws OSSException
Start the thick client. This method should be invoked at a point when the backend (if any) is already started and therefore it is safe to start the thick client gui or background tasks to connect to the these. Derived classes may overide this method to initialize any background tasks or perform any setup activitied before the gui is started.

Throws:
OSSException - - an error has occured

stopThickClient

protected void stopThickClient()
                        throws OSSException
Stop the thick client. This method is invoked at a point when the GUI was already closed so the application is no longer already for user. The derived classes may override this method to stop any background tasks.

Throws:
OSSException - - an error has occured

startGui

protected void startGui()
                 throws OSSException
Start the GUI portion of the thick client application. By this time the backend/background tasks should be already started.

Throws:
OSSException - - an error has occured

displayGUI

protected void displayGUI()
                   throws OSSException
Display the gui using previously initialized resources. This is done in separate method so that if application had a different way how to display gui then it can change this behavior.

Throws:
OSSException - - an error has occured

createModules

protected void createModules()
                      throws OSSException
Create modules, which should be available in the thick client application. The application is not fully constructed yet therefore the module should not attempt to access any part of the user interface.

Throws:
OSSException - - an error has occured

destroyModules

protected void destroyModules()
Destroy modules, which were created for the thick client application.


pasivateModule

protected void pasivateModule(ThickClientModule module)
Pasivate the specified module so that it is not available for user interaction anymore.

Parameters:
module - - module to pasivate

activateModule

protected boolean activateModule(ThickClientModule module,
                                 boolean bReactivate)
Activate specified module so that it is available for user interaction.

Parameters:
module - - module to activate
bReactivate - - this is true if the module was pasivated but it is being immediately activated again because the other module which caused it's pasivation coun't be activated again. This is false if some other module was active and now this module is being activated.
Returns:
boolean - true if sucessfully activated false if cannot be activated and either the previously active module should remain active or no module should be active


Copyright © 2003 - 2006 OpenSubsystems s.r.o.