View Javadoc
1 package org.apache.turbine.services.pool; 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 org.apache.turbine.util.TurbineException; 58 import org.apache.turbine.services.TurbineServices; 59 60 /*** 61 * This is a static accessor to common pooling tasks. 62 * 63 * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a> 64 * @version $Id: TurbinePool.java,v 1.1.1.1 2001/08/16 05:09:09 jvanzyl Exp $ 65 */ 66 public abstract class TurbinePool 67 { 68 /*** 69 * Gets an instance of a named class either from the pool 70 * or by calling the Factory Service if the pool is empty. 71 * 72 * @param className the name of the class. 73 * @return the instance. 74 * @throws TurbineException if recycling fails. 75 */ 76 public static Object getInstance(String className) 77 throws TurbineException 78 { 79 return getService().getInstance(className); 80 } 81 82 /*** 83 * Gets an instance of a named class either from the pool 84 * or by calling the Factory Service if the pool is empty. 85 * The specified class loader will be passed to the Factory Service. 86 * 87 * @param className the name of the class. 88 * @param loader the class loader. 89 * @return the instance. 90 * @throws TurbineException if recycling fails. 91 */ 92 public static Object getInstance(String className, 93 ClassLoader loader) 94 throws TurbineException 95 { 96 return getService().getInstance(className,loader); 97 } 98 99 /*** 100 * Gets an instance of a named class either from the pool 101 * or by calling the Factory Service if the pool is empty. 102 * Parameters for its constructor are given as an array of objects, 103 * primitive types must be wrapped with a corresponding class. 104 * 105 * @param className the name of the class. 106 * @param loader the class loader. 107 * @param params an array containing the parameters of the constructor. 108 * @param signature an array containing the signature of the constructor. 109 * @return the instance. 110 * @throws TurbineException if recycling fails. 111 */ 112 public static Object getInstance(String className, 113 Object[] params, 114 String[] signature) 115 throws TurbineException 116 { 117 return getService().getInstance(className,params,signature); 118 } 119 120 /*** 121 * Gets an instance of a named class either from the pool 122 * or by calling the Factory Service if the pool is empty. 123 * Parameters for its constructor are given as an array of objects, 124 * primitive types must be wrapped with a corresponding class. 125 * The specified class loader will be passed to the Factory Service. 126 * 127 * @param className the name of the class. 128 * @param loader the class loader. 129 * @param params an array containing the parameters of the constructor. 130 * @param signature an array containing the signature of the constructor. 131 * @return the instance. 132 * @throws TurbineException if recycling fails. 133 */ 134 public static Object getInstance(String className, 135 ClassLoader loader, 136 Object[] params, 137 String[] signature) 138 throws TurbineException 139 { 140 return getService().getInstance(className,loader,params,signature); 141 } 142 143 /*** 144 * Gets an instance of a specified class either from the pool 145 * or by instatiating from the class if the pool is empty. 146 * 147 * @param clazz the class. 148 * @return the instance. 149 * @throws TurbineException if recycling fails. 150 */ 151 public static Object getInstance(Class clazz) 152 throws TurbineException 153 { 154 return getService().getInstance(clazz); 155 } 156 157 /*** 158 * Gets an instance of a specified class either from the pool 159 * or by instatiating from the class if the pool is empty. 160 * 161 * @param clazz the class. 162 * @param params an array containing the parameters of the constructor. 163 * @param signature an array containing the signature of the constructor. 164 * @return the instance. 165 * @throws TurbineException if recycling fails. 166 */ 167 public static Object getInstance(Class clazz, 168 Object params[], 169 String signature[]) 170 throws TurbineException 171 { 172 return getService().getInstance(clazz,params,signature); 173 } 174 175 /*** 176 * Puts a used object back to the pool. Objects implementing 177 * the Recyclable interface can provide a recycle method to 178 * be called when they are reused and a dispose method to be 179 * called when they are returned to the pool. 180 * 181 * @param instance the object instance to recycle. 182 * @return true if the instance was accepted. 183 */ 184 public static boolean putInstance(Object instance) 185 { 186 return getService().putInstance(instance); 187 } 188 189 /*** 190 * Gets the pool service implementation. 191 * 192 * @return the pool service implementation. 193 */ 194 protected static PoolService getService() 195 { 196 return (PoolService) TurbineServices. 197 getInstance().getService(PoolService.SERVICE_NAME); 198 } 199 }

This page was automatically generated by Maven