You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by ge...@apache.org on 2002/04/21 20:36:07 UTC
cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime RuntimeConstants.java RuntimeServices.java RuntimeInstance.java
geirm 02/04/21 11:36:07
Modified: src/java/org/apache/velocity/runtime RuntimeConstants.java
RuntimeServices.java RuntimeInstance.java
Log:
Support for 'Uberspection', the federated introspection system (and
pluggable)
Revision Changes Path
1.32 +7 -1 jakarta-velocity/src/java/org/apache/velocity/runtime/RuntimeConstants.java
Index: RuntimeConstants.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/RuntimeConstants.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- RuntimeConstants.java 6 Nov 2001 03:23:05 -0000 1.31
+++ RuntimeConstants.java 21 Apr 2002 18:36:06 -0000 1.32
@@ -62,7 +62,7 @@
* @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
* @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
- * @version $Id: RuntimeConstants.java,v 1.31 2001/11/06 03:23:05 geirm Exp $
+ * @version $Id: RuntimeConstants.java,v 1.32 2002/04/21 18:36:06 geirm Exp $
*/
public interface RuntimeConstants
{
@@ -394,4 +394,10 @@
final static int NUMBER_OF_PARSERS = 20;
final static String PARSER_POOL_SIZE = "parser.pool.size";
+
+
+ /**
+ * key name for uberspector
+ */
+ final static String UBERSPECT_CLASSNAME = "runtime.introspector.uberspect";
}
1.5 +9 -36 jakarta-velocity/src/java/org/apache/velocity/runtime/RuntimeServices.java
Index: RuntimeServices.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/RuntimeServices.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- RuntimeServices.java 3 Jan 2002 12:40:23 -0000 1.4
+++ RuntimeServices.java 21 Apr 2002 18:36:06 -0000 1.5
@@ -92,6 +92,7 @@
import org.apache.velocity.util.StringUtils;
import org.apache.velocity.util.introspection.Introspector;
+import org.apache.velocity.util.introspection.Uberspect;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.exception.ParseErrorException;
@@ -107,9 +108,9 @@
* Currently implemented by RuntimeInstance.
*
* @author <a href="mailto:geirm@optonline.net">Geir Magusson Jr.</a>
- * @version $Id: RuntimeServices.java,v 1.4 2002/01/03 12:40:23 geirm Exp $
+ * @version $Id: RuntimeServices.java,v 1.5 2002/04/21 18:36:06 geirm Exp $
*/
-public interface RuntimeServices
+public interface RuntimeServices extends RuntimeLogger
{
/*
@@ -299,34 +300,6 @@
* @return class name of loader than can provide it
*/
public String getLoaderNameForResource( String resourceName );
-
- /**
- * Log a warning message.
- *
- * @param Object message to log
- */
- public void warn(Object message);
-
- /**
- * Log an info message.
- *
- * @param Object message to log
- */
- public void info(Object message);
-
- /**
- * Log an error message.
- *
- * @param Object message to log
- */
- public void error(Object message);
-
- /**
- * Log a debug message.
- *
- * @param Object message to log
- */
- public void debug(Object message);
/**
* String property accessor method with default to hide the
@@ -419,13 +392,13 @@
public ExtendedProperties getConfiguration();
/*
- * Return this instance's Introspector
- */
- public Introspector getIntrospector();
-
- /*
* Return the specified applcation attribute
*/
public Object getApplicationAttribute( Object key );
-
+
+ public Uberspect getUberspect();
+
+ public Introspector getIntrospector();
+
+
}
1.16 +81 -8 jakarta-velocity/src/java/org/apache/velocity/runtime/RuntimeInstance.java
Index: RuntimeInstance.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/RuntimeInstance.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- RuntimeInstance.java 12 Feb 2002 18:38:00 -0000 1.15
+++ RuntimeInstance.java 21 Apr 2002 18:36:06 -0000 1.16
@@ -93,6 +93,9 @@
import org.apache.velocity.util.StringUtils;
import org.apache.velocity.util.introspection.Introspector;
+import org.apache.velocity.util.introspection.Uberspect;
+import org.apache.velocity.util.introspection.UberspectImpl;
+import org.apache.velocity.util.introspection.UberspectLoggable;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.exception.ParseErrorException;
@@ -144,7 +147,7 @@
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
* @author <a href="mailto:jlb@houseofdistraction.com">Jeff Bowden</a>
* @author <a href="mailto:geirm@optonline.net">Geir Magusson Jr.</a>
- * @version $Id: RuntimeInstance.java,v 1.15 2002/02/12 18:38:00 dlr Exp $
+ * @version $Id: RuntimeInstance.java,v 1.16 2002/04/21 18:36:06 geirm Exp $
*/
public class RuntimeInstance implements RuntimeConstants, RuntimeServices
{
@@ -209,16 +212,18 @@
* to ensure that each instance is completely separate.
*/
private Introspector introspector = null;
-
-
+
+
/*
* Opaque reference to something specificed by the
* application for use in application supplied/specified
* pluggable components
*/
private Map applicationAttributes = null;
-
-
+
+
+ private Uberspect uberSpect;
+
public RuntimeInstance()
{
/*
@@ -268,19 +273,82 @@
initializeResourceManager();
initializeDirectives();
initializeParserPool();
-
+
+ initializeIntrospection();
/*
* initialize the VM Factory. It will use the properties
* accessable from Runtime, so keep this here at the end.
*/
vmFactory.initVelocimacro();
-
+
info("Velocity successfully started.");
initialized = true;
}
}
+
+ /**
+ * Gets the classname for the Uberspect introspection package and
+ * instantiates an instance.
+ */
+ private void initializeIntrospection()
+ throws Exception
+ {
+ String rm = getString(RuntimeConstants.UBERSPECT_CLASSNAME);
+
+ if (rm != null && rm.length() > 0)
+ {
+ Object o = null;
+
+ try
+ {
+ o = Class.forName(rm).newInstance();
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ String err = "The specified class for Uberspect ("
+ + rm
+ + ") does not exist (or is not accessible to the current classlaoder.";
+ error(err);
+ throw new Exception(err);
+ }
+
+ if (!(o instanceof Uberspect))
+ {
+ String err = "The specified class for Uberspect ("
+ + rm
+ + ") does not implement org.apache.velocity.util.introspector.Uberspect."
+ + " Velocity not initialized correctly.";
+
+ error(err);
+ throw new Exception(err);
+ }
+
+ uberSpect = (Uberspect) o;
+
+ if (uberSpect instanceof UberspectLoggable)
+ {
+ ((UberspectLoggable) uberSpect).setRuntimeLogger(this);
+ }
+
+ uberSpect.init();
+ }
+ else
+ {
+ /*
+ * someone screwed up. Lets not fool around...
+ */
+
+ String err = "It appears that no class was specified as the"
+ + " Uberspect. Please ensure that all configuration"
+ + " information is correct.";
+
+ error(err);
+ throw new Exception(err);
+ }
+ }
+
/**
* Initializes the Velocity Runtime with properties file.
* The properties file may be in the file system proper,
@@ -1093,7 +1161,7 @@
{
return introspector;
}
-
+
public Object getApplicationAttribute( Object key)
{
return applicationAttributes.get( key );
@@ -1102,6 +1170,11 @@
public Object setApplicationAttribute( Object key, Object o )
{
return applicationAttributes.put( key, o );
+ }
+
+ public Uberspect getUberspect()
+ {
+ return uberSpect;
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>