You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2011/08/08 20:45:05 UTC
svn commit: r1155054 - in
/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc:
internal/AbstractMethodInvokingInstrumenter.java
internal/services/PlasticProxyFactoryImpl.java
services/PlasticProxyFactory.java
Author: hlship
Date: Mon Aug 8 18:45:05 2011
New Revision: 1155054
URL: http://svn.apache.org/viewvc?rev=1155054&view=rev
Log:
Add some logic to chase down the ProQuest deployment issue, where they get a NPE inside AbstractMethodInvokingInstrumenter.toString()
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/AbstractMethodInvokingInstrumenter.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PlasticProxyFactoryImpl.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PlasticProxyFactory.java
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/AbstractMethodInvokingInstrumenter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/AbstractMethodInvokingInstrumenter.java?rev=1155054&r1=1155053&r2=1155054&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/AbstractMethodInvokingInstrumenter.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/AbstractMethodInvokingInstrumenter.java Mon Aug 8 18:45:05 2011
@@ -14,15 +14,10 @@
package org.apache.tapestry5.ioc.internal;
-import org.apache.tapestry5.ioc.Invokable;
-import org.apache.tapestry5.ioc.ModuleBuilderSource;
-import org.apache.tapestry5.ioc.ObjectLocator;
-import org.apache.tapestry5.ioc.OperationTracker;
-import org.apache.tapestry5.ioc.ServiceResources;
+import org.apache.tapestry5.ioc.*;
import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
import org.apache.tapestry5.ioc.internal.util.InjectionResources;
import org.apache.tapestry5.ioc.internal.util.InternalUtils;
-import org.apache.tapestry5.ioc.services.ClassFactory;
import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
import org.slf4j.Logger;
@@ -32,7 +27,7 @@ import java.util.Map;
/**
* Based class for service decorators and service advisors that work by invoking a module method.
- *
+ *
* @since 5.1.0.0
*/
public class AbstractMethodInvokingInstrumenter
@@ -54,7 +49,7 @@ public class AbstractMethodInvokingInstr
private final Logger logger;
public AbstractMethodInvokingInstrumenter(ModuleBuilderSource moduleSource, Method method,
- ServiceResources resources, PlasticProxyFactory proxyFactory)
+ ServiceResources resources, PlasticProxyFactory proxyFactory)
{
this.moduleSource = moduleSource;
this.method = method;
@@ -76,7 +71,9 @@ public class AbstractMethodInvokingInstr
@Override
public String toString()
{
- return proxyFactory.getMethodLocation(method).toString();
+ Location location = proxyFactory.getMethodLocation(method);
+
+ return location.toString();
}
private Object getModuleInstance()
@@ -108,12 +105,10 @@ public class AbstractMethodInvokingInstr
injectionResources, resources.getTracker());
result = method.invoke(getModuleInstance(), parameters);
- }
- catch (InvocationTargetException ite)
+ } catch (InvocationTargetException ite)
{
failure = ite.getTargetException();
- }
- catch (Exception ex)
+ } catch (Exception ex)
{
failure = ex;
}
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PlasticProxyFactoryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PlasticProxyFactoryImpl.java?rev=1155054&r1=1155053&r2=1155054&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PlasticProxyFactoryImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PlasticProxyFactoryImpl.java Mon Aug 8 18:45:05 2011
@@ -14,34 +14,21 @@
package org.apache.tapestry5.ioc.internal.services;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.util.List;
-
import org.apache.tapestry5.internal.plastic.PlasticInternalUtils;
import org.apache.tapestry5.internal.plastic.asm.Type;
-import org.apache.tapestry5.internal.plastic.asm.tree.AbstractInsnNode;
-import org.apache.tapestry5.internal.plastic.asm.tree.ClassNode;
-import org.apache.tapestry5.internal.plastic.asm.tree.InsnList;
-import org.apache.tapestry5.internal.plastic.asm.tree.LineNumberNode;
-import org.apache.tapestry5.internal.plastic.asm.tree.MethodNode;
+import org.apache.tapestry5.internal.plastic.asm.tree.*;
import org.apache.tapestry5.ioc.Location;
import org.apache.tapestry5.ioc.ObjectCreator;
import org.apache.tapestry5.ioc.internal.util.InternalUtils;
import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
-import org.apache.tapestry5.plastic.ClassInstantiator;
-import org.apache.tapestry5.plastic.InstructionBuilder;
-import org.apache.tapestry5.plastic.InstructionBuilderCallback;
-import org.apache.tapestry5.plastic.PlasticClass;
-import org.apache.tapestry5.plastic.PlasticClassListener;
-import org.apache.tapestry5.plastic.PlasticClassTransformation;
-import org.apache.tapestry5.plastic.PlasticClassTransformer;
-import org.apache.tapestry5.plastic.PlasticField;
-import org.apache.tapestry5.plastic.PlasticManager;
-import org.apache.tapestry5.plastic.PlasticMethod;
+import org.apache.tapestry5.plastic.*;
import org.slf4j.Logger;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.List;
+
public class PlasticProxyFactoryImpl implements PlasticProxyFactory
{
private final Logger logger;
@@ -145,13 +132,8 @@ public class PlasticProxyFactoryImpl imp
String constructorDescription = builder.toString();
- Location location = getMemberLocation(constructor, "<init>", Type.getConstructorDescriptor(constructor),
+ return getMemberLocation(constructor, "<init>", Type.getConstructorDescriptor(constructor),
constructorDescription);
-
- if (location != null)
- return location;
-
- return new StringLocation(builder.toString(), 0);
}
public Location getMemberLocation(Member member, String methodName, String memberTypeDesc, String textDescription)
@@ -170,8 +152,13 @@ public class PlasticProxyFactoryImpl imp
{
int lineNumber = findFirstLineNumber(mn.instructions);
+ // If debugging info is not available, we may lose the line number data, in which case,
+ // just generate the Location from the textDescription.
+
if (lineNumber < 1)
- return null;
+ {
+ break;
+ }
String description = String.format("%s (at %s:%d)", textDescription, classNode.sourceFile, lineNumber);
@@ -181,14 +168,17 @@ public class PlasticProxyFactoryImpl imp
// Didn't find it. Odd.
- return null;
+ return new StringLocation(textDescription, 0);
}
private int findFirstLineNumber(InsnList instructions)
{
for (AbstractInsnNode node = instructions.getFirst(); node != null; node = node.getNext())
{
- if (node instanceof LineNumberNode) { return ((LineNumberNode) node).line; }
+ if (node instanceof LineNumberNode)
+ {
+ return ((LineNumberNode) node).line;
+ }
}
return -1;
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PlasticProxyFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PlasticProxyFactory.java?rev=1155054&r1=1155053&r2=1155054&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PlasticProxyFactory.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PlasticProxyFactory.java Mon Aug 8 18:45:05 2011
@@ -14,9 +14,6 @@
package org.apache.tapestry5.ioc.services;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-
import org.apache.tapestry5.ioc.Location;
import org.apache.tapestry5.ioc.ObjectCreator;
import org.apache.tapestry5.plastic.ClassInstantiator;
@@ -24,10 +21,13 @@ import org.apache.tapestry5.plastic.Plas
import org.apache.tapestry5.plastic.PlasticClassTransformation;
import org.apache.tapestry5.plastic.PlasticClassTransformer;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
/**
* A service used to create proxies of varying types. As a secondary concern, manages to identify the
* location of methods and constructors, which is important for exception reporting.
- *
+ *
* @since 5.3
*/
public interface PlasticProxyFactory extends PlasticClassListenerHub
@@ -41,11 +41,9 @@ public interface PlasticProxyFactory ext
/**
* Creates a proxy object that implements the indicated interface, then invokes the callback to further
* configure the proxy.
- *
- * @param interfaceType
- * interface implemented by proxy
- * @param callback
- * configures the proxy
+ *
+ * @param interfaceType interface implemented by proxy
+ * @param callback configures the proxy
* @return instantiator that can be used to create an instance of the proxy class
*/
<T> ClassInstantiator<T> createProxy(Class<T> interfaceType, PlasticClassTransformer callback);
@@ -54,9 +52,8 @@ public interface PlasticProxyFactory ext
* Creates the underlying {@link PlasticClassTransformation} for an interface proxy. This should only be
* used in the cases where encapsulating the PlasticClass construction into a {@linkplain PlasticClassTransformer
* callback} is not feasible (which is the case for some of the older APIs inside Tapestry IoC).
- *
- * @param interfaceType
- * class proxy will extend from
+ *
+ * @param interfaceType class proxy will extend from
* @return transformation from which an instantiator may be created
*/
<T> PlasticClassTransformation<T> createProxyTransformation(Class<T> interfaceType);
@@ -66,31 +63,28 @@ public interface PlasticProxyFactory ext
* ObjectCreator. Each method invocation on the proxy will route through {@link ObjectCreator#createObject()} (the
* creator implementation may decide to
* cache the return value as appropriate).
- *
- * @param <T>
- * type of proxy
- * @param interfaceType
- * interface class for proxy
- * @param creator
- * object responsible for creating the real object
- * @param description
- * the <code>toString()</code> of the proxy
+ *
+ * @param <T> type of proxy
+ * @param interfaceType interface class for proxy
+ * @param creator object responsible for creating the real object
+ * @param description the <code>toString()</code> of the proxy
* @return proxy instance
*/
<T> T createProxy(Class<T> interfaceType, ObjectCreator<T> creator, String description);
/**
* Converts a method to a {@link Location}, which includes information about the source file name and line number.
- *
- * @param method
- * to look up
- * @return the location, or null if the necessary information is not available
+ *
+ * @param method to look up
+ * @return the location (identifying the method and possibly, the line number within the method)
*/
Location getMethodLocation(Method method);
/**
* Return a string representation for the constructor (including class and parameters) and (if available) file name
* and line number.
+ *
+ * @return the location (identifying the constructor and possibly, the line number within the method)
*/
Location getConstructorLocation(Constructor constructor);
}