You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jv...@apache.org on 2001/09/21 04:20:51 UTC
cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/services/resources ResourceService.java TurbineResourceService.java TurbineResources.java
jvanzyl 01/09/20 19:20:51
Modified: conf/database hypersonic
conf/torque/templates/sql/base Control.vm
src/java/org/apache/turbine Turbine.java
TurbineConstants.java
src/java/org/apache/turbine/services/resources
ResourceService.java TurbineResourceService.java
TurbineResources.java
Log:
- made changes to appropriate files so that ${variable} interpolation
will work in the TRP file.
Revision Changes Path
1.2 +2 -2 jakarta-turbine-2/conf/database/hypersonic
Index: hypersonic
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/conf/database/hypersonic,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- hypersonic 2001/08/16 05:06:56 1.1
+++ hypersonic 2001/09/21 02:20:51 1.2
@@ -1,3 +1,3 @@
-database.driver=org.hsql.jdbcDriver
-database.url=jdbc:HypersonicSQL:C:\TurbineDB\turbine
+database.driver=org.hsqldb.jdbcDriver
+database.url=jdbc:hsqldb:${applicationRoot}/db/${database.name}
database.adaptor=DBHypersonicSQL
1.2 +4 -1 jakarta-turbine-2/conf/torque/templates/sql/base/Control.vm
Index: Control.vm
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/conf/torque/templates/sql/base/Control.vm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Control.vm 2001/08/16 05:07:00 1.1
+++ Control.vm 2001/09/21 02:20:51 1.2
@@ -4,8 +4,11 @@
#set ( $fnamekeys= "sql/base/$targetDatabase/tablefk.vm" )
#foreach ($databaseModel in $appData.Databases)
-
+
#if ($project)
+
+ We have a defined project: $project
+
#if ($appData.MultipleDatabases)
#set ( $outFile = "${project}-${databaseModel.Name}-schema.sql" )
#else
1.4 +10 -2 jakarta-turbine-2/src/java/org/apache/turbine/Turbine.java
Index: Turbine.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/Turbine.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Turbine.java 2001/09/16 03:33:01 1.3
+++ Turbine.java 2001/09/21 02:20:51 1.4
@@ -116,7 +116,7 @@
* @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
* @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
- * @version $Id: Turbine.java,v 1.3 2001/09/16 03:33:01 jvanzyl Exp $
+ * @version $Id: Turbine.java,v 1.4 2001/09/21 02:20:51 jvanzyl Exp $
*/
public class Turbine
extends HttpServlet
@@ -210,7 +210,15 @@
// Initialize essential services (Resources & Logging)
services.initPrimaryServices(config);
-
+
+ // Now that TurbineResources is setup, we want to insert
+ // the applicationRoot and webappRoot into the resources
+ // so that ${applicationRoot} and ${webappRoot} can be
+ // use in the TRP.
+ TurbineResources.setProperty(APPLICATION_ROOT, applicationRoot);
+ TurbineResources.setProperty(WEBAPP_ROOT,
+ config.getServletContext().getRealPath(""));
+
// Initialize other services that require early init
services.initServices(config, false);
}
1.3 +1 -0 jakarta-turbine-2/src/java/org/apache/turbine/TurbineConstants.java
Index: TurbineConstants.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/TurbineConstants.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TurbineConstants.java 2001/08/28 16:33:46 1.2
+++ TurbineConstants.java 2001/09/21 02:20:51 1.3
@@ -276,4 +276,5 @@
public static final String DEFAULT_DOCUMENT_TYPE = "default.doctype";
public static final String APPLICATION_ROOT = "applicationRoot";
+ public static final String WEBAPP_ROOT = "webappRoot";
}
1.2 +10 -2 jakarta-turbine-2/src/java/org/apache/turbine/services/resources/ResourceService.java
Index: ResourceService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/resources/ResourceService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ResourceService.java 2001/08/16 05:09:11 1.1
+++ ResourceService.java 2001/09/21 02:20:51 1.2
@@ -83,13 +83,21 @@
* @author <a href="mailto:greg@shwoop.com">Greg Ritter</a>
* @author <a href="mailto:luta.raphael@networks.vivendi.net">Rapha�l Luta</a>
* @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
- * @version $Id: ResourceService.java,v 1.1 2001/08/16 05:09:11 jvanzyl Exp $
+ * @version $Id: ResourceService.java,v 1.2 2001/09/21 02:20:51 jvanzyl Exp $
*/
public interface ResourceService extends Service
{
public String SERVICE_NAME = "ResourceService";
-
+
+ /**
+ * Set a property in with a key=value pair.
+ *
+ * @param String key
+ * @param String value
+ */
+ public void setProperty(String key, String value);
+
/**
* The purpose of this method is to get the configuration resource
* with the given name as a boolean value.
1.3 +49 -4 jakarta-turbine-2/src/java/org/apache/turbine/services/resources/TurbineResourceService.java
Index: TurbineResourceService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/resources/TurbineResourceService.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TurbineResourceService.java 2001/08/28 16:27:23 1.2
+++ TurbineResourceService.java 2001/09/21 02:20:51 1.3
@@ -92,7 +92,7 @@
* @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
* @author <a href="mailto:luta.raphael@networks.vivendi.net">Rapha�l Luta</a>
* @author <a href="mailto:jvanzyl@periapt.com@">Jason van Zyl</a>
- * @version $Id: TurbineResourceService.java,v 1.2 2001/08/28 16:27:23 jvanzyl Exp $
+ * @version $Id: TurbineResourceService.java,v 1.3 2001/09/21 02:20:51 jvanzyl Exp $
*/
public class TurbineResourceService
extends TurbineBaseService
@@ -102,6 +102,9 @@
//private GenericResources generic = null;
private Configuration configuration = null;
+ private static final String START_TOKEN="${";
+ private static final String END_TOKEN="}";
+
/**
* Performs early initialization. Overrides init() method in
* BaseService to detect objects used in Turbine's Service
@@ -133,7 +136,8 @@
*
* @param config a ServletConfig object
*/
- public void init(ServletConfig config) throws InitializationException
+ public void init(ServletConfig config)
+ throws InitializationException
{
String props = config.getInitParameter(TurbineServices.PROPERTIES_PATH_KEY);
@@ -206,6 +210,47 @@
}
/**
+ * Set a property in with a key=value pair.
+ *
+ * @param String key
+ * @param String value
+ */
+ public void setProperty(String key, String value)
+ {
+ configuration.setProperty(key,value);
+ }
+
+ protected String interpolate(String base)
+ {
+ if (base == null)
+ {
+ return null;
+ }
+
+ int begin = -1;
+ int end = -1;
+ int prec = 0-END_TOKEN.length();
+ String variable = null;
+ StringBuffer result = new StringBuffer();
+
+ // FIXME: we should probably allow the escaping of the start token
+ while ( ((begin=base.indexOf(START_TOKEN,prec+END_TOKEN.length()))>-1)
+ && ((end=base.indexOf(END_TOKEN,begin))>-1) )
+ {
+ result.append(base.substring(prec+END_TOKEN.length(),begin));
+ variable = base.substring(begin+START_TOKEN.length(),end);
+ if (configuration.get(variable)!=null)
+ {
+ result.append(configuration.get(variable));
+ }
+ prec=end;
+ }
+ result.append(base.substring(prec+END_TOKEN.length(),base.length()));
+
+ return result.toString();
+ }
+
+ /**
* Wrapper around the configuration resources.
*
* @return A Configuration.
@@ -414,7 +459,7 @@
*/
public String getString(String name)
{
- return getConfiguration().getString(name);
+ return interpolate(getConfiguration().getString(name));
}
/**
@@ -428,7 +473,7 @@
public String getString(String name,
String def)
{
- return getConfiguration().getString(name, def);
+ return interpolate(getConfiguration().getString(name, def));
}
/**
1.2 +12 -1 jakarta-turbine-2/src/java/org/apache/turbine/services/resources/TurbineResources.java
Index: TurbineResources.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/resources/TurbineResources.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TurbineResources.java 2001/08/16 05:09:12 1.1
+++ TurbineResources.java 2001/09/21 02:20:51 1.2
@@ -71,7 +71,7 @@
* @author <a href="mailto:greg@shwoop.com">Greg Ritter</a>
* @author <a href="mailto:luta.raphael@networks.vivendi.net">Rapha�l Luta</a>
* @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
- * @version $Id: TurbineResources.java,v 1.1 2001/08/16 05:09:12 jvanzyl Exp $
+ * @version $Id: TurbineResources.java,v 1.2 2001/09/21 02:20:51 jvanzyl Exp $
*/
public abstract class TurbineResources
{
@@ -111,6 +111,17 @@
.getInstance()
.getService(ResourceService.SERVICE_NAME);
}
+
+ /**
+ * Set a property in with a key=value pair.
+ *
+ * @param String key
+ * @param String value
+ */
+ public static void setProperty(String key, String value)
+ {
+ getService().setProperty(key,value);
+ }
/**
* The purpose of this method is to get the configuration resource
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: cvs commit:
jakarta-turbine-2/src/java/org/apache/turbine/services/resources
ResourceService.java TurbineResourceService.java TurbineResources.java
Posted by Jason van Zyl <jv...@apache.org>.
On 9/20/01 10:20 PM, "jvanzyl@apache.org" <jv...@apache.org> wrote:
> jvanzyl 01/09/20 19:20:51
>
> Modified: conf/database hypersonic
> conf/torque/templates/sql/base Control.vm
> src/java/org/apache/turbine Turbine.java
> TurbineConstants.java
> src/java/org/apache/turbine/services/resources
> ResourceService.java TurbineResourceService.java
> TurbineResources.java
> Log:
> - made changes to appropriate files so that ${variable} interpolation
> will work in the TRP file.
Forgot to mention that all lifted all the ${variable} interpolation from
the Jetspeed codebase.
--
jvz.
Jason van Zyl
http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org