jvanzyl     01/06/14 07:42:27

  Modified:    src/java/org/apache/turbine/services/resources
                        ResourceService.java TurbineResourceService.java
                        TurbineResources.java
  Log:
  - updating service as per notes.
  
  Revision  Changes    Path
  1.12      +1 -19     
jakarta-turbine/src/java/org/apache/turbine/services/resources/ResourceService.java
  
  Index: ResourceService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/resources/ResourceService.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ResourceService.java      2001/05/05 14:43:58     1.11
  +++ ResourceService.java      2001/06/14 14:42:26     1.12
  @@ -83,7 +83,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Greg Ritter</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rapha�l Luta</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
  - * @version $Id: ResourceService.java,v 1.11 2001/05/05 14:43:58 jvanzyl Exp $
  + * @version $Id: ResourceService.java,v 1.12 2001/06/14 14:42:26 jvanzyl Exp $
    */
   public interface ResourceService extends Service
   {
  @@ -249,22 +249,4 @@
        * @return The value of the resource as a vector.
        */
       public Vector getVector(String name,Vector def);
  -
  -    /**
  -     * The purpose of this method is to extract a subset of configuraton
  -     * resources sharing a common name prefix.
  -     *
  -     * @param prefix the common name prefix
  -     * @return A ResourceService providing the subset of configuration.
  -     */
  -    public ResourceService getResources(String prefix);
  -
  -    /**
  -     * The purpose of this method is to extract a subset configuraton
  -     * sharing a common name prefix.
  -     *
  -     * @param prefix the common name prefix
  -     * @return A Configuration providing the subset of configuration.
  -     */
  -    public Configuration getConfiguration(String prefix);
   }
  
  
  
  1.32      +28 -203   
jakarta-turbine/src/java/org/apache/turbine/services/resources/TurbineResourceService.java
  
  Index: TurbineResourceService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/resources/TurbineResourceService.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- TurbineResourceService.java       2001/05/05 14:43:58     1.31
  +++ TurbineResourceService.java       2001/06/14 14:42:26     1.32
  @@ -58,17 +58,13 @@
   import java.util.Iterator;
   import java.util.Properties;
   import java.util.Vector;
  -import javax.servlet.ServletConfig;
  -import org.apache.turbine.services.BaseInitable;
  +import org.apache.turbine.Turbine;
   import org.apache.turbine.services.BaseServiceBroker;
   import org.apache.turbine.services.InitializationException;
   import org.apache.turbine.services.ServiceBroker;
  -import org.apache.turbine.services.TurbineBaseService;
  +import org.apache.turbine.services.BaseService;
   import org.apache.turbine.services.TurbineServices;
  -import org.apache.turbine.util.ServletUtils;
  -import org.apache.turbine.util.TurbineConfig;
   import org.apache.turbine.util.TurbineException;
  -import org.apache.velocity.runtime.configuration.Configuration;
   
   /**
    * <p>This implementation of the <code>resourcesService</code> relies
  @@ -91,154 +87,27 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Frank Y. Kim</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rapha�l Luta</a>
    * @author <a href="mailto:[EMAIL PROTECTED]@";>Jason van Zyl</a>
  - * @version $Id: TurbineResourceService.java,v 1.31 2001/05/05 14:43:58 jvanzyl Exp 
$
  + * @version $Id: TurbineResourceService.java,v 1.32 2001/06/14 14:42:26 jvanzyl Exp 
$
    */
  -public class TurbineResourceService extends TurbineBaseService
  +public class TurbineResourceService 
  +    extends BaseService
       implements ResourceService
   {
  -    /** The container for the generic resources. */
  -    //private GenericResources generic = null;
  -    private Configuration configuration = null;
  -
       /**
  -     * Performs early initialization.  Overrides init() method in
  -     * BaseService to detect objects used in Turbine's Service
  -     * initialization and pass them to apropriate init() methods.
  +     * Performs initialization. 
        *
  -     * @param data An Object to use for initialization activities.
        * @exception InitializationException, if initialization of this
        * class was not successful.
        */
  -    public void init( Object data )
  +    public void init() 
           throws InitializationException
  -    {
  -        if (data instanceof ServletConfig)
  -        {
  -            init((ServletConfig)data);
  -        }
  -        else if (data instanceof Properties)
  -        {
  -            init((Properties)data);
  -        }
  -        else if (data instanceof Configuration)
  -        {
  -            init((Configuration)data);
  -        }
  -    }
  -
  -    /**
  -     * This method is called when the Service is initialized
  -     *
  -     * @param config a ServletConfig object
  -     */
  -    public void init(ServletConfig config) throws InitializationException
  -    {
  -        String props = config.getInitParameter(TurbineServices.PROPERTIES_PATH_KEY);
  -        
  -        if(props == null) 
  -        {
  -            props = TurbineServices.PROPERTIES_PATH_DEFAULT;
  -        }
  -
  -        // This will attempt to find the location of the properties
  -        // file from the relative path to the WAR archive (ie:
  -        // docroot). Since JServ returns null for getRealPath()
  -        // because it was never implemented correctly, then we know we
  -        // will not have an issue with using it this way. I don't know
  -        // if this will break other servlet engines, but it probably
  -        // shouldn't since WAR files are the future anyways.
  -        props = ServletUtils.expandRelative(config, props);
  -
  -        try
  -        {
  -            init(new Configuration(props));
  -        }
  -        catch (IOException e)
  -        {
  -            throw new InitializationException("Can't load file " + props);
  -        }
  -    }
  -
  -    /**
  -     * Init the service with the given properties filename
  -     *
  -     * @deprecated
  -     * @param propertiesFileName The file name.
  -     * @exception IOException, if there was an I/O problem.
  -     */
  -    public static void setPropertiesFileName(String propertiesFileName)
  -        throws TurbineException
       {
  -        Configuration mappings = new Configuration();
  -        
  -        mappings.setProperty(ResourceService.SERVICE_NAME,
  -            TurbineResourceService.class.getName());
  -        
  -        TurbineServices services = (TurbineServices) TurbineServices.getInstance();
  -        services.initMapping(mappings);
  -        services.initServices(new TurbineConfig(".", propertiesFileName), true);
  -    }
  -
  -    /**
  -     * Init the service with the given properties object.  Called
  -     * from Cocoon to initialize Turbine.
  -     *
  -     * @param properties The java.util.Properties object sent from another process 
such as
  -     *                   Cocoon.  This Properties object contains all of the 
necessary properties
  -     *                   found in the TurbineResources.properties file.
  -     * @exception TurbineException, if there was an I/O problem.
  -     */
  -    public static void setProperties(Properties properties)
  -        throws TurbineException
  -    {
  -        Configuration mappings = new Configuration();
  -        
  -        mappings.setProperty(ResourceService.SERVICE_NAME,
  -            TurbineResourceService.class.getName());
  -        
  -        TurbineServices services = (TurbineServices) TurbineServices.getInstance();
  -        services.initMapping(mappings);
  -        services.initServices(properties, true);
  -    }
  -
  -    /**
  -     * Wrapper around the configuration resources.
  -     *
  -     * @return A Configuration.
  -     */
  -    public Configuration getConfiguration()
  -    {
  -        return configuration;
  -    }
  -
  -    /**
  -     * Initializer method that sets up the configuration resources.
  -     *
  -     * @param confs A Configurations object.
  -     */
  -    private void init(Configuration configuration)
  -    {
  -        this.configuration = configuration;
  +        // We are now using the Turbine class to retrieve
  +        // application specific configuration.
           setInit(true);
       }
   
       /**
  -     * The purpose of this method is to init the configuration
  -     * resource with a Properties object sent from a different system.
  -     * For example, a Properties sent over from Cocoon.  The reason
  -     * for this code is to provide a bridge between an
  -     * org.apache.turbine.util.Configurations class and an
  -     * org.apache.cocoon.framework.Configurations class.
  -     *
  -     * @param props A Properties object.
  -     */
  -    private void init(Properties props)
  -    {
  -        Configuration configuration = Configuration.convertProperties(props);
  -        init(configuration);
  -    }
  -
  -    /**
        * The purpose of this method is to get the configuration resource
        * with the given name as a boolean value.
        *
  @@ -247,7 +116,7 @@
        */
       public boolean getBoolean(String name)
       {
  -        return getConfiguration().getBoolean(name);
  +        return Turbine.getConfiguration().getBoolean(name);
       }
   
       /**
  @@ -259,10 +128,9 @@
        * @param def The default value of the resource.
        * @return The value of the named resource as a boolean.
        */
  -    public boolean getBoolean(String name,
  -                                     boolean def)
  +    public boolean getBoolean(String name, boolean def)
       {
  -        return getConfiguration().getBoolean(name, def);
  +        return Turbine.getConfiguration().getBoolean(name, def);
       }
   
       /**
  @@ -274,7 +142,7 @@
        */
       public double getDouble(String name)
       {
  -        return getConfiguration().getDouble(name);
  +        return Turbine.getConfiguration().getDouble(name);
       }
   
       /**
  @@ -288,7 +156,7 @@
       public double getDouble(String name,
                                      double def)
       {
  -        return getConfiguration().getDouble(name, def);
  +        return Turbine.getConfiguration().getDouble(name, def);
       }
   
       /**
  @@ -300,7 +168,7 @@
        */
       public float getFloat(String name)
       {
  -        return getConfiguration().getFloat(name);
  +        return Turbine.getConfiguration().getFloat(name);
       }
   
       /**
  @@ -314,7 +182,7 @@
       public float getFloat(String name,
                                    float def)
       {
  -        return getConfiguration().getFloat(name, def);
  +        return Turbine.getConfiguration().getFloat(name, def);
       }
   
       /**
  @@ -334,7 +202,7 @@
        */
       public int getInt(String name)
       {
  -        return getConfiguration().getInt(name);
  +        return Turbine.getConfiguration().getInt(name);
       }
   
       /**
  @@ -348,7 +216,7 @@
       public int getInt(String name,
                                int def)
       {
  -        return getConfiguration().getInt(name, def);
  +        return Turbine.getConfiguration().getInt(name, def);
       }
   
       /**
  @@ -360,7 +228,7 @@
       //public Enumeration getKeys()
       public Iterator getKeys()
       {
  -        return getConfiguration().getKeys();
  +        return Turbine.getConfiguration().getKeys();
       }
   
       /**
  @@ -372,7 +240,7 @@
        */
       public Iterator getKeys(String prefix)
       {
  -        return getConfiguration().getKeys(prefix);
  +        return Turbine.getConfiguration().getKeys(prefix);
       }
   
       /**
  @@ -384,7 +252,7 @@
        */
       public long getLong(String name)
       {
  -        return getConfiguration().getLong(name);
  +        return Turbine.getConfiguration().getLong(name);
       }
   
       /**
  @@ -398,7 +266,7 @@
       public long getLong(String name,
                                  long def)
       {
  -        return getConfiguration().getLong(name, def);
  +        return Turbine.getConfiguration().getLong(name, def);
       }
   
       /**
  @@ -410,7 +278,7 @@
        */
       public String getString(String name)
       {
  -        return getConfiguration().getString(name);
  +        return Turbine.getConfiguration().getString(name);
       }
   
       /**
  @@ -424,7 +292,7 @@
       public String getString(String name,
                                      String def)
       {
  -        return getConfiguration().getString(name, def);
  +        return Turbine.getConfiguration().getString(name, def);
       }
   
       /**
  @@ -436,7 +304,7 @@
        */
       public String[] getStringArray(String name)
       {
  -        return getConfiguration().getStringArray(name);
  +        return Turbine.getConfiguration().getStringArray(name);
       }
   
       /**
  @@ -448,7 +316,7 @@
        */
       public Vector getVector(String name)
       {
  -        return getConfiguration().getVector(name);
  +        return Turbine.getConfiguration().getVector(name);
       }
   
       /**
  @@ -458,52 +326,9 @@
        * @param name The resource name.
        * @param def The default value of the resource.
        * @return The value of the resource as a vector.
  -     */
  -    public Vector getVector(String name,
  -                                   Vector def)
  -    {
  -        return getConfiguration().getVector(name, def);
  -    }
  -
  -    /**
  -     * The purpose of this method is to extract a subset of configuraton
  -     * resources sharing a common name prefix. The prefix is stripped
  -     * from the names of the resulting resources.
  -     *
  -     * @param prefix the common name prefix
  -     * @return A ResourceService providing the subset of configuration.
  -     */
  -    public ResourceService getResources(String prefix)
  -    {
  -        Configuration config = getConfiguration().subset(prefix);
  -        
  -        if (config == null)
  -        {
  -            return null;
  -        }
  -        
  -        TurbineResourceService res = new TurbineResourceService();
  -        res.init(config);
  -        return (ResourceService)res;
  -    }
  -
  -    /**
  -     * The purpose of this method is to extract a subset of configuraton
  -     * resources sharing a common name prefix. The prefix is stripped
  -     * from the names of the resulting resources.
  -     *
  -     * @param prefix the common name prefix
  -     * @return A Configuration providing the subset of configuration.
        */
  -    public Configuration getConfiguration(String prefix)
  +    public Vector getVector(String name, Vector def)
       {
  -        Configuration config = getConfiguration().subset(prefix);
  -        
  -        if (config == null)
  -        {
  -            return null;
  -        }
  -        
  -        return config;
  +        return Turbine.getConfiguration().getVector(name, def);
       }
   }
  
  
  
  1.23      +4 -28     
jakarta-turbine/src/java/org/apache/turbine/services/resources/TurbineResources.java
  
  Index: TurbineResources.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/resources/TurbineResources.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- TurbineResources.java     2001/05/05 14:43:58     1.22
  +++ TurbineResources.java     2001/06/14 14:42:26     1.23
  @@ -56,8 +56,9 @@
   
   import java.util.Iterator;
   import java.util.Vector;
  -import javax.servlet.ServletConfig;
   import org.apache.turbine.services.TurbineServices;
  +
  +//!! has to go away.
   import org.apache.velocity.runtime.configuration.Configuration;
   
   /**
  @@ -71,7 +72,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Greg Ritter</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rapha�l Luta</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
  - * @version $Id: TurbineResources.java,v 1.22 2001/05/05 14:43:58 jvanzyl Exp $
  + * @version $Id: TurbineResources.java,v 1.23 2001/06/14 14:42:26 jvanzyl Exp $
    */
   public abstract class TurbineResources
   {
  @@ -107,8 +108,7 @@
       protected static ResourceService getService()
       {
           return (ResourceService)TurbineServices
  -                    .getInstance()
  -                    .getService(ResourceService.SERVICE_NAME);
  +            .getInstance().getService(ResourceService.SERVICE_NAME);
       }
   
       /**
  @@ -327,29 +327,5 @@
                                      Vector def)
       {
           return getService().getVector(name,def);
  -    }
  -
  -    /**
  -     * The purpose of this method is to extract a subset of configuraton
  -     * resources sharing a common name prefix.
  -     *
  -     * @param prefix the common name prefix
  -     * @return A ResourceService providing the subset of configuration.
  -     */
  -    public static ResourceService getResources(String prefix)
  -    {
  -        return getService().getResources(prefix);
  -    }
  -
  -    /**
  -     * The purpose of this method is to extract a subset configuraton
  -     * sharing a common name prefix.
  -     *
  -     * @param prefix the common name prefix
  -     * @return A Configuration providing the subset of configuration.
  -     */
  -    public static Configuration getConfiguration(String prefix)
  -    {
  -        return getService().getConfiguration(prefix);
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to