You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@esme.apache.org by es...@apache.org on 2011/10/16 12:20:52 UTC
svn commit: r1184790 - in /esme/trunk/server/src/main:
resources/props/default.props resources/props/heroku.props
scala/bootstrap/liftweb/Boot.scala
Author: esjewett
Date: Sun Oct 16 10:20:51 2011
New Revision: 1184790
URL: http://svn.apache.org/viewvc?rev=1184790&view=rev
Log:
Update so that we can use an environment variable for the JDBC connection URL, to support Heroku.
Modified:
esme/trunk/server/src/main/resources/props/default.props
esme/trunk/server/src/main/resources/props/heroku.props
esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala
Modified: esme/trunk/server/src/main/resources/props/default.props
URL: http://svn.apache.org/viewvc/esme/trunk/server/src/main/resources/props/default.props?rev=1184790&r1=1184789&r2=1184790&view=diff
==============================================================================
--- esme/trunk/server/src/main/resources/props/default.props (original)
+++ esme/trunk/server/src/main/resources/props/default.props Sun Oct 16 10:20:51 2011
@@ -26,7 +26,9 @@ admin_text_port=9989
admin_http_port=8099
esme.enable_tracks=true
esme.enable_actions=true
-esme.enable_tokens=true
+esme.enable_tokens=true
+
+;jdbc_connect_url_from_env=DATABASE_URL
;Enable LDAP
ldap.enabled=false
Modified: esme/trunk/server/src/main/resources/props/heroku.props
URL: http://svn.apache.org/viewvc/esme/trunk/server/src/main/resources/props/heroku.props?rev=1184790&r1=1184789&r2=1184790&view=diff
==============================================================================
--- esme/trunk/server/src/main/resources/props/heroku.props (original)
+++ esme/trunk/server/src/main/resources/props/heroku.props Sun Oct 16 10:20:51 2011
@@ -15,7 +15,9 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-*/
+*/
+
+jdbc_connect_url_from_env=DATABASE_URL
esme.enable_tracks=true
esme.enable_actions=true
Modified: esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala
URL: http://svn.apache.org/viewvc/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala?rev=1184790&r1=1184789&r2=1184790&view=diff
==============================================================================
--- esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala (original)
+++ esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala Sun Oct 16 10:20:51 2011
@@ -42,7 +42,8 @@ import common.Full
import mapper._
import provider.HTTPRequest
import org.compass.core._
-import org.compass.core.config.CompassConfiguration
+import org.compass.core.config.CompassConfiguration
+import scala.sys.SystemProperties
import net.liftweb.widgets.tablesorter._
import widgets.autocomplete.AutoComplete
@@ -51,9 +52,7 @@ import com.twitter.ostrich.admin.{Runtim
import com.twitter.ostrich.stats.Stats
import _root_.net.liftweb.widgets.logchanger._
-
-
-
+
/**
* A class that's instantiated early and run. It allows the application
* to modify lift's environment
@@ -62,17 +61,25 @@ class Boot extends Loggable {
def boot {
// Get DB from container if available
+ DefaultConnectionIdentifier.jndiName = Props.get("jndi.name") openOr "esme"
- DefaultConnectionIdentifier.jndiName = Props.get("jndi.name") openOr "esme"
-
- // Deal with Database
-
+ // Are we supposed to use an env variable for the JDBC connect URL?
+ val env_var:Box[String] = Props.get("jdbc_connect_url_from_env")
+ val jdbc_connect_url : String =
+ if(env_var.isEmpty) {
+ Props.get("jdbc_connect_url") openOr "jdbc:derby:esme_db;create=true"
+ } else {
+ val sys = new SystemProperties
+ sys.get(env_var.openOr("DATABASE_URL")).getOrElse("jdbc:derby:esme_db;create=true")
+ }
+
+ // Deal with Database
if (!DB.jndiJdbcConnAvailable_?) {
- val vendor =
- new StandardDBVendor(Props.get("db_driver") openOr "org.apache.derby.jdbc.EmbeddedDriver",
- Props.get("jdbc_connect_url") openOr
- "jdbc:derby:esme_db;create=true",
- Props.get("db_user"), Props.get("db_pwd"))
+ val vendor = new StandardDBVendor(Props.get("db_driver") openOr
+ "org.apache.derby.jdbc.EmbeddedDriver",
+ jdbc_connect_url,
+ Props.get("db_user"),
+ Props.get("db_pwd"))
LiftRules.unloadHooks.append(vendor.closeAllConnections_! _)