Class SingletonUberspector
- All Implemented Interfaces:
org.apache.velocity.util.introspection.Uberspect,org.apache.velocity.util.introspection.UberspectLoggable,org.apache.velocity.util.RuntimeServicesAware
- Direct Known Subclasses:
PluginAwareSecureUberspector
Uberspect instance is used for all constructed Velocity engines rather than
creating a new instance for each engine. This is particularly useful when the Uberspect implementation is
expensive to create or has state that should be shared across all engines.
Simply extend this class and override newUberspector() to return the desired Uberspect
implementation, then wire in the new class name using the runtime.introspector.uberspect property in the
Velocity configuration. If you instantiate this class directly, it will use the default SecureUberspector.
This class can also optionally track the coupled Introspector if one exists by overriding
newIntrospector(org.apache.velocity.runtime.log.Log, org.apache.velocity.runtime.RuntimeServices) and replacing the Introspector construction within your Uberspector with
getIntrospectorInternal(org.apache.velocity.runtime.log.Log, org.apache.velocity.runtime.RuntimeServices). You may then call getIntrospector() at any time to access the coupled
Introspector instance.
There is however one caveat, and that is that the Uberspect instance will be initialised with the
RuntimeServices provided by the first engine that calls init(). It is thus important that the first
engine initialisation is deterministic for consistent, reproducible configuration.
- Since:
- 6.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.velocity.util.introspection.Introspectorprotected org.apache.velocity.util.introspection.IntrospectorgetIntrospectorInternal(org.apache.velocity.runtime.log.Log log, org.apache.velocity.runtime.RuntimeServices runtimeServices) getIterator(Object obj, org.apache.velocity.util.introspection.Info info) org.apache.velocity.util.introspection.VelMethodgetMethod(Object obj, String method, Object[] args, org.apache.velocity.util.introspection.Info info) org.apache.velocity.util.introspection.VelPropertyGetgetPropertyGet(Object obj, String identifier, org.apache.velocity.util.introspection.Info info) org.apache.velocity.util.introspection.VelPropertySetgetPropertySet(Object obj, String identifier, Object arg, org.apache.velocity.util.introspection.Info info) voidinit()This guarantees the Uberspector will only be initialised once but doesn't guarantee whichRuntimeServicesit will be initialised with.protected org.apache.velocity.util.introspection.IntrospectornewIntrospector(org.apache.velocity.runtime.log.Log log, org.apache.velocity.runtime.RuntimeServices runtimeServices) protected org.apache.velocity.util.introspection.UberspectvoidsetLog(org.apache.velocity.runtime.log.Log log) voidsetRuntimeLogger(org.apache.velocity.runtime.RuntimeLogger logger) voidsetRuntimeServices(org.apache.velocity.runtime.RuntimeServices rs)
-
Constructor Details
-
SingletonUberspector
public SingletonUberspector()
-
-
Method Details
-
newUberspector
protected org.apache.velocity.util.introspection.Uberspect newUberspector() -
getIntrospectorInternal
protected org.apache.velocity.util.introspection.Introspector getIntrospectorInternal(org.apache.velocity.runtime.log.Log log, org.apache.velocity.runtime.RuntimeServices runtimeServices) -
newIntrospector
protected org.apache.velocity.util.introspection.Introspector newIntrospector(org.apache.velocity.runtime.log.Log log, org.apache.velocity.runtime.RuntimeServices runtimeServices) -
getIntrospector
public org.apache.velocity.util.introspection.Introspector getIntrospector() -
init
This guarantees the Uberspector will only be initialised once but doesn't guarantee whichRuntimeServicesit will be initialised with.- Specified by:
initin interfaceorg.apache.velocity.util.introspection.Uberspect- Throws:
Exception
-
getIterator
public Iterator getIterator(Object obj, org.apache.velocity.util.introspection.Info info) throws Exception - Specified by:
getIteratorin interfaceorg.apache.velocity.util.introspection.Uberspect- Throws:
Exception
-
getMethod
public org.apache.velocity.util.introspection.VelMethod getMethod(Object obj, String method, Object[] args, org.apache.velocity.util.introspection.Info info) throws Exception - Specified by:
getMethodin interfaceorg.apache.velocity.util.introspection.Uberspect- Throws:
Exception
-
getPropertyGet
public org.apache.velocity.util.introspection.VelPropertyGet getPropertyGet(Object obj, String identifier, org.apache.velocity.util.introspection.Info info) throws Exception - Specified by:
getPropertyGetin interfaceorg.apache.velocity.util.introspection.Uberspect- Throws:
Exception
-
getPropertySet
public org.apache.velocity.util.introspection.VelPropertySet getPropertySet(Object obj, String identifier, Object arg, org.apache.velocity.util.introspection.Info info) throws Exception - Specified by:
getPropertySetin interfaceorg.apache.velocity.util.introspection.Uberspect- Throws:
Exception
-
setRuntimeServices
public void setRuntimeServices(org.apache.velocity.runtime.RuntimeServices rs) - Specified by:
setRuntimeServicesin interfaceorg.apache.velocity.util.RuntimeServicesAware
-
setLog
public void setLog(org.apache.velocity.runtime.log.Log log) - Specified by:
setLogin interfaceorg.apache.velocity.util.introspection.UberspectLoggable
-
setRuntimeLogger
public void setRuntimeLogger(org.apache.velocity.runtime.RuntimeLogger logger) - Specified by:
setRuntimeLoggerin interfaceorg.apache.velocity.util.introspection.UberspectLoggable
-