[seam-commits] Seam SVN: r8484 - trunk/src/wicket/org/jboss/seam/wicket/ioc.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Sat Jul 19 11:48:26 EDT 2008
Author: pete.muir at jboss.org
Date: 2008-07-19 11:48:26 -0400 (Sat, 19 Jul 2008)
New Revision: 8484
Added:
trunk/src/wicket/org/jboss/seam/wicket/ioc/StatelessInterceptor.java
Removed:
trunk/src/wicket/org/jboss/seam/wicket/ioc/Interceptor.java
Modified:
trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectionInterceptor.java
trunk/src/wicket/org/jboss/seam/wicket/ioc/ConversationInterceptor.java
trunk/src/wicket/org/jboss/seam/wicket/ioc/EventInterceptor.java
trunk/src/wicket/org/jboss/seam/wicket/ioc/JavassistInstrumentor.java
trunk/src/wicket/org/jboss/seam/wicket/ioc/WicketHandler.java
Log:
Do more at deployment time
Modified: trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectionInterceptor.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectionInterceptor.java 2008-07-19 15:48:10 UTC (rev 8483)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectionInterceptor.java 2008-07-19 15:48:26 UTC (rev 8484)
@@ -3,7 +3,7 @@
import org.jboss.seam.wicket.WicketComponent;
-public class BijectionInterceptor<T> implements Interceptor<T>
+public class BijectionInterceptor<T> implements StatelessInterceptor<T>
{
public Object afterInvoke(InvocationContext<T> invocationContext, Object result)
Modified: trunk/src/wicket/org/jboss/seam/wicket/ioc/ConversationInterceptor.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/ConversationInterceptor.java 2008-07-19 15:48:10 UTC (rev 8483)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/ConversationInterceptor.java 2008-07-19 15:48:26 UTC (rev 8484)
@@ -20,21 +20,12 @@
import org.jboss.seam.pageflow.Pageflow;
import org.jboss.seam.persistence.PersistenceContexts;
-public class ConversationInterceptor<T> implements Interceptor<T>
+public class ConversationInterceptor<T> implements StatelessInterceptor<T>
{
- private boolean isConversationManagement(InvocationContext<T> invocationContext)
- {
- return invocationContext.getAccessibleObject().isAnnotationPresent(Begin.class) ||
- invocationContext.getAccessibleObject().isAnnotationPresent(End.class) ||
- invocationContext.getAccessibleObject().isAnnotationPresent(BeginTask.class) ||
- invocationContext.getAccessibleObject().isAnnotationPresent(EndTask.class) ||
- invocationContext.getAccessibleObject().isAnnotationPresent(StartTask.class);
- }
-
public void beforeInvoke(InvocationContext<T> invocationContext)
{
- if (isConversationManagement(invocationContext))
+ if (invocationContext.getComponent().isConversationManagementMethod(invocationContext.getAccessibleObject()))
{
if ( isMissingJoin(invocationContext) )
{
@@ -51,7 +42,7 @@
public Object afterInvoke(InvocationContext<T> invocationContext, Object result)
{
- if (isConversationManagement(invocationContext))
+ if (invocationContext.getComponent().isConversationManagementMethod(invocationContext.getAccessibleObject()))
{
beginConversationIfNecessary(invocationContext, result);
endConversationIfNecessary(invocationContext, result);
Modified: trunk/src/wicket/org/jboss/seam/wicket/ioc/EventInterceptor.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/EventInterceptor.java 2008-07-19 15:48:10 UTC (rev 8483)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/EventInterceptor.java 2008-07-19 15:48:26 UTC (rev 8484)
@@ -3,7 +3,7 @@
import org.jboss.seam.annotations.RaiseEvent;
import org.jboss.seam.core.Events;
-public class EventInterceptor<T> implements Interceptor<T>
+public class EventInterceptor<T> implements StatelessInterceptor<T>
{
public Object afterInvoke(InvocationContext<T> invocationContext, Object result)
Deleted: trunk/src/wicket/org/jboss/seam/wicket/ioc/Interceptor.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/Interceptor.java 2008-07-19 15:48:10 UTC (rev 8483)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/Interceptor.java 2008-07-19 15:48:26 UTC (rev 8484)
@@ -1,15 +0,0 @@
-package org.jboss.seam.wicket.ioc;
-
-import java.io.Serializable;
-
-
-public interface Interceptor<T> extends Serializable
-{
-
- public void beforeInvoke(InvocationContext<T> invocationContext);
-
- public Object afterInvoke(InvocationContext<T> invocationContext, Object result);
-
- public Exception handleException(InvocationContext<T> invocationContext, Exception exception);
-
-}
Modified: trunk/src/wicket/org/jboss/seam/wicket/ioc/JavassistInstrumentor.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/JavassistInstrumentor.java 2008-07-19 15:48:10 UTC (rev 8483)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/JavassistInstrumentor.java 2008-07-19 15:48:26 UTC (rev 8484)
@@ -11,7 +11,6 @@
import javassist.CtConstructor;
import javassist.CtField;
import javassist.CtMethod;
-import javassist.CtNewConstructor;
import javassist.CtNewMethod;
import javassist.LoaderClassPath;
import javassist.Modifier;
@@ -138,7 +137,7 @@
CtClass instrumentedComponent = classPool.get(InstrumentedComponent.class.getName());
implementation.addInterface(instrumentedComponent);
CtMethod getHandlerMethod = CtNewMethod.getter("getHandler", handlerField);
- CtMethod getEnclosingInstance = CtNewMethod.make("public " + InstrumentedComponent.class.getName() +" getEnclosingInstance() { return " + WicketHandler.class.getName() + ".getEnclosingInstance(this, 10); }", implementation);
+ CtMethod getEnclosingInstance = CtNewMethod.make("public " + InstrumentedComponent.class.getName() +" getEnclosingInstance() { return handler.getEnclosingInstance(this); }", implementation);
implementation.addMethod(getEnclosingInstance);
implementation.addMethod(getHandlerMethod);
@@ -230,16 +229,6 @@
src += "java.lang.reflect.Constructor constructor = this.getClass().getDeclaredConstructor(parameterTypes);";
return src;
}
-
- private static String createParametersArray(CtBehavior behavior) throws NotFoundException
- {
- String src = "Object[] parameters = new Object[" + behavior.getParameterTypes().length + "];";
- for (int i = 0; i < behavior.getParameterTypes().length; i++)
- {
- src += "parameters[" + i + "] = $" + i + ";";
- }
- return src;
- }
private static boolean isInstrumentable(CtClass clazz)
{
Copied: trunk/src/wicket/org/jboss/seam/wicket/ioc/StatelessInterceptor.java (from rev 8481, trunk/src/wicket/org/jboss/seam/wicket/ioc/Interceptor.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/StatelessInterceptor.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/StatelessInterceptor.java 2008-07-19 15:48:26 UTC (rev 8484)
@@ -0,0 +1,15 @@
+package org.jboss.seam.wicket.ioc;
+
+import java.io.Serializable;
+
+
+public interface StatelessInterceptor<T> extends Serializable
+{
+
+ public void beforeInvoke(InvocationContext<T> invocationContext);
+
+ public Object afterInvoke(InvocationContext<T> invocationContext, Object result);
+
+ public Exception handleException(InvocationContext<T> invocationContext, Exception exception);
+
+}
Modified: trunk/src/wicket/org/jboss/seam/wicket/ioc/WicketHandler.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/WicketHandler.java 2008-07-19 15:48:10 UTC (rev 8483)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/WicketHandler.java 2008-07-19 15:48:26 UTC (rev 8484)
@@ -2,8 +2,8 @@
import java.io.Serializable;
import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import java.util.ArrayList;
import java.util.List;
import org.jboss.seam.wicket.WicketComponent;
@@ -23,7 +23,6 @@
this.type = type;
}
- private List<Interceptor> interceptors;
private Class<?> type;
private transient WicketComponent component;
private int reentrant = 0;
@@ -37,18 +36,6 @@
return component;
}
- private List<Interceptor> getInterceptors()
- {
- if (interceptors == null)
- {
- interceptors = new ArrayList<Interceptor>();
- interceptors.add(new BijectionInterceptor());
- interceptors.add(new ConversationInterceptor());
- interceptors.add(new EventInterceptor());
- }
- return interceptors;
- }
-
public void beforeInvoke(Object target, Method calledMethod)
{
doBeforeInvoke(new InvocationContext(calledMethod, target, getComponent()));
@@ -74,7 +61,7 @@
{
if (reentrant == 0)
{
- for (Interceptor interceptor : getInterceptors())
+ for (StatelessInterceptor interceptor : (List<StatelessInterceptor>) getComponent().getInterceptors())
{
interceptor.beforeInvoke(invocationContext);
}
@@ -97,7 +84,7 @@
reentrant--;
if (reentrant == 0)
{
- for (Interceptor interceptor : getInterceptors())
+ for (StatelessInterceptor interceptor : (List<StatelessInterceptor>) getComponent().getInterceptors())
{
exception = interceptor.handleException(invocationContext, exception);
}
@@ -110,9 +97,9 @@
reentrant--;
if (reentrant == 0)
{
- for (int i = interceptors.size() - 1; i >= 0; i--)
+ for (int i = getComponent().getInterceptors().size() - 1; i >= 0; i--)
{
- result = interceptors.get(i).afterInvoke(invocationContext, result);
+ result = ((StatelessInterceptor) getComponent().getInterceptors().get(i)).afterInvoke(invocationContext, result);
}
}
return result;
@@ -123,14 +110,14 @@
return reentrant > 0;
}
- public static InstrumentedComponent getEnclosingInstance(Object bean, int level)
+ public InstrumentedComponent getEnclosingInstance(Object bean)
{
- Class enclosingType = bean.getClass().getEnclosingClass();
+ Class enclosingType = getComponent().getClass();
if (enclosingType != null)
{
try
{
- java.lang.reflect.Field enclosingField = bean.getClass().getDeclaredField("this$" + level);
+ Field enclosingField = bean.getClass().getDeclaredField(getComponent().getEnclosingInstanceVariableName());
enclosingField.setAccessible(true);
Object enclosingInstance = enclosingField.get(bean);
if (enclosingInstance instanceof InstrumentedComponent)
@@ -138,19 +125,9 @@
return (InstrumentedComponent) enclosingInstance;
}
}
- catch (Exception e)
- {
- if (level == 0)
- {
- return null;
- }
- else
- {
- return getEnclosingInstance(bean, level -1);
- }
- }
+ catch (Exception e) {}
}
return null;
}
-
+
}
More information about the seam-commits
mailing list