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/25 04:18:17 UTC

cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/services/resources TurbineResourceService.java

jvanzyl     01/09/24 19:18:17

  Modified:    src/java/org/apache/turbine/services/resources
                        TurbineResourceService.java
  Log:
  - moving code over from the VariableResources class in Jetspeed so
    that Jetspeed can simply use the TurbineResources class.
  
    Santiago/Raphael: I am not caching the results of interpolation and I
    am keeping dynamic reloading of configuration in mind. If this
    causes a performance hit because jetspeed makes these calls
    repeatedly than we'll work something out.
  
  Revision  Changes    Path
  1.4       +44 -6     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TurbineResourceService.java	2001/09/21 02:20:51	1.3
  +++ TurbineResourceService.java	2001/09/25 02:18:17	1.4
  @@ -56,6 +56,7 @@
   
   import java.io.IOException;
   import java.util.Iterator;
  +import java.util.Enumeration;
   import java.util.Properties;
   import java.util.Vector;
   import javax.servlet.ServletConfig;
  @@ -92,7 +93,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.3 2001/09/21 02:20:51 jvanzyl Exp $
  + * @version $Id: TurbineResourceService.java,v 1.4 2001/09/25 02:18:17 jvanzyl Exp $
    */
   public class TurbineResourceService 
       extends TurbineBaseService
  @@ -471,7 +472,7 @@
        * @return The value of the resource as a string.
        */
       public String getString(String name,
  -                                   String def)
  +                            String def)
       {
           return interpolate(getConfiguration().getString(name, def));
       }
  @@ -485,7 +486,17 @@
        */
       public String[] getStringArray(String name)
       {
  -        return getConfiguration().getStringArray(name);
  +        String[] std = getConfiguration().getStringArray(name);
  +
  +        if (std != null) 
  +        {
  +            for(int i=0; i<std.length; i++) 
  +            {
  +                std[i]=interpolate(std[i]);
  +            }
  +        }
  +        
  +        return std;
       }
   
       /**
  @@ -497,7 +508,20 @@
        */
       public Vector getVector(String name)
       {
  -        return getConfiguration().getVector(name);
  +        Vector std = getConfiguration().getVector(name);
  +        
  +        if (std != null) 
  +        {
  +            Vector newstd = new Vector();
  +            Enumeration en = std.elements();
  +            while (en.hasMoreElements()) 
  +            {
  +                newstd.addElement(interpolate((String)en.nextElement()));
  +            }
  +            std = newstd;
  +        }
  +        
  +        return std;
       }
   
       /**
  @@ -509,9 +533,23 @@
        * @return The value of the resource as a vector.
        */
       public Vector getVector(String name,
  -                                   Vector def)
  +                            Vector def)
       {
  -        return getConfiguration().getVector(name, def);
  +        Vector std = getVector(name); 
  +        if (std == null) 
  +        {
  +            if (def != null) 
  +            {
  +                std = new Vector();
  +                Enumeration en = def.elements();
  +                while (en.hasMoreElements()) 
  +                {
  +                    std.addElement(interpolate((String)en.nextElement()));
  +                }
  +            }
  +        }
  +
  +        return std;
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org