org.apache.avalon.phoenix.components.application
Class DefaultApplication

org.apache.avalon.phoenix.components.application.DefaultApplication
All Implemented Interfaces:
Application, ApplicationMBean

public final class DefaultApplication
implements Application, ApplicationMBean

This is the basic container of blocks. A server application represents an aggregation of blocks that act together to form an application.

Author:
Peter Donald, Leo Simons

Fields inherited from interface org.apache.avalon.phoenix.interfaces.Application
ROLE
 
Fields inherited from interface org.apache.avalon.phoenix.interfaces.ApplicationMBean
ROLE
 
Constructor Summary
DefaultApplication()
           
 
Method Summary
 void dispose()
           
 void enableLogging(Logger logger)
           
 Object getBlock(String name)
          Retrieve Block with specified name.
 String[] getBlockNames()
          Retrieve names of Blocks contained in application.
 String getDescription()
          Get the string used to describe the application in the UI.
 String getDisplayName()
          Get the name to display in Management UI.
 String getHomeDirectory()
          Get location of Application installation
protected  SarMetaData getMetaData()
           
 String getName()
          Get the name of the application.
 void initialize()
           
 boolean isRunning()
          Return true if the application is running or false otherwise.
 void restart()
          Shutdown and restart the application running.
 void setApplicationContext(ApplicationContext context)
          Set the context in which the Application is "executed".
 void shutdown(org.apache.avalon.phoenix.components.application.BlockEntry entry)
          Method to run a Block through it's shutdown phase.
 void start()
          Start the application running.
 void startup(org.apache.avalon.phoenix.components.application.BlockEntry entry)
          Method to run a Block through it's startup phase.
 void startupListener(BlockListenerMetaData metaData)
          Method to run a BlockListener through it's startup phase.
 void stop()
          Stop the application running.
 

Constructor Detail

DefaultApplication

public DefaultApplication()
Method Detail

enableLogging

public void enableLogging(Logger logger)

initialize

public void initialize()
                throws Exception

start

public void start()
           throws IllegalStateException,
                  ApplicationException
Start the application running. This is only valid when isRunning() returns false, otherwise it will generate an IllegalStateException.
Specified by:
start in interface ApplicationMBean
Throws:
IllegalStateException - if application is already running
ApplicationException - if the application failed to start. the message part of exception will contain more information pertaining to why the application failed to startup

restart

public void restart()
             throws IllegalStateException,
                    ApplicationException
Shutdown and restart the application running. This is only valid when isRunning() returns true, otherwise it will generate an IllegalStateException. This is equivelent to calling stop() and then start() in succession.
Specified by:
restart in interface ApplicationMBean
Throws:
IllegalStateException - if application is not already running
ApplicationException - if the application failed to stop or start. the message part of exception will contain more information pertaining to why the application failed to startup/shutdown

stop

public void stop()
          throws IllegalStateException,
                 ApplicationException
Stop the application running. This is only valid when isRunning() returns true, otherwise it will generate an IllegalStateException.
Specified by:
stop in interface ApplicationMBean
Throws:
IllegalStateException - if application is not already running
ApplicationException - if the application failed to shutdown. the message part of exception will contain more information pertaining to why the application failed to shutodwn

dispose

public void dispose()

setApplicationContext

public void setApplicationContext(ApplicationContext context)
Description copied from interface: Application
Set the context in which the Application is "executed".
Specified by:
setApplicationContext in interface Application
Following copied from interface: org.apache.avalon.phoenix.interfaces.Application
Parameters:
context - the applications context

getBlockNames

public String[] getBlockNames()
Description copied from interface: Application
Retrieve names of Blocks contained in application.
Specified by:
getBlockNames in interface Application
Following copied from interface: org.apache.avalon.phoenix.interfaces.Application
Returns:
 

getBlock

public Object getBlock(String name)
Description copied from interface: Application
Retrieve Block with specified name. If no such block exists a null will be returned.
Specified by:
getBlock in interface Application
Parameters:
name -  
Returns:
 

getName

public String getName()
Get the name of the application.
Specified by:
getName in interface ApplicationMBean
Returns:
the name of the application

getDisplayName

public String getDisplayName()
Get the name to display in Management UI.
Specified by:
getDisplayName in interface ApplicationMBean
Returns:
the name of the application to display in UI

getDescription

public String getDescription()
Get the string used to describe the application in the UI.
Specified by:
getDescription in interface ApplicationMBean
Returns:
a short description of the application

getHomeDirectory

public String getHomeDirectory()
Get location of Application installation
Specified by:
getHomeDirectory in interface ApplicationMBean
Returns:
the home directory of application

isRunning

public boolean isRunning()
Return true if the application is running or false otherwise.
Specified by:
isRunning in interface ApplicationMBean
Returns:
true if application is running, false otherwise

getMetaData

protected final SarMetaData getMetaData()

startup

public void startup(org.apache.avalon.phoenix.components.application.BlockEntry entry)
             throws Exception
Method to run a Block through it's startup phase. This will involve notification of BlockListener objects, creation of the Block/Block Proxy object, calling the startup Avalon Lifecycle methods and updating State property of BlockEntry. Errors that occur during shutdown will be logged appropriately and cause exceptions with useful messages to be raised.
Parameters:
entry - the entry containing Block
Throws:
Exception - if an error occurs when block passes through a specific lifecycle stage

shutdown

public void shutdown(org.apache.avalon.phoenix.components.application.BlockEntry entry)
              throws org.apache.excalibur.containerkit.lifecycle.LifecycleException
Method to run a Block through it's shutdown phase. This will involve notification of BlockListener objects, invalidating the proxy object, calling the shutdown Avalon Lifecycle methods and updating State property of BlockEntry. Errors that occur during shutdown will be logged appropraitely.
Parameters:
entry - the entry containing Block

startupListener

public void startupListener(BlockListenerMetaData metaData)
                     throws Exception
Method to run a BlockListener through it's startup phase. This will involve creation of BlockListener object and configuration of object if appropriate.
Parameters:
metaData - the BlockListenerMetaData
Throws:
Exception - if an error occurs when listener passes through a specific lifecycle stage


Copyright © 2001 Apache Jakarta Project. All Rights Reserved.