[jboss-cvs] JBossAS SVN: r107172 - in projects/interceptors/trunk: jboss-interceptor/src/test/java/org/jboss/interceptors/proxy and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jul 28 15:35:40 EDT 2010
Author: marius.bogoevici
Date: 2010-07-28 15:35:39 -0400 (Wed, 28 Jul 2010)
New Revision: 107172
Added:
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/context/
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/context/InterceptionChain.java
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/context/InvocationContextFactory.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DefaultInvocationContextFactory.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/SimpleInterceptionChain.java
Removed:
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionChain.java
Modified:
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorInvocationContext.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreatorImpl.java
projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTestCase.java
projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/SubclassingInterceptionTestCase.java
Log:
add option for customizing the invocation context
Added: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DefaultInvocationContextFactory.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DefaultInvocationContextFactory.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DefaultInvocationContextFactory.java 2010-07-28 19:35:39 UTC (rev 107172)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed 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.jboss.interceptor.proxy;
+
+import java.lang.reflect.Method;
+
+import javax.interceptor.InvocationContext;
+
+import org.jboss.interceptor.spi.context.InterceptionChain;
+import org.jboss.interceptor.spi.context.InvocationContextFactory;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class DefaultInvocationContextFactory implements InvocationContextFactory
+{
+ public InvocationContext newInvocationContext(InterceptionChain chain, Object o, Method method, Object[] args)
+ {
+ return new InterceptorInvocationContext(chain, o, method, args);
+ }
+
+ public InvocationContext newInvocationContext(InterceptionChain chain, Object o, Method method, Object timer)
+ {
+ return new InterceptorInvocationContext(chain, o, method, timer);
+ }
+}
Deleted: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionChain.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionChain.java 2010-07-28 18:28:56 UTC (rev 107171)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionChain.java 2010-07-28 19:35:39 UTC (rev 107172)
@@ -1,123 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
- * contributors by the @authors tag. See the copyright.txt in the
- * distribution for a full listing of individual contributors.
- *
- * Licensed 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.jboss.interceptor.proxy;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.interceptor.InvocationContext;
-
-import org.jboss.interceptor.spi.model.InterceptionType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
- */
-public class InterceptionChain
-{
-
- private final Logger log = LoggerFactory.getLogger(InterceptionChain.class);
-
- private Object target;
-
- private Method targetMethod;
-
- private int currentPosition;
-
- private final InterceptionType interceptionType;
-
- private List<InterceptorInvocation.InterceptorMethodInvocation> interceptorMethodInvocations;
-
- public InterceptionChain(Collection<InterceptorInvocation<?>> interceptorInvocations, InterceptionType interceptionType, Object target, Method targetMethod)
- {
- this.interceptionType = interceptionType;
- this.target = target;
- this.targetMethod = targetMethod;
- this.currentPosition = 0;
- interceptorMethodInvocations = new ArrayList<InterceptorInvocation.InterceptorMethodInvocation>();
- for (InterceptorInvocation<?> interceptorInvocation : interceptorInvocations)
- {
- interceptorMethodInvocations.addAll(interceptorInvocation.getInterceptorMethodInvocations());
- }
- }
-
- public Object invokeNext(InvocationContext invocationContext) throws Throwable
- {
-
- try
- {
- if (hasNext())
- {
- InterceptorInvocation.InterceptorMethodInvocation nextInterceptorMethodInvocation = interceptorMethodInvocations.get(currentPosition++);
- if (log.isTraceEnabled())
- {
- log.trace("Invoking next interceptor in chain:" + nextInterceptorMethodInvocation.method.toString());
- }
- if (nextInterceptorMethodInvocation.method.getJavaMethod().getParameterTypes().length == 1)
- {
- return nextInterceptorMethodInvocation.invoke(invocationContext);
- }
- else if (nextInterceptorMethodInvocation.method.getJavaMethod().getParameterTypes().length == 0)
- {
- nextInterceptorMethodInvocation.invoke(null);
- while (hasNext())
- {
- nextInterceptorMethodInvocation = interceptorMethodInvocations.get(currentPosition++);
- if (nextInterceptorMethodInvocation.method.getJavaMethod().getParameterTypes().length != 0)
- {
- throw new IllegalStateException("Impossible state: lifecycle callback interceptor method on target class has more than one argument:" + nextInterceptorMethodInvocation.getMethod());
- }
- nextInterceptorMethodInvocation.invoke(null);
- }
- return null;
- }
- else
- {
- throw new IllegalStateException("Impossible state: interceptor method has more than one argument:" + nextInterceptorMethodInvocation.getMethod());
- }
- }
- else
- {
- if (targetMethod != null)
- {
-
- return targetMethod.invoke(target, invocationContext.getParameters());
-
- }
- else
- {
- return null;
- }
- }
- }
- catch (InvocationTargetException e)
- {
- throw e.getCause();
- }
- }
-
- public boolean hasNext()
- {
- return currentPosition < interceptorMethodInvocations.size();
- }
-
-}
Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorInvocationContext.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorInvocationContext.java 2010-07-28 18:28:56 UTC (rev 107171)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorInvocationContext.java 2010-07-28 19:35:39 UTC (rev 107172)
@@ -27,6 +27,8 @@
import javax.interceptor.InvocationContext;
+import org.jboss.interceptor.spi.context.InterceptionChain;
+
/**
* @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
*/
@@ -114,7 +116,7 @@
{
try
{
- return interceptionChain.invokeNext(this);
+ return interceptionChain.invokeNextInterceptor(this);
}
catch (Exception e)
{
Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java 2010-07-28 18:28:56 UTC (rev 107171)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java 2010-07-28 19:35:39 UTC (rev 107172)
@@ -14,6 +14,7 @@
import javassist.util.proxy.MethodHandler;
import javassist.util.proxy.ProxyObject;
import org.jboss.interceptor.reader.InterceptorMetadataUtils;
+import org.jboss.interceptor.spi.context.InvocationContextFactory;
import org.jboss.interceptor.spi.instance.InterceptorInstantiator;
import org.jboss.interceptor.spi.metadata.ClassMetadata;
import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
@@ -28,12 +29,6 @@
*/
public class InterceptorMethodHandler implements MethodHandler, Serializable
{
-
- private Map<ClassMetadata<?>, Object> interceptorHandlerInstances = new HashMap<ClassMetadata<?>, Object>();
- private InterceptorMetadata targetClassInterceptorMetadata;
- private InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
- private Object targetInstance;
-
private static MethodHandler DEFAULT_METHOD_HANDLER = new MethodHandler()
{
@@ -45,12 +40,22 @@
}
};
+ private Map<ClassMetadata<?>, Object> interceptorHandlerInstances = new HashMap<ClassMetadata<?>, Object>();
+ private InterceptorMetadata targetClassInterceptorMetadata;
+ private InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+ private Object targetInstance;
+ private InvocationContextFactory invocationContextFactory;
private boolean proxy;
- public InterceptorMethodHandler(Object targetInstance, InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel, InterceptorInstantiator<ClassMetadata<?>, ?> interceptorInstantiator, InterceptorMetadata targetClassMetadata, boolean proxy)
+ public InterceptorMethodHandler(Object targetInstance,
+ InterceptorMetadata targetClassMetadata,
+ InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel,
+ InterceptorInstantiator<ClassMetadata<?>, ?> interceptorInstantiator,
+ InvocationContextFactory invocationContextFactory,
+ boolean proxy )
{
this.targetInstance = targetInstance;
-
+ this.invocationContextFactory = invocationContextFactory;
if (interceptionModel == null)
{
throw new IllegalArgumentException("Interception model must not be null");
@@ -68,6 +73,11 @@
this.proxy = proxy;
}
+ protected boolean isProxy()
+ {
+ return proxy;
+ }
+
public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable
{
ReflectionUtils.ensureAccessible(thisMethod);
@@ -113,28 +123,18 @@
List<ClassMetadata> interceptorList = interceptionModel.getInterceptors(interceptionType, thisMethod);
Collection<InterceptorInvocation<?>> interceptorInvocations = new ArrayList<InterceptorInvocation<?>>();
-
for (ClassMetadata<?> interceptorReference : interceptorList)
{
interceptorInvocations.add(new InterceptorInvocation(interceptorHandlerInstances.get(interceptorReference), InterceptorMetadataUtils.readMetadataForInterceptorClass(interceptorReference), interceptionType));
}
-
if (targetClassInterceptorMetadata != null && targetClassInterceptorMetadata.getInterceptorMethods(interceptionType) != null && !targetClassInterceptorMetadata.getInterceptorMethods(interceptionType).isEmpty())
{
interceptorInvocations.add(new InterceptorInvocation(isProxy() ? targetInstance : self, targetClassInterceptorMetadata, interceptionType));
}
-
- InterceptionChain chain = new InterceptionChain(interceptorInvocations, interceptionType, isProxy() ? targetInstance : self, isProxy() ? thisMethod : proceedingMethod);
- return chain.invokeNext(new InterceptorInvocationContext(chain, isProxy() ? targetInstance : self, isProxy() ? thisMethod : proceedingMethod, args));
-
+ SimpleInterceptionChain chain = new SimpleInterceptionChain(interceptorInvocations, interceptionType, isProxy() ? targetInstance : self, isProxy() ? thisMethod : proceedingMethod);
+ return chain.invokeNextInterceptor(invocationContextFactory.newInvocationContext(chain, isProxy() ? targetInstance : self, isProxy() ? thisMethod : proceedingMethod, args));
}
- protected boolean isProxy()
- {
- return proxy;
- }
-
-
private void writeObject(ObjectOutputStream objectOutputStream) throws IOException
{
try
Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreatorImpl.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreatorImpl.java 2010-07-28 18:28:56 UTC (rev 107171)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreatorImpl.java 2010-07-28 19:35:39 UTC (rev 107172)
@@ -23,6 +23,7 @@
import javassist.util.proxy.MethodHandler;
import javassist.util.proxy.ProxyObject;
import org.jboss.interceptor.proxy.javassist.CompositeHandler;
+import org.jboss.interceptor.spi.context.InvocationContextFactory;
import org.jboss.interceptor.spi.instance.InterceptorInstantiator;
import org.jboss.interceptor.spi.metadata.ClassMetadata;
import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
@@ -36,13 +37,15 @@
public class InterceptorProxyCreatorImpl implements InterceptorProxyCreator
{
+ private InvocationContextFactory invocationContextFactory;
private InterceptionModel<ClassMetadata<?>,ClassMetadata> interceptionModel;
private InterceptorInstantiator<ClassMetadata<?>, Object> interceptorInstantiator;
- public InterceptorProxyCreatorImpl(InterceptorInstantiator<ClassMetadata<?>, Object> interceptorInstantiator, InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel)
+ public InterceptorProxyCreatorImpl(InterceptorInstantiator<ClassMetadata<?>, Object> interceptorInstantiator, InvocationContextFactory invocationContextFactory, InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel)
{
this.interceptorInstantiator = interceptorInstantiator;
+ this.invocationContextFactory = invocationContextFactory;
this.interceptionModel = interceptionModel;
}
@@ -105,12 +108,12 @@
public <T> MethodHandler createMethodHandler(Object target, ClassMetadata<T> proxyClass, InterceptorMetadata interceptorMetadata)
{
- return new InterceptorMethodHandler(target, interceptionModel, interceptorInstantiator, interceptorMetadata, true);
+ return new InterceptorMethodHandler(target, interceptorMetadata, interceptionModel, interceptorInstantiator, invocationContextFactory, true);
}
public <T> MethodHandler createSubclassingMethodHandler(Object targetInstance, ClassMetadata<T> proxyClass, InterceptorMetadata interceptorMetadata)
{
- return new InterceptorMethodHandler(targetInstance, interceptionModel, interceptorInstantiator, interceptorMetadata, false);
+ return new InterceptorMethodHandler(targetInstance, interceptorMetadata, interceptionModel, interceptorInstantiator, invocationContextFactory, false);
}
Copied: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/SimpleInterceptionChain.java (from rev 107154, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionChain.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/SimpleInterceptionChain.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/SimpleInterceptionChain.java 2010-07-28 19:35:39 UTC (rev 107172)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed 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.jboss.interceptor.proxy;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.interceptor.InvocationContext;
+
+import org.jboss.interceptor.spi.context.InterceptionChain;
+import org.jboss.interceptor.spi.model.InterceptionType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class SimpleInterceptionChain implements InterceptionChain
+{
+
+ private final Logger log = LoggerFactory.getLogger(SimpleInterceptionChain.class);
+
+ private Object target;
+
+ private Method targetMethod;
+
+ private int currentPosition;
+
+ private final InterceptionType interceptionType;
+
+ private List<InterceptorInvocation.InterceptorMethodInvocation> interceptorMethodInvocations;
+
+ public SimpleInterceptionChain(Collection<InterceptorInvocation<?>> interceptorInvocations, InterceptionType interceptionType, Object target, Method targetMethod)
+ {
+ this.interceptionType = interceptionType;
+ this.target = target;
+ this.targetMethod = targetMethod;
+ this.currentPosition = 0;
+ interceptorMethodInvocations = new ArrayList<InterceptorInvocation.InterceptorMethodInvocation>();
+ for (InterceptorInvocation<?> interceptorInvocation : interceptorInvocations)
+ {
+ interceptorMethodInvocations.addAll(interceptorInvocation.getInterceptorMethodInvocations());
+ }
+ }
+
+ public Object invokeNextInterceptor(InvocationContext invocationContext) throws Throwable
+ {
+
+ try
+ {
+ if (hasNextInterceptor())
+ {
+ InterceptorInvocation.InterceptorMethodInvocation nextInterceptorMethodInvocation = interceptorMethodInvocations.get(currentPosition++);
+ if (log.isTraceEnabled())
+ {
+ log.trace("Invoking next interceptor in chain:" + nextInterceptorMethodInvocation.method.toString());
+ }
+ if (nextInterceptorMethodInvocation.method.getJavaMethod().getParameterTypes().length == 1)
+ {
+ return nextInterceptorMethodInvocation.invoke(invocationContext);
+ }
+ else if (nextInterceptorMethodInvocation.method.getJavaMethod().getParameterTypes().length == 0)
+ {
+ nextInterceptorMethodInvocation.invoke(null);
+ while (hasNextInterceptor())
+ {
+ nextInterceptorMethodInvocation = interceptorMethodInvocations.get(currentPosition++);
+ if (nextInterceptorMethodInvocation.method.getJavaMethod().getParameterTypes().length != 0)
+ {
+ throw new IllegalStateException("Impossible state: lifecycle callback interceptor method on target class has more than one argument:" + nextInterceptorMethodInvocation.getMethod());
+ }
+ nextInterceptorMethodInvocation.invoke(null);
+ }
+ return null;
+ }
+ else
+ {
+ throw new IllegalStateException("Impossible state: interceptor method has more than one argument:" + nextInterceptorMethodInvocation.getMethod());
+ }
+ }
+ else
+ {
+ if (targetMethod != null)
+ {
+
+ return targetMethod.invoke(target, invocationContext.getParameters());
+
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+ catch (InvocationTargetException e)
+ {
+ throw e.getCause();
+ }
+ }
+
+ public boolean hasNextInterceptor()
+ {
+ return currentPosition < interceptorMethodInvocations.size();
+ }
+
+}
Modified: projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTestCase.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTestCase.java 2010-07-28 18:28:56 UTC (rev 107171)
+++ projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTestCase.java 2010-07-28 19:35:39 UTC (rev 107172)
@@ -29,6 +29,7 @@
import javassist.util.proxy.MethodHandler;
import javassist.util.proxy.ProxyObject;
import org.jboss.interceptor.builder.InterceptionModelBuilder;
+import org.jboss.interceptor.proxy.DefaultInvocationContextFactory;
import org.jboss.interceptor.proxy.DirectClassInterceptorInstantiator;
import org.jboss.interceptor.proxy.InterceptorProxyCreatorImpl;
import org.jboss.interceptor.proxy.javassist.CompositeHandler;
@@ -459,7 +460,8 @@
private <T> T proxifyInstance(T instance, Class<? extends T> targetClass)
{
- InterceptorProxyCreatorImpl ipc = new InterceptorProxyCreatorImpl(interceptionHandlerFactory, interceptionModelRegistry.get(targetClass));
+ DefaultInvocationContextFactory contextFactory = new DefaultInvocationContextFactory();
+ InterceptorProxyCreatorImpl ipc = new InterceptorProxyCreatorImpl(interceptionHandlerFactory, contextFactory, interceptionModelRegistry.get(targetClass));
InterceptorMetadata classMetadata = InterceptorMetadataUtils.readMetadataForTargetClass(ReflectiveClassMetadata.of(targetClass));
ClassMetadata<? extends T> targetClassMetadata = ReflectiveClassMetadata.of(targetClass);
MethodHandler methodHandler = ipc.createMethodHandler(instance, targetClassMetadata, classMetadata);
Modified: projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/SubclassingInterceptionTestCase.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/SubclassingInterceptionTestCase.java 2010-07-28 18:28:56 UTC (rev 107171)
+++ projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/SubclassingInterceptionTestCase.java 2010-07-28 19:35:39 UTC (rev 107172)
@@ -26,6 +26,7 @@
import javassist.util.proxy.ProxyObject;
import org.jboss.interceptor.builder.InterceptionModelBuilder;
+import org.jboss.interceptor.proxy.DefaultInvocationContextFactory;
import org.jboss.interceptor.proxy.DirectClassInterceptorInstantiator;
import org.jboss.interceptor.proxy.InterceptorProxyCreatorImpl;
import org.jboss.interceptor.proxy.javassist.CompositeHandler;
@@ -94,6 +95,7 @@
private Map<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>> interceptionModelRegistry;
private DirectClassInterceptorInstantiator interceptionHandlerFactory;
+ private DefaultInvocationContextFactory invocationContextFactory;
@Before
public void setUp()
@@ -444,7 +446,8 @@
private <T> T createAdvisedInstance(Class<? extends T> targetClass, Object... args) throws Exception
{
InterceptionModel<ClassMetadata<?>, ClassMetadata> classMetadataInterceptionModel = interceptionModelRegistry.get(targetClass);
- InterceptorProxyCreatorImpl ipc = new InterceptorProxyCreatorImpl(interceptionHandlerFactory, classMetadataInterceptionModel);
+ invocationContextFactory = new DefaultInvocationContextFactory();
+ InterceptorProxyCreatorImpl ipc = new InterceptorProxyCreatorImpl(interceptionHandlerFactory, invocationContextFactory, classMetadataInterceptionModel);
return ipc.createProxyFromClass(ReflectiveClassMetadata.of((Class<? extends T>) targetClass), new Class<?>[]{String.class}, args, InterceptorMetadataUtils.readMetadataForTargetClass(ReflectiveClassMetadata.of((Class<? extends T>) targetClass)));
}
Copied: projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/context/InterceptionChain.java (from rev 107154, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionChain.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/context/InterceptionChain.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/context/InterceptionChain.java 2010-07-28 19:35:39 UTC (rev 107172)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed 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.jboss.interceptor.spi.context;
+
+import javax.interceptor.InvocationContext;
+
+/**
+ * @author Marius Bogoevici
+ */
+public interface InterceptionChain
+{
+ Object invokeNextInterceptor(InvocationContext invocationContext) throws Throwable;
+ boolean hasNextInterceptor();
+}
Added: projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/context/InvocationContextFactory.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/context/InvocationContextFactory.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/context/InvocationContextFactory.java 2010-07-28 19:35:39 UTC (rev 107172)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed 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.jboss.interceptor.spi.context;
+
+import java.lang.reflect.Method;
+
+import javax.interceptor.InvocationContext;
+
+/**
+ * @author Marius Bogoevici
+ */
+public interface InvocationContextFactory
+{
+ InvocationContext newInvocationContext(InterceptionChain chain, Object o, Method method, Object[] args);
+}
More information about the jboss-cvs-commits
mailing list