com.vodafone360.people.engine
Class EngineManager

java.lang.Object
  extended by com.vodafone360.people.engine.EngineManager

public class EngineManager
extends java.lang.Object

EngineManager class is responsible for creating, handling and deletion of engines in the People client. The EngineManager determine when each engine should be run based on the engine's next run time or whether there is a waiting request for that engine. The EngineManager routes received responses to the appropriate engine.


Nested Class Summary
static class EngineManager.EngineId
          Identifiers for engines.
 
Field Summary
private static long ENGINE_RUN_TIME_THRESHOLD
          Maximum time the run function for an engine is allowed to run before a warning message will be displayed (debug only)
private  ActivitiesEngine mActivitiesEngine
           
private  ContactSyncEngine mContactSyncEngine
           
private  ContentEngine mContentEngine
           
private  java.util.HashMap<java.lang.Integer,BaseEngine> mEngineList
          Engine manager maintains a list of all engines in the system.
private  GroupsEngine mGroupsEngine
           
private  IdentityEngine mIdentityEngine
           
private  LoginEngine mLoginEngine
           
private  PresenceEngine mPresenceEngine
           
private  RemoteService mService
          Reference to the object which provides access to the WorkerThread.
private  SyncMeEngine mSyncMeEngine
           
private  BaseEngine.IEngineEventCallback mUiEventCallback
          Engines require access the BaseEngine.IEngineEventCallback interface.
private  UpgradeEngine mUpgradeEngine
           
private static EngineManager sEngineManager
          EngineManager is a singleton, so this is the static reference
 
Constructor Summary
private EngineManager(RemoteService service, BaseEngine.IEngineEventCallback uiCallback)
          Engine Manager Constructor
 
Method Summary
private  void addEngine(BaseEngine newEngine)
          Add a new engine to the EngineManager.
private  void closeEngine(BaseEngine engine)
          Closes an engine and removes it from the list.
private  void createActivitiesEngine()
          Create instance of ActivitiesEngine.
private  void createContactSyncEngine()
           
private  void createContentEngine()
          Create instance of ContentEngine.
static void createEngineManager(RemoteService service, BaseEngine.IEngineEventCallback uiCallback)
          Create instance of EngineManager.
private  void createGroupsEngine()
           
private  void createIdentityEngine()
          Create instance of IdentityEngine.
private  void createLoginEngine()
          Create instance of LoginEngine.
private  void createPresenceEngine()
          Create instance of PresenceEngine.
private  void createSyncMeEngine()
          Create instance of ActivitiesEngine.
private  void createUpgradeEngine()
          Create instance of UpgradeEngine.
static void destroyEngineManager()
          Destroy EngineManager.
 ActivitiesEngine getActivitiesEngine()
          Fetch activities engine, starting it if necessary.
 ContactSyncEngine getContactSyncEngine()
          Fetch contact sync engine, starting it if necessary.
 ContentEngine getContentEngine()
          Fetch content engine, starting it if necessary.
 GroupsEngine getGroupsEngine()
          Fetch contact sync engine, starting it if necessary.
private static java.lang.String getHumanReadableTime(long absoluteTime, long currentTime)
          Display the Absolute Time in a human readable format (for testing only).
 IdentityEngine getIdentityEngine()
          Fetch identity engine, starting it if necessary.
static EngineManager getInstance()
          Get single instance of EngineManager.
 LoginEngine getLoginEngine()
          Fetch login engine, starting it if necessary.
 PresenceEngine getPresenceEngine()
          Fetch presence engine, starting it if necessary.
 SyncMeEngine getSyncMeEngine()
          Fetch activities engine, starting it if necessary.
 UpgradeEngine getUpgradeEngine()
          Fetch upgrade engine, starting it if necessary.
 void onCommsInMessage(EngineManager.EngineId source)
          Respond to incoming message received from Comms layer.
private  void onCreate()
          Called immediately after manager has been created.
private  void onDestroy()
          Called just before the service is stopped.
 void resetAllEngines()
          Resets all the engines.
 long runEngines()
          Run any waiting engines and return the time in milliseconds from now when this method needs to be called again.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sEngineManager

private static EngineManager sEngineManager
EngineManager is a singleton, so this is the static reference


mEngineList

private final java.util.HashMap<java.lang.Integer,BaseEngine> mEngineList
Engine manager maintains a list of all engines in the system. This is a map between the engine ID and the engine reference.


mService

private RemoteService mService
Reference to the object which provides access to the WorkerThread.


mUiEventCallback

private BaseEngine.IEngineEventCallback mUiEventCallback
Engines require access the BaseEngine.IEngineEventCallback interface. Implements several useful methods for engines such as UI request complete.


mLoginEngine

private LoginEngine mLoginEngine
See Also:
LoginEngine

mUpgradeEngine

private UpgradeEngine mUpgradeEngine
See Also:
UpgradeEngine

mActivitiesEngine

private ActivitiesEngine mActivitiesEngine
See Also:
ActivitiesEngine

mSyncMeEngine

private SyncMeEngine mSyncMeEngine
See Also:
SyncMeEngine

mPresenceEngine

private PresenceEngine mPresenceEngine
See Also:
PresenceEngine

mIdentityEngine

private IdentityEngine mIdentityEngine
See Also:
IdentityEngine

mContactSyncEngine

private ContactSyncEngine mContactSyncEngine
See Also:
ContactSyncEngine

mGroupsEngine

private GroupsEngine mGroupsEngine
See Also:
GroupsEngine

mContentEngine

private ContentEngine mContentEngine
See Also:
ContentEngine

ENGINE_RUN_TIME_THRESHOLD

private static final long ENGINE_RUN_TIME_THRESHOLD
Maximum time the run function for an engine is allowed to run before a warning message will be displayed (debug only)

See Also:
Constant Field Values
Constructor Detail

EngineManager

private EngineManager(RemoteService service,
                      BaseEngine.IEngineEventCallback uiCallback)
Engine Manager Constructor

Parameters:
service - RemoteService reference
uiCallback - Provides useful engine callback functionality.
Method Detail

createEngineManager

public static void createEngineManager(RemoteService service,
                                       BaseEngine.IEngineEventCallback uiCallback)
Create instance of EngineManager.

Parameters:
service - RemoteService reference
uiCallback - Provides useful engine callback functionality.

destroyEngineManager

public static void destroyEngineManager()
Destroy EngineManager.


getInstance

public static EngineManager getInstance()
Get single instance of EngineManager.

Returns:
EngineManager singleton instance.

addEngine

private void addEngine(BaseEngine newEngine)
Add a new engine to the EngineManager.

Parameters:
newEngine - Engine to be added.

closeEngine

private void closeEngine(BaseEngine engine)
Closes an engine and removes it from the list.

Parameters:
engine - Reference of engine by base class BaseEngine to close

onCreate

private void onCreate()
Called immediately after manager has been created. Starts the necessary engines


onDestroy

private void onDestroy()
Called just before the service is stopped. Shuts down all the engines


getLoginEngine

public LoginEngine getLoginEngine()
Fetch login engine, starting it if necessary.

Returns:
a LoginEngine object

createLoginEngine

private void createLoginEngine()
Create instance of LoginEngine.


getUpgradeEngine

public UpgradeEngine getUpgradeEngine()
Fetch upgrade engine, starting it if necessary.

Returns:
UpgradeEngine object

createUpgradeEngine

private void createUpgradeEngine()
Create instance of UpgradeEngine.


getActivitiesEngine

public ActivitiesEngine getActivitiesEngine()
Fetch activities engine, starting it if necessary.

Returns:
a ActivitiesEngine object

createActivitiesEngine

private void createActivitiesEngine()
Create instance of ActivitiesEngine.


getSyncMeEngine

public SyncMeEngine getSyncMeEngine()
Fetch activities engine, starting it if necessary.

Returns:
a ActivitiesEngine object

createSyncMeEngine

private void createSyncMeEngine()
Create instance of ActivitiesEngine.


getPresenceEngine

public PresenceEngine getPresenceEngine()
Fetch presence engine, starting it if necessary.

Returns:
Presence Engine object

getIdentityEngine

public IdentityEngine getIdentityEngine()
Fetch identity engine, starting it if necessary.

Returns:
IdentityEngine object

getContentEngine

public ContentEngine getContentEngine()
Fetch content engine, starting it if necessary.

Returns:
ContentEngine object

getContactSyncEngine

public ContactSyncEngine getContactSyncEngine()
Fetch contact sync engine, starting it if necessary.

Returns:
ContactSyncEngine object

createContactSyncEngine

private void createContactSyncEngine()

getGroupsEngine

public GroupsEngine getGroupsEngine()
Fetch contact sync engine, starting it if necessary.

Returns:
ContactSyncEngine object

createGroupsEngine

private void createGroupsEngine()

createIdentityEngine

private void createIdentityEngine()
Create instance of IdentityEngine.


createContentEngine

private void createContentEngine()
Create instance of ContentEngine.


createPresenceEngine

private void createPresenceEngine()
Create instance of PresenceEngine.


onCommsInMessage

public void onCommsInMessage(EngineManager.EngineId source)
Respond to incoming message received from Comms layer. If this message has a valid engine id it is routed to that engine, otherwise The EngineManager will try to get the next response.

Parameters:
source - EngineId associated with incoming message.

runEngines

public long runEngines()
Run any waiting engines and return the time in milliseconds from now when this method needs to be called again.

Returns:
-1 never needs to run, 0 needs to run as soon as possible, CurrentTime + 60000 in 1 minute, etc.

getHumanReadableTime

private static java.lang.String getHumanReadableTime(long absoluteTime,
                                                     long currentTime)
Display the Absolute Time in a human readable format (for testing only).

Parameters:
absoluteTime - Time to convert
currentTime - Current time, for creating all relative times
Returns:
Absolute time in human readable form

resetAllEngines

public void resetAllEngines()
Resets all the engines. Note: the method will block until all the engines have performed the reset.



JavaDoc