[cvs] expresso commit by lhamel: add convenience for getting dbname
from
JCorporate Ltd
jcorp at jcorporate.com
Thu Dec 9 01:03:05 UTC 2004
Log Message:
-----------
add convenience for getting dbname from RequestRegistry
Modified Files:
--------------
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/services/dbobj:
Setup.java
Revision Data
-------------
Index: Setup.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/services/dbobj/Setup.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/services/dbobj/Setup.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/services/dbobj/Setup.java -u -r1.29 -r1.30
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/services/dbobj/Setup.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/services/dbobj/Setup.java
@@ -77,6 +77,7 @@
import com.jcorporate.expresso.core.misc.ConfigManager;
import com.jcorporate.expresso.core.misc.ConfigurationException;
import com.jcorporate.expresso.core.misc.StringUtil;
+import com.jcorporate.expresso.core.registry.RequestRegistry;
import org.apache.log4j.Logger;
import java.util.Enumeration;
@@ -223,12 +224,43 @@
log.debug("No setup info yet for db " + dbName);
}
- return "";
+ return ""; // why not return null?
}
return getValue(dbName, "com.jcorporate.expresso.core.ExpressoSchema",
setupCode);
} /* getValue(String, String) */
+
+
+ /**
+ * Get a config value for the default schema,
+ * using the current db context from RequestRegistry (assumes we are in a
+ * situation where call is happening within a request scope).
+ * Config values are like INI file variables or registry entries - except
+ * stored in a database. There is one database connection held open for
+ * accessing these values from the connection pool. This function simply
+ * references the Expresso Schema's setup values. For your own application
+ * you will want to call the getValue that names your Schema
+ *
+ * @param setupCode The code string of the setup code required
+ * @return String value stored in the given config value
+ * @throws DBException If the value cannot be retrieved
+ */
+ public static String getValue(String setupCode)
+ throws DBException {
+
+ String dbName = RequestRegistry.getDataContext();
+ if (tableNotExists.contains(dbName)) {
+ if (log.isDebugEnabled()) {
+ log.debug("No setup info yet for db " + dbName);
+ }
+
+ return ""; // why not return null?
+ }
+
+ return getValue(dbName, "com.jcorporate.expresso.core.ExpressoSchema",
+ setupCode);
+ } /* getValue(String) */
/**
More information about the cvs
mailing list