Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/java/org/apache/velocity/runtime/parser/node/PublicFieldExecutor.java b/src/java/org/apache/velocity/runtime/parser/node/PublicFieldExecutor.java
- new file mode 100644
- index 0000000..f9fea30
- --- /dev/null
- +++ b/src/java/org/apache/velocity/runtime/parser/node/PublicFieldExecutor.java
- @@ -0,0 +1,141 @@
- +package org.apache.velocity.runtime.parser.node;
- +
- +/*
- + * Licensed to the Apache Software Foundation (ASF) under one
- + * or more contributor license agreements. See the NOTICE file
- + * distributed with this work for additional information
- + * regarding copyright ownership. The ASF licenses this file
- + * to you under the Apache License, Version 2.0 (the
- + * "License"); you may not use this file except in compliance
- + * with the License. You may obtain a copy of the License at
- + *
- + * http://www.apache.org/licenses/LICENSE-2.0
- + *
- + * Unless required by applicable law or agreed to in writing,
- + * software distributed under the License is distributed on an
- + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- + * KIND, either express or implied. See the License for the
- + * specific language governing permissions and limitations
- + * under the License.
- + */
- +
- +import java.lang.reflect.Field;
- +import java.lang.reflect.InvocationTargetException;
- +
- +import org.apache.commons.lang.StringUtils;
- +import org.apache.velocity.exception.VelocityException;
- +import org.apache.velocity.runtime.RuntimeLogger;
- +import org.apache.velocity.runtime.log.Log;
- +import org.apache.velocity.runtime.log.RuntimeLoggerLog;
- +import org.apache.velocity.util.introspection.Introspector;
- +
- +/**
- + * Returns the value of a public field when executed.
- + */
- +public class PublicFieldExecutor extends AbstractExecutor
- +{
- + private final Introspector introspector;
- +
- + /**
- + * Field to be accessed
- + */
- + private Field field = null;
- +
- + /**
- + * @param log
- + * @param introspector
- + * @param clazz
- + * @param property
- + * @since 1.5
- + */
- + public PublicFieldExecutor(final Log log, final Introspector introspector,
- + final Class clazz, final String property)
- + {
- + this.log = log;
- + this.introspector = introspector;
- +
- + // Don't allow passing in the empty string or null because
- + // it will either fail with a StringIndexOutOfBounds error
- + // or the introspector will get confused.
- + if (StringUtils.isNotEmpty(property))
- + {
- + discover(clazz, property);
- + }
- + }
- +
- + /**
- + * @param r
- + * @param introspector
- + * @param clazz
- + * @param property
- + * @deprecated RuntimeLogger is deprecated. Use the other constructor.
- + */
- + public PublicFieldExecutor(final RuntimeLogger r, final Introspector introspector,
- + final Class clazz, final String property)
- + {
- + this(new RuntimeLoggerLog(r), introspector, clazz, property);
- + }
- +
- + public boolean isAlive() {
- + return getField() != null;
- + }
- +
- + /**
- + * @return The current field.
- + */
- + public Field getField()
- + {
- + return field;
- + }
- +
- + /**
- + * @param field
- + */
- + protected void setField(final Field field)
- + {
- + this.field = field;
- + }
- +
- + /**
- + * @return The current introspector.
- + * @since 1.5
- + */
- + protected Introspector getIntrospector()
- + {
- + return this.introspector;
- + }
- +
- + /**
- + * @param clazz
- + * @param property
- + */
- + protected void discover(final Class clazz, final String property)
- + {
- + try
- + {
- + setField(introspector.getField(clazz, property));
- + }
- + /**
- + * pass through application level runtime exceptions
- + */
- + catch( RuntimeException e )
- + {
- + throw e;
- + }
- + catch(Exception e)
- + {
- + String msg = "Exception while looking for public field '" + property;
- + log.error(msg, e);
- + throw new VelocityException(msg, e);
- + }
- + }
- +
- + /**
- + * @see org.apache.velocity.runtime.parser.node.AbstractExecutor#execute(java.lang.Object)
- + */
- + public Object execute(Object o)
- + throws IllegalAccessException, InvocationTargetException
- + {
- + return isAlive() ? getField().get(o) : null;
- + }
- +}
- diff --git a/src/java/org/apache/velocity/runtime/parser/node/SetPublicFieldExecutor.java b/src/java/org/apache/velocity/runtime/parser/node/SetPublicFieldExecutor.java
- new file mode 100644
- index 0000000..9467e5c
- --- /dev/null
- +++ b/src/java/org/apache/velocity/runtime/parser/node/SetPublicFieldExecutor.java
- @@ -0,0 +1,147 @@
- +package org.apache.velocity.runtime.parser.node;
- +
- +/*
- + * Licensed to the Apache Software Foundation (ASF) under one
- + * or more contributor license agreements. See the NOTICE file
- + * distributed with this work for additional information
- + * regarding copyright ownership. The ASF licenses this file
- + * to you under the Apache License, Version 2.0 (the
- + * "License"); you may not use this file except in compliance
- + * with the License. You may obtain a copy of the License at
- + *
- + * http://www.apache.org/licenses/LICENSE-2.0
- + *
- + * Unless required by applicable law or agreed to in writing,
- + * software distributed under the License is distributed on an
- + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- + * KIND, either express or implied. See the License for the
- + * specific language governing permissions and limitations
- + * under the License.
- + */
- +
- +import java.lang.reflect.Field;
- +import java.lang.reflect.InvocationTargetException;
- +import java.lang.reflect.Modifier;
- +
- +import org.apache.commons.lang.StringUtils;
- +import org.apache.velocity.exception.VelocityException;
- +import org.apache.velocity.runtime.log.Log;
- +import org.apache.velocity.util.introspection.Introspector;
- +
- +/**
- + * Executor for setting public fields in objects
- + *
- + * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
- + * @author <a href="mailto:cdauth@cdauth.eu">Candid Dauth</a>
- + */
- +public class SetPublicFieldExecutor
- + extends SetExecutor
- +{
- + private final Introspector introspector;
- +
- + /**
- + * Field to be accessed
- + */
- + private Field field = null;
- +
- + /**
- + * @param log
- + * @param introspector
- + * @param clazz
- + * @param property
- + * @param arg
- + */
- + public SetPublicFieldExecutor(final Log log, final Introspector introspector,
- + final Class clazz, final String property, final Object arg)
- + {
- + this.log = log;
- + this.introspector = introspector;
- +
- + // Don't allow passing in the empty string or null because
- + // it will either fail with a StringIndexOutOfBounds error
- + // or the introspector will get confused.
- + if (StringUtils.isNotEmpty(property))
- + {
- + discover(clazz, property, arg);
- + }
- + }
- +
- + public boolean isAlive() {
- + return getField() != null;
- + }
- +
- + /**
- + * @return The current field.
- + */
- + public Field getField()
- + {
- + return field;
- + }
- +
- + /**
- + * @param field
- + */
- + protected void setField(final Field field)
- + {
- + this.field = field;
- + }
- +
- + /**
- + * @return The current introspector.
- + */
- + protected Introspector getIntrospector()
- + {
- + return this.introspector;
- + }
- +
- + /**
- + * @param clazz
- + * @param property
- + * @param arg
- + */
- + protected void discover(final Class clazz, final String property, final Object arg)
- + {
- + try
- + {
- + Field field = introspector.getField(clazz, property);
- + if(!Modifier.isFinal(field.getModifiers()))
- + {
- + setField(field);
- + }
- + }
- + /**
- + * pass through application level runtime exceptions
- + */
- + catch( RuntimeException e )
- + {
- + throw e;
- + }
- + catch(Exception e)
- + {
- + String msg = "Exception while looking for public field '" + property;
- + log.error(msg, e);
- + throw new VelocityException(msg, e);
- + }
- + }
- +
- + /**
- + * Execute method against context.
- + * @param o
- + * @param value
- + * @return The value of the invocation.
- + * @throws IllegalAccessException
- + * @throws InvocationTargetException
- + */
- + public Object execute(final Object o, final Object value)
- + throws IllegalAccessException, InvocationTargetException
- + {
- + if (isAlive())
- + {
- + Object oldValue = getField().get(o);
- + getField().set(o, value);
- + return oldValue;
- + }
- + else
- + return null;
- + }
- +}
- diff --git a/src/java/org/apache/velocity/util/introspection/ClassFieldMap.java b/src/java/org/apache/velocity/util/introspection/ClassFieldMap.java
- new file mode 100644
- index 0000000..5597ebe
- --- /dev/null
- +++ b/src/java/org/apache/velocity/util/introspection/ClassFieldMap.java
- @@ -0,0 +1,175 @@
- +package org.apache.velocity.util.introspection;
- +
- +/*
- + * Licensed to the Apache Software Foundation (ASF) under one
- + * or more contributor license agreements. See the NOTICE file
- + * distributed with this work for additional information
- + * regarding copyright ownership. The ASF licenses this file
- + * to you under the Apache License, Version 2.0 (the
- + * "License"); you may not use this file except in compliance
- + * with the License. You may obtain a copy of the License at
- + *
- + * http://www.apache.org/licenses/LICENSE-2.0
- + *
- + * Unless required by applicable law or agreed to in writing,
- + * software distributed under the License is distributed on an
- + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- + * KIND, either express or implied. See the License for the
- + * specific language governing permissions and limitations
- + * under the License.
- + */
- +
- +import java.lang.reflect.Field;
- +import java.lang.reflect.Modifier;
- +import java.util.Map;
- +import org.apache.velocity.runtime.log.Log;
- +import org.apache.velocity.util.MapFactory;
- +
- +/**
- + * A cache of introspection information for a specific class instance.
- + * Keys {@link java.lang.reflect.Field} objects by the field names.
- + *
- + * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
- + * @author <a href="mailto:bob@werken.com">Bob McWhirter</a>
- + * @author <a href="mailto:szegedia@freemail.hu">Attila Szegedi</a>
- + * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
- + * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
- + * @author Nathan Bubna
- + * @author <a href="mailto:cdauth@cdauth.eu">Candid Dauth</a>
- + */
- +public class ClassFieldMap
- +{
- + /** Set true if you want to debug the reflection code */
- + private static final boolean debugReflection = false;
- +
- + /** Class logger */
- + private final Log log;
- +
- + /**
- + * Class passed into the constructor used to as
- + * the basis for the Field map.
- + */
- + private final Class clazz;
- +
- + /**
- + * String --> Field map, the key is the field name
- + */
- + private final Map fieldCache;
- +
- + /**
- + * Standard constructor
- + * @param clazz The class for which this ClassMap gets constructed.
- + */
- + public ClassFieldMap(final Class clazz, final Log log)
- + {
- + this.clazz = clazz;
- + this.log = log;
- +
- + if (debugReflection && log.isDebugEnabled())
- + {
- + log.debug("=================================================================");
- + log.debug("== Class: " + clazz);
- + }
- +
- + fieldCache = createFieldCache();
- +
- + if (debugReflection && log.isDebugEnabled())
- + {
- + log.debug("=================================================================");
- + }
- + }
- +
- + /**
- + * Returns the class object whose fields are cached by this map.
- + *
- + * @return The class object whose fields are cached by this map.
- + */
- + public Class getCachedClass()
- + {
- + return clazz;
- + }
- +
- + /**
- + * Find a Field using the field name.
- + *
- + * @param name The field name to look up.
- + * @return A Field object representing the field to invoke or null.
- + */
- + public Field findField(final String name)
- + {
- + return (Field)fieldCache.get(name);
- + }
- +
- + /**
- + * Populate the Map of direct hits. These
- + * are taken from all the public fields
- + * that our class, its parents and their implemented interfaces provide.
- + */
- + private Map createFieldCache()
- + {
- + Map fieldCache = MapFactory.create(false);
- + //
- + // Looks through all elements in the class hierarchy.
- + //
- + // We ignore all SecurityExceptions that might happen due to SecurityManager restrictions (prominently
- + // hit with Tomcat 5.5).
- + // Ah, the miracles of Java for(;;) ...
- + for (Class classToReflect = getCachedClass(); classToReflect != null ; classToReflect = classToReflect.getSuperclass())
- + {
- + if (Modifier.isPublic(classToReflect.getModifiers()))
- + {
- + populateFieldCacheWith(fieldCache, classToReflect);
- + }
- + Class [] interfaces = classToReflect.getInterfaces();
- + for (int i = 0; i < interfaces.length; i++)
- + {
- + populateFieldCacheWithInterface(fieldCache, interfaces[i]);
- + }
- + }
- + // return the already initialized cache
- + return fieldCache;
- + }
- +
- + /* recurses up interface heirarchy to get all super interfaces (VELOCITY-689) */
- + private void populateFieldCacheWithInterface(Map fieldCache, Class iface)
- + {
- + if (Modifier.isPublic(iface.getModifiers()))
- + {
- + populateFieldCacheWith(fieldCache, iface);
- + }
- + Class[] supers = iface.getInterfaces();
- + for (int i=0; i < supers.length; i++)
- + {
- + populateFieldCacheWithInterface(fieldCache, supers[i]);
- + }
- + }
- +
- + private void populateFieldCacheWith(Map fieldCache, Class classToReflect)
- + {
- + if (debugReflection && log.isDebugEnabled())
- + {
- + log.debug("Reflecting " + classToReflect);
- + }
- +
- + try
- + {
- + Field[] fields = classToReflect.getDeclaredFields();
- + for (int i = 0; i < fields.length; i++)
- + {
- + int modifiers = fields[i].getModifiers();
- + if (Modifier.isPublic(modifiers))
- + {
- + fieldCache.put(fields[i].getName(), fields[i]);
- + }
- + }
- + }
- + catch (SecurityException se) // Everybody feels better with...
- + {
- + if (log.isDebugEnabled())
- + {
- + log.debug("While accessing fields of " + classToReflect + ": ", se);
- + }
- + }
- + }
- +
- +}
- diff --git a/src/java/org/apache/velocity/util/introspection/IntrospectorBase.java b/src/java/org/apache/velocity/util/introspection/IntrospectorBase.java
- index db6031f..48f469d 100644
- --- a/src/java/org/apache/velocity/util/introspection/IntrospectorBase.java
- +++ b/src/java/org/apache/velocity/util/introspection/IntrospectorBase.java
- @@ -19,6 +19,7 @@ package org.apache.velocity.util.introspection;
- * under the License.
- */
- +import java.lang.reflect.Field;
- import java.lang.reflect.Method;
- import org.apache.velocity.runtime.log.Log;
- @@ -49,6 +50,7 @@ import org.apache.velocity.runtime.log.Log;
- * @author <a href="mailto:szegedia@freemail.hu">Attila Szegedi</a>
- * @author <a href="mailto:paulo.gaspar@krankikom.de">Paulo Gaspar</a>
- * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
- + * @author <a href="mailto:cdauth@cdauth.eu">Candid Dauth</a>
- * @version $Id: IntrospectorBase.java 685685 2008-08-13 21:43:27Z nbubna $
- */
- public abstract class IntrospectorBase
- @@ -106,6 +108,35 @@ public abstract class IntrospectorBase
- }
- /**
- + * Gets the field defined by <code>name</code>.
- + *
- + * @param c Class in which the method search is taking place
- + * @param name Name of the field being searched for
- + *
- + * @return The desired Field object.
- + * @throws IllegalArgumentException When the parameters passed in can not be used for introspection.
- + */
- + public Field getField(final Class c, final String name)
- + throws IllegalArgumentException
- + {
- + if (c == null)
- + {
- + throw new IllegalArgumentException("class object is null!");
- + }
- +
- + IntrospectorCache ic = getIntrospectorCache();
- +
- + ClassFieldMap classFieldMap = ic.getFieldMap(c);
- + if (classFieldMap == null)
- + {
- + ic.put(c);
- + classFieldMap = ic.getFieldMap(c);
- + }
- +
- + return classFieldMap.findField(name);
- + }
- +
- + /**
- * Return the internal IntrospectorCache object.
- *
- * @return The internal IntrospectorCache object.
- diff --git a/src/java/org/apache/velocity/util/introspection/IntrospectorCache.java b/src/java/org/apache/velocity/util/introspection/IntrospectorCache.java
- index 3b70728..a730996 100644
- --- a/src/java/org/apache/velocity/util/introspection/IntrospectorCache.java
- +++ b/src/java/org/apache/velocity/util/introspection/IntrospectorCache.java
- @@ -23,6 +23,7 @@ package org.apache.velocity.util.introspection;
- * The introspector cache API definition.
- *
- * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
- + * @author <a href="mailto:cdauth@cdauth.eu">Candid Dauth</a>
- * @version $Id: IntrospectorCache.java 685685 2008-08-13 21:43:27Z nbubna $
- * @since 1.5
- */
- @@ -44,6 +45,16 @@ public interface IntrospectorCache {
- ClassMap get(Class c);
- /**
- + * Lookup a given Class object in the cache. If it does not exist,
- + * check whether this is due to a class change and purge the caches
- + * eventually.
- + *
- + * @param c The class to look up.
- + * @return A ClassFieldMap object or null if it does not exist in the cache.
- + */
- + ClassFieldMap getFieldMap(final Class c);
- +
- + /**
- * Creates a class map for specific class and registers it in the
- * cache. Also adds the qualified name to the name->class map
- * for later Classloader change detection.
- diff --git a/src/java/org/apache/velocity/util/introspection/IntrospectorCacheImpl.java b/src/java/org/apache/velocity/util/introspection/IntrospectorCacheImpl.java
- index 1dbe9cd..6b7ebab 100644
- --- a/src/java/org/apache/velocity/util/introspection/IntrospectorCacheImpl.java
- +++ b/src/java/org/apache/velocity/util/introspection/IntrospectorCacheImpl.java
- @@ -30,6 +30,7 @@ import org.apache.velocity.runtime.log.Log;
- * This is the internal introspector cache implementation.
- *
- * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
- + * @author <a href="mailto:cdauth@cdauth.eu">Candid Dauth</a>
- * @version $Id: IntrospectorCacheImpl.java 898032 2010-01-11 19:51:03Z nbubna $
- * @since 1.5
- */
- @@ -50,6 +51,11 @@ public final class IntrospectorCacheImpl implements IntrospectorCache
- private final Map classMapCache = new HashMap();
- /**
- + * Holds the field maps for the classes we know about. Map: Class --> ClassFieldMap object.
- + */
- + private final Map classFieldMapCache = new HashMap();
- +
- + /**
- * Keep the names of the classes in another map. This is needed for a multi-classloader environment where it is possible
- * to have Class 'Foo' loaded by a classloader and then get asked to introspect on 'Foo' from another class loader. While these
- * two Class objects have the same name, a <code>classMethodMaps.get(Foo.class)</code> will return null. For that case, we
- @@ -73,13 +79,14 @@ public final class IntrospectorCacheImpl implements IntrospectorCache
- synchronized (classMapCache)
- {
- classMapCache.clear();
- + classFieldMapCache.clear();
- classNameCache.clear();
- log.debug(CACHEDUMP_MSG);
- }
- }
- /**
- - * Lookup a given Class object in the cache. If it does not exist,
- + * Lookup a given Class object in the cache. If it does not exist,
- * check whether this is due to a class change and purge the caches
- * eventually.
- *
- @@ -114,6 +121,41 @@ public final class IntrospectorCacheImpl implements IntrospectorCache
- }
- /**
- + * Lookup a given Class object in the cache. If it does not exist,
- + * check whether this is due to a class change and purge the caches
- + * eventually.
- + *
- + * @param c The class to look up.
- + * @return A ClassFieldMap object or null if it does not exist in the cache.
- + */
- + public ClassFieldMap getFieldMap(final Class c)
- + {
- + if (c == null)
- + {
- + throw new IllegalArgumentException("class is null!");
- + }
- +
- + ClassFieldMap classFieldMap = (ClassFieldMap)classFieldMapCache.get(c);
- + if (classFieldMap == null)
- + {
- + /*
- + * check to see if we have it by name.
- + * if so, then we have an object with the same
- + * name but loaded through a different class loader.
- + * In that case, we will just dump the cache to be sure.
- + */
- + synchronized (classMapCache)
- + {
- + if (classNameCache.contains(c.getName()))
- + {
- + clear();
- + }
- + }
- + }
- + return classFieldMap;
- + }
- +
- + /**
- * Creates a class map for specific class and registers it in the
- * cache. Also adds the qualified name to the name->class map
- * for later Classloader change detection.
- @@ -124,9 +166,11 @@ public final class IntrospectorCacheImpl implements IntrospectorCache
- public ClassMap put(final Class c)
- {
- final ClassMap classMap = new ClassMap(c, log);
- + final ClassFieldMap classFieldMap = new ClassFieldMap(c, log);
- synchronized (classMapCache)
- {
- classMapCache.put(c, classMap);
- + classFieldMapCache.put(c, classFieldMap);
- classNameCache.add(c.getName());
- }
- return classMap;
- diff --git a/src/java/org/apache/velocity/util/introspection/UberspectPublicFields.java b/src/java/org/apache/velocity/util/introspection/UberspectPublicFields.java
- new file mode 100644
- index 0000000..e854e67
- --- /dev/null
- +++ b/src/java/org/apache/velocity/util/introspection/UberspectPublicFields.java
- @@ -0,0 +1,137 @@
- +/*
- + * Licensed to the Apache Software Foundation (ASF) under one
- + * or more contributor license agreements. See the NOTICE file
- + * distributed with this work for additional information
- + * regarding copyright ownership. The ASF licenses this file
- + * to you under the Apache License, Version 2.0 (the
- + * "License"); you may not use this file except in compliance
- + * with the License. You may obtain a copy of the License at
- + *
- + * http://www.apache.org/licenses/LICENSE-2.0
- + *
- + * Unless required by applicable law or agreed to in writing,
- + * software distributed under the License is distributed on an
- + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- + * KIND, either express or implied. See the License for the
- + * specific language governing permissions and limitations
- + * under the License.
- + */
- +
- +package org.apache.velocity.util.introspection;
- +
- +import java.util.Iterator;
- +import org.apache.velocity.runtime.RuntimeLogger;
- +import org.apache.velocity.runtime.log.Log;
- +import org.apache.velocity.runtime.log.RuntimeLoggerLog;
- +import org.apache.velocity.runtime.parser.node.PublicFieldExecutor;
- +import org.apache.velocity.runtime.parser.node.SetPublicFieldExecutor;
- +import org.apache.velocity.util.introspection.UberspectImpl.VelGetterImpl;
- +import org.apache.velocity.util.introspection.UberspectImpl.VelSetterImpl;
- +
- +/**
- + * Implementation of Uberspect to additionally provide access to public fields.
- + *
- + * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
- + * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
- + * @author <a href="mailto:cdauth@cdauth.eu">Candid Dauth</a>
- + */
- +public class UberspectPublicFields implements Uberspect, UberspectLoggable
- +{
- + /**
- + * Our runtime logger.
- + */
- + protected Log log;
- +
- + /**
- + * the default Velocity introspector
- + */
- + protected Introspector introspector;
- +
- + /**
- + * init - generates the Introspector. As the setup code
- + * makes sure that the log gets set before this is called,
- + * we can initialize the Introspector using the log object.
- + */
- + public void init()
- + {
- + introspector = new Introspector(log);
- + }
- +
- + /**
- + * Sets the runtime logger - this must be called before anything
- + * else.
- + *
- + * @param log The logger instance to use.
- + * @since 1.5
- + */
- + public void setLog(Log log)
- + {
- + this.log = log;
- + }
- +
- + /**
- + * @param runtimeLogger
- + * @deprecated Use setLog(Log log) instead.
- + */
- + public void setRuntimeLogger(RuntimeLogger runtimeLogger)
- + {
- + // in the off chance anyone still uses this method
- + // directly, use this hack to keep it working
- + setLog(new RuntimeLoggerLog(runtimeLogger));
- + }
- +
- + /**
- + * Property getter
- + * @param obj
- + * @param identifier
- + * @param i
- + * @return A Velocity Getter Method.
- + * @throws Exception
- + */
- + public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i) throws Exception
- + {
- + if (obj == null)
- + {
- + return null;
- + }
- +
- + Class claz = obj.getClass();
- +
- + PublicFieldExecutor executor = new PublicFieldExecutor(log, introspector, claz, identifier);
- +
- + return (executor.isAlive()) ? new VelGetterImpl(executor) : null;
- + }
- +
- + /**
- + * Property setter
- + * @param obj
- + * @param identifier
- + * @param arg
- + * @param i
- + * @return A Velocity Setter method.
- + * @throws Exception
- + */
- + public VelPropertySet getPropertySet(Object obj, String identifier, Object arg, Info i) throws Exception {
- + if (obj == null)
- + {
- + return null;
- + }
- +
- + Class claz = obj.getClass();
- +
- + SetPublicFieldExecutor executor = new SetPublicFieldExecutor(log, introspector, claz, identifier, arg);
- +
- + return (executor.isAlive()) ? new VelSetterImpl(executor) : null;
- + }
- +
- + public Iterator getIterator(Object obj, Info info) throws Exception
- + {
- + return null;
- + }
- +
- + public VelMethod getMethod(Object obj, String method, Object[] args, Info info) throws Exception
- + {
- + return null;
- + }
- +
- +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement