public class PropertiesFileLoader extends Object
Modifier and Type | Field and Description |
---|---|
protected static String |
COMMENT_PREFIX |
static String |
DISABLE_SUFFIX_KEY |
protected File |
propertiesFile |
static Pattern |
PROPERTY_PATTERN
Pattern that matches :
#username=password
username=password
The regular expression is used to obtain 2 capturing groups, group(1) is used to obtain the username,
group(2) is used to obtain the password. |
Constructor and Description |
---|
PropertiesFileLoader(String path,
String relativeTo) |
Modifier and Type | Method and Description |
---|---|
protected void |
addLineContent(BufferedReader bufferedFileReader,
List<String> content,
String line)
Add the line to the content
|
protected void |
beginPersistence()
Method called to indicate the start of persisting the properties.
|
protected String |
cleanKey(String key) |
protected void |
endPersistence(BufferedWriter writer)
Method called to indicate persisting the properties file is now complete.
|
static String |
escapeString(String name,
char[] escapeArray) |
org.jboss.msc.inject.Injector<PathManager> |
getPathManagerInjectorInjector() |
Properties |
getProperties() |
protected void |
load() |
protected void |
loadAsRequired() |
void |
persistProperties()
Saves changes in properties file.
|
protected List<String> |
readFile(File file) |
protected void |
safeClose(Closeable c) |
void |
start(org.jboss.msc.service.StartContext context) |
void |
stop(org.jboss.msc.service.StopContext context) |
protected void |
verifyProperties(Properties properties)
Provides the base class with an opportunity to verify the contents of the properties before they are used.
|
protected void |
write(BufferedWriter writer,
String line,
boolean newLine) |
protected static final String COMMENT_PREFIX
public static final Pattern PROPERTY_PATTERN
#username=password
username=password
group(1)
is used to obtain the username,
group(2)
is used to obtain the password.
Usernames can contain the following in any number and in any order: -
'.', '-', ',', '@'
'='
public static final String DISABLE_SUFFIX_KEY
protected File propertiesFile
public org.jboss.msc.inject.Injector<PathManager> getPathManagerInjectorInjector()
public void start(org.jboss.msc.service.StartContext context) throws org.jboss.msc.service.StartException
org.jboss.msc.service.StartException
public void stop(org.jboss.msc.service.StopContext context)
public Properties getProperties() throws IOException
IOException
protected void loadAsRequired() throws IOException
IOException
protected void load() throws IOException
IOException
public void persistProperties() throws IOException
IOException
protected List<String> readFile(File file) throws IOException
IOException
protected void addLineContent(BufferedReader bufferedFileReader, List<String> content, String line) throws IOException
bufferedFileReader
- The file readercontent
- The content of the fileline
- The current read lineIOException
protected void beginPersistence() throws IOException
IOException
protected void write(BufferedWriter writer, String line, boolean newLine) throws IOException
IOException
protected void endPersistence(BufferedWriter writer) throws IOException
IOException
protected void safeClose(Closeable c)
protected void verifyProperties(Properties properties) throws IOException
properties
- - The Properties instance to verify.IOException
Copyright © 2023 JBoss by Red Hat. All rights reserved.