Skip to content

Commit

Permalink
Move set JNDI property to start action, only run initialisation once
Browse files Browse the repository at this point in the history
  • Loading branch information
sbearcsiro committed Aug 16, 2017
1 parent ec03457 commit 9b98720
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/kotlin/au/org/ala/cas/jndi/JndiRunListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ open class JndiRunListener(val application: SpringApplication, args: Array<Strin
override fun starting() {
println("JNDI Run Listener - starting")
Class.forName("com.mysql.jdbc.Driver").newInstance() // TODO???
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.osjava.sj.SimpleContextFactory") // override the Tomcat apache naming factory
}


override fun environmentPrepared(environment: ConfigurableEnvironment?) {
log.debug("JNDI Run Listener - environment prepared")
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.osjava.sj.SimpleContextFactory") // override the Tomcat apache naming factory
}

override fun contextPrepared(context: ConfigurableApplicationContext?) {
Expand All @@ -39,11 +39,11 @@ open class JndiRunListener(val application: SpringApplication, args: Array<Strin
if (location != null) {
log.info("Using {} for JNDI root directory", location)
System.setProperty(SimpleJndi.ROOT, location) // SimpleJNDI will use this as an override to the value in jndi.properties
val ctx = InitialContext()
log.debug("Created initial context {}", ctx)
log.info("JNDI config complete")
initialised = true
}

val ctx = InitialContext()
log.info("JNDI config complete")
initialised = true
}
}

Expand Down

0 comments on commit 9b98720

Please sign in to comment.