KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fulcrum > intake > TurbineIntake


1 package org.apache.fulcrum.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 JavaDoc;
58 import org.apache.fulcrum.intake.model.Group;
59 import org.apache.fulcrum.ServiceException;
60 import org.apache.fulcrum.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 2004/11/12 10:25:56 epugh 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 ServiceException if recycling fails.
81      */

82     public static Group getGroup(String JavaDoc groupName)
83         throws ServiceException
84     {
85         if (groupName == null)
86         {
87             throw new ServiceException (
88                 "TurbineIntake.getGroup(groupName) is null");
89         }
90         return getService().getGroup(groupName);
91     }
92     
93     /**
94      * Gets an instance of a named group either from the pool
95      * or by calling the Factory Service if the pool is empty and
96      * then initialize it using the ValueParser looking for
97      * a NEW id.
98      *
99      * @param groupName the name of the group.
100      * @param pp the request parameters that may contain matching keys
101      * @return a Group instance.
102      * @throws ServiceException if recycling fails.
103      * /
104     public static Group getGroup(String groupName, ValueParser pp)
105         throws Exception
106     {
107         return getService().getGroup(groupName, pp);
108     }
109
110     /**
111      * Gets an instance of a named group either from the pool
112      * or by calling the Factory Service if the pool is empty and
113      * then initialize it using the ValueParser looking for id.
114      *
115      * @param groupName the name of the group.
116      * @param pp the request parameters that may contain matching keys
117      * @return a Group instance.
118      * @throws ServiceException if recycling fails.
119      * /
120     public static Group getGroup(String groupName,
121                                  ValueParser pp, String id)
122         throws Exception
123     {
124         return getService().getGroup(groupName, pp, id);
125     }
126     */

127
128     /**
129      * Puts a group back to the pool.
130      * @param instance the object instance to recycle.
131      * @return true if the instance was accepted.
132      */

133     public static void releaseGroup(Group instance)
134     {
135         getService().releaseGroup(instance);
136     }
137
138     /**
139      * Gets the current size of the pool for a named group.
140      *
141      * @param groupName the name of the group.
142      */

143     public static int getSize(String JavaDoc groupName)
144     {
145         return getService().getSize(groupName);
146     }
147
148     /**
149      * Names of all the defined groups.
150      *
151      * @return array of names.
152      */

153     public static String JavaDoc[] getGroupNames()
154     {
155         return getService().getGroupNames();
156     }
157
158     /**
159      * Gets the key (usually a short identifier) for a group.
160      *
161      * @param groupName the name of the group.
162      * @return the the key.
163      */

164     public static String JavaDoc getGroupKey(String JavaDoc groupName)
165     {
166         return getService().getGroupKey(groupName);
167     }
168
169     /**
170      * Gets the group name given its key.
171      *
172      * @param the the key.
173      * @return groupName the name of the group.
174      */

175     public static String JavaDoc getGroupName(String JavaDoc groupKey)
176     {
177         return getService().getGroupName(groupKey);
178     }
179
180     /**
181      * Gets the Method that can be used to set a property.
182      *
183      * @param className the name of the object.
184      * @param propName the name of the property.
185      * @return the setter.
186      */

187     public static Method JavaDoc getFieldSetter(String JavaDoc className, String JavaDoc propName)
188     {
189         return getService().getFieldSetter(className, propName);
190     }
191
192     /**
193      * Gets the Method that can be used to get a property value.
194      *
195      * @param className the name of the object.
196      * @param propName the name of the property.
197      * @return the getter.
198      */

199     public static Method JavaDoc getFieldGetter(String JavaDoc className, String JavaDoc propName)
200     {
201         return getService().getFieldGetter(className, propName);
202     }
203
204     /**
205      * Utility method for accessing the service
206      * implementation
207      *
208      * @return a IntakeService implementation instance
209      */

210     private static IntakeService getService()
211     {
212         return (IntakeService)TurbineServices
213             .getInstance().getService(IntakeService.SERVICE_NAME);
214     }
215
216 }
217
218
219
220
221
222
223
224
225
226
227
Popular Tags