Expresso 5-6

com.jcorporate.expresso.kernel
Class DefaultContainerImpl

java.lang.Object
  extended bycom.jcorporate.expresso.kernel.internal.ContainerImplBase
      extended bycom.jcorporate.expresso.kernel.DefaultContainerImpl
All Implemented Interfaces:
ComponentContainer

public class DefaultContainerImpl
extends ContainerImplBase

This class is the default Container Implementation used by the Expresso Framework. You can change this by modifying the SystemFactory.

It provides basic container usability such as component location, component management, component listeners, etc

Author:
Michael Rimov

Constructor Summary
DefaultContainerImpl()
          Basic constructor.
 
Method Summary
protected  ComponentContainer _getParentContainer()
          getParentContainer without the locking
protected  boolean _isComponentExists(String componentName)
          Version of isComponentExists without the locking.
 void addComponent(ExpressoComponent newComponent)
          To register the component for control by the Component Manager.
 void destroyContainer()
          Global Container Destruction.
protected  void finalize()
          Just in case..... if all references to the root container have been released and GC is running, then make sure we 'cleanly' destroy all nested components.
 Map getChildComponents()
          Retrieves a list of instances of all contained ExpressoComponents.
 ComponentContainer getParentContainer()
          Return the parent container
 void installComponent(ExpressoComponent newComponent, InstallationOptions installOptions, InstallLog installLog)
          Install a component into the system.
 boolean isComponentExists(String componentName)
          Query the container to see if a particular service name is installed in the system
 ExpressoComponent locateComponent(String componentName)
          Locates an Expresso Service for use by a client.
 void removeComponent(String componentName)
          Removes a component from this container.
 void setParentContainer(ComponentContainer newParent)
          Set the parent container of this container
 void uninstallComponent(String componentName, InstallationOptions installOptions, InstallLog installLog)
          Uninstalls the component.
 
Methods inherited from class com.jcorporate.expresso.kernel.internal.ContainerImplBase
getContainerComponent, setContainerComponent
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultContainerImpl

public DefaultContainerImpl()
Basic constructor.

Method Detail

removeComponent

public void removeComponent(String componentName)
Removes a component from this container.

Specified by:
removeComponent in interface ComponentContainer
Specified by:
removeComponent in class ContainerImplBase
Parameters:
componentName - The name of the component to remove.

getChildComponents

public Map getChildComponents()
Retrieves a list of instances of all contained ExpressoComponents. Use this for iterating through the components of a current 'context'. Do not attempt to modify the map given. Either add or remove a component through the addComponent or removeComponent methods.

Specified by:
getChildComponents in interface ComponentContainer
Specified by:
getChildComponents in class ContainerImplBase
Returns:
Read only map of the components.

locateComponent

public ExpressoComponent locateComponent(String componentName)
Locates an Expresso Service for use by a client.

Specified by:
locateComponent in interface ComponentContainer
Specified by:
locateComponent in class ContainerImplBase
Parameters:
componentName - the name of the service to locate.
Returns:
ExpressoService.
Throws:
IllegalArgumentException - if the service cannot be found.
IllegalStateException - if the service exists, but is not in a 'runnable' state due to some configuration error or other unforeseen issue.

installComponent

public void installComponent(ExpressoComponent newComponent,
                             InstallationOptions installOptions,
                             InstallLog installLog)
Install a component into the system. If newComponent implements installable then it shall be installed. After that, the component is added.

Specified by:
installComponent in interface ComponentContainer
Specified by:
installComponent in class ContainerImplBase
Parameters:
newComponent - An instance of the component to install.
installOptions - any installation options [optional]
installLog - a Logger-like interface to a component tha records the process of the installation including any errors, etc.

uninstallComponent

public void uninstallComponent(String componentName,
                               InstallationOptions installOptions,
                               InstallLog installLog)
Uninstalls the component. If the component implements installable then it shall be uninstalled. After that, it shall be removed.

Specified by:
uninstallComponent in interface ComponentContainer
Specified by:
uninstallComponent in class ContainerImplBase
Parameters:
componentName - the name of the component to uninstall
installLog - a Logger-like interface to a component tha records the process of the installation including any errors, etc.
installOptions - any installation options to use.

isComponentExists

public boolean isComponentExists(String componentName)
Query the container to see if a particular service name is installed in the system

Specified by:
isComponentExists in interface ComponentContainer
Specified by:
isComponentExists in class ContainerImplBase
Parameters:
componentName - the name of the component to query for.
Returns:
true if the service is installed and running.

_isComponentExists

protected boolean _isComponentExists(String componentName)
Version of isComponentExists without the locking. Prevents deadlocks for internal use.

Parameters:
componentName - the name of the component
Returns:
true if the component exists

addComponent

public void addComponent(ExpressoComponent newComponent)
To register the component for control by the Component Manager. This will in essense transfer the control of ther service to the Component Manager. This will often be called by the Configuration Bootstrap system.

Specified by:
addComponent in interface ComponentContainer
Specified by:
addComponent in class ContainerImplBase
Parameters:
newComponent - the component to install

getParentContainer

public ComponentContainer getParentContainer()
Return the parent container

Specified by:
getParentContainer in interface ComponentContainer
Overrides:
getParentContainer in class ContainerImplBase
Returns:
ContainerImpl interface

_getParentContainer

protected ComponentContainer _getParentContainer()
getParentContainer without the locking

Returns:
ComponentContainer instance

setParentContainer

public void setParentContainer(ComponentContainer newParent)
Set the parent container of this container

Specified by:
setParentContainer in interface ComponentContainer
Overrides:
setParentContainer in class ContainerImplBase
Parameters:
newParent - the new Parent Container

destroyContainer

public void destroyContainer()
Global Container Destruction. Iterate depth first through all the subcompoennts, possibly calling stop, and possibly calling destroy.

Specified by:
destroyContainer in interface ComponentContainer
Overrides:
destroyContainer in class ContainerImplBase

finalize

protected void finalize()
                 throws Throwable
Just in case..... if all references to the root container have been released and GC is running, then make sure we 'cleanly' destroy all nested components. Of course, since finalize() doesn't necessarily get called, this isn't a guaranteed fixit.. but at least it's a shot in the right direction

Throws:
Throwable

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.