Package org.eclipse.rdf4j.common.app
Class AppConfiguration
- java.lang.Object
-
- org.eclipse.rdf4j.common.app.AppConfiguration
-
- All Implemented Interfaces:
Configuration
public class AppConfiguration extends java.lang.Object implements Configuration
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
APP_CONFIG_FILE
private java.lang.String
applicationId
private java.lang.String[]
commandLineArgs
private java.io.File
dataDir
private java.lang.String
dataDirName
private static java.lang.String
DEFAULT_LOGGING
private static java.lang.String
DEFAULT_PREFIX
private java.lang.String
fullName
private LogConfiguration
loggingConfiguration
private java.lang.String
longName
private java.util.Properties
properties
private ProxySettings
proxySettings
private AppVersion
version
-
Fields inherited from interface org.eclipse.rdf4j.common.app.config.Configuration
DEFAULT_RESOURCES_LOCATION, DIR, RESOURCES_LOCATION
-
-
Constructor Summary
Constructors Constructor Description AppConfiguration()
Create a new, uninitialized application configuration.AppConfiguration(java.lang.String applicationId)
Create the application configuration.AppConfiguration(java.lang.String applicationId, java.lang.String longName)
Create the application configuration.AppConfiguration(java.lang.String applicationId, java.lang.String longName, AppVersion version)
Create the application configuration.AppConfiguration(java.lang.String applicationId, AppVersion version)
Create the application configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
configureDataDir()
Configure the data dir.void
destroy()
Clean up configuration resources.java.lang.String
getApplicationId()
Get the name of the application (e.g.java.lang.String[]
getCommandLineArgs()
Get the command line arguments of the application.java.io.File
getDataDir()
Get the data directory as Filejava.lang.String
getFullName()
Get the full name of the application, which consists of the long name and the version number.LogConfiguration
getLogConfiguration()
Get logging configurationjava.lang.String
getLongName()
Get the long name of the application.java.util.Properties
getProperties()
Get the propertiesProxySettings
getProxySettings()
Get proxy settingsAppVersion
getVersion()
Get the version of the application.void
init()
Initialize the configuration settings.void
init(boolean loadLogConfig)
Initialize configuration and proxy settings, optionally load (logback) loggingvoid
load()
Load the configuration settings.private LogConfiguration
loadLogConfiguration()
Load and instantiate the logging configuration.void
save()
Store configuration settings.void
setApplicationId(java.lang.String applicationId)
Set the application ID stringvoid
setCommandLineArgs(java.lang.String[] args)
Set the command line arguments specified to the application.void
setDataDirName(java.lang.String dataDirName)
Set the name of the data directoryprivate void
setFullName()
Set full name based upon long name and versionvoid
setLongName(java.lang.String longName)
Set the long name of the application.void
setProxySettings(ProxySettings proxySettings)
Set proxy settingsvoid
setVersion(AppVersion version)
Set the version of the application.
-
-
-
Field Detail
-
APP_CONFIG_FILE
private static final java.lang.String APP_CONFIG_FILE
- See Also:
- Constant Field Values
-
DEFAULT_PREFIX
private static final java.lang.String DEFAULT_PREFIX
- See Also:
- Constant Field Values
-
DEFAULT_LOGGING
private static final java.lang.String DEFAULT_LOGGING
- See Also:
- Constant Field Values
-
applicationId
private java.lang.String applicationId
-
longName
private java.lang.String longName
-
fullName
private java.lang.String fullName
-
version
private AppVersion version
-
commandLineArgs
private java.lang.String[] commandLineArgs
-
dataDirName
private java.lang.String dataDirName
-
dataDir
private java.io.File dataDir
-
loggingConfiguration
private LogConfiguration loggingConfiguration
-
proxySettings
private ProxySettings proxySettings
-
properties
private java.util.Properties properties
-
-
Constructor Detail
-
AppConfiguration
public AppConfiguration()
Create a new, uninitialized application configuration.
-
AppConfiguration
public AppConfiguration(java.lang.String applicationId)
Create the application configuration.- Parameters:
applicationId
- the ID of the application
-
AppConfiguration
public AppConfiguration(java.lang.String applicationId, AppVersion version)
Create the application configuration.- Parameters:
applicationId
- the ID of the applicationversion
- the application's version
-
AppConfiguration
public AppConfiguration(java.lang.String applicationId, java.lang.String longName)
Create the application configuration.- Parameters:
applicationId
- the ID of the applicationlongName
- the long name of the application
-
AppConfiguration
public AppConfiguration(java.lang.String applicationId, java.lang.String longName, AppVersion version)
Create the application configuration.- Parameters:
applicationId
- the ID of the applicationlongName
- the long name of the applicationversion
- the application's version
-
-
Method Detail
-
load
public void load() throws java.io.IOException
Description copied from interface:Configuration
Load the configuration settings. Settings will be loaded from a user and application specific location first. If no such settings exists, an attempt will be made to retrieve settings from a resource on the classpath. If no such settings exist either, settings will be loaded from a default resource on the classpath.- Specified by:
load
in interfaceConfiguration
- Throws:
java.io.IOException
- if the configuration settings could not be loaded due to an I/O problem.
-
save
public void save() throws java.io.IOException
Description copied from interface:Configuration
Store configuration settings. Settings will be stored in a user and application specific location.- Specified by:
save
in interfaceConfiguration
- Throws:
java.io.IOException
- if the configuration settings could not be saved due to an I/O problem.
-
init
public void init() throws java.io.IOException
Description copied from interface:Configuration
Initialize the configuration settings.- Specified by:
init
in interfaceConfiguration
- Throws:
java.io.IOException
- if the configuration settings could not be initialized because of an I/O problem.
-
init
public void init(boolean loadLogConfig) throws java.io.IOException
Initialize configuration and proxy settings, optionally load (logback) logging- Parameters:
loadLogConfig
- load logging configuration- Throws:
java.io.IOException
-
destroy
public void destroy() throws java.io.IOException
Description copied from interface:Configuration
Clean up configuration resources.- Specified by:
destroy
in interfaceConfiguration
- Throws:
java.io.IOException
- if one or more resources could not be cleaned up. Implementations should attempt to clean up as many resources as possible before returning or throwing an exception.
-
getApplicationId
public java.lang.String getApplicationId()
Get the name of the application (e.g. "AutoFocus" or "Metadata Server").- Returns:
- the name of the application
-
setApplicationId
public final void setApplicationId(java.lang.String applicationId)
Set the application ID string- Parameters:
applicationId
- string
-
setDataDirName
public void setDataDirName(java.lang.String dataDirName)
Set the name of the data directory- Parameters:
dataDirName
-
-
getLongName
public java.lang.String getLongName()
Get the long name of the application.- Returns:
- the long name of the application
-
setLongName
public final void setLongName(java.lang.String longName)
Set the long name of the application.- Parameters:
longName
- the new name
-
getFullName
public java.lang.String getFullName()
Get the full name of the application, which consists of the long name and the version number.- Returns:
- the full name of the application
-
setFullName
private void setFullName()
Set full name based upon long name and version
-
getVersion
public AppVersion getVersion()
Get the version of the application.- Returns:
- the version of the application
-
setVersion
public final void setVersion(AppVersion version)
Set the version of the application.- Parameters:
version
- the new version
-
getCommandLineArgs
public java.lang.String[] getCommandLineArgs()
Get the command line arguments of the application.- Returns:
- A String array, as (typically) specified to the main method.
-
setCommandLineArgs
public void setCommandLineArgs(java.lang.String[] args)
Set the command line arguments specified to the application.- Parameters:
args
- A String array containing the arguments as specified to the main method.
-
getDataDir
public java.io.File getDataDir()
Get the data directory as File- Returns:
- data directory
-
getLogConfiguration
public LogConfiguration getLogConfiguration()
Get logging configuration- Returns:
- log configuration
-
getProxySettings
public ProxySettings getProxySettings()
Get proxy settings- Returns:
- proxy settings
-
setProxySettings
public void setProxySettings(ProxySettings proxySettings)
Set proxy settings- Parameters:
proxySettings
- proxy settings
-
configureDataDir
private void configureDataDir()
Configure the data dir. Determination of the data dir might be deferred to Platform.
-
loadLogConfiguration
private LogConfiguration loadLogConfiguration() throws java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException
Load and instantiate the logging configuration.- Returns:
- the logging configuration
- Throws:
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
-
getProperties
public java.util.Properties getProperties()
Get the properties- Returns:
- Returns the properties.
-
-