[jboss-cvs] JBossAS SVN: r94045 - in projects/interceptors/trunk/src: main/java/org/jboss/interceptor/proxy and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Sep 27 00:52:05 EDT 2009
Author: marius.bogoevici
Date: 2009-09-27 00:52:05 -0400 (Sun, 27 Sep 2009)
New Revision: 94045
Added:
projects/interceptors/trunk/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadata.java
projects/interceptors/trunk/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadataImpl.java
projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandler.java
projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandlerFactory.java
projects/interceptors/trunk/src/main/java/org/jboss/interceptor/registry/InterceptorClassMetadataRegistry.java
projects/interceptors/trunk/src/main/java/org/jboss/interceptor/util/ReflectionUtils.java
projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/
projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTest.java
projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/InterceptorWithAllMethods.java
projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/InterceptorWithSomeMethods.java
projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/SimpleInheritanceChildInterceptor.java
projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/SimpleInheritanceParentInterceptor.java
projects/interceptors/trunk/src/test/java/org/jboss/interceptors/proxy/
Removed:
projects/interceptors/trunk/src/main/java/org/jboss/interceptor/model/ClassInterceptorMetadata.java
projects/interceptors/trunk/src/main/java/org/jboss/interceptor/model/InterceptorMetadata.java
projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/SimpleInterceptionHandler.java
projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/SimpleInterceptionHandlerFactory.java
Modified:
projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreatorImpl.java
projects/interceptors/trunk/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java
projects/interceptors/trunk/src/test/java/org/jboss/interceptors/InterceptionTest.java
Log:
Adding unit tests for metadata, correcting resolution of interceptor methods, extracting utility code in utility classes
Deleted: projects/interceptors/trunk/src/main/java/org/jboss/interceptor/model/ClassInterceptorMetadata.java
===================================================================
--- projects/interceptors/trunk/src/main/java/org/jboss/interceptor/model/ClassInterceptorMetadata.java 2009-09-27 03:14:54 UTC (rev 94044)
+++ projects/interceptors/trunk/src/main/java/org/jboss/interceptor/model/ClassInterceptorMetadata.java 2009-09-27 04:52:05 UTC (rev 94045)
@@ -1,91 +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.model;
-
-import org.jboss.interceptor.proxy.InterceptorException;
-
-import javax.interceptor.InvocationContext;
-import java.lang.reflect.Method;
-import java.util.*;
-
-/**
- * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
- */
-public class ClassInterceptorMetadata implements InterceptorMetadata
-{
-
- private Class<?> interceptorClass;
-
- private Map<InterceptionType, List<Method>> methodMap = new HashMap<InterceptionType, List<Method>>();
-
- public ClassInterceptorMetadata(Class<?> interceptorClass)
- {
- this.interceptorClass = interceptorClass;
-
- Class<?> currentClass = interceptorClass;
-
-
- Set<String> foundMethodNames = new HashSet<String>();
- do
- {
- Set<InterceptionType> detectedInterceptorTypes = new HashSet<InterceptionType>();
- for (InterceptionType interceptionType : InterceptionTypeRegistry.getSupportedInterceptionTypes())
- {
- for (Method method : currentClass.getDeclaredMethods())
- {
- if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0].equals(InvocationContext.class) && method.getAnnotation(InterceptionTypeRegistry.getAnnotationClass(interceptionType)) != null)
- {
- if (methodMap.get(interceptionType) == null)
- methodMap.put(interceptionType, new LinkedList<Method>());
- if (detectedInterceptorTypes.contains(interceptionType))
- throw new InterceptorException("Same interception type cannot be specified twice on the same class");
- else
- detectedInterceptorTypes.add(interceptionType);
- // add method in the list - if it is there already, it means that it has been added by a subclass
- ensureAccessible(method);
- if (!foundMethodNames.contains(method.getName()))
- {
- methodMap.get(interceptionType).add(method);
- foundMethodNames.add(method.getName());
- }
- }
- }
- }
- currentClass = currentClass.getSuperclass();
- } while (currentClass != null);
- }
-
- public static void ensureAccessible(Method method)
- {
- if (!method.isAccessible())
- {
- method.setAccessible(true);
- }
- }
-
- public Class<?> getInterceptorClass()
- {
- return interceptorClass;
- }
-
- public List<Method> getInterceptorMethods(InterceptionType interceptionType)
- {
- return methodMap.get(interceptionType);
- }
-
-}
Copied: projects/interceptors/trunk/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadata.java (from rev 94044, projects/interceptors/trunk/src/main/java/org/jboss/interceptor/model/InterceptorMetadata.java)
===================================================================
--- projects/interceptors/trunk/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadata.java (rev 0)
+++ projects/interceptors/trunk/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadata.java 2009-09-27 04:52:05 UTC (rev 94045)
@@ -0,0 +1,41 @@
+/*
+ * 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.model;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+/**
+ * A
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public interface InterceptorClassMetadata
+{
+ Class<?> getInterceptorClass();
+
+ /**
+ * Returns the list of methods to be invoked on this class when doing
+ * interception (as an interceptor is supposed to invoke the superclass
+ * methods too)
+ *
+ * @param interceptionType
+ * @return a list of methods
+ */
+ List<Method> getInterceptorMethods(InterceptionType interceptionType);
+
+}
Copied: projects/interceptors/trunk/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadataImpl.java (from rev 94044, projects/interceptors/trunk/src/main/java/org/jboss/interceptor/model/ClassInterceptorMetadata.java)
===================================================================
--- projects/interceptors/trunk/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadataImpl.java (rev 0)
+++ projects/interceptors/trunk/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadataImpl.java 2009-09-27 04:52:05 UTC (rev 94045)
@@ -0,0 +1,89 @@
+/*
+ * 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.model;
+
+import org.jboss.interceptor.proxy.InterceptorException;
+import org.jboss.interceptor.util.InterceptionUtils;
+import org.jboss.interceptor.util.ReflectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.lang.reflect.Method;
+import java.util.*;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class InterceptorClassMetadataImpl implements InterceptorClassMetadata
+{
+
+ private Log log = LogFactory.getLog(InterceptorClassMetadataImpl.class);
+
+ private Class<?> interceptorClass;
+
+ private Map<InterceptionType, List<Method>> methodMap = new HashMap<InterceptionType, List<Method>>();
+
+ public InterceptorClassMetadataImpl(Class<?> interceptorClass)
+ {
+ this.interceptorClass = interceptorClass;
+
+ Class<?> currentClass = interceptorClass;
+
+
+ Set<String> foundMethodNames = new HashSet<String>();
+ do
+ {
+ Set<InterceptionType> detectedInterceptorTypes = new HashSet<InterceptionType>();
+ for (InterceptionType interceptionType : InterceptionTypeRegistry.getSupportedInterceptionTypes())
+ {
+ for (Method method : currentClass.getDeclaredMethods())
+ {
+ if (InterceptionUtils.isInterceptorMethod(interceptionType, method))
+ {
+ if (methodMap.get(interceptionType) == null)
+ methodMap.put(interceptionType, new LinkedList<Method>());
+ if (detectedInterceptorTypes.contains(interceptionType))
+ throw new InterceptorException("Same interception type cannot be specified twice on the same class");
+ else
+ detectedInterceptorTypes.add(interceptionType);
+ // add method in the list - if it is there already, it means that it has been added by a subclass
+ ReflectionUtils.ensureAccessible(method);
+ if (!foundMethodNames.contains(method.getName()))
+ {
+ methodMap.get(interceptionType).add(method);
+ foundMethodNames.add(method.getName());
+ }
+ }
+ }
+ }
+ currentClass = currentClass.getSuperclass();
+ } while (currentClass != null);
+ }
+
+ public Class<?> getInterceptorClass()
+ {
+ return interceptorClass;
+ }
+
+ public List<Method> getInterceptorMethods(InterceptionType interceptionType)
+ {
+ List<Method> methods = methodMap.get(interceptionType);
+ return methods == null ? Collections.EMPTY_LIST : methods;
+ }
+
+}
Deleted: projects/interceptors/trunk/src/main/java/org/jboss/interceptor/model/InterceptorMetadata.java
===================================================================
--- projects/interceptors/trunk/src/main/java/org/jboss/interceptor/model/InterceptorMetadata.java 2009-09-27 03:14:54 UTC (rev 94044)
+++ projects/interceptors/trunk/src/main/java/org/jboss/interceptor/model/InterceptorMetadata.java 2009-09-27 04:52:05 UTC (rev 94045)
@@ -1,32 +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.model;
-
-import java.lang.reflect.Method;
-import java.util.List;
-
-/**
- * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
- */
-public interface InterceptorMetadata
-{
- Class<?> getInterceptorClass();
-
- List<Method> getInterceptorMethods(InterceptionType interceptionType);
-
-}
Copied: projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandler.java (from rev 94044, projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/SimpleInterceptionHandler.java)
===================================================================
--- projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandler.java (rev 0)
+++ projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandler.java 2009-09-27 04:52:05 UTC (rev 94045)
@@ -0,0 +1,143 @@
+/*
+ * 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 org.jboss.interceptor.model.InterceptionType;
+import org.jboss.interceptor.model.InterceptorClassMetadata;
+import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
+
+import javax.interceptor.InvocationContext;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class DirectClassInterceptionHandler implements InterceptionHandler
+{
+
+ private final Object interceptorInstance;
+
+ private InterceptorClassMetadata interceptorMetadata;
+
+ private Class<?> clazz;
+
+ public DirectClassInterceptionHandler(Object interceptorInstance, Class<?> clazz)
+ {
+ if (interceptorInstance == null)
+ throw new IllegalArgumentException("Interceptor instance cannot be null");
+
+ this.clazz = (clazz == null) ? interceptorInstance.getClass() : clazz;
+ this.interceptorInstance = interceptorInstance;
+ this.interceptorMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(this.clazz);
+
+ }
+
+ public DirectClassInterceptionHandler(Class<?> simpleInterceptorClass)
+ {
+
+ if (simpleInterceptorClass == null)
+ throw new IllegalArgumentException("Class must not be null");
+
+ this.clazz = simpleInterceptorClass;
+ try
+ {
+ this.interceptorInstance = simpleInterceptorClass.newInstance();
+ } catch (Exception e)
+ {
+ throw new InterceptorException("Cannot create interceptor instance:", e);
+ }
+ this.interceptorMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(this.clazz);
+
+ }
+
+ public Object invoke(Object target, InterceptionType interceptionType, InvocationContext invocationContext) throws Exception
+ {
+ List<Method> methods = interceptorMetadata.getInterceptorMethods(interceptionType);
+ if (methods != null)
+ {
+ DelegatingInvocationContext delegatingInvocationContext = new DelegatingInvocationContext(invocationContext, interceptorInstance, methods);
+ return delegatingInvocationContext.proceed();
+ } else
+ throw new InterceptorException(target.toString() + " was requested to perform " + interceptionType.name() + " but no such method is defined on it");
+ }
+
+
+ public boolean handles(Class<?> clazz)
+ {
+ return this.clazz.equals(clazz);
+ }
+
+ public class DelegatingInvocationContext implements InvocationContext
+ {
+
+ private InvocationContext delegateInvocationContext;
+
+ private Object targetObject;
+
+ private Queue<Method> invocationQueue;
+
+ public DelegatingInvocationContext(InvocationContext delegateInvocationContext, Object targetObject, List<Method> methods)
+ {
+ this.delegateInvocationContext = delegateInvocationContext;
+ this.targetObject = targetObject;
+ this.invocationQueue = new ConcurrentLinkedQueue<Method>(methods);
+ }
+
+ public Map<String, Object> getContextData()
+ {
+ return delegateInvocationContext.getContextData();
+ }
+
+ public Method getMethod()
+ {
+ return delegateInvocationContext.getMethod();
+ }
+
+ public Object[] getParameters()
+ {
+ return delegateInvocationContext.getParameters();
+ }
+
+ public Object getTarget()
+ {
+ return delegateInvocationContext.getTarget();
+ }
+
+ public Object proceed() throws Exception
+ {
+ if (!invocationQueue.isEmpty())
+ {
+ return invocationQueue.remove().invoke(targetObject, this);
+ } else
+ {
+ return delegateInvocationContext.proceed();
+ }
+ }
+
+ public void setParameters(Object[] params)
+ {
+ delegateInvocationContext.setParameters(params);
+ }
+ }
+
+}
+
Copied: projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandlerFactory.java (from rev 93795, projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/SimpleInterceptionHandlerFactory.java)
===================================================================
--- projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandlerFactory.java (rev 0)
+++ projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandlerFactory.java 2009-09-27 04:52:05 UTC (rev 94045)
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class DirectClassInterceptionHandlerFactory implements InterceptionHandlerFactory {
+
+ public InterceptionHandler createForClass(Class<?> clazz) {
+ return new DirectClassInterceptionHandler(clazz);
+ }
+}
Modified: projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreatorImpl.java
===================================================================
--- projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreatorImpl.java 2009-09-27 03:14:54 UTC (rev 94044)
+++ projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreatorImpl.java 2009-09-27 04:52:05 UTC (rev 94045)
@@ -17,17 +17,20 @@
package org.jboss.interceptor.proxy;
+import javassist.util.proxy.MethodHandler;
+import javassist.util.proxy.ProxyFactory;
+import org.jboss.interceptor.model.InterceptionType;
+import org.jboss.interceptor.model.InterceptorClassMetadata;
import org.jboss.interceptor.registry.InterceptorRegistry;
-import org.jboss.interceptor.model.InterceptionType;
-import org.jboss.interceptor.model.InterceptorMetadata;
-import org.jboss.interceptor.model.ClassInterceptorMetadata;
+import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
import static org.jboss.interceptor.util.InterceptionUtils.isAroundInvokeInterceptionCandidate;
-import javassist.util.proxy.ProxyFactory;
-import javassist.util.proxy.MethodHandler;
import javax.interceptor.AroundInvoke;
import java.lang.reflect.Method;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
@@ -117,7 +120,7 @@
private InterceptorRegistry registry;
private Map<Class<?>, InterceptionHandler> interceptorHandlerInstances = new HashMap<Class<?>, InterceptionHandler>();
private Class<?> targetClazz;
- private InterceptorMetadata targetClassInterceptorMetadata;
+ private InterceptorClassMetadata targetClassInterceptorMetadata;
public InstanceProxifyingMethodHandler(Object target, Class<?> targetClass, InterceptorRegistry<Class<?>> registry)
{
@@ -137,8 +140,8 @@
{
interceptorHandlerInstances.put(interceptorClazz, interceptionHandlerFactory.createForClass(interceptorClazz));
}
- targetClassInterceptorMetadata = new ClassInterceptorMetadata(targetClazz);
- interceptorHandlerInstances.put(targetClazz, new SimpleInterceptionHandler(target, targetClazz));
+ targetClassInterceptorMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(targetClazz);
+ interceptorHandlerInstances.put(targetClazz, new DirectClassInterceptionHandler(target, targetClazz));
}
public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable
@@ -184,7 +187,7 @@
private InterceptorRegistry registry;
private Map<Class<?>, InterceptionHandler> interceptorHandlerInstances = new HashMap<Class<?>, InterceptionHandler>();
private Class<?> targetClazz;
- private InterceptorMetadata targetClassInterceptorMetadata;
+ private InterceptorClassMetadata targetClassInterceptorMetadata;
public AutoProxifiedMethodHandler(Class<?> targetClazz, InterceptorRegistry<Class<?>> registry)
@@ -197,9 +200,9 @@
for (Class<?> interceptorClazz : registry.getInterceptionModel(this.targetClazz).getAllInterceptors())
{
- interceptorHandlerInstances.put(interceptorClazz, new SimpleInterceptionHandler(interceptorClazz));
+ interceptorHandlerInstances.put(interceptorClazz, new DirectClassInterceptionHandler(interceptorClazz));
}
- targetClassInterceptorMetadata = new ClassInterceptorMetadata(targetClazz);
+ targetClassInterceptorMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(targetClazz);
}
public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable
@@ -241,7 +244,7 @@
private void addSelfAsInterceptorHandler(Object self)
{
if (!interceptorHandlerInstances.containsKey(targetClazz))
- interceptorHandlerInstances.put(targetClazz, new SimpleInterceptionHandler(self, targetClazz));
+ interceptorHandlerInstances.put(targetClazz, new DirectClassInterceptionHandler(self, targetClazz));
}
}
Deleted: projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/SimpleInterceptionHandler.java
===================================================================
--- projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/SimpleInterceptionHandler.java 2009-09-27 03:14:54 UTC (rev 94044)
+++ projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/SimpleInterceptionHandler.java 2009-09-27 04:52:05 UTC (rev 94045)
@@ -1,142 +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 org.jboss.interceptor.model.InterceptionType;
-import org.jboss.interceptor.model.InterceptorMetadata;
-import org.jboss.interceptor.model.ClassInterceptorMetadata;
-
-import javax.interceptor.InvocationContext;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
-/**
- * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
- */
-public class SimpleInterceptionHandler implements InterceptionHandler
-{
-
- private final Object interceptorInstance;
-
- private InterceptorMetadata interceptorMetadata;
-
- private Class<?> clazz;
-
- public SimpleInterceptionHandler(Object interceptorInstance, Class<?> clazz)
- {
- if (interceptorInstance == null)
- throw new IllegalArgumentException("Interceptor instance cannot be null");
-
- this.clazz = (clazz == null) ? interceptorInstance.getClass() : clazz;
- this.interceptorInstance = interceptorInstance;
- this.interceptorMetadata = new ClassInterceptorMetadata(this.clazz);
-
- }
-
- public SimpleInterceptionHandler(Class<?> simpleInterceptorClass)
- {
-
- if (simpleInterceptorClass == null)
- throw new IllegalArgumentException("Class must not be null");
-
- this.clazz = simpleInterceptorClass;
- try
- {
- this.interceptorInstance = simpleInterceptorClass.newInstance();
- } catch (Exception e)
- {
- throw new InterceptorException("Cannot create interceptor instance:", e);
- }
- this.interceptorMetadata = new ClassInterceptorMetadata(this.clazz);
-
- }
-
- public Object invoke(Object target, InterceptionType interceptionType, InvocationContext invocationContext) throws Exception
- {
- List<Method> methods = interceptorMetadata.getInterceptorMethods(interceptionType);
- if (methods != null)
- {
- DelegatingInvocationContext delegatingInvocationContext = new DelegatingInvocationContext(invocationContext, interceptorInstance, methods);
- return delegatingInvocationContext.proceed();
- } else
- throw new InterceptorException(target.toString() + " was requested to perform " + interceptionType.name() + " but no such method is defined on it");
- }
-
-
- public boolean handles(Class<?> clazz)
- {
- return this.clazz.equals(clazz);
- }
-
- public class DelegatingInvocationContext implements InvocationContext
- {
-
- private InvocationContext delegateInvocationContext;
-
- private Object targetObject;
-
- private Queue<Method> invocationQueue;
-
- public DelegatingInvocationContext(InvocationContext delegateInvocationContext, Object targetObject, List<Method> methods)
- {
- this.delegateInvocationContext = delegateInvocationContext;
- this.targetObject = targetObject;
- this.invocationQueue = new ConcurrentLinkedQueue<Method>(methods);
- }
-
- public Map<String, Object> getContextData()
- {
- return delegateInvocationContext.getContextData();
- }
-
- public Method getMethod()
- {
- return delegateInvocationContext.getMethod();
- }
-
- public Object[] getParameters()
- {
- return delegateInvocationContext.getParameters();
- }
-
- public Object getTarget()
- {
- return delegateInvocationContext.getTarget();
- }
-
- public Object proceed() throws Exception
- {
- if (!invocationQueue.isEmpty())
- {
- return invocationQueue.remove().invoke(targetObject, this);
- } else
- {
- return delegateInvocationContext.proceed();
- }
- }
-
- public void setParameters(Object[] params)
- {
- delegateInvocationContext.setParameters(params);
- }
- }
-
-}
-
Deleted: projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/SimpleInterceptionHandlerFactory.java
===================================================================
--- projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/SimpleInterceptionHandlerFactory.java 2009-09-27 03:14:54 UTC (rev 94044)
+++ projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/SimpleInterceptionHandlerFactory.java 2009-09-27 04:52:05 UTC (rev 94045)
@@ -1,28 +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;
-
-/**
- * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
- */
-public class SimpleInterceptionHandlerFactory implements InterceptionHandlerFactory {
-
- public InterceptionHandler createForClass(Class<?> clazz) {
- return new SimpleInterceptionHandler(clazz);
- }
-}
Added: projects/interceptors/trunk/src/main/java/org/jboss/interceptor/registry/InterceptorClassMetadataRegistry.java
===================================================================
--- projects/interceptors/trunk/src/main/java/org/jboss/interceptor/registry/InterceptorClassMetadataRegistry.java (rev 0)
+++ projects/interceptors/trunk/src/main/java/org/jboss/interceptor/registry/InterceptorClassMetadataRegistry.java 2009-09-27 04:52:05 UTC (rev 94045)
@@ -0,0 +1,71 @@
+/*
+ * 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.registry;
+
+import org.jboss.interceptor.model.InterceptorClassMetadataImpl;
+import org.jboss.interceptor.model.InterceptorClassMetadata;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class InterceptorClassMetadataRegistry
+{
+ private static InterceptorClassMetadataRegistry interceptorMetadataRegistry;
+
+ private final Map<Class<?>, InterceptorClassMetadata> interceptorClassMetadataMap = new ConcurrentHashMap<Class<?>, InterceptorClassMetadata>();
+
+ private final Lock lock = new ReentrantLock();
+
+ static
+ {
+ interceptorMetadataRegistry = new InterceptorClassMetadataRegistry();
+ }
+
+ public static InterceptorClassMetadataRegistry getRegistry()
+ {
+ return interceptorMetadataRegistry;
+ }
+
+ public InterceptorClassMetadata getInterceptorClassMetadata(Class<?> interceptorClass)
+ {
+ if (!interceptorClassMetadataMap.containsKey(interceptorClass))
+ {
+ try
+ {
+ lock.lock();
+ //verify that metadata hasn't been added while waiting for the lock
+ if (!interceptorClassMetadataMap.containsKey(interceptorClass))
+ {
+ interceptorClassMetadataMap.put(interceptorClass, new InterceptorClassMetadataImpl(interceptorClass));
+ }
+ } catch (Exception e)
+ {
+ lock.unlock();
+ }
+ }
+
+ return interceptorClassMetadataMap.get(interceptorClass);
+
+ }
+
+}
Modified: projects/interceptors/trunk/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java
===================================================================
--- projects/interceptors/trunk/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java 2009-09-27 03:14:54 UTC (rev 94044)
+++ projects/interceptors/trunk/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java 2009-09-27 04:52:05 UTC (rev 94045)
@@ -20,8 +20,10 @@
import org.jboss.interceptor.proxy.InterceptorProxyCreatorImpl;
import org.jboss.interceptor.model.InterceptionType;
import org.jboss.interceptor.model.InterceptionTypeRegistry;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
-import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@@ -30,6 +32,8 @@
*/
public class InterceptionUtils
{
+ private static final Log LOG = LogFactory.getLog(InterceptionUtils.class);
+
public static void executePostConstruct(Object proxy)
{
if (proxy instanceof InterceptorProxyCreatorImpl.LifecycleMixin)
@@ -65,4 +69,77 @@
return Modifier.isPublic(modifiers)
&& !Modifier.isStatic(modifiers);
}
+
+ /**
+ *
+ * @param interceptionType
+ * @param method
+ * @return
+ */
+ public static boolean isInterceptorMethod(InterceptionType interceptionType, Method method)
+ {
+
+ if (method.getAnnotation(InterceptionTypeRegistry.getAnnotationClass(interceptionType)) == null)
+ return false;
+
+ if (interceptionType.isLifecycleCallback())
+ {
+ if (!Void.TYPE.equals(method.getReturnType()))
+ {
+ LOG.warn("Method " + method.getName() + " on class " + method.getDeclaringClass().getName()
+ + " is annotated with " + interceptionType.getAnnotationClassName()
+ + " but does not have a void return type");
+ return false;
+ }
+
+ Class<?>[] parameterTypes = method.getParameterTypes();
+
+ if (parameterTypes.length > 1)
+ {
+ LOG.warn("Method " + method.getName() + " on class " + method.getDeclaringClass().getName()
+ + " is annotated with " + interceptionType.getAnnotationClassName()
+ + " but has more than 1 parameter");
+ return false;
+ }
+
+ if (parameterTypes.length == 1 && !InvocationContext.class.equals(parameterTypes[0]))
+ {
+ LOG.warn("Method " + method.getName() + " on class " + method.getDeclaringClass().getName()
+ + " is annotated with " + interceptionType.getAnnotationClassName()
+ + " but does not have a " + InvocationContext.class.getName() + " parameter ");
+ return false;
+ }
+
+ return true;
+ } else
+ {
+ if (!Object.class.equals(method.getReturnType()))
+ {
+ LOG.warn("Method " + method.getName() + " on class " + method.getDeclaringClass().getName()
+ + " is annotated with " + interceptionType.getAnnotationClassName()
+ + " but does not return a " + Object.class.getName());
+ return false;
+ }
+
+ Class<?>[] parameterTypes = method.getParameterTypes();
+
+ if (parameterTypes.length != 1)
+ {
+ LOG.warn("Method " + method.getName() + " on class " + method.getDeclaringClass().getName()
+ + " is annotated with " + interceptionType.getAnnotationClassName()
+ + " but does not have exactly 1 parameter");
+ return false;
+ }
+
+ if (!InvocationContext.class.equals(parameterTypes[0]))
+ {
+ LOG.warn("Method " + method.getName() + " on class " + method.getDeclaringClass().getName()
+ + " is annotated with " + interceptionType.getAnnotationClassName()
+ + " but does not have a " + InvocationContext.class.getName() + " parameter ");
+ return false;
+ }
+
+ return true;
+ }
+ }
}
Added: projects/interceptors/trunk/src/main/java/org/jboss/interceptor/util/ReflectionUtils.java
===================================================================
--- projects/interceptors/trunk/src/main/java/org/jboss/interceptor/util/ReflectionUtils.java (rev 0)
+++ projects/interceptors/trunk/src/main/java/org/jboss/interceptor/util/ReflectionUtils.java 2009-09-27 04:52:05 UTC (rev 94045)
@@ -0,0 +1,35 @@
+/*
+ * 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.util;
+
+import java.lang.reflect.Method;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class ReflectionUtils
+{
+
+ public static void ensureAccessible(Method method)
+ {
+ if (!method.isAccessible())
+ {
+ method.setAccessible(true);
+ }
+ }
+}
Modified: projects/interceptors/trunk/src/test/java/org/jboss/interceptors/InterceptionTest.java
===================================================================
--- projects/interceptors/trunk/src/test/java/org/jboss/interceptors/InterceptionTest.java 2009-09-27 03:14:54 UTC (rev 94044)
+++ projects/interceptors/trunk/src/test/java/org/jboss/interceptors/InterceptionTest.java 2009-09-27 04:52:05 UTC (rev 94045)
@@ -20,7 +20,7 @@
import org.jboss.interceptor.model.InterceptionModelBuilder;
import org.jboss.interceptor.proxy.InterceptorProxyCreator;
import org.jboss.interceptor.proxy.InterceptorProxyCreatorImpl;
-import org.jboss.interceptor.proxy.SimpleInterceptionHandlerFactory;
+import org.jboss.interceptor.proxy.DirectClassInterceptionHandlerFactory;
import org.jboss.interceptor.registry.InterceptorRegistry;
import org.jboss.interceptor.util.InterceptionUtils;
import org.junit.Assert;
@@ -66,7 +66,7 @@
builder.interceptPreDestroy().with(MySecondInterceptor.class);
interceptorRegistry.registerInterceptionModel(FootballTeam.class, builder.build());
- interceptorProxyCreator = new InterceptorProxyCreatorImpl(interceptorRegistry, new SimpleInterceptionHandlerFactory());
+ interceptorProxyCreator = new InterceptorProxyCreatorImpl(interceptorRegistry, new DirectClassInterceptionHandlerFactory());
}
Added: projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTest.java
===================================================================
--- projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTest.java (rev 0)
+++ projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTest.java 2009-09-27 04:52:05 UTC (rev 94045)
@@ -0,0 +1,90 @@
+/*
+ * 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.interceptors.metadata;
+
+import org.junit.Test;
+import org.junit.Assert;
+import static org.junit.Assert.assertEquals;
+import org.jboss.interceptor.model.InterceptorClassMetadata;
+import org.jboss.interceptor.model.InterceptionType;
+import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class InterceptorClassMetadataTest
+{
+
+ @Test
+ public void testInterceptorWithAllMethods()
+ {
+ InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(InterceptorWithAllMethods.class);
+
+ List<Method> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
+ assertEquals(true, postConstructMethods.size() == 1);
+ assertEquals(postConstructMethods.get(0).getName(), "doPostConstruct");
+
+ List<Method> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
+ assertEquals(true, preDestroyMethods.size() == 1);
+ assertEquals(preDestroyMethods.get(0).getName(), "doPreDestroy");
+
+ List<Method> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
+ assertEquals(true, aroundInvokeMethods.size() == 1);
+ assertEquals(aroundInvokeMethods.get(0).getName(), "doAroundInvoke");
+
+ List<Method> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
+ assertEquals(true, postActivateMethods.size() == 1);
+ assertEquals(postActivateMethods.get(0).getName(), "doPostActivate");
+
+
+ List<Method> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
+ assertEquals(true, prePassivateMethods.size() == 1);
+ assertEquals(prePassivateMethods.get(0).getName(), "doPrePassivate");
+
+ }
+
+ @Test
+ public void testInterceptorWithSomeMethods()
+ {
+ InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(InterceptorWithSomeMethods.class);
+
+ List<Method> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
+ assertEquals(true, postConstructMethods.size() == 0);
+
+ List<Method> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
+ assertEquals(true, preDestroyMethods.size() == 1);
+ assertEquals(preDestroyMethods.get(0).getName(), "doPreDestroy");
+
+ List<Method> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
+ assertEquals(true, aroundInvokeMethods.size() == 1);
+ assertEquals(aroundInvokeMethods.get(0).getName(), "doAroundInvoke");
+
+ List<Method> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
+ assertEquals(true, postActivateMethods.size() == 1);
+ assertEquals(postActivateMethods.get(0).getName(), "doPostActivate");
+
+
+ List<Method> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
+ assertEquals(true, prePassivateMethods.size() == 0);
+
+ }
+
+}
Added: projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/InterceptorWithAllMethods.java
===================================================================
--- projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/InterceptorWithAllMethods.java (rev 0)
+++ projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/InterceptorWithAllMethods.java 2009-09-27 04:52:05 UTC (rev 94045)
@@ -0,0 +1,61 @@
+/*
+ * 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.interceptors.metadata;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class InterceptorWithAllMethods
+{
+ @AroundInvoke
+ public Object doAroundInvoke(InvocationContext invocationContext)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @PostConstruct
+ public void doPostConstruct(InvocationContext invocationContext)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @PreDestroy
+ public void doPreDestroy(InvocationContext invocationContext)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @PostActivate
+ public void doPostActivate(InvocationContext invocationContext)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @PrePassivate
+ public void doPrePassivate(InvocationContext invocationContext)
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Added: projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/InterceptorWithSomeMethods.java
===================================================================
--- projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/InterceptorWithSomeMethods.java (rev 0)
+++ projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/InterceptorWithSomeMethods.java 2009-09-27 04:52:05 UTC (rev 94045)
@@ -0,0 +1,51 @@
+/*
+ * 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.interceptors.metadata;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class InterceptorWithSomeMethods
+{
+ @AroundInvoke
+ public Object doAroundInvoke(InvocationContext invocationContext)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+
+ @PreDestroy
+ public void doPreDestroy(InvocationContext invocationContext)
+ {
+
+ }
+
+ @PostActivate
+ public void doPostActivate(InvocationContext invocationContext)
+ {
+
+ }
+
+}
\ No newline at end of file
Added: projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/SimpleInheritanceChildInterceptor.java
===================================================================
--- projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/SimpleInheritanceChildInterceptor.java (rev 0)
+++ projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/SimpleInheritanceChildInterceptor.java 2009-09-27 04:52:05 UTC (rev 94045)
@@ -0,0 +1,33 @@
+/*
+ * 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.interceptors.metadata;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class SimpleInheritanceChildInterceptor
+{
+ @AroundInvoke
+ public Object doAroundInvoke(InvocationContext invocationContext)
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Added: projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/SimpleInheritanceParentInterceptor.java
===================================================================
--- projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/SimpleInheritanceParentInterceptor.java (rev 0)
+++ projects/interceptors/trunk/src/test/java/org/jboss/interceptors/metadata/SimpleInheritanceParentInterceptor.java 2009-09-27 04:52:05 UTC (rev 94045)
@@ -0,0 +1,33 @@
+/*
+ * 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.interceptors.metadata;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class SimpleInheritanceParentInterceptor
+{
+ @PostConstruct
+ public void doPostConstruct()
+ {
+
+ }
+
+}
More information about the jboss-cvs-commits
mailing list