nl.gx.webmanager.wcb.foundation
Class ComponentBase

java.lang.Object
  extended by nl.gx.webmanager.wcb.foundation.ComponentBase
All Implemented Interfaces:
DelegatedControllerAware, Component
Direct Known Subclasses:
ComponentTypeBase, SimpleElementComponent, SimpleFormComponent, SimpleMediaItemComponent, SimpleMetaDataComponent, SimplePanelComponent, SimplePresentationComponent, SimpleProfileProviderComponent, SimpleServiceComponent, SimpleServletComponent

public abstract class ComponentBase
extends java.lang.Object
implements Component, DelegatedControllerAware

Base implementation for component interface, is extended by implementations in componenttype bundles.

Author:
arjans

Field Summary
protected static java.util.logging.Logger LOG
           
protected  org.osgi.framework.BundleContext myBundleContext
           
protected  ComponentBundleImpl myComponentBundle
           
protected  ComponentDefinitionImpl myComponentDefinition
           
 
Constructor Summary
ComponentBase()
           
 
Method Summary
 void dependencyAdded(org.osgi.framework.ServiceReference serviceReference, java.lang.Object serviceObject)
          This callback method for the dependencymanager adds all available declared dependencies for this component.
 void dependencyRemoved(org.osgi.framework.ServiceReference serviceReference, java.lang.Object serviceObject)
          This callback method for the dependencymanager removes all unavailable declared dependencies for this component.
 void exportContent(javax.jcr.Node node, boolean exportBinaries, java.io.OutputStream out)
          Writes the repository content associated with the given Node to given OutputStream.
 void extensionAdded(org.osgi.framework.ServiceReference serviceReference, java.lang.Object serviceObject)
          This callback method for the dependencymanager adds all available declared extensions for this component.
 void extensionRemoved(org.osgi.framework.ServiceReference serviceReference, java.lang.Object serviceObject)
          This callback method for the dependencymanager removes all unavailable declared extensions for this component.
 org.osgi.framework.BundleContext getBundleContext()
          Returns the bundle context of the component.
 java.lang.Class[] getClassesFromBundle()
          Retrieve all classes from the bundle.
 java.lang.Class getClassForName(java.lang.String fullyQualifiedClassName)
          Returns the class for the given fully qualified class name.
 ComponentBundle getComponentBundle()
          Returns the component bundle which contains this component.
 ComponentDefinition getComponentDefinition()
          Returns the definition containing all metadata describing this component.
 DelegatedController getDelegatedController()
          Returns the Spring controller to whom controller logic must be delegated
 java.util.Collection<ExtensionProvider> getExtensions(java.lang.String interfaceClassName)
          
 java.lang.String getId()
          Return the identifier for this component.
 java.lang.Object getInstance()
          Returns an instance of the component's class.
 java.lang.Object getInstanceForName(java.lang.String fullyQualifiedClassName)
          Returns an instance of the given class if it is serviced by this component's OSGi bundle.
protected  javax.jcr.Node getPrivateNode()
          Retrieve a private node for this panelcomponent.
 javax.jcr.Node getPrivateNode(java.lang.String websiteIdentifier)
          Retrieve a private node for this panelcomponent.
 java.lang.String getTypeId()
          Return the identifier for this components type.
 WrapperDefinition[] getWrapperDefinitions()
          Returns the component's WrapperDefinitions.
 void importContent(javax.jcr.Node targetNode, boolean importBinaries, java.io.InputStream in, int uuidbehavior)
          Imports content into the JCR.
 void internalDoStart()
          Call-back method used by the dependency manager.
 void internalDoStop()
          Call-back method used by the dependency manager.
 void onDestroy()
          Can be implemented by components for attaching logic to a destroy event.
 void onInit()
          Can be implemented by components for attaching logic to a init event.
 void onInstall()
          Can be implemented by components for attaching logic to an install event.
 boolean onPurge()
          Can be implemented by components for attaching logic to a purge event.
 void onStart()
          Can be implemented by components for attaching logic to a start event.
 void onStop()
          Can be implemented by components for attaching logic to a stop event.
 boolean onUninstall()
          Can be implemented by components for attaching logic to an uninstall event Note that the WCB containing the component needs to be ACTIVE in order for the onUninstall to be invoked.
 void onUpdate()
          Can be implemented by components for attaching logic to an update event.
 void purgeContent()
          Deprecated. 
 void setBundleContext(org.osgi.framework.BundleContext bundleContext)
          Sets the context of the OSGi bundle which contains this component.
 void setComponentBundle(ComponentBundle componentBundle)
          Sets the component bundle which contains this component.
 void setComponentBundle(ComponentBundleImpl componentBundle)
           
 void setComponentDefinition(ComponentDefinition componentDefinition)
          Set the definition containing all metadata describing this component.
 void setComponentManager(ComponentManager componentManager)
          
 void setDelegatedController(DelegatedController controller)
          Sets the Spring controller to whom controller logic must be delegated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final java.util.logging.Logger LOG

myComponentDefinition

protected ComponentDefinitionImpl myComponentDefinition

myComponentBundle

protected ComponentBundleImpl myComponentBundle

myBundleContext

protected org.osgi.framework.BundleContext myBundleContext
Constructor Detail

ComponentBase

public ComponentBase()
Method Detail

getId

public java.lang.String getId()
Return the identifier for this component.

Specified by:
getId in interface Component
Returns:
a string identifier

getTypeId

public java.lang.String getTypeId()
Return the identifier for this components type.

Specified by:
getTypeId in interface Component
Returns:
a string identifier

onStart

public void onStart()
Can be implemented by components for attaching logic to a start event.

Specified by:
onStart in interface Component

internalDoStart

public final void internalDoStart()
Call-back method used by the dependency manager.


onStop

public void onStop()
Can be implemented by components for attaching logic to a stop event.

Specified by:
onStop in interface Component

internalDoStop

public final void internalDoStop()
Call-back method used by the dependency manager.


onInit

public void onInit()
Can be implemented by components for attaching logic to a init event.

Specified by:
onInit in interface Component

onDestroy

public void onDestroy()
Can be implemented by components for attaching logic to a destroy event.

Specified by:
onDestroy in interface Component

onInstall

public void onInstall()
Can be implemented by components for attaching logic to an install event.

Specified by:
onInstall in interface Component

onUpdate

public void onUpdate()
Can be implemented by components for attaching logic to an update event.

Specified by:
onUpdate in interface Component

purgeContent

@Deprecated
public void purgeContent()
Deprecated. 

This method is deprecated. Use onPurge() instead.

Specified by:
purgeContent in interface Component

onPurge

public boolean onPurge()
Can be implemented by components for attaching logic to a purge event. Note that the WCB containing the component needs to be ACTIVE in order for the onPurge to be invoked.

Specified by:
onPurge in interface Component
Returns:
true if the install succeeded, false otherwise. If false is returned, the WCB will not be purged.

onUninstall

public boolean onUninstall()
Can be implemented by components for attaching logic to an uninstall event Note that the WCB containing the component needs to be ACTIVE in order for the onUninstall to be invoked.

Specified by:
onUninstall in interface Component
Returns:
true if the uninstallation succeeded, false otherwise. If false is returned, the WCB will not be uninstalled.

getComponentDefinition

public ComponentDefinition getComponentDefinition()
Returns the definition containing all metadata describing this component.

Specified by:
getComponentDefinition in interface Component
Returns:
the definition containing all metadata describing this component

setComponentDefinition

public void setComponentDefinition(ComponentDefinition componentDefinition)
Set the definition containing all metadata describing this component.

Specified by:
setComponentDefinition in interface Component
Parameters:
componentDefinition - Definition containing all metadata describing this component

getComponentBundle

public ComponentBundle getComponentBundle()
Returns the component bundle which contains this component.

Specified by:
getComponentBundle in interface Component
Returns:
the component bundle which contains this component

setComponentBundle

public void setComponentBundle(ComponentBundle componentBundle)
Sets the component bundle which contains this component.

Specified by:
setComponentBundle in interface Component
Parameters:
componentBundle - Component bundle which contains this component

setComponentBundle

public void setComponentBundle(ComponentBundleImpl componentBundle)
Parameters:
componentBundle -

setBundleContext

public void setBundleContext(org.osgi.framework.BundleContext bundleContext)
Sets the context of the OSGi bundle which contains this component.

Specified by:
setBundleContext in interface Component
Parameters:
bundleContext - Context of the OSGi bundle which contains this component

setComponentManager

public void setComponentManager(ComponentManager componentManager)

Specified by:
setComponentManager in interface Component

getBundleContext

public org.osgi.framework.BundleContext getBundleContext()
Returns the bundle context of the component.

Returns:
bundlecontext of the component

dependencyAdded

public final void dependencyAdded(org.osgi.framework.ServiceReference serviceReference,
                                  java.lang.Object serviceObject)
This callback method for the dependencymanager adds all available declared dependencies for this component. TODO evaluate this is OK. Note it overwrites any old entries.

Parameters:
serviceReference - the serviceReference
serviceObject - the serviceObject

dependencyRemoved

public final void dependencyRemoved(org.osgi.framework.ServiceReference serviceReference,
                                    java.lang.Object serviceObject)
This callback method for the dependencymanager removes all unavailable declared dependencies for this component.

Parameters:
serviceReference - the serviceReference
serviceObject - the serviceObject

getExtensions

public java.util.Collection<ExtensionProvider> getExtensions(java.lang.String interfaceClassName)

Specified by:
getExtensions in interface Component
Returns:

extensionAdded

public final void extensionAdded(org.osgi.framework.ServiceReference serviceReference,
                                 java.lang.Object serviceObject)
This callback method for the dependencymanager adds all available declared extensions for this component.

Parameters:
serviceReference - the serviceReference
serviceObject - the serviceObject

extensionRemoved

public final void extensionRemoved(org.osgi.framework.ServiceReference serviceReference,
                                   java.lang.Object serviceObject)
This callback method for the dependencymanager removes all unavailable declared extensions for this component.

Parameters:
serviceReference - the serviceReference
serviceObject - the serviceObject

getClassForName

public java.lang.Class getClassForName(java.lang.String fullyQualifiedClassName)
Returns the class for the given fully qualified class name. Return null if it can't be found.

Specified by:
getClassForName in interface Component
Parameters:
fullyQualifiedClassName - fully qualified class name
Returns:
the class for the given fully qualified class name. Return null if it can't be found.

getWrapperDefinitions

public WrapperDefinition[] getWrapperDefinitions()
Returns the component's WrapperDefinitions.

Specified by:
getWrapperDefinitions in interface Component
Returns:
the component's WrapperDefinitions

getClassesFromBundle

public java.lang.Class[] getClassesFromBundle()
Retrieve all classes from the bundle.

Specified by:
getClassesFromBundle in interface Component
Returns:
an array of classes present in the bundle

getInstance

public java.lang.Object getInstance()
Returns an instance of the component's class.

Specified by:
getInstance in interface Component
Returns:
an instance of the component's class

getInstanceForName

public java.lang.Object getInstanceForName(java.lang.String fullyQualifiedClassName)
Returns an instance of the given class if it is serviced by this component's OSGi bundle.

Specified by:
getInstanceForName in interface Component
Parameters:
fullyQualifiedClassName - Fully qualified class name
Returns:
an instance of the given class if it is serviced by this component's OSGi bundle

getPrivateNode

protected final javax.jcr.Node getPrivateNode()
Retrieve a private node for this panelcomponent.

Returns:
the private node

getPrivateNode

public final javax.jcr.Node getPrivateNode(java.lang.String websiteIdentifier)
Retrieve a private node for this panelcomponent. If websiteIdentifier!=null, then the webContainerNode is returned (specific for the current webinitiatif). Otherwise, the allContainerNode is returned (the same for all webinitiatifs).

Specified by:
getPrivateNode in interface Component
Parameters:
websiteIdentifier - the unique identifier of the cuurent webinitiatif, or null if the allContainerNode should be returned
Returns:
the private node

exportContent

public void exportContent(javax.jcr.Node node,
                          boolean exportBinaries,
                          java.io.OutputStream out)
                   throws ExportException
Writes the repository content associated with the given Node to given OutputStream. The default implementation uses the JCR exportSystemView method and recursively exports the start node and all its subnodes. If the default implementation does not suffice, then any subclass can override it (i.e., a WCB developer can extend SimplePanelComponent and implement WCB-specific export functionality).

Specified by:
exportContent in interface Component
Parameters:
node - the root of the subtree to be serialized
exportBinaries - whether binaries should be included
out - The OutputStream to which the systemview on the content is exported.
Throws:
ExportException - on error

importContent

public void importContent(javax.jcr.Node targetNode,
                          boolean importBinaries,
                          java.io.InputStream in,
                          int uuidbehavior)
                   throws ImportException
Imports content into the JCR. The default implementation uses the JCR Session.importXML method. The choice to import binaries is ignored in the default implementation since the JCR importXML methods do not support it (binaries are always imported). If the default implementation does not suffice, then any subclass can override it (i.e., a WCB developer can extend SimplePanelComponent and implement WCB-specific import functionality).

Specified by:
importContent in interface Component
Parameters:
targetNode - the node under which the deserialized subtree is added
importBinaries - whether binary content should be imported; ignored by the default implementation
in - the inputstream from which the xml to deserialize is read
uuidbehavior - a four-value flag that governs how incoming UUIDs are handled
Throws:
ImportException - on error

getDelegatedController

public DelegatedController getDelegatedController()
Returns the Spring controller to whom controller logic must be delegated

Specified by:
getDelegatedController in interface DelegatedControllerAware
Returns:
The Spring controller to whom controller logic must be delegated

setDelegatedController

public void setDelegatedController(DelegatedController controller)
Sets the Spring controller to whom controller logic must be delegated

Specified by:
setDelegatedController in interface DelegatedControllerAware
Parameters:
controller - The controller of this entity


Copyright © 2007-2010 GX creative online development BV. All Rights Reserved.