org.apache.avalon.phoenix.components.embeddor
Class DefaultEmbeddor

java.lang.Object
  |
  +--AbstractLogEnabled
        |
        +--org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor
All Implemented Interfaces:
Embeddor, EmbeddorMBean
Direct Known Subclasses:
SingleAppEmbeddor

public class DefaultEmbeddor
extends AbstractLogEnabled
implements Embeddor, EmbeddorMBean

This is the object that is interacted with to create, manage and dispose of the kernel and related resources.

Author:
Leo Simons, Peter Donald, Joerg Bauer
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.apache.avalon.phoenix.interfaces.Embeddor
ROLE
 
Fields inherited from interface org.apache.avalon.phoenix.interfaces.EmbeddorMBean
ROLE
 
Constructor Summary
DefaultEmbeddor()
           
 
Method Summary
 void configure(Configuration configuration)
           
 void contextualize(Context context)
          Pass the Context to the embeddor.
protected  void deployDefaultApplications()
          The deployer is used to load the applications from the default-apps-location specified in Parameters.
protected  void deployFile(String name, File file)
           
 void dispose()
          Release all the resources associated with kernel.
 void execute()
          This is the main method of the embeddor.
 String getBuild()
          Get a string defining the build.
 String getHomeDirectory()
          Get location of Phoenix installation
protected  Kernel getKernel()
          Allow subclasses to get access to kernel.
 String getName()
          Get name by which the server is know.
protected  Parameters getParameters()
          Allow subclasses to get access to parameters.
 Date getStartTime()
          Get the date at which this server started.
 long getUpTimeInMillis()
          Retrieve the number of millisecond the server has been up.
 String getVersion()
          Retrieve a string identifying version of server.
 void initialize()
          Creates the core handlers - logger, deployer, Manager and Kernel.
 void parameterize(Parameters parameters)
          Set parameters for this component.
 void restart()
          Ask the embeddor to restart itself if this operation is supported.
 void shutdown()
          Request the Embeddor shutsdown.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultEmbeddor

public DefaultEmbeddor()
Method Detail

contextualize

public void contextualize(Context context)
                   throws ContextException
Pass the Context to the embeddor. It is expected that the following will be entries in context;

Parameters:
context -
Throws:
ContextException

parameterize

public void parameterize(Parameters parameters)
                  throws ParameterException
Set parameters for this component. This must be called after contextualize() and before initialize() Make sure to provide all the neccessary information through these parameters. All information it needs consists of strings. There are two types of strings included in parameters. The first type include parameters used to setup proeprties of the embeddor. The second type include the implementation names of the components that the Embeddor manages. For instance if you want to replace the ConfigurationRepository with your own repository you would pass in a parameter such as;

org.apache.avalon.phoenix.interfaces.ConfigurationRepository = com.biz.MyCustomConfigurationRepository

Of the other type of parameters, the following are supported by the DefaultEmbeddor implementation of Embeddor. Note that some of the embedded components may support other parameters.

Parameters:
parameters - the Parameters for embeddor
Throws:
ParameterException - if an error occurs

configure

public void configure(Configuration configuration)
               throws ConfigurationException
ConfigurationException

initialize

public void initialize()
                throws Exception
Creates the core handlers - logger, deployer, Manager and Kernel. Note that these are not set up properly until you have called the run() method.

Exception

execute

public void execute()
             throws Exception
This is the main method of the embeddor. It sets up the core components, and then deploys the Facilities. These are registered with the Kernel and the Manager. The same happens for the Applications. Now, the Kernel is taken through its lifecycle. When it is finished, as well as all the applications running in it, it is shut down, after which the PhoenixEmbeddor is as well.

Exception

dispose

public void dispose()
Release all the resources associated with kernel.


shutdown

public void shutdown()
Request the Embeddor shutsdown.

Specified by:
shutdown in interface Embeddor

restart

public void restart()
             throws UnsupportedOperationException
Ask the embeddor to restart itself if this operation is supported.

Specified by:
restart in interface EmbeddorMBean
Throws:
UnsupportedOperationException - if restart not supported

getName

public String getName()
Get name by which the server is know. Usually this defaults to "Phoenix" but the admin may assign another name. This is useful when you are managing a cluster of Phoenix servers.

Specified by:
getName in interface EmbeddorMBean
Returns:
the name of server

getHomeDirectory

public String getHomeDirectory()
Get location of Phoenix installation

Specified by:
getHomeDirectory in interface EmbeddorMBean
Returns:
the home directory of phoenix

getStartTime

public Date getStartTime()
Get the date at which this server started.

Specified by:
getStartTime in interface EmbeddorMBean
Returns:
the date at which this server started

getUpTimeInMillis

public long getUpTimeInMillis()
Retrieve the number of millisecond the server has been up.

Specified by:
getUpTimeInMillis in interface EmbeddorMBean
Returns:
the the number of millisecond the server has been up

getVersion

public String getVersion()
Retrieve a string identifying version of server. Usually looks like "v4.0.1a".

Specified by:
getVersion in interface EmbeddorMBean
Returns:
version string of server.

getBuild

public String getBuild()
Get a string defining the build. Possibly the date on which it was built, where it was built, with what features it was built and so forth.

Specified by:
getBuild in interface EmbeddorMBean
Returns:
the string describing build

deployDefaultApplications

protected void deployDefaultApplications()
                                  throws Exception
The deployer is used to load the applications from the default-apps-location specified in Parameters. TODO: load facilities from .fars as well.

Throws:
Exception - if an error occurs

deployFile

protected final void deployFile(String name,
                                File file)
                         throws Exception
Exception

getKernel

protected final Kernel getKernel()
Allow subclasses to get access to kernel.

Returns:
the Kernel

getParameters

protected final Parameters getParameters()
Allow subclasses to get access to parameters.

Returns:
the Parameters


Copyright © 2001 Apache Jakarta Project. All Rights Reserved.