dlr 02/01/02 00:11:57
Modified: src/java/org/apache/turbine/pipeline ValveDefinition.java
Log:
Added a toValve() method which returns an instance of the Valve
implementation represented by a ValveDefinition. Includes some error
detection.
Revision Changes Path
1.3 +26 -1
jakarta-turbine-3/src/java/org/apache/turbine/pipeline/ValveDefinition.java
Index: ValveDefinition.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/ValveDefinition.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -u -r1.2 -r1.3
--- ValveDefinition.java 2 Jan 2002 07:48:34 -0000 1.2
+++ ValveDefinition.java 2 Jan 2002 08:11:57 -0000 1.3
@@ -54,11 +54,15 @@
* <http://www.apache.org/>.
*/
+import org.apache.turbine.Valve;
+import org.apache.turbine.TurbineException;
+
/**
* This class describes a valve for use with a TurbinePipeline.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: ValveDefinition.java,v 1.2 2002/01/02 07:48:34 dlr Exp $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
+ * @version $Id: ValveDefinition.java,v 1.3 2002/01/02 08:11:57 dlr Exp $
*/
public class ValveDefinition
{
@@ -113,4 +117,25 @@
{
return className;
}
+
+ /**
+ * Returns an instance of the <code>Valve</code> represented by
+ * this object.
+ *
+ * @return An instance of the <code>Valve</code> named by
+ * <code>className</code>.
+ * @exception TurbineException Definition class is not a {@link
+ * org.apache.turbine.Valve} implementation.
+ * @exception Exception Error instantiating class.
+ */
+ public Valve toValve()
+ throws TurbineException, Exception
+ {
+ Class c = Class.forName(getClassName());
+ if (!c.isAssignableFrom(Valve.class))
+ {
+ throw new TurbineException(c.getName() + " is not a Valve");
+ }
+ return (Valve) c.newInstance();
+ }
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>