Package org.apache.fulcrum.yaafi.cli
Class Main
java.lang.Object
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
FieldsModifier and TypeFieldDescriptionstatic final Stringparameter for the application container configuration filestatic final Stringparameter for setting a shutdown hookstatic final Stringparameter for the application home directorystatic final Stringparameter for blocking the main thread in Main.run()static final Stringparameter for the application namestatic final Stringparameter for the application temporary directory -
Constructor Summary
ConstructorsConstructorDescriptionMain()ConstructorConstructor 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
Modifier and TypeMethodDescriptionvoiddispose()Dispose the YAAFI containerString[]getArgs()org.apache.avalon.framework.logger.Loggerorg.apache.avalon.framework.service.ServiceManagerbooleanvoidInitialize the instancebooleanbooleanstatic voidThe main method.static FilemakeAbsoluteFile(File baseDir, String name) Determines the file location of the given name.makeAbsoluteFile(String fileName) Locates the file for the given file name.makeAbsolutePath(String fileName) Locates the file for the given file name.voidonWait()Depending on the configuration this method might block the calling thread or return immediately.voidrun()Runs the instance by initializing it and potentially blocking the invoking thread depending on the configuration.voidsetApplicationHome(String applicationHome) voidsetApplicationName(String applicationName) voidvoidsetContainerConfigValue(String containerConfigValue) voidsetHasShutdownHook(boolean hasShutdownHook) voidsetHasShutdownHook(Boolean hasShutdownHook) voidsetHasShutdownHook(String hasShutdownHook) protected voidsetInitialized(boolean isInitialized) voidsetIsBlocking(boolean isBlocking) voidsetIsBlocking(Boolean isBlocking) voidsetIsBlocking(String isBlocking) voidsetLogger(org.apache.avalon.framework.logger.Logger logger) voidsetTempHome(String tempHome) protected voidshutdown()Terminates the instancetoString()
-
Field Details
-
APPLICATION_NAME
parameter for the application name- See Also:
-
APPLICATION_HOME
parameter for the application home directory- See Also:
-
APPLICATION_TEMP
parameter for the application temporary directory- See Also:
-
APPLICATION_CONFIG
parameter for the application container configuration file- See Also:
-
APPLICATION_HASSHUTDOWNHOOK
parameter for setting a shutdown hook- See Also:
-
APPLICATION_ISBLOCKING
parameter for blocking the main thread in Main.run()- See Also:
-
-
Constructor Details
-
Main
public Main()Constructor -
Main
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
- Parameters:
args- the command line arguments
-
-
Method Details
-
main
The main method.- Parameters:
args- Command line arguments- Throws:
Exception- the execution failed
-
makeAbsoluteFile
Determines the file location of the given name. If the name denotes a relative file location it will be resolved using the application home directory.- Parameters:
baseDir- the base directoryname- the filename- Returns:
- the file
-
dispose
public void dispose()Dispose the YAAFI container- Specified by:
disposein interfaceorg.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. -
onWait
public void onWait()Depending on the configuration this method might block the calling thread or return immediately. We currently poll a volatile variable which is not the most elegant solution. -
makeAbsoluteFile
Locates the file for the given file name.- Parameters:
fileName- the filename- Returns:
- an absolute file
-
makeAbsolutePath
Locates the file for the given file name.- Parameters:
fileName- the filename- Returns:
- an absolute path
-
getServiceContainer
- Returns:
- Returns the ServiceContainer interface
-
getServiceManager
public org.apache.avalon.framework.service.ServiceManager getServiceManager()- Returns:
- Returns the ServiceManager interface
-
getApplicationHome
- Returns:
- Returns the applicationHome.
-
setApplicationHome
- Parameters:
applicationHome- The applicationHome to set.
-
getContainerConfigValue
- Returns:
- Returns the containerConfigValue.
-
setContainerConfigValue
- 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
- Parameters:
isBlocking- The isBlocking to set.
-
setIsBlocking
- Parameters:
isBlocking- The isBlocking to set.
-
getTempHome
- Returns:
- Returns the tempHome.
-
setTempHome
- 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
- Returns:
- Returns the applicationName.
-
setApplicationName
- Parameters:
applicationName- The applicationName to set.
-
getArgs
- Returns:
- Returns the args.
-
setArgs
- 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
- Parameters:
hasShutdownHook- The hasShutdownHook to set.
-
setHasShutdownHook
- Parameters:
hasShutdownHook- The hasShutdownHook to set.
-
toString
-
isInitialized
public boolean isInitialized()- Returns:
- Returns the isInitialized.
-
setInitialized
protected void setInitialized(boolean isInitialized) - Parameters:
isInitialized- The isInitialized to set.
-
initialize
Initialize the instance- Throws:
Exception- the initialization failed
-
shutdown
protected void shutdown()Terminates the instance
-