nl.gx.webmanager.wcb.lifecycle
Class WCBLifecycleManager

java.lang.Object
  extended by nl.gx.webmanager.wcb.lifecycle.WCBLifecycleManager
Direct Known Subclasses:
WCBInstallManager, WCBPurgeManager, WCBResourceManager, WCBUninstallManager, WCBUpdateManager

public abstract class WCBLifecycleManager
extends java.lang.Object

This class is the base class for business logic that should be performed upon some lifecycle change of a WCB. The lifecycle of the WCB is associated with the lifecycle of the OSGi bundle.

Author:
ivol

Field Summary
protected  org.osgi.framework.Bundle myBundle
           
protected  ComponentBundleDefinition myBundleDefinition
           
protected  nl.gx.webmanager.wcb.componentmanager.impl.ComponentManagerImpl myComponentManager
           
protected  boolean myIsWCB
           
protected  org.osgi.service.prefs.PreferencesService myPreferencesService
           
protected  JcrRepository myRepositoryService
           
 
Constructor Summary
WCBLifecycleManager(nl.gx.webmanager.wcb.componentmanager.impl.ComponentManagerImpl componentManager, org.osgi.framework.Bundle bundle)
          Constructor of the lifecycle manager with the bundle.
WCBLifecycleManager(nl.gx.webmanager.wcb.componentmanager.impl.ComponentManagerImpl componentManager, ComponentBundleDefinition bundleDefinition)
          Constructor of the lifecycle manager with an active Component bundle definition.
 
Method Summary
 void deleteBundleResources()
          Delete the bundle resources from disk
protected  void deleteResourcesFromDisk(java.lang.String[] fileNames, java.lang.String relativePath)
          Deletes an array of files on a given relative path from disk.
protected  java.lang.String getBaseDirectory()
          Return the WCB base directory
protected  java.lang.String getWebrootDirectory()
          Return the webroot directory
protected  void purgePreferences(boolean deleteAll)
          Purge the preferences
protected  void setBooleanPreference(java.lang.String baseNode, java.lang.String subNode, java.lang.String preference, boolean value)
          Sets a preference for the given base node and the given subnode.
protected  void setLanguageResources()
          Sets the language resources for the bundle definition from the JAR file
protected  void setLastModified()
          Store the last modified timestamp of the bundle in the component bundle's preferences.
protected  long startInfoMessage(java.lang.String action)
          Start an info message
protected  void stopInfoMessage(java.lang.String action, boolean success, long starttime)
          Stop an info message
 boolean validateWCBKey()
          Validates the key of the WCB for the WCB ID this lifecycle manager manages.
static boolean validateWCBKey(java.lang.String WCBID, java.lang.String key)
          Validates the key of a WCB.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myComponentManager

protected nl.gx.webmanager.wcb.componentmanager.impl.ComponentManagerImpl myComponentManager

myPreferencesService

protected org.osgi.service.prefs.PreferencesService myPreferencesService

myRepositoryService

protected JcrRepository myRepositoryService

myBundle

protected org.osgi.framework.Bundle myBundle

myBundleDefinition

protected ComponentBundleDefinition myBundleDefinition

myIsWCB

protected boolean myIsWCB
Constructor Detail

WCBLifecycleManager

public WCBLifecycleManager(nl.gx.webmanager.wcb.componentmanager.impl.ComponentManagerImpl componentManager,
                           org.osgi.framework.Bundle bundle)
Constructor of the lifecycle manager with the bundle. Can be invoked in any state of the bundle.

Parameters:
componentManager - The component manager this class is instantiated from
bundleDefinition - The component bundle definition subject to the lifecycle change

WCBLifecycleManager

public WCBLifecycleManager(nl.gx.webmanager.wcb.componentmanager.impl.ComponentManagerImpl componentManager,
                           ComponentBundleDefinition bundleDefinition)
Constructor of the lifecycle manager with an active Component bundle definition. Can only be invoked when the component bundle is in the ACTIVE state

Parameters:
componentManager - The component manager this class is instantiated from
bundleDefinition - The component bundle definition subject to the lifecycle change
Method Detail

deleteResourcesFromDisk

protected void deleteResourcesFromDisk(java.lang.String[] fileNames,
                                       java.lang.String relativePath)
Deletes an array of files on a given relative path from disk.

Parameters:
fileNames - Array of file names
relativePath - Relative path on disk

getBaseDirectory

protected java.lang.String getBaseDirectory()
Return the WCB base directory

Returns:
the WCB base directory

getWebrootDirectory

protected java.lang.String getWebrootDirectory()
Return the webroot directory

Returns:
the webroot directory

setLastModified

protected void setLastModified()
                        throws org.osgi.service.prefs.BackingStoreException
Store the last modified timestamp of the bundle in the component bundle's preferences.

Throws:
org.osgi.service.prefs.BackingStoreException

setBooleanPreference

protected void setBooleanPreference(java.lang.String baseNode,
                                    java.lang.String subNode,
                                    java.lang.String preference,
                                    boolean value)
Sets a preference for the given base node and the given subnode.

Parameters:
baseNode - Identifying name of the base node.
subNode - Identifying name of the sub node.
preference - Identifying name of the preference to be set.
value - Value for the preference to be set.

deleteBundleResources

public void deleteBundleResources()
Delete the bundle resources from disk


setLanguageResources

protected void setLanguageResources()
Sets the language resources for the bundle definition from the JAR file


purgePreferences

protected void purgePreferences(boolean deleteAll)
Purge the preferences

Parameters:
deleteAll - If true, all preferences are removed, event the ones that are used by the WebManager platform (lastmodified)

startInfoMessage

protected long startInfoMessage(java.lang.String action)
Start an info message

Parameters:
action - Lifecycle action that is performed
Returns:
Current time in milliseconds

stopInfoMessage

protected void stopInfoMessage(java.lang.String action,
                               boolean success,
                               long starttime)
Stop an info message

Parameters:
action - Lifecycle action that was performed
success - Indication if the lifecycle action
starttime -

validateWCBKey

public boolean validateWCBKey()
Validates the key of the WCB for the WCB ID this lifecycle manager manages. This method logs a warning when the key cannot be validated.


validateWCBKey

public static boolean validateWCBKey(java.lang.String WCBID,
                                     java.lang.String key)
Validates the key of a WCB. The key is a one-way-hash of the WCB ID; this method validates whether the given WCB ID and key belong together.

Parameters:
WCBID - The WCB ID for which to validate the key
key - The key of the WCB ID
Returns:
true if the validation succeeds, false otherwise


Copyright © 2007-2011 GX Software BV. All Rights Reserved.