|
AJCT – Another Java Configuration Tool – Configuration Sources
Introduction
AJCT configuration sources are used to read configuration data from. It may vary from simple property files or System properties to data stored in LDAP objects. Any mixture of sources can be used. If you need to use more than one source, the initial source must be an XML source (this is the only source that supports 'includes'.
Every source can be used as the initial configuration source (with the limitation mentioned above) using start-up parameters. By default, AJCT looks for the file <hostname>.config.xml in the classpath.
Currently, the following sources are supported without custom extensions:
XML configuration source (type=xml)
An XML configuration source reads the configuration source from an XML file. The file can be on the local filesystem, class path or retrievable via an URL.
Parameter
|
Description
|
location
|
Where to look for the XML resource. Possible values: file, classpath (default) or URL
|
filename
|
The name of the file. (default: <hostname>.config.xml)
|
The XML file is expected to be in the following format:
<configuration>
<!-- Example configuration for ldap sources below -->
<section name="ldap">
<entry key="host" value="myldapserver.mydomain.com"/>
<entry key="port" value="389"/>
<entry key="user" value="admin"/>
<entry key="password" value="dummy"/>
<entry key="url" value="ldap://[ldap]{user}@[ldap]{host}:[ldap]{port}/"/>
</section>
<!-- Example configuration for jdbc sources below -->
<section name="jdbc">
<entry key="host" value="localhost"/>
<entry key="user" value="admin"/>
<entry key="password" value="dummy"/>
<entry key="url" value="jdbc:mysql://[jdbc]{host}:3306/mydatabase"/>
</section>
<!-- Example properties config source: this will look for the file 'Test.properties' in the current path -->
<include type="properties" section="propertiesSource" filename="Test.properties" location="file"/>
<!-- Example included xml config source (build a hierachy of config sources): this will lokk for the file 'subconfig.xml' in the classpath -->
<include type="xml" filename="subconfig.xml" location="classpath"/>
<!-- Example included JDBC config source -->
<include type="jdbc" driver="com.mysql.jdbc.Driver" url="[jdbc]{url}" username="[jdbc]{user}" password="[jdbc]{password}" sql="SELECT 'FUNLOCS' AS SECTIONNAME, CODE AS ENTRYKEY, DESCRIPTION AS ENTRYVALUE FROM all_funlocs"/>
<!-- Example ldap config source for the email host and from address -->
<include type="ldap1" url="[ldap]{url}" password="[ldap]{password}" isssl="false" section="ldap.emailconfig" configDn="cn=Default Notification Collection,cn=Security" configAttributes="notfSMTPEmailHost,notfSMTPEmailFrom"/>
<!-- Example system config source in namespace 'java' -->
<include type="system" namespace="java" section="javaSystemProps"/>
<!-- Example driverset configuration config source -->
<include type="driverconfig" url="[ldap]{url}" password="[ldap]{password}" isssl="false" section="ldap.driverset" configDn="cn=DriverSet,ou=Services,o=Test" configAttributes="key1,key2"/>
<!-- other configurations -->
<section name="other">
<entry key="akey" value="avalue"/>
</section>
</configuration>
|
The example above specifies a section called “ldap� wich is used to include an ldap1 configuration and a driverconfig resource below it.
After including the ldap1 configuration resource, it includes the system properties in the namespace 'java'.
It ends by adding another section.
Note: the XML file is processed in the order that it appears. The substitution used in the include statement is processed when processing the include statement.
Properties configuration source (type=properties)
A Properties configuration source reads the configuration source from a java properties file. The file can be on the local filesystem, class path or retrievable via an URL.
Parameter
|
Description
|
section
|
The AJCT configuration section that will contain the properties from the file.
|
location
|
Where to look for the properties resource. Possible values: file, classpath (default) or URL
|
filename
|
The name of the file. (default: <hostname>.config.properties)
|
Windows ini file configuration source (type=ini)
A Windows ini file configuration source reads the configuration source from a Windows ini formatted file. The file can be on the local filesystem, class path or retrievable via an URL.
Parameter
|
Description
|
location
|
Where to look for the ini file. Possible values: file, classpath (default) or URL
|
filename
|
The name of the file. (default: <hostname>.config.ini)
|
System configuration source (type=system)
A system configuration source reads java system properties. The properties can be limited to a given namespace (eg: specifying the namespace 'java' will only include the system properties starting with 'java.'.
Parameter
|
Description
|
section
|
The AJCT configuration section that will contain the (subset of) system properties. Default: 'system'.
|
namespace
|
A filter to limit the inclusion of system properties to those in the given namespace. Default no namespace filter.
|
Using the XML example, the configuration section javaSystemProps might contain the following key/value pairs:
class.version=49.0
vm.name=Java HotSpot(TM) Client VM
vm.version=1.5.0_06-b05
...
|
JDBC configuration source (type=jdbc)
A JDBC configuration source reads data from a JDBC data source (URL) into one or more sections of AJCT. For the moment, connection pooling is not supported. A direct JDBC connection is used.
Parameter
|
Description
|
driver
|
The JDBC driver to use. Example: com.mysql.jdbc.Driver.
|
url
|
The JDBC URL. The format is driver specific. An example for the above MySQL driver could be: jdbc:mysql://localhost:3306/mydatabase
|
username
|
The username to log in into the database.
|
password
|
The password to log in into the database.
|
sql
|
The SQL query to run against the database. The query must at least return 3 columns (for section, key and value). It is assumed that the columns have the following names: SECTIONNAME, ENTRYKEY and ENTRYVALUE for the respective name of the section, name of the key within the section and the value for that key. If a given column cannot be found by name, it is assumed to be at the following index's:
SECTIONNAME: index 1
ENTRYKEY: index 2
ENTRYVALUE: index 3
A row without sectionname or entrykey value will not be added to the configuration. This will not throw an exception (but it will show up in the logs).
Example value: SELECT 'FUNLOCS' AS SECTIONNAME, CODE AS ENTRYKEY, DESCRIPTION AS ENTRYVALUE FROM all_funlocs
|
JNDI datasource configuration source (type=jndi)
A JNDI datasource configuration source reads data from a JNDI data source (URL) into one or more sections of AJCT. A J2EE environment is required in order to use this (JNDI Datasource is a J2EE feature).
Parameter
|
Description
|
name
|
The name of the JNDI datasource. The name is specified in your J2EE environment. It most frequently has the format java:comp/env/jdbc/TestDB.
|
sql
|
The SQL query to run against the database. The query must at least return 3 columns (for section, key and value). It is assumed that the columns have the following names: SECTIONNAME, ENTRYKEY and ENTRYVALUE for the respective name of the section, name of the key within the section and the value for that key. If a given column cannot be found by name, it is assumed to be at the following index's:
SECTIONNAME: index 1
ENTRYKEY: index 2
ENTRYVALUE: index 3
A row without sectionname or entrykey value will not be added to the configuration. This will not throw an exception (but it will show up in the logs).
Example value: SELECT 'FUNLOCS' AS SECTIONNAME, CODE AS ENTRYKEY, DESCRIPTION AS ENTRYVALUE FROM all_funlocs
|
LDAP configuration source (type=LDAP1)
The LDAP configuration source reads data from a single ldap object.
Parameter
|
Description
|
section
|
The AJCT configuration section that will contain the ldap configuration source key/value pairs.
|
LdapCtxFactory
|
For advanced users: the context factory to use. By default, it first tries the system property java.naming.factory.initial. If not found, it uses
com.sun.jndi.ldap.LdapCtxFactory
|
url
|
LDAP url to use. Default: ldap://localhost:389
Format of the URL: ldap://[<user>@]<host>[:<port>]
|
password
|
Password to use for the LDAP store.
|
userdn
|
If not given in the URL, the username can be set separate as well. Note: userDN in url takes higher precedence.
|
security
|
For advanced users: security level to use. By default, the default set by the context factory is used.
|
isssl
|
Boolean indicating if we need to use ssl. False by default.
|
configdn
|
DN of the configuration object to read.
|
configAttributes
|
List of attributes to read. If not given, all attributes are read.
|
Using the XML example, the configuration section ldap.emailconfig might contain the following key/value pairs:
notfSMTPEmailFrom=someone@mycompany.com
notfSMTPEmailHost=smtp.mycompany.com
|
Novell IDM driver configuration source (type=driverconfig)
The driverconfig reads the configuration of a Novell IDM driver.
Parameter
|
Description
|
section
|
The AJCT configuration section that will contain the driver's configuration key/value pairs.
|
LdapCtxFactory
|
For advanced users: the context factory to use. By default, it first tries the system property java.naming.factory.initial. If not found, it uses
com.sun.jndi.ldap.LdapCtxFactory
|
url
|
LDAP url to use. Default: ldap://localhost:389
Format of the URL: ldap://[<user>@]<host>[:<port>]
|
password
|
Password to use for the LDAP store.
|
userdn
|
If not given in the URL, the username can be set separate as well. Note: userDN in url takes higher precedence.
|
security
|
For advanced users: security level to use. By default, the default set by the context factory is used.
|
isssl
|
Boolean indicating if we need to use ssl. False by default.
|
configdn
|
DN of a driver (or the driver set to read the global parameters).
|
configAttributes
|
List of attributes to read. If not given, all attributes are read.
|
Using the XML example, the configuration section ldap.driverset might contain the following key/value pairs:
key1=some value
key2=some other value
|
|