You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ra...@apache.org on 2001/04/03 02:26:37 UTC
cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/services/urlmanager JetspeedURLManagerService.java
raphael 01/04/02 17:26:37
Modified: src/java/org/apache/jetspeed/services/resources
VariableResourcesService.java
src/java/org/apache/jetspeed/services/urlmanager
JetspeedURLManagerService.java
Log:
- update Turbine dependency to TDKa13
- modify VariableResourceService so that you can import the
servlet init parameters as variables within the TR.p file
Revision Changes Path
1.7 +31 -3 jakarta-jetspeed/src/java/org/apache/jetspeed/services/resources/VariableResourcesService.java
Index: VariableResourcesService.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/resources/VariableResourcesService.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- VariableResourcesService.java 2001/03/07 06:49:17 1.6
+++ VariableResourcesService.java 2001/04/03 00:26:32 1.7
@@ -62,8 +62,9 @@
import javax.servlet.ServletContext;
// Turbine stuff.
-import org.apache.turbine.util.Configurations;
-import org.apache.turbine.util.ExtendedProperties;
+//import org.apache.turbine.util.Configurations;
+//import org.apache.turbine.util.ExtendedProperties;
+import org.apache.velocity.runtime.configuration.Configuration;
import org.apache.turbine.services.resources.TurbineResourceService;
import org.apache.turbine.services.TurbineServices;
import org.apache.turbine.services.InitializationException;
@@ -83,8 +84,21 @@
* Vector myVar = TurbineResources.getVector("myvar");
* </code></p>
*
+ * <p>This implementation allows the use of several pre-defined variables within
+ * the configuration file. The variables are identified by the following
+ * sequence of tokens: ${<varname>}. Varname is always folded to lowercase.</p>
+ * <P>The predefined variables are:
+ * <ul>
+ * <li>webapp.dir: base directory for the web application
+ * <li>jvm.dir: JVM startup directory
+ * </ul>
+ * </p>
+ * <p>The init parameters of the servlet are also imported as default variables.
+ * They may override the previously defined default variables
+ * </p>
+ *
* @author <a href="mailto:raphael@apache.org">Rapha�l Luta</a>
- * @version $Id: VariableResourcesService.java,v 1.6 2001/03/07 06:49:17 taylor Exp $
+ * @version $Id: VariableResourcesService.java,v 1.7 2001/04/03 00:26:32 raphael Exp $
*/
public class VariableResourcesService extends TurbineResourceService
{
@@ -149,6 +163,7 @@
String path = ctxt.getRealPath("/");
+ // define web app dir
if (path != null) {
variables.put(WEBAPP_DIR, normalizePath(path) );
}
@@ -161,6 +176,8 @@
variables.put(WEB_DIR, normalizePath(path) );
}
*/
+
+ // define JVM app dir
try {
path = new File(".").getCanonicalPath();
if (path != null) {
@@ -170,7 +187,18 @@
//very unlikely that the JVM can't
//resolve its path
}
+
+ // load servlet init parameters as variables, they may override
+ // the previously defined variables. All param names are folded
+ // to lower case
+ Enumeration en = config.getInitParameterNames();
+ while( en.hasMoreElements() ) {
+ String paramName = (String)en.nextElement();
+ String paramValue = config.getInitParameter(paramName);
+ variables.put(paramName.toLowerCase(),paramValue);
+ }
+
}
private static String normalizePath(String path) {
1.10 +17 -17 jakarta-jetspeed/src/java/org/apache/jetspeed/services/urlmanager/JetspeedURLManagerService.java
Index: JetspeedURLManagerService.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/urlmanager/JetspeedURLManagerService.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- JetspeedURLManagerService.java 2001/03/07 06:49:32 1.9
+++ JetspeedURLManagerService.java 2001/04/03 00:26:35 1.10
@@ -55,11 +55,11 @@
package org.apache.jetspeed.services.urlmanager;
import org.apache.turbine.util.Log;
-import org.apache.turbine.services.resources.TurbineResources;
import org.apache.turbine.services.TurbineBaseService;
-import org.apache.jetspeed.services.enginecontext.EngineContext;
-import org.apache.turbine.util.Configurations;
-import org.apache.turbine.util.ExtendedProperties;
+import org.apache.jetspeed.services.resources.JetspeedResources;
+//import org.apache.turbine.util.Configurations;
+//import org.apache.turbine.util.ExtendedProperties;
+import org.apache.velocity.runtime.configuration.Configuration;
import javax.servlet.ServletConfig;
import java.util.*;
import java.io.*;
@@ -75,7 +75,7 @@
* @see URLManagerService
* @author <a href="mailto:raphael@apache.org">Rapha�l Luta</a>
* @author <a href="mailto:sgala@hisitech.com">Santiago Gala</a>
- * @version $Id: JetspeedURLManagerService.java,v 1.9 2001/03/07 06:49:32 taylor Exp $
+ * @version $Id: JetspeedURLManagerService.java,v 1.10 2001/04/03 00:26:35 raphael Exp $
*/
public class JetspeedURLManagerService
extends TurbineBaseService
@@ -127,30 +127,30 @@
{
Log.note ( "JetspeedURLManagerService early init()....starting!");
- // Proxy Settings are stored as 'services.URLManager.proxy.<protocol>.port' and as
- // 'services.URLManager.proxy.<protocol>.port' in JetspeedResource.properties.
- // Get a list of settings and store them in the hashtable
+ // Proxy Settings are stored as 'services.URLManager.proxy.<protocol>.port' and as
+ // 'services.URLManager.proxy.<protocol>.port' in JetspeedResource.properties.
+ // Get a list of settings and store them in the hashtable
String prefix = "services." + URLManagerService.SERVICE_NAME + ".proxy.";
- Enumeration resourceKeys = TurbineResources.getKeys( prefix );
+ Iterator resourceKeys = JetspeedResources.getKeys( prefix );
String key, hashKey;
Object hashValue = null;
- while( resourceKeys.hasMoreElements() )
+ while( resourceKeys.hasNext() )
{
- key = (String)resourceKeys.nextElement();
+ key = (String)resourceKeys.next();
hashKey = key.substring(prefix.length()).toLowerCase();
if ( hashKey.endsWith(".host") )
{
- hashValue = TurbineResources.getString(key);
+ hashValue = JetspeedResources.getString(key);
proxies.put( hashKey, hashValue );
}
else if ( hashKey.endsWith(".port") )
{
- hashValue = TurbineResources.getInteger(key);
+ hashValue = new Integer(JetspeedResources.getInt(key));
proxies.put( hashKey, hashValue );
}
}
- path = EngineContext.getRealPath( TurbineResources
+ path = config.getServletContext().getRealPath( JetspeedResources
.getString( "services."+URLManagerService.SERVICE_NAME+".url" ) );
load();
@@ -332,12 +332,12 @@
private synchronized void load() {
Map store = new HashMap();
- Configurations config = null;
+ Configuration config = null;
Log.note( "Restoring the URLs from disk: " + path );
try {
- config = new Configurations( new ExtendedProperties( path ) );
+ config = new Configuration( path );
int count = 1;
String url = null;
@@ -414,7 +414,7 @@
*/
public String getProxyHost( String protocol ) {
String proxyHost = (String)proxies.get( (protocol + ".host").toLowerCase() );
-
+
return proxyHost;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org