org.apache.fulcrum.yaafi.cli
Class Main

java.lang.Object
  extended by org.apache.fulcrum.yaafi.cli.Main
All Implemented Interfaces:
Runnable, org.apache.avalon.framework.activity.Disposable

public class Main
extends Object
implements Runnable, org.apache.avalon.framework.activity.Disposable

An example of the embedding of a YAAFI kernel inside an arbitrary application.


Field Summary
static String APPLICATION_CONFIG
          parameter for the application container configuration file
static String APPLICATION_HASSHUTDOWNHOOK
          parameter for setting a shutdown hook
static String APPLICATION_HOME
          parameter for the application home directory
static String APPLICATION_ISBLOCKING
          parameter for blocking the main thread in Main.run()
static String APPLICATION_NAME
          parameter for the application name
static String APPLICATION_TEMP
          parameter for the application temporary directory
 
Constructor Summary
Main()
          Constructor
Main(String[] args)
          Constructor The following command line parameters are supported --yaafi.cli.applicationName name --yaafi.cli.applicationHome dir --yaafi.cli.tempHome dir --yaafi.cli.isBlocking [true|false] --yaafi.cli.hasShutdownHook [true|false] --yaafi.cli.config file
 
Method Summary
 void dispose()
          Dispose the YAAFI container
 String getApplicationHome()
           
 String getApplicationName()
           
 String[] getArgs()
           
 String getContainerConfigValue()
           
 org.apache.avalon.framework.logger.Logger getLogger()
           
 ServiceContainer getServiceContainer()
           
 org.apache.avalon.framework.service.ServiceManager getServiceManager()
           
 String getTempHome()
           
 boolean hasShutdownHook()
           
 void initialize()
          Initialize the instance
 boolean isBlocking()
           
 boolean isInitialized()
           
static void main(String[] args)
          The main method.
static File makeAbsoluteFile(File baseDir, String name)
          Determines the file location of the given name.
 File makeAbsoluteFile(String fileName)
          Locates the file for the given file name.
 String makeAbsolutePath(String fileName)
          Locates the file for the given file name.
 void onWait()
          Depending on the configuration this method might block the calling thread or return immediatly.
 void run()
          Runs the instance by initializing it and potentially blocking the invoking thread depending on the configuration.
 void setApplicationHome(String applicationHome)
           
 void setApplicationName(String applicationName)
           
 void setArgs(String[] args)
           
 void setContainerConfigValue(String containerConfigValue)
           
 void setHasShutdownHook(boolean hasShutdownHook)
           
 void setHasShutdownHook(Boolean hasShutdownHook)
           
 void setHasShutdownHook(String hasShutdownHook)
           
protected  void setInitialized(boolean isInitialized)
           
 void setIsBlocking(boolean isBlocking)
           
 void setIsBlocking(Boolean isBlocking)
           
 void setIsBlocking(String isBlocking)
           
 void setLogger(org.apache.avalon.framework.logger.Logger logger)
           
 void setTempHome(String tempHome)
           
protected  void shutdown()
          Terminates the instance
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

APPLICATION_NAME

public static final String APPLICATION_NAME
parameter for the application name

See Also:
Constant Field Values

APPLICATION_HOME

public static final String APPLICATION_HOME
parameter for the application home directory

See Also:
Constant Field Values

APPLICATION_TEMP

public static final String APPLICATION_TEMP
parameter for the application temporary directory

See Also:
Constant Field Values

APPLICATION_CONFIG

public static final String APPLICATION_CONFIG
parameter for the application container configuration file

See Also:
Constant Field Values

APPLICATION_HASSHUTDOWNHOOK

public static final String APPLICATION_HASSHUTDOWNHOOK
parameter for setting a shutdown hook

See Also:
Constant Field Values

APPLICATION_ISBLOCKING

public static final String APPLICATION_ISBLOCKING
parameter for blocking the main thread in Main.run()

See Also:
Constant Field Values
Constructor Detail

Main

public Main()
Constructor


Main

public Main(String[] args)
Constructor The following command line parameters are supported

Parameters:
args - the command line arguments
Method Detail

main

public static void main(String[] args)
                 throws Exception
The main method.

Parameters:
args - Command line arguments
Throws:
Exception - the execution failed

makeAbsoluteFile

public static File makeAbsoluteFile(File baseDir,
                                    String name)
Determines the file location of the given name. If the name denotes a relative file location it will be rsolved using the application home directory.

Parameters:
baseDir - the base directory
name - the filename
Returns:
the file

dispose

public void dispose()
Dispose the YAAFI container

Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable

run

public void run()
Runs the instance by initializing it and potentially blocking the invoking thread depending on the configuration.

Specified by:
run in interface Runnable
See Also:
Runnable.run()

onWait

public void onWait()
Depending on the configuration this method might block the calling thread or return immediatly. We currently poll a volatile variable which is not the most elegant solution.


makeAbsoluteFile

public File makeAbsoluteFile(String fileName)
Locates the file for the given file name.

Parameters:
fileName - the filename
Returns:
an absolute file

makeAbsolutePath

public String makeAbsolutePath(String fileName)
Locates the file for the given file name.

Parameters:
fileName - the filename
Returns:
an absolute path

getServiceContainer

public ServiceContainer getServiceContainer()
Returns:
Returns the ServiceContainer interface

getServiceManager

public org.apache.avalon.framework.service.ServiceManager getServiceManager()
Returns:
Returns the ServiceManager interface

getApplicationHome

public String getApplicationHome()
Returns:
Returns the applicationHome.

setApplicationHome

public void setApplicationHome(String applicationHome)
Parameters:
applicationHome - The applicationHome to set.

getContainerConfigValue

public String getContainerConfigValue()
Returns:
Returns the containerConfigValue.

setContainerConfigValue

public void setContainerConfigValue(String containerConfigValue)
Parameters:
containerConfigValue - The containerConfigValue to set.

isBlocking

public boolean isBlocking()
Returns:
Returns the isBlocking.

setIsBlocking

public void setIsBlocking(boolean isBlocking)
Parameters:
isBlocking - The isBlocking to set.

setIsBlocking

public void setIsBlocking(Boolean isBlocking)
Parameters:
isBlocking - The isBlocking to set.

setIsBlocking

public void setIsBlocking(String isBlocking)
Parameters:
isBlocking - The isBlocking to set.

getTempHome

public String getTempHome()
Returns:
Returns the tempHome.

setTempHome

public void setTempHome(String tempHome)
Parameters:
tempHome - The tempHome to set.

getLogger

public org.apache.avalon.framework.logger.Logger getLogger()
Returns:
Returns the logger.

setLogger

public void setLogger(org.apache.avalon.framework.logger.Logger logger)
Parameters:
logger - The logger to set.

getApplicationName

public String getApplicationName()
Returns:
Returns the applicationName.

setApplicationName

public void setApplicationName(String applicationName)
Parameters:
applicationName - The applicationName to set.

getArgs

public String[] getArgs()
Returns:
Returns the args.

setArgs

public void setArgs(String[] args)
Parameters:
args - The args to set.

hasShutdownHook

public boolean hasShutdownHook()
Returns:
Returns the hasShutdownHook.

setHasShutdownHook

public void setHasShutdownHook(boolean hasShutdownHook)
Parameters:
hasShutdownHook - The hasShutdownHook to set.

setHasShutdownHook

public void setHasShutdownHook(Boolean hasShutdownHook)
Parameters:
hasShutdownHook - The hasShutdownHook to set.

setHasShutdownHook

public void setHasShutdownHook(String hasShutdownHook)
Parameters:
hasShutdownHook - The hasShutdownHook to set.

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

isInitialized

public boolean isInitialized()
Returns:
Returns the isInitialized.

setInitialized

protected void setInitialized(boolean isInitialized)
Parameters:
isInitialized - The isInitialized to set.

initialize

public void initialize()
                throws Exception
Initialize the instance

Throws:
Exception - the initialization failed

shutdown

protected void shutdown()
Terminates the instance



Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.