View Javadoc
1 package org.apache.turbine.services.intake; 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.lang.reflect.Method; 58 import org.apache.turbine.services.intake.model.Group; 59 import org.apache.turbine.util.TurbineException; 60 import org.apache.turbine.services.TurbineServices; 61 62 /*** 63 * This is a Facade class for IntakeService. 64 * 65 * This class provides static methods that call related methods of the 66 * implementation of the IntakeService used by the System, according to 67 * the settings in TurbineResources. 68 * 69 * @author <a href="mailto:jmcnally@collab.net">John McNally</a> 70 * @version $Id: TurbineIntake.java,v 1.1.1.1 2001/08/16 05:08:55 jvanzyl Exp $ 71 */ 72 public abstract class TurbineIntake 73 { 74 /*** 75 * Gets an instance of a named group either from the pool 76 * or by calling the Factory Service if the pool is empty. 77 * 78 * @param groupName the name of the group. 79 * @return a Group instance. 80 * @throws TurbineException if recycling fails. 81 */ 82 public static Group getGroup(String groupName) 83 throws TurbineException 84 { 85 return getService().getGroup(groupName); 86 } 87 /*** 88 * Gets an instance of a named group either from the pool 89 * or by calling the Factory Service if the pool is empty and 90 * then initialize it using the ParameterParser looking for 91 * a NEW id. 92 * 93 * @param groupName the name of the group. 94 * @param pp the request parameters that may contain matching keys 95 * @return a Group instance. 96 * @throws TurbineException if recycling fails. 97 * / 98 public static Group getGroup(String groupName, ParameterParser pp) 99 throws Exception 100 { 101 return getService().getGroup(groupName, pp); 102 } 103 104 /** 105 * Gets an instance of a named group either from the pool 106 * or by calling the Factory Service if the pool is empty and 107 * then initialize it using the ParameterParser looking for id. 108 * 109 * @param groupName the name of the group. 110 * @param pp the request parameters that may contain matching keys 111 * @return a Group instance. 112 * @throws TurbineException if recycling fails. 113 * / 114 public static Group getGroup(String groupName, 115 ParameterParser pp, String id) 116 throws Exception 117 { 118 return getService().getGroup(groupName, pp, id); 119 } 120 */ 121 122 /*** 123 * Puts a group back to the pool. 124 * @param instance the object instance to recycle. 125 * @return true if the instance was accepted. 126 */ 127 public static boolean releaseGroup(Group instance) 128 { 129 return getService().releaseGroup(instance); 130 } 131 132 /*** 133 * Gets the capacity of the pool for a named group. 134 * 135 * @param groupName the name of the group. 136 */ 137 public static int getCapacity(String groupName) 138 { 139 return getService().getCapacity(groupName); 140 } 141 142 /*** 143 * Sets the capacity of the pool for a named group. 144 * Note that the pool will be cleared after the change. 145 * 146 * @param groupName the name of the group. 147 * @param capacity the new capacity. 148 */ 149 public static void setCapacity(String groupName, int capacity) 150 { 151 getService().setCapacity(groupName, capacity); 152 } 153 154 /*** 155 * Gets the current size of the pool for a named group. 156 * 157 * @param groupName the name of the group. 158 */ 159 public static int getSize(String groupName) 160 { 161 return getService().getSize(groupName); 162 } 163 164 /*** 165 * Clears instances of a named group from the pool. 166 * 167 * @param groupName the name of the group. 168 */ 169 public static void clearPool(String groupName) 170 { 171 getService().clearPool(groupName); 172 } 173 174 /*** 175 * Clears all instances from the pool. 176 */ 177 public static void clearPool() 178 { 179 getService().clearPool(); 180 } 181 182 /*** 183 * Names of all the defined groups. 184 * 185 * @return array of names. 186 */ 187 public static String[] getGroupNames() 188 { 189 return getService().getGroupNames(); 190 } 191 192 /*** 193 * Gets the key (usually a short identifier) for a group. 194 * 195 * @param groupName the name of the group. 196 * @return the the key. 197 */ 198 public static String getGroupKey(String groupName) 199 { 200 return getService().getGroupKey(groupName); 201 } 202 203 /*** 204 * Gets the group name given its key. 205 * 206 * @param the the key. 207 * @return groupName the name of the group. 208 */ 209 public static String getGroupName(String groupKey) 210 { 211 return getService().getGroupName(groupKey); 212 } 213 214 /*** 215 * Gets the Method that can be used to set a property. 216 * 217 * @param className the name of the object. 218 * @param propName the name of the property. 219 * @return the setter. 220 */ 221 public static Method getFieldSetter(String className, String propName) 222 { 223 return getService().getFieldSetter(className, propName); 224 } 225 226 /*** 227 * Gets the Method that can be used to get a property value. 228 * 229 * @param className the name of the object. 230 * @param propName the name of the property. 231 * @return the getter. 232 */ 233 public static Method getFieldGetter(String className, String propName) 234 { 235 return getService().getFieldGetter(className, propName); 236 } 237 238 /*** 239 * Utility method for accessing the service 240 * implementation 241 * 242 * @return a IntakeService implementation instance 243 */ 244 private static IntakeService getService() 245 { 246 return (IntakeService)TurbineServices 247 .getInstance().getService(IntakeService.SERVICE_NAME); 248 } 249 250 } 251 252 253 254 255 256 257 258 259 260

This page was automatically generated by Maven