View Javadoc
1 package org.apache.turbine.services.resources; 2 3 /* ==================================================================== 4 * The Apache Software License, Version 1.1 5 * 6 * Copyright (c) 2001 The Apache Software Foundation. All rights 7 * reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in 18 * the documentation and/or other materials provided with the 19 * distribution. 20 * 21 * 3. The end-user documentation included with the redistribution, 22 * if any, must include the following acknowledgment: 23 * "This product includes software developed by the 24 * Apache Software Foundation (http://www.apache.org/)." 25 * Alternately, this acknowledgment may appear in the software itself, 26 * if and wherever such third-party acknowledgments normally appear. 27 * 28 * 4. The names "Apache" and "Apache Software Foundation" and 29 * "Apache Turbine" must not be used to endorse or promote products 30 * derived from this software without prior written permission. For 31 * written permission, please contact apache@apache.org. 32 * 33 * 5. Products derived from this software may not be called "Apache", 34 * "Apache Turbine", nor may "Apache" appear in their name, without 35 * prior written permission of the Apache Software Foundation. 36 * 37 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 38 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 39 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 40 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 41 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 43 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 44 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 45 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 47 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 48 * SUCH DAMAGE. 49 * ==================================================================== 50 * 51 * This software consists of voluntary contributions made by many 52 * individuals on behalf of the Apache Software Foundation. For more 53 * information on the Apache Software Foundation, please see 54 * <http://www.apache.org/>;. 55 */ 56 57 import java.util.Iterator; 58 import java.util.Vector; 59 import org.apache.commons.configuration.Configuration; 60 import org.apache.turbine.services.Service; 61 62 63 /*** 64 * <p>This service define a resource interface for accessing the configuration 65 * information of the application.</p> 66 * <p>Since implementations of this service are used by Turbine itself and 67 * the <code>TurbineServices</code> depends on their proper operation, they 68 * must respect some specific implementation rules:</p> 69 * <ul> 70 * <li>They can't use other services or classes depending on any services 71 * in their inititialization code. This would create circular services 72 * dependency 73 * </li> 74 * <li>They must provide an early initialization init method. The 75 * <code>ServletConfig</code> init parameters are the only way 76 * to retrieve parameters for this service. It's impossible to use 77 * TurbineServices utility methods for this purpose 78 * </li> 79 * </ul> 80 * 81 * @author <a href="mailto:jon@clearink.com">Jon S. Stevens</a> 82 * @author <a href="mailto:greg@shwoop.com">Greg Ritter</a> 83 * @author <a href="mailto:luta.raphael@networks.vivendi.net">Raphaël Luta</a> 84 * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a> 85 * @version $Id: ResourceService.java,v 1.5 2002/07/11 16:53:25 mpoeschl Exp $ 86 */ 87 public interface ResourceService extends Service 88 { 89 90 public String SERVICE_NAME = "ResourceService"; 91 92 /*** 93 * Set a property in with a key=value pair. 94 * 95 * @param String key 96 * @param String value 97 */ 98 public void setProperty(String key, String value); 99 100 /*** 101 * The purpose of this method is to get the configuration resource 102 * with the given name as a boolean value. 103 * 104 * @param name The resource name. 105 * @return The value of the named resource as a boolean. 106 */ 107 public boolean getBoolean(String name); 108 109 /*** 110 * The purppose of this method is to get the configuration 111 * resource with the given name as a boolean value, or a default 112 * value. 113 * 114 * @param name The resource name. 115 * @param def The default value of the resource. 116 * @return The value of the named resource as a boolean. 117 */ 118 public boolean getBoolean(String name,boolean def); 119 120 /*** 121 * The purpose of this method is to get the configuration resource 122 * with the given name as a double. 123 * 124 * @param name The resoource name. 125 * @return The value of the named resource as double. 126 */ 127 public double getDouble(String name); 128 129 /*** 130 * The purpose of this method is to get the configuration resource 131 * with the given name as a double, or a default value. 132 * 133 * @param name The resource name. 134 * @param def The default value of the resource. 135 * @return The value of the named resource as a double. 136 */ 137 public double getDouble(String name,double def); 138 139 /*** 140 * The purpose of this method is to get the configuration resource 141 * with the given name as a float. 142 * 143 * @param name The resource name. 144 * @return The value of the resource as a float. 145 */ 146 public float getFloat(String name); 147 148 /*** 149 * The purpose of this method is to get the configuration resource 150 * with the given name as a float, or a default value. 151 * 152 * @param name The resource name. 153 * @param def The default value of the resource. 154 * @return The value of the resource as a float. 155 */ 156 public float getFloat(String name,float def); 157 158 /*** 159 * The purpose of this method is to get the configuration resource 160 * with the given name as an integer. 161 * 162 * @param name The resource name. 163 * @return The value of the resource as an integer. 164 */ 165 public int getInt(String name); 166 167 /*** 168 * The purpose of this method is to get the configuration resource 169 * with the given name as an integer, or a default value. 170 * 171 * @param name The resource name. 172 * @param def The default value of the resource. 173 * @return The value of the resource as an integer. 174 */ 175 public int getInt(String name,int def); 176 177 /*** 178 * Get the list of the keys contained in the configuration 179 * repository. 180 * 181 * @return An Enumeration with all the keys. 182 */ 183 public Iterator getKeys(); 184 185 /*** 186 * Get the list of the keys contained in the configuration 187 * repository that match the specified prefix. 188 * 189 * @param prefix A String prefix to test against. 190 * @return An Enumeration of keys that match the prefix. 191 */ 192 public Iterator getKeys(String prefix); 193 194 /*** 195 * The purpose of this method is to get the configuration resource 196 * with the given name as a long. 197 * 198 * @param name The resource name. 199 * @return The value of the resource as a long. 200 */ 201 public long getLong(String name); 202 203 /*** 204 * The purpose of this method is to get the configuration resource 205 * with the given name as a long, or a default value. 206 * 207 * @param name The resource name. 208 * @param def The default value of the resource. 209 * @return The value of the resource as a long. 210 */ 211 public long getLong(String name,long def); 212 213 /*** 214 * The purpose of this method is to get the configuration resource 215 * with the given name as a string. 216 * 217 * @param name The resource name. 218 * @return The value of the resource as a string. 219 */ 220 public String getString(String name); 221 222 /*** 223 * The purpose of this method is to get the configuration resource 224 * with the given name as a string, or a default value. 225 * 226 * @param name The resource name. 227 * @param def The default value of the resource. 228 * @return The value of the resource as a string. 229 */ 230 public String getString(String name,String def); 231 232 /*** 233 * The purpose of this method is to get the configuration resource 234 * with the given name as a string array. 235 * 236 * @param name The resource name. 237 * @return The value of the resource as a string array. 238 */ 239 public String[] getStringArray(String name); 240 241 /*** 242 * The purpose of this method is to get the configuration resource 243 * with the given name as a vector. 244 * 245 * @param name The resource name. 246 * @return The value of the resource as a vector. 247 */ 248 public Vector getVector(String name); 249 250 /*** 251 * The purpose of this method is to get the configuration resource 252 * with the given name as a vector, or a default value. 253 * 254 * @param name The resource name. 255 * @param def The default value of the resource. 256 * @return The value of the resource as a vector. 257 */ 258 public Vector getVector(String name,Vector def); 259 260 /*** 261 * The purpose of this method is to extract a subset of configuraton 262 * resources sharing a common name prefix. 263 * 264 * @param prefix the common name prefix 265 * @return A ResourceService providing the subset of configuration. 266 */ 267 public ResourceService getResources(String prefix); 268 269 /*** 270 * The purpose of this method is to extract a subset configuraton 271 * sharing a common name prefix. 272 * 273 * @param prefix the common name prefix 274 * @return A Configuration providing the subset of configuration. 275 */ 276 public Configuration getConfiguration(String prefix); 277 }

This page was automatically generated by Maven