View Javadoc

1   package org.apache.turbine.services.intake;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.beans.IntrospectionException;
23  
24  import java.lang.reflect.Method;
25  
26  import org.apache.turbine.services.intake.model.Group;
27  
28  /***
29   * This service provides access to input processing objects based
30   * on an XML specification.
31   *
32   * <p>Localization of Intake's error messages can be accomplished
33   * using Turbine's <code>LocalizationTool</code> from a Velocity template
34   * as follows:
35   * <blockquote><code></pre>
36   * $l10n.get($intake.SomeGroup.SomeField.Message)
37   * </pre></code></blockquote>
38   * </p>
39   *
40   * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
41   * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
42   * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
43   * @version $Id: IntakeService.java 534527 2007-05-02 16:10:59Z tv $
44   */
45  public interface IntakeService
46  {
47      /***
48       * The key under which this service is stored in TurbineServices.
49       */
50      String SERVICE_NAME = "IntakeService";
51  
52      /***
53       * The property specifying the location of the xml specification.
54       */
55      String XML_PATH = "xml.path";
56  
57      /***
58       * The default location of the xml specification.
59       */
60      String XML_PATH_DEFAULT = "WEB-INF/conf/intake.xml";
61  
62      /***
63       * The property specifying the location where a serialized version of
64       * the xml specification can be written for faster restarts..
65       */
66      String SERIAL_XML = "serialize.path";
67  
68      /***
69       * The default location where a serialized version of
70       * the xml specification can be written for faster restarts..
71       */
72      String SERIAL_XML_DEFAULT = "WEB-INF/appData.ser";
73  
74      /***
75       * The default pool capacity.
76       */
77      int DEFAULT_POOL_CAPACITY = 1024;
78  
79      /***
80       * Gets an instance of a named group either from the pool
81       * or by calling the Factory Service if the pool is empty.
82       *
83       * @param groupName the name of the group.
84       * @return a Group instance.
85       * @throws IntakeException if recycling fails.
86       */
87      Group getGroup(String groupName)
88              throws IntakeException;
89  
90      /***
91       * Puts a group back to the pool.
92       * @param instance the object instance to recycle.
93       *
94       * @throws IntakeException The passed group name does not exist.
95       */
96      void releaseGroup(Group instance)
97              throws IntakeException;
98  
99      /***
100      * Gets the current size of the pool for a named group.
101      *
102      * @param groupName the name of the group.
103      *
104      * @throws IntakeException The passed group name does not exist.
105      */
106     int getSize(String groupName)
107             throws IntakeException;
108 
109     /***
110      * Names of all the defined groups.
111      *
112      * @return array of names.
113      */
114     String[] getGroupNames();
115 
116     /***
117      * Gets the key (usually a short identifier) for a group.
118      *
119      * @param groupName the name of the group.
120      * @return the key.
121      */
122     String getGroupKey(String groupName);
123 
124     /***
125      * Gets the group name given its key.
126      *
127      * @param groupKey the key.
128      * @return groupName the name of the group.
129      */
130     String getGroupName(String groupKey);
131 
132     /***
133      * Gets the Method that can be used to set a property.
134      *
135      * @param className the name of the object.
136      * @param propName the name of the property.
137      * @return the setter.
138      * @throws ClassNotFoundException
139      * @throws IntrospectionException
140      */
141     Method getFieldSetter(String className, String propName)
142             throws ClassNotFoundException, IntrospectionException;
143 
144     /***
145      * Gets the Method that can be used to get a property value.
146      *
147      * @param className the name of the object.
148      * @param propName the name of the property.
149      * @return the getter.
150      * @throws ClassNotFoundException
151      * @throws IntrospectionException
152      */
153     Method getFieldGetter(String className, String propName)
154             throws ClassNotFoundException, IntrospectionException;
155 }
156 
157 
158 
159 
160