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 String
parameter for the application container configuration filestatic final String
parameter for setting a shutdown hookstatic final String
parameter for the application home directorystatic final String
parameter for blocking the main thread in Main.run()static final String
parameter for the application namestatic final String
parameter 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 TypeMethodDescriptionvoid
dispose()
Dispose the YAAFI containerString[]
getArgs()
org.apache.avalon.framework.logger.Logger
org.apache.avalon.framework.service.ServiceManager
boolean
void
Initialize the instanceboolean
boolean
static void
The main method.static File
makeAbsoluteFile
(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.void
onWait()
Depending on the configuration this method might block the calling thread or return immediately.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
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 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:
dispose
in 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
-