Skip to content

Commit 47a5b73

Browse files
committed
Added simpleJNDI as a provided library
The easiest method to access sql databases in metafacture is to access them via JNDI. This commit adds a simple JNDI implementation to the provided-libs folder.
1 parent 29ea437 commit 47a5b73

File tree

4 files changed

+64
-4
lines changed

4 files changed

+64
-4
lines changed

pom.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,21 @@
231231
<dependency>
232232
<groupId>org.slf4j</groupId>
233233
<artifactId>slf4j-log4j12</artifactId>
234-
<version>1.7.2</version>
234+
<version>1.7.6</version>
235+
<scope>provided</scope>
236+
</dependency>
237+
238+
<dependency>
239+
<groupId>simple-jndi</groupId>
240+
<artifactId>simple-jndi</artifactId>
241+
<version>0.11.4.1</version>
242+
<scope>provided</scope>
243+
</dependency>
244+
245+
<dependency>
246+
<groupId>commons-dbcp</groupId>
247+
<artifactId>commons-dbcp</artifactId>
248+
<version>1.4</version>
235249
<scope>provided</scope>
236250
</dependency>
237251

src/main/assembly/assembly.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@
6767
<directory>${project.basedir}/src/main/config/</directory>
6868
<outputDirectory>config/</outputDirectory>
6969
<includes>
70-
<include>java-options.conf</include>
71-
<include>log4j.xml</include>
70+
<include>**/*</include>
7271
</includes>
7372
<directoryMode>0755</directoryMode>
7473
<fileMode>0644</fileMode>

src/main/config/java-options.conf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@
55
# Undefined variables remain in the configuration.
66

77
-Xmx512m
8-
-Dlog4j.configuration="file:///$METAFACTURE_HOME/config/log4j.xml"
8+
99
-Dflux.pluginsdir="$METAFACTURE_HOME/plugins"
1010
-Dflux.provideddir="$METAFACTURE_HOME/provided-libs"
1111

12+
# Configure log4j to read its configuration from a file:
13+
-Dlog4j.configuration="file:///$METAFACTURE_HOME/config/log4j.xml"
14+
15+
# Configure simple jndi as default jndi provider:
16+
-Djava.naming.factory.initial=org.osjava.sj.SimpleContextFactory
17+
-Dorg.osjava.sj.root="file:///$METAFACTURE_HOME/config/jndi"
18+
1219
# Append additional options defined in the
1320
# environment (The start-up script ensures
1421
# that this variable is always defined):

src/main/config/jndi/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Place your JNDI properties files in this directory. By default
2+
metafacture-runner uses [simpleJNDI](http://code.google.com/p/osjava/wiki/SimpleJNDI)
3+
as JNDI provider.
4+
5+
# Examples
6+
7+
One of the most common use cases of JNDI is to provide data sources for
8+
JDBC. However, JNDI can be used to pass other variables into a program
9+
as well. The following to examples demonstrate how to define data sources
10+
and other values.
11+
12+
More elaborate examples can be found in the simpleJDNI documentation which
13+
is part of the [binary download package](http://code.google.com/p/osjava/downloads/detail?name=simple-jndi-0.11.4.1.zip&can=2&q=)
14+
of simpleJNDI.
15+
16+
## Data sources
17+
18+
To register a data source with the name `MySqlDB`, create a property
19+
file named `MySqlDB.properties` with the following contents:
20+
21+
```
22+
type=javax.sql.DataSource
23+
driver=com.mysql.jdbc.Driver
24+
url=jdbc:mysql://localhost:3306/DBNAME
25+
user=USER
26+
password=PASSWORD
27+
```
28+
29+
## Other values
30+
31+
Other values can be made available via JNDI by creating property files
32+
such as the following:
33+
34+
```
35+
enabled = true
36+
enabled.type = java.lang.Boolean
37+
```
38+
39+
If this file is saved as `debug.properties`, the value of enabled can
40+
be accessed as follows: `debug.enabled`.

0 commit comments

Comments
 (0)