nl.gx.webmanager.wcb.foundation
Class ComponentBundleImpl

java.lang.Object
  extended by nl.gx.webmanager.wcb.foundation.ComponentBundleImpl
All Implemented Interfaces:
ComponentBundle

public final class ComponentBundleImpl
extends java.lang.Object
implements ComponentBundle

Implementation of a GX WebManager componentbundle providing registration and management of the components the WCB provides.

Author:
bramk

Constructor Summary
ComponentBundleImpl(ComponentBundleDefinition bundleDefinition, org.apache.felix.dependencymanager.DependencyManager dependencyManager)
          Constructor.
 
Method Summary
 void componentTypeAdded(org.osgi.framework.ServiceReference serviceReference, java.lang.Object service)
          Call-back method for the dependency manager.
 void componentTypeRemoved(org.osgi.framework.ServiceReference serviceReference, java.lang.Object service)
          Call-back method for the dependency manager.
 void deleteExcludedBundleResources(java.lang.String srcFileNamePrefix, java.lang.String destFileNamePrefix, java.lang.String baseDirectory)
          delete all files not in the given jar source (srcFileNamePrefix) from the given destFileNamePrefix.
 void deleteFileFromDisk(java.io.File file)
          Delete file from disk.
 void destroy()
          Callback from dependencymanager.
 java.lang.String formatFileName(java.lang.String fileName)
          Ensure that the given fileName is a system path; System specifiek direcory indicators.
 java.lang.String getBaseDirectory()
          Returns the base directory where all backend files are located.
 org.osgi.framework.BundleContext getBundleContext()
          Gets the bundle context.
 ComponentBundleDefinition getBundleDefinition()
          
 org.apache.felix.dependencymanager.DependencyManager getDependencyManager()
          Gets the dependency manager.
 java.util.List<java.lang.String> getRegisteredComponentIds()
          Returns all component ids registered by the ComponentBundle.
 org.osgi.framework.Version getVersion()
          The technical version of a ComponentBundle is read from the Manifest.
 java.lang.String getWebrootDirectory()
          Returns the base directory where all static files are located.
 java.lang.String getWorkDirectory()
          path of a working directory which can be used by this component bundle to store temporary or non-temporary files.
 void init()
          Callback from dependencymanager.
 boolean isLicensed(ComponentDefinition componentDefinition)
          Returns if a valid license is installed for the given component definition
 void start()
          Checks if the component bundle's components are registered, if not, it registers the components.
 void stop()
          Deactivates all component bundle's components.
 java.lang.String substringAfter(java.lang.String str, java.lang.String separator)
          Return the substring of str after the seperator.
 void writeComponentBundleResourcesToFile(java.lang.String srcFileNamePrefix, java.lang.String destFileNamePrefix, java.lang.String baseDirectory)
          deploy all files from the given jar source (srcFileNamePrefix)to the given destFileNamePrefix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentBundleImpl

public ComponentBundleImpl(ComponentBundleDefinition bundleDefinition,
                           org.apache.felix.dependencymanager.DependencyManager dependencyManager)
Constructor.

Parameters:
bundleDefinition - bundleDefinition for this bundle
dependencyManager - dependencyManager for this bundle
Method Detail

init

public void init()
Callback from dependencymanager.


destroy

public void destroy()
Callback from dependencymanager.


start

public void start()
           throws java.lang.Exception
Checks if the component bundle's components are registered, if not, it registers the components. Then checks if the components are installed, if not, it installs the components. Finally activates all components.

Specified by:
start in interface ComponentBundle
Throws:
java.lang.Exception - when starting of ComponentBundle was not successful.

stop

public void stop()
Deactivates all component bundle's components.

Specified by:
stop in interface ComponentBundle

componentTypeAdded

public void componentTypeAdded(org.osgi.framework.ServiceReference serviceReference,
                               java.lang.Object service)
Call-back method for the dependency manager. The Component Bundle has a non-required service dependency on Component Types with this call-back method. In case of a Component Type being added make sure that all components this bundle exposes that are of the added component type are checked, and if not made a service of yet create a service and register to the dependency manager.

Parameters:
serviceReference - Reference to the added component type service and its meta data.
service - The actual component type service.
See Also:
ComponentBundleActivatorBase#init(BundleContext, DependencyManager)}

componentTypeRemoved

public void componentTypeRemoved(org.osgi.framework.ServiceReference serviceReference,
                                 java.lang.Object service)
Call-back method for the dependency manager. A call occurs whenever a component type service is not active anymore. The dependency manager makes sure any component services that are of the type of component that is being removed is made inactive.

Parameters:
serviceReference - Reference to the added component type service and its meta data.
service - The actual component type service.

getBundleDefinition

public ComponentBundleDefinition getBundleDefinition()

Specified by:
getBundleDefinition in interface ComponentBundle
Returns:

getVersion

public org.osgi.framework.Version getVersion()
The technical version of a ComponentBundle is read from the Manifest.

Specified by:
getVersion in interface ComponentBundle
Returns:
the technical version, or null if not defined properly in the Manifest

getBundleContext

public org.osgi.framework.BundleContext getBundleContext()
Gets the bundle context.

Returns:
bundle context

getDependencyManager

public org.apache.felix.dependencymanager.DependencyManager getDependencyManager()
Gets the dependency manager.

Returns:
dependency manager.

isLicensed

public boolean isLicensed(ComponentDefinition componentDefinition)
Returns if a valid license is installed for the given component definition

Specified by:
isLicensed in interface ComponentBundle
Parameters:
componentDefinition - Component definition to check the license for
Returns:
true if a valid license is installed for the component definition or the component definition is not licensed, false otherwise

getBaseDirectory

public java.lang.String getBaseDirectory()
Returns the base directory where all backend files are located.

Specified by:
getBaseDirectory in interface ComponentBundle
Returns:
the base directory where all backend files are located

getWebrootDirectory

public java.lang.String getWebrootDirectory()
Returns the base directory where all static files are located.

Specified by:
getWebrootDirectory in interface ComponentBundle
Returns:
the base directory where all static files are located

getWorkDirectory

public java.lang.String getWorkDirectory()
path of a working directory which can be used by this component bundle to store temporary or non-temporary files. This work directory is intended to be used only by master, never by slaves. For this reason this method will return null when retrieved from a slave.

Specified by:
getWorkDirectory in interface ComponentBundle
Returns:
Full path to a local working directory when this method is invoked from the master, null if this method is invoked from a slave or if the directory could not be created.

getRegisteredComponentIds

public java.util.List<java.lang.String> getRegisteredComponentIds()
Returns all component ids registered by the ComponentBundle.

Specified by:
getRegisteredComponentIds in interface ComponentBundle
Returns:
all component ids registered by the ComponentBundle

deleteFileFromDisk

public void deleteFileFromDisk(java.io.File file)
Delete file from disk.

Specified by:
deleteFileFromDisk in interface ComponentBundle
Parameters:
file - File to delete

writeComponentBundleResourcesToFile

public void writeComponentBundleResourcesToFile(java.lang.String srcFileNamePrefix,
                                                java.lang.String destFileNamePrefix,
                                                java.lang.String baseDirectory)
deploy all files from the given jar source (srcFileNamePrefix)to the given destFileNamePrefix.

Specified by:
writeComponentBundleResourcesToFile in interface ComponentBundle
Parameters:
srcFileNamePrefix - prefix for the srcFileNames location in the jar f.e. editpresentation/
destFileNamePrefix - destenation path can hold bundle specific names f.e. /WEB-INF/wm/jsp/edit/wcb/{bundle_id}/
baseDirectory - base directory for the destination path

formatFileName

public java.lang.String formatFileName(java.lang.String fileName)
Ensure that the given fileName is a system path; System specifiek direcory indicators.

Specified by:
formatFileName in interface ComponentBundle
Parameters:
fileName - Original file name
Returns:
fileName File name formatted using the correct directory separators

substringAfter

public java.lang.String substringAfter(java.lang.String str,
                                       java.lang.String separator)
Return the substring of str after the seperator.

Specified by:
substringAfter in interface ComponentBundle
Parameters:
str - input String
separator - seperator string
Returns:
substring after seperator, "" if seperator not exists

deleteExcludedBundleResources

public void deleteExcludedBundleResources(java.lang.String srcFileNamePrefix,
                                          java.lang.String destFileNamePrefix,
                                          java.lang.String baseDirectory)
delete all files not in the given jar source (srcFileNamePrefix) from the given destFileNamePrefix.

Specified by:
deleteExcludedBundleResources in interface ComponentBundle
Parameters:
srcFileNamePrefix - prefix for the srcFileNames location in the jar f.e. editpresentation/
destFileNamePrefix - destenation path can hold bundle specific names f.e. /WEB-INF/wm/jsp/edit/wcb/{bundle_id}/
baseDirectory - base directory for the destination path


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