Added another context configuration file. Made the datasource config property more obvious.

This commit is contained in:
Jonathan Bernard
2015-03-23 04:08:54 -05:00
parent fb722a898e
commit a83d8e4dd8
8 changed files with 29 additions and 8 deletions

View File

@ -8,9 +8,10 @@ public class NLSongsContext {
public static NLSongsDB songsDB
public static String mediaUrlBase
public static String mediaBaseUrl
public static String makeUrl(Service service, Song song) {
return mediaUrlBase + service.@date.toString('yyyy-MM-dd') +
'/' + song.name.replaceAll(/\s/, '') + '.ogg' }
return mediaBaseUrl + '/' + service.@date.toString('yyyy-MM-dd') + '_' +
service.serviceType.name().toLowerCase() + '_' +
song.name.replaceAll(/[\s'"\\\/\?!]/, '') + '.ogg' }
}

View File

@ -14,9 +14,15 @@ public final class NLSongsContextListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent event) {
def context = event.servletContext
// Load the context configuration.
Properties props = new Properties()
NLSongsContextListener.getResourceAsStream(
context.getInitParameter('context.config.file')).withStream { is ->
props.load(is) }
// Create the pooled data source
HikariConfig hcfg = new HikariConfig(
context.getInitParameter("context.config.file"))
context.getInitParameter('datasource.config.file'))
HikariDataSource hds = new HikariDataSource(hcfg)
@ -24,7 +30,8 @@ public final class NLSongsContextListener implements ServletContextListener {
NLSongsDB songsDB = new NLSongsDB(hds)
context.setAttribute('songsDB', songsDB)
NLSongsContext.songsDB = songsDB }
NLSongsContext.songsDB = songsDB
NLSongsContext.mediaBaseUrl = props["nlsongs.media.baseUrl"] }
public void contextDestroyed(ServletContextEvent event) {
def context = event.servletContext