[jboss-cvs] JBossAS SVN: r106596 - in projects/interceptors/trunk: jboss-interceptor and 20 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jul 12 10:54:50 EDT 2010
Author: marius.bogoevici
Date: 2010-07-12 10:54:45 -0400 (Mon, 12 Jul 2010)
New Revision: 106596
Added:
projects/interceptors/trunk/jboss-interceptor-api/
projects/interceptors/trunk/jboss-interceptor-api/pom.xml
projects/interceptors/trunk/jboss-interceptor-api/src/
projects/interceptors/trunk/jboss-interceptor-api/src/main/
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/handler/
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/handler/InterceptionHandler.java
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/handler/InterceptionHandlerFactory.java
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/ClassMetadata.java
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/InterceptorMetadata.java
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/InterceptorMetadataReader.java
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/MethodMetadata.java
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/model/
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/model/InterceptionModel.java
projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/model/InterceptionType.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/builder/
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/builder/BuildableInterceptionModel.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/builder/InterceptionModelBuilder.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/builder/InterceptionModelImpl.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/builder/MethodReference.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/metadataregistry/
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/metadataregistry/InterceptorMetadataRegistry.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/metadataregistry/SimpleInterceptorMetadataRegistry.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorException.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/InterceptorMetadataUtils.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/ReflectiveClassMetadata.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/ReflectiveMethodMetadata.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/SimpleInterceptorMetadata.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionTypeRegistry.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptorMetadataException.java
Removed:
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/InterceptorException.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionHandler.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionHandlerFactory.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/proxy/SubclassedProxy.java
Modified:
projects/interceptors/trunk/jboss-interceptor/pom.xml
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/AbstractClassInterceptionHandler.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandler.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandlerFactory.java
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/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/InterceptorProxyCreator.java
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/SubclassingInterceptorMethodHandler.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/ImmutableIteratorWrapper.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/proxy/TargetInstanceProxy.java
projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTestCase.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
projects/interceptors/trunk/pom.xml
Log:
Major overhaul of the interceptor library: bumped version to 1.1.0-SNAPSHOT, split into api/impl, removed InterceptorModelRegistry, simplified the API.
Modified: projects/interceptors/trunk/jboss-interceptor/pom.xml
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/pom.xml 2010-07-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/pom.xml 2010-07-12 14:54:45 UTC (rev 106596)
@@ -1,52 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.jboss.interceptor</groupId>
- <artifactId>jboss-interceptor-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </parent>
+ <parent>
+ <groupId>org.jboss.interceptor</groupId>
+ <artifactId>jboss-interceptor-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
- <artifactId>jboss-interceptor</artifactId>
- <name>JBoss EJB 3.1 Common Interceptor Library</name>
+ <artifactId>jboss-interceptor-impl</artifactId>
+ <name>JBoss EJB 3.1 Common Interceptor Library Implementation</name>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.spec.javax.interceptor</groupId>
- <artifactId>jboss-interceptors-api_1.1_spec</artifactId>
- <optional>true</optional>
- </dependency>
+ <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.jboss.interceptor</groupId>
+ <artifactId>jboss-interceptor-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <optional>true</optional>
- </dependency>
-
-
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.jboss.spec.javax.interceptor</groupId>
+ <artifactId>jboss-interceptors-api_1.1_spec</artifactId>
+ <optional>true</optional>
+ </dependency>
- <dependency>
- <groupId>org.jboss.ejb3</groupId>
- <artifactId>jboss-ejb3-api</artifactId>
- <optional>true</optional>
- </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
- </dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-api</artifactId>
+ <optional>true</optional>
+ </dependency>
+
+ </dependencies>
+
</project>
Deleted: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/InterceptorException.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/InterceptorException.java 2010-07-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/InterceptorException.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -1,44 +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;
-
-/**
- * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
- */
- at SuppressWarnings("serial")
-public class InterceptorException extends RuntimeException
-{
- public InterceptorException()
- {
- }
-
- public InterceptorException(String s)
- {
- super(s);
- }
-
- public InterceptorException(String s, Throwable throwable)
- {
- super(s, throwable);
- }
-
- public InterceptorException(Throwable throwable)
- {
- super(throwable);
- }
-}
Added: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/builder/BuildableInterceptionModel.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/builder/BuildableInterceptionModel.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/builder/BuildableInterceptionModel.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,16 @@
+package org.jboss.interceptor.builder;
+
+import java.lang.reflect.Method;
+
+import org.jboss.interceptor.spi.model.InterceptionModel;
+import org.jboss.interceptor.spi.model.InterceptionType;
+
+/**
+ * An interception model that can be manipulated by the builder
+ * @author Marius Bogoevici
+ */
+public interface BuildableInterceptionModel<T,I> extends InterceptionModel<T, I>
+{
+ void setIgnoresGlobals(Method m, boolean b);
+ void appendInterceptors(InterceptionType interceptionType, Method method, I[] interceptors);
+}
Copied: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/builder/InterceptionModelBuilder.java (from rev 106491, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/builder/InterceptionModelBuilder.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/builder/InterceptionModelBuilder.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/builder/InterceptionModelBuilder.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,137 @@
+/*
+ * 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.builder;
+
+import static org.jboss.interceptor.spi.model.InterceptionType.POST_ACTIVATE;
+import static org.jboss.interceptor.spi.model.InterceptionType.POST_CONSTRUCT;
+import static org.jboss.interceptor.spi.model.InterceptionType.PRE_DESTROY;
+import static org.jboss.interceptor.spi.model.InterceptionType.PRE_PASSIVATE;
+
+import java.lang.reflect.Method;
+
+import org.jboss.interceptor.spi.model.InterceptionModel;
+import org.jboss.interceptor.spi.model.InterceptionType;
+
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class InterceptionModelBuilder<T, I>
+{
+
+ private BuildableInterceptionModel<T, I> interceptionModel;
+
+ private T interceptedEntity;
+
+ private InterceptionModelBuilder(T interceptedEntity)
+ {
+ this.interceptedEntity = interceptedEntity;
+ this.interceptionModel = new InterceptionModelImpl<T, I>(interceptedEntity);
+ }
+
+ private InterceptionModelBuilder(BuildableInterceptionModel<T, I> interceptionModel)
+ {
+ if (interceptionModel == null)
+ {
+ throw new IllegalArgumentException("Interception model must not be null");
+ }
+ this.interceptedEntity = interceptionModel.getInterceptedEntity();
+ this.interceptionModel = interceptionModel;
+ }
+
+ public static <T,I> InterceptionModelBuilder<T,I> newBuilderFor(T entity, Class<I> interceptorType)
+ {
+ return new InterceptionModelBuilder<T, I>(entity);
+ }
+
+ public static <T, I> InterceptionModelBuilder<T, I> changeBuilderFor(BuildableInterceptionModel<T,I> interceptionModel)
+ {
+ return new InterceptionModelBuilder(interceptionModel);
+ }
+
+ public T getInterceptedEntity()
+ {
+ return interceptedEntity;
+ }
+
+ public InterceptionModel<T, I> build()
+ {
+ return interceptionModel;
+ }
+
+ public MethodInterceptorDescriptor interceptAll()
+ {
+ return new MethodInterceptorDescriptor(null, InterceptionType.values());
+ }
+
+ public MethodInterceptorDescriptor interceptAroundInvoke(Method m)
+ {
+ return new MethodInterceptorDescriptor(m, InterceptionType.AROUND_INVOKE);
+ }
+
+ public MethodInterceptorDescriptor interceptAroundTimeout(Method m)
+ {
+ return new MethodInterceptorDescriptor(m, InterceptionType.AROUND_TIMEOUT);
+ }
+
+ public MethodInterceptorDescriptor interceptPostConstruct()
+ {
+ return new MethodInterceptorDescriptor(null, POST_CONSTRUCT);
+ }
+
+ public MethodInterceptorDescriptor interceptPreDestroy()
+ {
+ return new MethodInterceptorDescriptor(null, PRE_DESTROY);
+ }
+
+ public MethodInterceptorDescriptor interceptPrePassivate()
+ {
+ return new MethodInterceptorDescriptor(null, PRE_PASSIVATE);
+ }
+
+ public MethodInterceptorDescriptor interceptPostActivate()
+ {
+ return new MethodInterceptorDescriptor(null, POST_ACTIVATE);
+ }
+
+ public void ignoreGlobalInterceptors(Method m)
+ {
+ this.interceptionModel.setIgnoresGlobals(m, true);
+ }
+
+ public final class MethodInterceptorDescriptor
+ {
+ private Method method;
+
+ private InterceptionType[] interceptionTypes;
+
+ public MethodInterceptorDescriptor(Method m, InterceptionType... interceptionType)
+ {
+ this.method = m;
+ this.interceptionTypes = interceptionType;
+ }
+
+ public void with(I... interceptors)
+ {
+ for (InterceptionType interceptionType: interceptionTypes)
+ {
+ InterceptionModelBuilder.this.interceptionModel.appendInterceptors(interceptionType, method, interceptors);
+ }
+ }
+ }
+
+}
Added: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/builder/InterceptionModelImpl.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/builder/InterceptionModelImpl.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/builder/InterceptionModelImpl.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,170 @@
+/*
+ * 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.builder;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.interceptor.proxy.InterceptorException;
+import org.jboss.interceptor.spi.model.InterceptionType;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+class InterceptionModelImpl<T, I> implements BuildableInterceptionModel<T, I>
+{
+
+ private Map<InterceptionType, List<I>> globalInterceptors = new HashMap<InterceptionType, List<I>>();
+
+ private Map<InterceptionType, Map<MethodReference, List<I>>> methodBoundInterceptors = new HashMap<InterceptionType, Map<MethodReference, List<I>>>();
+
+ private Set<MethodReference> methodsIgnoringGlobals = new HashSet<MethodReference>();
+
+ private Set<I> allInterceptors = new LinkedHashSet<I>();
+
+ private T interceptedEntity;
+
+ public InterceptionModelImpl(T interceptedEntity)
+ {
+ this.interceptedEntity = interceptedEntity;
+ }
+
+ public List<I> getInterceptors(InterceptionType interceptionType, Method method)
+ {
+ if (interceptionType.isLifecycleCallback() && method != null)
+ {
+ throw new IllegalArgumentException("On a lifecycle callback, the associated method must be null");
+ }
+
+ if (!interceptionType.isLifecycleCallback() && method == null)
+ {
+ throw new IllegalArgumentException("Around-invoke and around-timeout interceptors are defined for a given method");
+ }
+
+ if (interceptionType.isLifecycleCallback())
+ {
+ if (globalInterceptors.containsKey(interceptionType))
+ {
+ return globalInterceptors.get(interceptionType);
+ }
+ }
+ else
+ {
+ ArrayList<I> returnedInterceptors = new ArrayList<I>();
+ if (!methodsIgnoringGlobals.contains(methodHolder(method)) && globalInterceptors.containsKey(interceptionType))
+ {
+ returnedInterceptors.addAll(globalInterceptors.get(interceptionType));
+ }
+ if (methodBoundInterceptors.containsKey(interceptionType) && methodBoundInterceptors.get(interceptionType).containsKey(methodHolder(method)))
+ {
+ returnedInterceptors.addAll(methodBoundInterceptors.get(interceptionType).get(methodHolder(method)));
+ }
+ return returnedInterceptors;
+ }
+ return Collections.EMPTY_LIST;
+ }
+
+ public Set<I> getAllInterceptors()
+ {
+ return Collections.unmodifiableSet(allInterceptors);
+ }
+
+ public T getInterceptedEntity()
+ {
+ return this.interceptedEntity;
+ }
+
+ public void setIgnoresGlobals(Method method, boolean ignoresGlobals)
+ {
+ if (ignoresGlobals)
+ {
+ methodsIgnoringGlobals.add(methodHolder(method));
+ }
+ else
+ {
+ methodsIgnoringGlobals.remove(methodHolder(method));
+ }
+ }
+
+ public void appendInterceptors(InterceptionType interceptionType, Method method, I... interceptors)
+ {
+ if (null == method)
+ {
+ List<I> interceptorsList = globalInterceptors.get(interceptionType);
+ if (interceptorsList == null)
+ {
+ interceptorsList = new ArrayList<I>();
+ globalInterceptors.put(interceptionType, interceptorsList);
+ }
+ appendInterceptorClassesToList(interceptionType, interceptorsList, interceptors);
+ }
+ else
+ {
+ if (null == methodBoundInterceptors.get(interceptionType))
+ {
+ methodBoundInterceptors.put(interceptionType, new HashMap<MethodReference, List<I>>());
+ }
+ List<I> interceptorsList = methodBoundInterceptors.get(interceptionType).get(methodHolder(method));
+ if (interceptorsList == null)
+ {
+ interceptorsList = new ArrayList<I>();
+ methodBoundInterceptors.get(interceptionType).put(methodHolder(method), interceptorsList);
+ }
+ if (globalInterceptors.containsKey(interceptionType))
+ {
+ validateDuplicateInterceptors(interceptionType, globalInterceptors.get(interceptionType), interceptors);
+ }
+ appendInterceptorClassesToList(interceptionType, interceptorsList, interceptors);
+ }
+ allInterceptors.addAll(Arrays.asList(interceptors));
+ }
+
+ private void appendInterceptorClassesToList(InterceptionType interceptionType, List<I> interceptorsList, I... interceptors)
+ {
+ validateDuplicateInterceptors(interceptionType, interceptorsList, interceptors);
+ interceptorsList.addAll(Arrays.asList(interceptors));
+ }
+
+ private void validateDuplicateInterceptors(InterceptionType interceptionType, List<I> interceptorsList, I[] interceptors)
+ {
+ for (I interceptor : interceptors)
+ {
+ if (interceptorsList.contains(interceptor))
+ {
+ if (interceptionType != null)
+ {
+ throw new InterceptorException("Duplicate interceptor class definition when binding" + interceptor + " on " + interceptionType.name());
+ }
+ }
+ }
+ }
+
+ private static MethodReference methodHolder(Method method)
+ {
+ return MethodReference.of(method, true);
+ }
+
+}
Copied: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/builder/MethodReference.java (from rev 106491, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/MethodHolder.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/builder/MethodReference.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/builder/MethodReference.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,144 @@
+/*
+ * 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.builder;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+
+import org.jboss.interceptor.proxy.InterceptorException;
+import org.jboss.interceptor.spi.metadata.MethodMetadata;
+import org.jboss.interceptor.util.ReflectionUtils;
+
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class MethodReference implements Serializable
+{
+ private String methodName;
+
+ private Class<?>[] parameterTypes;
+
+ private Class<?> declaringClass;
+
+
+ public static MethodReference of(Method method, boolean withDeclaringClass)
+ {
+ return new MethodReference(method, withDeclaringClass);
+ }
+
+ public static MethodReference of(MethodMetadata method, boolean withDeclaringClass)
+ {
+ return new MethodReference(method.getJavaMethod(), withDeclaringClass);
+ }
+
+ private MethodReference(Method method, boolean withDeclaringClass)
+ {
+ this.methodName = method.getName();
+ this.parameterTypes = method.getParameterTypes();
+ if (withDeclaringClass)
+ this.declaringClass = method.getDeclaringClass();
+ }
+
+ private MethodReference(String methodName, Class<?>[] parameterTypes, Class<?> declaringClass)
+ {
+ this.methodName = methodName;
+ this.parameterTypes = parameterTypes;
+ this.declaringClass = declaringClass;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ MethodReference that = (MethodReference) o;
+
+ if (declaringClass != null ? !declaringClass.equals(that.declaringClass) : that.declaringClass != null)
+ return false;
+ if (methodName != null ? !methodName.equals(that.methodName) : that.methodName != null) return false;
+ if (!Arrays.equals(parameterTypes, that.parameterTypes)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = methodName != null ? methodName.hashCode() : 0;
+ result = 31 * result + (parameterTypes != null ? Arrays.hashCode(parameterTypes) : 0);
+ result = 31 * result + (declaringClass != null ? declaringClass.hashCode() : 0);
+ return result;
+ }
+
+ private Object writeReplace()
+ {
+ return new MethodHolderSerializationProxy(this);
+ }
+
+ static class MethodHolderSerializationProxy implements Serializable
+ {
+ private String className;
+ private String methodName;
+ private String parameterClassNames[];
+
+ MethodHolderSerializationProxy(MethodReference methodReference)
+ {
+ className = methodReference.declaringClass != null? methodReference.declaringClass.getName() : null;
+ methodName = methodReference.methodName;
+ if (methodReference.parameterTypes != null)
+ {
+ parameterClassNames = new String[methodReference.parameterTypes.length];
+ int i = 0;
+ for (Class<?> parameterType: methodReference.parameterTypes)
+ {
+ parameterClassNames[i++] = parameterType.getName();
+ }
+ }
+ }
+
+ private Object readResolve()
+ {
+
+ try
+ {
+ Class<?>[] parameterTypes = null;
+ if (parameterClassNames != null)
+ {
+ parameterTypes = new Class<?>[parameterClassNames.length];
+ for (int i = 0; i<parameterClassNames.length; i++)
+ {
+ parameterTypes[i] = ReflectionUtils.classForName(parameterClassNames[i]);
+ }
+ }
+ Class<?> declaringClass = null;
+ if (className != null)
+ {
+ declaringClass = ReflectionUtils.classForName(className);
+ }
+ return new MethodReference(methodName, parameterTypes, declaringClass);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new InterceptorException("Error while deserializing intercepted instance", e);
+ }
+ }
+ }
+}
Copied: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/metadataregistry/InterceptorMetadataRegistry.java (from rev 106491, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/registry/InterceptorMetadataRegistry.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/metadataregistry/InterceptorMetadataRegistry.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/metadataregistry/InterceptorMetadataRegistry.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,18 @@
+package org.jboss.interceptor.metadataregistry;
+
+import org.jboss.interceptor.spi.metadata.ClassMetadata;
+import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
+
+
+/**
+ * Acts as a repository of
+ *
+ * @author Marius Bogoevici
+ */
+public interface InterceptorMetadataRegistry
+{
+ InterceptorMetadata getInterceptorClassMetadata(ClassMetadata interceptorClass);
+
+ InterceptorMetadata getInterceptorClassMetadata(ClassMetadata interceptorClass, boolean isInterceptorTargetClass);
+
+}
Copied: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/metadataregistry/SimpleInterceptorMetadataRegistry.java (from rev 106491, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/registry/SimpleInterceptorMetadataRegistry.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/metadataregistry/SimpleInterceptorMetadataRegistry.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/metadataregistry/SimpleInterceptorMetadataRegistry.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,123 @@
+/*
+ * 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.metadataregistry;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.jboss.interceptor.reader.InterceptorMetadataUtils;
+import org.jboss.interceptor.spi.metadata.ClassMetadata;
+import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
+
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class SimpleInterceptorMetadataRegistry implements InterceptorMetadataRegistry
+{
+ private final Map<Key, InterceptorMetadata> interceptorClassMetadataMap = new ConcurrentHashMap<Key, InterceptorMetadata>();
+
+ private final Lock lock = new ReentrantLock();
+
+ public InterceptorMetadata getInterceptorClassMetadata(ClassMetadata interceptorClass)
+ {
+ return this.getInterceptorClassMetadata(interceptorClass, false);
+ }
+
+ public InterceptorMetadata getInterceptorClassMetadata(ClassMetadata interceptorClass, boolean isInterceptorTargetClass)
+ {
+ Key key = new Key(interceptorClass, isInterceptorTargetClass);
+ if (!interceptorClassMetadataMap.containsKey(key))
+ {
+ try
+ {
+ lock.lock();
+ //verify that metadata hasn't been added while waiting for the lock
+ if (!interceptorClassMetadataMap.containsKey(key))
+ {
+ if (isInterceptorTargetClass)
+ interceptorClassMetadataMap.put(key, InterceptorMetadataUtils.readMetadataForTargetClass(interceptorClass));
+ else
+ interceptorClassMetadataMap.put(key, InterceptorMetadataUtils.readMetadataForInterceptorClass(interceptorClass));
+ }
+ }
+ finally
+ {
+ lock.unlock();
+ }
+ }
+
+ return interceptorClassMetadataMap.get(key);
+
+ }
+
+ public void cleanup()
+ {
+ this.interceptorClassMetadataMap.clear();
+ }
+
+ public static final class Key
+ {
+ private String className;
+
+ private boolean isInterceptorTargetClass;
+
+ private Key(ClassMetadata clazz, boolean interceptorTargetClass)
+ {
+ this.className = clazz.getClassName();
+ isInterceptorTargetClass = interceptorTargetClass;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ Key key = (Key) o;
+
+ if (isInterceptorTargetClass != key.isInterceptorTargetClass)
+ {
+ return false;
+ }
+ if (className != null ? !className.equals(key.className) : key.className != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = className != null ? className.hashCode() : 0;
+ result = 31 * result + (isInterceptorTargetClass ? 1 : 0);
+ return result;
+ }
+ }
+
+}
Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/AbstractClassInterceptionHandler.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/AbstractClassInterceptionHandler.java 2010-07-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/AbstractClassInterceptionHandler.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -17,22 +17,22 @@
package org.jboss.interceptor.proxy;
-import java.lang.reflect.Method;
+import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.Iterator;
-import java.util.Queue;
import java.util.List;
import java.util.Map;
+import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
-import java.io.Serializable;
import javax.interceptor.InvocationContext;
-import org.jboss.interceptor.model.metadata.InterceptorMetadata;
-import org.jboss.interceptor.model.metadata.reader.MethodMetadataProvider;
+import org.jboss.interceptor.spi.handler.InterceptionHandler;
+import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
+import org.jboss.interceptor.spi.metadata.MethodMetadata;
+import org.jboss.interceptor.spi.model.InterceptionType;
import org.jboss.interceptor.util.ReflectionUtils;
-import org.jboss.interceptor.InterceptorException;
-import org.jboss.interceptor.model.InterceptionType;
/**
* @author Marius Bogoevici
@@ -49,9 +49,9 @@
}
- public Object invoke(Object target, InterceptionType interceptionType, InvocationContext invocationContext) throws Exception
+ public Object intercept(Object target, InterceptionType interceptionType, InvocationContext invocationContext) throws Exception
{
- List<MethodMetadataProvider> methods = interceptorMetadata.getInterceptorMethods(interceptionType);
+ List<MethodMetadata> methods = interceptorMetadata.getInterceptorMethods(interceptionType);
if (methods != null)
{
DelegatingInvocationContext delegatingInvocationContext = new DelegatingInvocationContext(invocationContext, getInterceptorInstance(), methods, interceptionType);
@@ -63,11 +63,6 @@
}
}
- public InterceptorMetadata getInterceptorMetadata()
- {
- return interceptorMetadata;
- }
-
public class DelegatingInvocationContext implements InvocationContext
{
@@ -76,14 +71,14 @@
private Object targetObject;
private InterceptionType interceptionType;
- private Queue<MethodMetadataProvider> invocationQueue;
+ private Queue<MethodMetadata> invocationQueue;
- public DelegatingInvocationContext(InvocationContext delegateInvocationContext, Object targetObject, List<MethodMetadataProvider> methods, InterceptionType interceptionType)
+ public DelegatingInvocationContext(InvocationContext delegateInvocationContext, Object targetObject, List<MethodMetadata> methods, InterceptionType interceptionType)
{
this.delegateInvocationContext = delegateInvocationContext;
this.targetObject = targetObject;
this.interceptionType = interceptionType;
- this.invocationQueue = new ConcurrentLinkedQueue<MethodMetadataProvider>(methods);
+ this.invocationQueue = new ConcurrentLinkedQueue<MethodMetadata>(methods);
}
public Map<String, Object> getContextData()
@@ -114,10 +109,10 @@
{
if (AbstractClassInterceptionHandler.this.interceptorMetadata.isTargetClass() && interceptionType.isLifecycleCallback())
{
- Iterator<MethodMetadataProvider> methodIterator = invocationQueue.iterator();
+ Iterator<MethodMetadata> methodIterator = invocationQueue.iterator();
while (methodIterator.hasNext())
{
- MethodMetadataProvider interceptorMethod = methodIterator.next();
+ MethodMetadata interceptorMethod = methodIterator.next();
ReflectionUtils.ensureAccessible(interceptorMethod.getJavaMethod());
// interceptor methods defined on
interceptorMethod.getJavaMethod().invoke(targetObject);
@@ -126,7 +121,7 @@
}
else
{
- MethodMetadataProvider interceptorMethod = invocationQueue.remove();
+ MethodMetadata interceptorMethod = invocationQueue.remove();
ReflectionUtils.ensureAccessible(interceptorMethod.getJavaMethod());
if (interceptorMethod.getJavaMethod().getParameterTypes().length == 0)
{
Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandler.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandler.java 2010-07-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandler.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -17,9 +17,9 @@
package org.jboss.interceptor.proxy;
-import org.jboss.interceptor.model.metadata.InterceptorMetadata;
-import org.jboss.interceptor.InterceptorException;
+import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
+
/**
* @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
*/
@@ -42,7 +42,8 @@
try
{
this.interceptorInstance = simpleInterceptorClass.newInstance();
- } catch (Exception e)
+ }
+ catch (Exception e)
{
throw new InterceptorException("Cannot create interceptor instance:", e);
}
Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandlerFactory.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandlerFactory.java 2010-07-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandlerFactory.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -17,8 +17,10 @@
package org.jboss.interceptor.proxy;
-import org.jboss.interceptor.model.metadata.reader.ReflectiveClassMetadataProvider;
-import org.jboss.interceptor.model.metadata.registry.InterceptorMetadataRegistry;
+import org.jboss.interceptor.metadataregistry.InterceptorMetadataRegistry;
+import org.jboss.interceptor.reader.ReflectiveClassMetadata;
+import org.jboss.interceptor.spi.handler.InterceptionHandler;
+import org.jboss.interceptor.spi.handler.InterceptionHandlerFactory;
/**
* @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
@@ -34,6 +36,6 @@
public InterceptionHandler createFor(Class<?> clazz)
{
- return new DirectClassInterceptionHandler(clazz, interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadataProvider.of(clazz)));
+ return new DirectClassInterceptionHandler(clazz, interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadata.of(clazz)));
}
}
Modified: 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-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionChain.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -17,13 +17,14 @@
package org.jboss.interceptor.proxy;
-import javax.interceptor.InvocationContext;
-
-import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.List;
-import org.jboss.interceptor.model.InterceptionType;
+import javax.interceptor.InvocationContext;
+
+import org.jboss.interceptor.spi.handler.InterceptionHandler;
+import org.jboss.interceptor.spi.model.InterceptionType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,20 +38,18 @@
private Object target;
- private Object[] parameters;
-
private Method targetMethod;
private int currentPosition;
private List<InterceptionHandler> interceptorHandlers;
+
private final InterceptionType interceptionType;
- public InterceptionChain(List<InterceptionHandler> interceptorHandlers, InterceptionType interceptionType, Object target, Method targetMethod, Object[] parameters)
+ public InterceptionChain(List<InterceptionHandler> interceptorHandlers, InterceptionType interceptionType, Object target, Method targetMethod)
{
this.interceptorHandlers = interceptorHandlers;
this.interceptionType = interceptionType;
- this.parameters = parameters;
this.target = target;
this.targetMethod = targetMethod;
this.currentPosition = 0;
@@ -66,7 +65,7 @@
{
log.trace("Invoking next interceptor in chain:" + nextInterceptorHandler.getClass().getName());
}
- return nextInterceptorHandler.invoke(target, interceptionType, invocationContext);
+ return nextInterceptorHandler.intercept(target, interceptionType, invocationContext);
}
else
{
Deleted: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionHandler.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionHandler.java 2010-07-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionHandler.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -1,31 +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 javax.interceptor.InvocationContext;
-
-/**
- * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
- */
-public interface InterceptionHandler
-{
- public Object invoke(Object target, InterceptionType interceptionType, InvocationContext invocationContext) throws Exception;
-}
-
Deleted: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionHandlerFactory.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionHandlerFactory.java 2010-07-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionHandlerFactory.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -1,26 +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 interface InterceptionHandlerFactory<I> {
-
- InterceptionHandler createFor(I clazz);
-}
Copied: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorException.java (from rev 106491, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/InterceptorException.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorException.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorException.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,44 @@
+/*
+ * 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>
+ */
+ at SuppressWarnings("serial")
+public class InterceptorException extends RuntimeException
+{
+ public InterceptorException()
+ {
+ }
+
+ public InterceptorException(String s)
+ {
+ super(s);
+ }
+
+ public InterceptorException(String s, Throwable throwable)
+ {
+ super(s, throwable);
+ }
+
+ public InterceptorException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
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-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorInvocationContext.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -17,17 +17,16 @@
package org.jboss.interceptor.proxy;
-import org.jboss.interceptor.InterceptorException;
-import javax.interceptor.InvocationContext;
-
+import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.HashMap;
-import java.lang.reflect.Method;
+import javax.interceptor.InvocationContext;
+
/**
* @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
*/
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-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -1,21 +1,23 @@
package org.jboss.interceptor.proxy;
-import java.io.Serializable;
-import java.io.ObjectOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
-import java.util.Map;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
-import java.util.ArrayList;
-import java.lang.reflect.Method;
+import java.util.Map;
-import org.jboss.interceptor.model.metadata.InterceptorMetadata;
-import org.jboss.interceptor.model.InterceptionModel;
-import org.jboss.interceptor.model.InterceptionType;
-import org.jboss.interceptor.model.InterceptionTypeRegistry;
-import org.jboss.interceptor.util.ReflectionUtils;
+import org.jboss.interceptor.util.InterceptionTypeRegistry;
+import org.jboss.interceptor.spi.handler.InterceptionHandler;
+import org.jboss.interceptor.spi.handler.InterceptionHandlerFactory;
+import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
+import org.jboss.interceptor.spi.model.InterceptionModel;
+import org.jboss.interceptor.spi.model.InterceptionType;
import org.jboss.interceptor.util.InterceptionUtils;
+import org.jboss.interceptor.util.ReflectionUtils;
import org.jboss.interceptor.util.proxy.TargetInstanceProxyMethodHandler;
/**
@@ -26,34 +28,26 @@
private Map<Object, InterceptionHandler> interceptorHandlerInstances = new HashMap<Object, InterceptionHandler>();
private InterceptorMetadata targetClassInterceptorMetadata;
- private List<InterceptionModel<Class<?>, ?>> interceptionModels;
+ private InterceptionModel<Class<?>, ?> interceptionModel;
- public InterceptorMethodHandler(Object target, Class<?> targetClass, List<InterceptionModel<Class<?>, ?>> interceptionModels, List<InterceptionHandlerFactory<?>> interceptionHandlerFactories, InterceptorMetadata targetClassMetadata)
+ public InterceptorMethodHandler(Object target, Class<?> targetClass, InterceptionModel<Class<?>, ?> interceptionModel, InterceptionHandlerFactory<?> interceptionHandlerFactory, InterceptorMetadata targetClassMetadata)
{
super(target, targetClass != null ? targetClass : target.getClass());
- if (interceptionModels == null)
+ if (interceptionModel == null)
{
throw new IllegalArgumentException("Interception model must not be null");
}
-
- if (interceptionHandlerFactories == null)
+ if (interceptionHandlerFactory == null)
{
throw new IllegalArgumentException("Interception handler factory must not be null");
}
- if (interceptionModels.size() != interceptionHandlerFactories.size())
- {
- throw new IllegalArgumentException("For each interception model, an interception factory must be provided");
- }
- this.interceptionModels = interceptionModels;
+ this.interceptionModel = interceptionModel;
- for (int i = 0; i < interceptionModels.size(); i++)
+ for (Object interceptorReference : this.interceptionModel.getAllInterceptors())
{
- for (Object interceptorReference : this.interceptionModels.get(i).getAllInterceptors())
- {
- interceptorHandlerInstances.put(interceptorReference, ((InterceptionHandlerFactory) interceptionHandlerFactories.get(i)).createFor((Object) interceptorReference));
- }
+ interceptorHandlerInstances.put(interceptorReference, ((InterceptionHandlerFactory) interceptionHandlerFactory).createFor(interceptorReference));
}
targetClassInterceptorMetadata = targetClassMetadata;
}
@@ -95,21 +89,18 @@
{
List<InterceptionHandler> interceptionHandlers = new ArrayList<InterceptionHandler>();
- for (InterceptionModel interceptionModel : interceptionModels)
- {
List<?> interceptorList = interceptionModel.getInterceptors(interceptionType, thisMethod);
for (Object interceptorReference : interceptorList)
{
interceptionHandlers.add(interceptorHandlerInstances.get(interceptorReference));
}
- }
if (targetClassInterceptorMetadata != null && targetClassInterceptorMetadata.getInterceptorMethods(interceptionType) != null && !targetClassInterceptorMetadata.getInterceptorMethods(interceptionType).isEmpty())
{
interceptionHandlers.add(new DirectClassInterceptionHandler<Class<?>>(getTargetInstance(), targetClassInterceptorMetadata));
}
- InterceptionChain chain = new InterceptionChain(interceptionHandlers, interceptionType, getTargetInstance(), thisMethod, args);
+ InterceptionChain chain = new InterceptionChain(interceptionHandlers, interceptionType, getTargetInstance(), thisMethod);
return chain.invokeNext(new InterceptorInvocationContext(chain, getTargetInstance(), thisMethod, args));
}
Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreator.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreator.java 2010-07-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreator.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -18,7 +18,7 @@
package org.jboss.interceptor.proxy;
import javassist.util.proxy.MethodHandler;
-import org.jboss.interceptor.model.metadata.InterceptorMetadata;
+import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
/**
* @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
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-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreatorImpl.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -18,18 +18,14 @@
package org.jboss.interceptor.proxy;
import java.lang.reflect.Constructor;
-import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
import javassist.util.proxy.MethodHandler;
import javassist.util.proxy.ProxyObject;
-import org.jboss.interceptor.InterceptorException;
import org.jboss.interceptor.proxy.javassist.CompositeHandler;
-import org.jboss.interceptor.model.InterceptionModel;
-import org.jboss.interceptor.model.registry.InterceptionModelRegistry;
-import org.jboss.interceptor.model.metadata.InterceptorMetadata;
+import org.jboss.interceptor.spi.handler.InterceptionHandlerFactory;
+import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
+import org.jboss.interceptor.spi.model.InterceptionModel;
import org.jboss.interceptor.util.InterceptionUtils;
import sun.reflect.ReflectionFactory;
@@ -39,23 +35,17 @@
public class InterceptorProxyCreatorImpl implements InterceptorProxyCreator
{
- private List<InterceptionModelRegistry<Class<?>, ?>> interceptionModelRegistries;
+ private InterceptionModel<Class<?>,?> interceptionModel;
- private List<InterceptionHandlerFactory<?>> interceptionHandlerFactories;
+ private InterceptionHandlerFactory<?> interceptionHandlerFactory;
- public InterceptorProxyCreatorImpl(List<InterceptionModelRegistry<Class<?>, ?>> interceptionModelRegistries, List<InterceptionHandlerFactory<?>> interceptionHandlerFactories)
+ public InterceptorProxyCreatorImpl(InterceptionHandlerFactory<?> interceptionHandlerFactory, InterceptionModel<Class<?>, ?> interceptionModel)
{
- this.interceptionModelRegistries = interceptionModelRegistries;
- this.interceptionHandlerFactories = interceptionHandlerFactories;
+ this.interceptionHandlerFactory = interceptionHandlerFactory;
+ this.interceptionModel = interceptionModel;
}
- public InterceptorProxyCreatorImpl(InterceptionModelRegistry<Class<?>, ?> interceptionModelRegistries, InterceptionHandlerFactory<?> interceptionHandlerFactories)
- {
- this.interceptionModelRegistries = Collections.<InterceptionModelRegistry<Class<?>, ?>>singletonList(interceptionModelRegistries);
- this.interceptionHandlerFactories = Collections.<InterceptionHandlerFactory<?>>singletonList(interceptionHandlerFactories);
- }
-
public <T> T createProxyFromInstance(final Object target, Class<T> proxifiedClass, Class<?>[] constructorTypes, Object[] constructorArguments, InterceptorMetadata interceptorClassMetadata)
{
MethodHandler interceptorMethodHandler = createMethodHandler(target, proxifiedClass, interceptorClassMetadata);
@@ -120,24 +110,15 @@
public <T> MethodHandler createMethodHandler(Object target, Class<T> proxyClass, InterceptorMetadata interceptorMetadata)
{
- return new InterceptorMethodHandler(target, proxyClass, getModelsFor(proxyClass), interceptionHandlerFactories, interceptorMetadata);
+ return new InterceptorMethodHandler(target, proxyClass, interceptionModel, interceptionHandlerFactory, interceptorMetadata);
}
public <T> MethodHandler createSubclassingMethodHandler(Object targetInstance, Class<T> proxyClass, InterceptorMetadata interceptorMetadata)
{
- return new SubclassingInterceptorMethodHandler(targetInstance, getModelsFor(proxyClass), interceptionHandlerFactories, interceptorMetadata);
+ return new SubclassingInterceptorMethodHandler(targetInstance, interceptionModel, interceptionHandlerFactory, interceptorMetadata);
}
- private <T> List<InterceptionModel<Class<?>, ?>> getModelsFor(Class<T> proxyClass)
- {
- List<InterceptionModel<Class<?>, ?>> interceptionModels = new ArrayList<InterceptionModel<Class<?>, ?>>();
- for (InterceptionModelRegistry interceptionModelRegistry : interceptionModelRegistries)
- {
- interceptionModels.add(interceptionModelRegistry.getInterceptionModel(proxyClass));
- }
- return interceptionModels;
- }
private <T> Constructor<T> getNoArgConstructor(Class<T> clazz)
{
Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/SubclassingInterceptorMethodHandler.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/SubclassingInterceptorMethodHandler.java 2010-07-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/SubclassingInterceptorMethodHandler.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -12,10 +12,12 @@
import javassist.util.proxy.MethodHandler;
import javassist.util.proxy.ProxyObject;
-import org.jboss.interceptor.model.InterceptionModel;
-import org.jboss.interceptor.model.InterceptionType;
-import org.jboss.interceptor.model.InterceptionTypeRegistry;
-import org.jboss.interceptor.model.metadata.InterceptorMetadata;
+import org.jboss.interceptor.util.InterceptionTypeRegistry;
+import org.jboss.interceptor.spi.handler.InterceptionHandler;
+import org.jboss.interceptor.spi.handler.InterceptionHandlerFactory;
+import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
+import org.jboss.interceptor.spi.model.InterceptionModel;
+import org.jboss.interceptor.spi.model.InterceptionType;
import org.jboss.interceptor.util.InterceptionUtils;
import org.jboss.interceptor.util.ReflectionUtils;
@@ -27,7 +29,7 @@
private Map<Object, InterceptionHandler> interceptorHandlerInstances = new HashMap<Object, InterceptionHandler>();
private InterceptorMetadata targetClassInterceptorMetadata;
- private List<InterceptionModel<Class<?>, ?>> interceptionModels;
+ private InterceptionModel<Class<?>, ?> interceptionModel;
private Object targetInstance;
private static MethodHandler DEFAULT_METHOD_HANDLER = new MethodHandler() {
@@ -40,10 +42,10 @@
}
};
- public SubclassingInterceptorMethodHandler(Object targetInstance, List<InterceptionModel<Class<?>, ?>> interceptionModels, List<InterceptionHandlerFactory<?>> interceptionHandlerFactories, InterceptorMetadata targetClassMetadata)
+ public SubclassingInterceptorMethodHandler(Object targetInstance, InterceptionModel<Class<?>, ?> interceptionModel, InterceptionHandlerFactory<?> interceptionHandlerFactories, InterceptorMetadata targetClassMetadata)
{
this.targetInstance = targetInstance;
- if (interceptionModels == null)
+ if (interceptionModel == null)
{
throw new IllegalArgumentException("Interception model must not be null");
}
@@ -53,19 +55,11 @@
throw new IllegalArgumentException("Interception handler factory must not be null");
}
- if (interceptionModels.size() != interceptionHandlerFactories.size())
- {
- throw new IllegalArgumentException("For each interception model, an interception factory must be provided");
- }
+ this.interceptionModel = interceptionModel;
- this.interceptionModels = interceptionModels;
-
- for (int i = 0; i < interceptionModels.size(); i++)
+ for (Object interceptorReference : this.interceptionModel.getAllInterceptors())
{
- for (Object interceptorReference : this.interceptionModels.get(i).getAllInterceptors())
- {
- interceptorHandlerInstances.put(interceptorReference, ((InterceptionHandlerFactory) interceptionHandlerFactories.get(i)).createFor((Object) interceptorReference));
- }
+ interceptorHandlerInstances.put(interceptorReference, ((InterceptionHandlerFactory) interceptionHandlerFactories).createFor(interceptorReference));
}
targetClassInterceptorMetadata = targetClassMetadata;
}
@@ -106,21 +100,17 @@
private Object executeInterception(Object self, Method proceedingMethod, Method thisMethod, Object[] args, InterceptionType interceptionType) throws Throwable
{
List<InterceptionHandler> interceptionHandlers = new ArrayList<InterceptionHandler>();
- for (InterceptionModel interceptionModel : interceptionModels)
+ List<?> interceptorList = interceptionModel.getInterceptors(interceptionType, thisMethod);
+ for (Object interceptorReference : interceptorList)
{
- List<?> interceptorList = interceptionModel.getInterceptors(interceptionType, thisMethod);
- for (Object interceptorReference : interceptorList)
- {
- interceptionHandlers.add(interceptorHandlerInstances.get(interceptorReference));
- }
+ interceptionHandlers.add(interceptorHandlerInstances.get(interceptorReference));
}
-
if (targetClassInterceptorMetadata != null && targetClassInterceptorMetadata.getInterceptorMethods(interceptionType) != null && !targetClassInterceptorMetadata.getInterceptorMethods(interceptionType).isEmpty())
{
interceptionHandlers.add(new DirectClassInterceptionHandler<Class<?>>(self, targetClassInterceptorMetadata));
}
- InterceptionChain chain = new InterceptionChain(interceptionHandlers, interceptionType,self, proceedingMethod, args);
+ InterceptionChain chain = new InterceptionChain(interceptionHandlers, interceptionType, self, proceedingMethod);
return chain.invokeNext(new InterceptorInvocationContext(chain, self, thisMethod, args));
}
Added: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/InterceptorMetadataUtils.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/InterceptorMetadataUtils.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/InterceptorMetadataUtils.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,176 @@
+package org.jboss.interceptor.reader;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.interceptor.InvocationContext;
+
+import org.jboss.interceptor.builder.MethodReference;
+import org.jboss.interceptor.spi.metadata.ClassMetadata;
+import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
+import org.jboss.interceptor.spi.metadata.MethodMetadata;
+import org.jboss.interceptor.spi.model.InterceptionType;
+import org.jboss.interceptor.util.InterceptionTypeRegistry;
+import org.jboss.interceptor.util.InterceptorMetadataException;
+import org.jboss.interceptor.util.ReflectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class InterceptorMetadataUtils
+{
+
+ private static final Logger LOG = LoggerFactory.getLogger(InterceptorMetadataUtils.class);
+
+ public static InterceptorMetadata readMetadataForInterceptorClass(ClassMetadata classMetadata)
+ {
+ return new SimpleInterceptorMetadata(classMetadata, false, buildMethodMap(classMetadata, false));
+ }
+
+ public static InterceptorMetadata readMetadataForTargetClass(ClassMetadata classMetadata)
+ {
+ return new SimpleInterceptorMetadata(classMetadata, true, buildMethodMap(classMetadata, true));
+ }
+
+ public static boolean isInterceptorMethod(InterceptionType interceptionType, MethodMetadata method, boolean forTargetClass)
+ {
+
+ if (method.getAnnotation(InterceptionTypeRegistry.getAnnotationClass(interceptionType)) == null)
+ {
+ return false;
+ }
+
+ if (interceptionType.isLifecycleCallback())
+ {
+ if (!Void.TYPE.equals(method.getReturnType().getJavaClass()))
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not have a void return type");
+ }
+ return false;
+ }
+
+ Class<?>[] parameterTypes = method.getJavaMethod().getParameterTypes();
+
+ if (forTargetClass && parameterTypes.length != 0)
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "is defined on the target class and does not have 0 arguments");
+ }
+ return false;
+ }
+
+ if (!forTargetClass && parameterTypes.length != 1)
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not have exactly one parameter");
+ }
+ return false;
+ }
+
+ if (parameterTypes.length == 1 && !InvocationContext.class.equals(parameterTypes[0]))
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "its single argument is not a " + InvocationContext.class.getName());
+ }
+ return false;
+ }
+
+ return true;
+ }
+ else
+ {
+ if (!Object.class.equals(method.getReturnType().getJavaClass()))
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not return a " + Object.class.getName());
+ }
+ return false;
+ }
+
+ Class<?>[] parameterTypes = method.getJavaMethod().getParameterTypes();
+
+ if (parameterTypes.length != 1)
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not have exactly 1 parameter");
+ }
+ return false;
+ }
+
+ if (!InvocationContext.class.equals(parameterTypes[0]))
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not have a " + InvocationContext.class.getName() + " parameter ");
+ }
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ static String getStandardIgnoredMessage(InterceptionType interceptionType, Method method)
+ {
+ return "Method " + method.getName() + " defined on class " + method.getDeclaringClass().getName()
+ + " will not be used for interception, since it is not defined according to the specification. It is annotated with @"
+ + interceptionType.annotationClassName() + ", but ";
+ }
+
+ static Map<InterceptionType, List<MethodMetadata>> buildMethodMap(ClassMetadata interceptorClass, boolean forTargetClass)
+ {
+ Map<InterceptionType, List<MethodMetadata>> methodMap = new HashMap<InterceptionType, List<MethodMetadata>>();
+ ClassMetadata currentClass = interceptorClass;
+ Set<MethodReference> foundMethods = new HashSet<MethodReference>();
+ do
+ {
+ Set<InterceptionType> detectedInterceptorTypes = new HashSet<InterceptionType>();
+
+ for (MethodMetadata method : currentClass.getDeclaredMethods())
+ {
+ for (InterceptionType interceptionType : InterceptionTypeRegistry.getSupportedInterceptionTypes())
+ {
+ if (isInterceptorMethod(interceptionType, method, forTargetClass))
+ {
+ if (methodMap.get(interceptionType) == null)
+ {
+ methodMap.put(interceptionType, new LinkedList<MethodMetadata>());
+ }
+ if (detectedInterceptorTypes.contains(interceptionType))
+ {
+ throw new InterceptorMetadataException("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.getJavaMethod());
+ if (!foundMethods.contains(MethodReference.of(method, false)))
+ {
+ methodMap.get(interceptionType).add(0, method);
+ }
+ }
+ }
+ foundMethods.add(MethodReference.of(method, false));
+ }
+ currentClass = currentClass.getSuperclass();
+ }
+ while (!Object.class.equals(currentClass.getJavaClass()));
+ return methodMap;
+ }
+}
Copied: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/ReflectiveClassMetadata.java (from rev 106491, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/reader/ReflectiveClassMetadataProvider.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/ReflectiveClassMetadata.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/ReflectiveClassMetadata.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,81 @@
+/*
+ * 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.reader;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.Iterator;
+
+import org.jboss.interceptor.spi.metadata.ClassMetadata;
+import org.jboss.interceptor.spi.metadata.MethodMetadata;
+import org.jboss.interceptor.util.ArrayIterator;
+import org.jboss.interceptor.util.ImmutableIteratorWrapper;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class ReflectiveClassMetadata implements ClassMetadata, Serializable
+{
+
+ private Class<?> clazz;
+
+ private ReflectiveClassMetadata(Class<?> clazz)
+ {
+ this.clazz = clazz;
+ }
+
+ public static ClassMetadata of(Class<?> clazz)
+ {
+ return new ReflectiveClassMetadata(clazz);
+ }
+
+ public String getClassName()
+ {
+ return clazz.getName();
+ }
+
+ public Iterable<MethodMetadata> getDeclaredMethods()
+ {
+ return new Iterable<MethodMetadata>()
+ {
+ public Iterator<MethodMetadata> iterator()
+ {
+ return new ImmutableIteratorWrapper<Method>(new ArrayIterator(ReflectiveClassMetadata.this.clazz.getDeclaredMethods()))
+ {
+ @Override
+ protected MethodMetadata wrapObject(Method method)
+ {
+ return ReflectiveMethodMetadata.of(method);
+ }
+ };
+ }
+ };
+ }
+
+ public Class<?> getJavaClass()
+ {
+ return clazz;
+ }
+
+ public ClassMetadata getSuperclass()
+ {
+ Class<?> superClass = clazz.getSuperclass();
+ return superClass == null? null : new ReflectiveClassMetadata(superClass);
+ }
+
+}
Copied: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/ReflectiveMethodMetadata.java (from rev 106491, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/reader/ReflectiveMethodMetadataProvider.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/ReflectiveMethodMetadata.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/ReflectiveMethodMetadata.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,59 @@
+/*
+ * 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.reader;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+import org.jboss.interceptor.spi.metadata.ClassMetadata;
+import org.jboss.interceptor.spi.metadata.MethodMetadata;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class ReflectiveMethodMetadata implements MethodMetadata, Serializable
+{
+ private Method javaMethod;
+
+ private ReflectiveMethodMetadata(Method method)
+ {
+ this.javaMethod = method;
+ }
+
+ public static MethodMetadata of(Method method)
+ {
+ return new ReflectiveMethodMetadata(method);
+ }
+
+ public Annotation getAnnotation(Class<? extends Annotation> annotationClass)
+ {
+ return javaMethod.getAnnotation(annotationClass);
+ }
+
+ public Method getJavaMethod()
+ {
+ return javaMethod;
+ }
+
+ public ClassMetadata getReturnType()
+ {
+ return ReflectiveClassMetadata.of(javaMethod.getReturnType());
+ }
+
+}
Copied: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/SimpleInterceptorMetadata.java (from rev 106491, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/AbstractInterceptorMetadata.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/SimpleInterceptorMetadata.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/SimpleInterceptorMetadata.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,97 @@
+/*
+ * 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.reader;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.interceptor.spi.metadata.ClassMetadata;
+import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
+import org.jboss.interceptor.spi.metadata.MethodMetadata;
+import org.jboss.interceptor.spi.model.InterceptionType;
+
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class SimpleInterceptorMetadata implements InterceptorMetadata, Serializable
+{
+
+ private ClassMetadata interceptorClass;
+
+ private Map<InterceptionType, List<MethodMetadata>> interceptorMethodMap;
+
+ private boolean targetClass;
+
+ public SimpleInterceptorMetadata(ClassMetadata interceptorClass, boolean targetClass, Map<InterceptionType, List<MethodMetadata>> interceptorMethodMap)
+ {
+ this.interceptorClass = interceptorClass;
+ this.targetClass = targetClass;
+ this.interceptorMethodMap = interceptorMethodMap;
+ }
+
+ public ClassMetadata getInterceptorClass()
+ {
+ return interceptorClass;
+ }
+
+ public List<MethodMetadata> getInterceptorMethods(InterceptionType interceptionType)
+ {
+ if (interceptorMethodMap != null)
+ {
+ List<MethodMetadata> methods = interceptorMethodMap.get(interceptionType);
+ return methods == null ? Collections.<MethodMetadata>emptyList() : methods;
+ }
+ else
+ {
+ return Collections.<MethodMetadata>emptyList();
+ }
+ }
+
+ public boolean isTargetClass()
+ {
+ return targetClass;
+ }
+
+ private Object writeReplace()
+ {
+ return new MetadataSerializationProxy(interceptorClass, targetClass);
+ }
+
+ private static class MetadataSerializationProxy implements Serializable
+ {
+
+ private ClassMetadata classMetadata;
+ private boolean targetClass;
+
+ MetadataSerializationProxy(ClassMetadata classMetadata, boolean targetClass)
+ {
+ this.classMetadata = classMetadata;
+ this.targetClass = targetClass;
+ }
+
+ public Object readResolve()
+ {
+ return targetClass?
+ InterceptorMetadataUtils.readMetadataForTargetClass(classMetadata):
+ InterceptorMetadataUtils.readMetadataForInterceptorClass(classMetadata);
+ }
+ }
+}
Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/ImmutableIteratorWrapper.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/ImmutableIteratorWrapper.java 2010-07-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/ImmutableIteratorWrapper.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -19,12 +19,12 @@
import java.util.Iterator;
-import org.jboss.interceptor.model.metadata.reader.MethodMetadataProvider;
+import org.jboss.interceptor.spi.metadata.MethodMetadata;
/**
* @author Marius Bogoevici
*/
-public abstract class ImmutableIteratorWrapper<T> implements Iterator<MethodMetadataProvider>
+public abstract class ImmutableIteratorWrapper<T> implements Iterator<MethodMetadata>
{
private Iterator<T> originalIterator;
@@ -40,12 +40,12 @@
return originalIterator.hasNext();
}
- public MethodMetadataProvider next()
+ public MethodMetadata next()
{
return wrapObject(originalIterator.next());
}
- protected abstract MethodMetadataProvider wrapObject(T t);
+ protected abstract MethodMetadata wrapObject(T t);
public void remove()
{
Copied: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionTypeRegistry.java (from rev 106491, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptionTypeRegistry.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionTypeRegistry.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionTypeRegistry.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,70 @@
+/*
+ * 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.annotation.Annotation;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+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 final class InterceptionTypeRegistry
+{
+
+ private static final Logger LOG = LoggerFactory.getLogger(InterceptionTypeRegistry.class);
+ private static Map<InterceptionType, Class<? extends Annotation>> interceptionAnnotationClasses;
+
+ static
+ {
+ interceptionAnnotationClasses = new HashMap<InterceptionType, Class<? extends Annotation>>();
+
+ for (InterceptionType interceptionType: InterceptionType.values())
+ {
+ try
+ {
+ interceptionAnnotationClasses.put(interceptionType, (Class<? extends Annotation>) ReflectionUtils.classForName(interceptionType.annotationClassName()));
+ } catch (Exception e)
+ {
+ LOG.warn("Class '" + interceptionType.annotationClassName() + "' not found, interception based on it is not enabled" );
+ }
+ }
+
+ }
+
+ public static Collection<InterceptionType> getSupportedInterceptionTypes()
+ {
+ return interceptionAnnotationClasses.keySet();
+ }
+
+ public static boolean isSupported(InterceptionType interceptionType)
+ {
+ return interceptionAnnotationClasses.containsKey(interceptionType);
+ }
+
+ public static Class<? extends Annotation> getAnnotationClass(InterceptionType interceptionType)
+ {
+ return interceptionAnnotationClasses.get(interceptionType);
+ }
+}
Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java 2010-07-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -20,26 +20,13 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
import java.util.concurrent.Callable;
-import javax.interceptor.InvocationContext;
-
import javassist.util.proxy.MethodHandler;
import javassist.util.proxy.ProxyFactory;
-import org.jboss.interceptor.InterceptorException;
-import org.jboss.interceptor.model.InterceptionType;
-import org.jboss.interceptor.model.InterceptionTypeRegistry;
-import org.jboss.interceptor.model.MethodHolder;
-import org.jboss.interceptor.model.metadata.InterceptorMetadataException;
-import org.jboss.interceptor.model.metadata.reader.ClassMetadataProvider;
-import org.jboss.interceptor.model.metadata.reader.MethodMetadataProvider;
+import org.jboss.interceptor.proxy.InterceptorException;
import org.jboss.interceptor.proxy.LifecycleMixin;
+import org.jboss.interceptor.spi.model.InterceptionType;
import org.jboss.interceptor.util.proxy.TargetInstanceProxy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,7 +36,6 @@
*/
public class InterceptionUtils
{
- private static final Logger LOG = LoggerFactory.getLogger(InterceptionUtils.class);
public static final String POST_CONSTRUCT = "lifecycle_mixin_$$_postConstruct";
public static final String PRE_DESTROY = "lifecycle_mixin_$$_preDestroy";
@@ -144,104 +130,6 @@
return true;
}
- /**
- * @param interceptionType
- * @param method
- * @param forTargetClass
- * @return
- */
- public static boolean isInterceptorMethod(InterceptionType interceptionType, MethodMetadataProvider method, boolean forTargetClass)
- {
-
- if (method.getAnnotation(InterceptionTypeRegistry.getAnnotationClass(interceptionType)) == null)
- {
- return false;
- }
-
- if (interceptionType.isLifecycleCallback())
- {
- if (!Void.TYPE.equals(method.getReturnType().getJavaClass()))
- {
- if (LOG.isDebugEnabled())
- {
- LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not have a void return type");
- }
- return false;
- }
-
- Class<?>[] parameterTypes = method.getJavaMethod().getParameterTypes();
-
- if (forTargetClass && parameterTypes.length != 0)
- {
- if (LOG.isDebugEnabled())
- {
- LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "is defined on the target class and does not have 0 arguments");
- }
- return false;
- }
-
- if (!forTargetClass && parameterTypes.length != 1)
- {
- if (LOG.isDebugEnabled())
- {
- LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not have exactly one parameter");
- }
- return false;
- }
-
- if (parameterTypes.length == 1 && !InvocationContext.class.equals(parameterTypes[0]))
- {
- if (LOG.isDebugEnabled())
- {
- LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "its single argument is not a " + InvocationContext.class.getName());
- }
- return false;
- }
-
- return true;
- }
- else
- {
- if (!Object.class.equals(method.getReturnType().getJavaClass()))
- {
- if (LOG.isDebugEnabled())
- {
- LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not return a " + Object.class.getName());
- }
- return false;
- }
-
- Class<?>[] parameterTypes = method.getJavaMethod().getParameterTypes();
-
- if (parameterTypes.length != 1)
- {
- if (LOG.isDebugEnabled())
- {
- LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not have exactly 1 parameter");
- }
- return false;
- }
-
- if (!InvocationContext.class.equals(parameterTypes[0]))
- {
- if (LOG.isDebugEnabled())
- {
- LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not have a " + InvocationContext.class.getName() + " parameter ");
- }
- return false;
- }
-
- return true;
- }
- }
-
- private static String getStandardIgnoredMessage(InterceptionType interceptionType, Method method)
- {
- return "Method " + method.getName() + " defined on class " + method.getDeclaringClass().getName()
- + " will not be used for interception, since it is not defined according to the specification. It is annotated with @"
- + interceptionType.annotationClassName() + ", but ";
- }
-
public static boolean supportsEjb3InterceptorDeclaration()
{
return INTERCEPTORS_ANNOTATION_CLASS != null && EXCLUDE_CLASS_INTERCEPTORS_ANNOTATION_CLASS != null;
@@ -290,46 +178,4 @@
return clazz;
}
- public static Map<InterceptionType, List<MethodMetadataProvider>> buildMethodMap(ClassMetadataProvider interceptorClass, boolean isTargetClass)
- {
- Map<InterceptionType, List<MethodMetadataProvider>> methodMap = new HashMap<InterceptionType, List<MethodMetadataProvider>>();
- ClassMetadataProvider currentClass = interceptorClass;
- Set<MethodHolder> foundMethods = new HashSet<MethodHolder>();
- do
- {
- Set<InterceptionType> detectedInterceptorTypes = new HashSet<InterceptionType>();
-
- for (MethodMetadataProvider method : currentClass.getDeclaredMethods())
- {
- for (InterceptionType interceptionType : InterceptionTypeRegistry.getSupportedInterceptionTypes())
- {
- if (isInterceptorMethod(interceptionType, method, isTargetClass))
- {
- if (methodMap.get(interceptionType) == null)
- {
- methodMap.put(interceptionType, new LinkedList<MethodMetadataProvider>());
- }
- if (detectedInterceptorTypes.contains(interceptionType))
- {
- throw new InterceptorMetadataException("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.getJavaMethod());
- if (!foundMethods.contains(MethodHolder.of(method, false)))
- {
- methodMap.get(interceptionType).add(0, method);
- }
- }
- }
- foundMethods.add(MethodHolder.of(method, false));
- }
- currentClass = currentClass.getSuperclass();
- }
- while (!Object.class.equals(currentClass.getJavaClass()));
- return methodMap;
- }
}
Copied: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptorMetadataException.java (from rev 106491, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/InterceptorMetadataException.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptorMetadataException.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptorMetadataException.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,45 @@
+/*
+ * 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 org.jboss.interceptor.proxy.InterceptorException;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class InterceptorMetadataException extends InterceptorException
+{
+ public InterceptorMetadataException()
+ {
+ }
+
+ public InterceptorMetadataException(String s)
+ {
+ super(s);
+ }
+
+ public InterceptorMetadataException(String s, Throwable throwable)
+ {
+ super(s, throwable);
+ }
+
+ public InterceptorMetadataException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
Deleted: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/proxy/SubclassedProxy.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/proxy/SubclassedProxy.java 2010-07-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/proxy/SubclassedProxy.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -1,12 +0,0 @@
-package org.jboss.interceptor.util.proxy;
-
-/**
- * Created by IntelliJ IDEA.
- * User: marius
- * Date: Apr 9, 2010
- * Time: 1:57:31 PM
- * To change this template use File | Settings | File Templates.
- */
-public interface SubclassedProxy
-{
-}
Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/proxy/TargetInstanceProxy.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/proxy/TargetInstanceProxy.java 2010-07-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/proxy/TargetInstanceProxy.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -1,7 +1,5 @@
package org.jboss.interceptor.util.proxy;
-import javassist.util.proxy.MethodHandler;
-
/**
* @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
*/
Modified: projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTestCase.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTestCase.java 2010-07-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTestCase.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -14,21 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.jboss.interceptors.metadata;
import static org.junit.Assert.assertEquals;
import java.util.List;
-import org.jboss.interceptor.model.InterceptionType;
-import org.jboss.interceptor.model.metadata.InterceptorMetadata;
-import org.jboss.interceptor.model.metadata.InterceptorMetadataException;
-import org.jboss.interceptor.model.metadata.reader.MethodMetadataProvider;
-import org.jboss.interceptor.model.metadata.reader.ReflectiveClassMetadataProvider;
-import org.jboss.interceptor.model.metadata.reader.SimpleInterceptorMetadataReader;
-import org.jboss.interceptor.model.metadata.registry.InterceptorMetadataRegistry;
-import org.jboss.interceptor.model.metadata.registry.SimpleInterceptorMetadataRegistry;
+import org.jboss.interceptor.metadataregistry.InterceptorMetadataRegistry;
+import org.jboss.interceptor.metadataregistry.SimpleInterceptorMetadataRegistry;
+import org.jboss.interceptor.reader.ReflectiveClassMetadata;
+import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
+import org.jboss.interceptor.spi.metadata.MethodMetadata;
+import org.jboss.interceptor.spi.model.InterceptionType;
+import org.jboss.interceptor.util.InterceptorMetadataException;
import org.junit.Before;
import org.junit.Test;
@@ -43,31 +41,31 @@
@Before
public void setUp()
{
- interceptorMetadataRegistry = new SimpleInterceptorMetadataRegistry(SimpleInterceptorMetadataReader.getInstance());
+ interceptorMetadataRegistry = new SimpleInterceptorMetadataRegistry();
}
@Test
public void testInterceptorWithAllMethods()
{
- InterceptorMetadata interceptorClassMetadata = interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadataProvider.of(InterceptorWithAllMethods.class));
+ InterceptorMetadata interceptorClassMetadata = interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadata.of(InterceptorWithAllMethods.class));
- List<MethodMetadataProvider> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
+ List<MethodMetadata> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
assertEquals(true, postConstructMethods.size() == 1);
assertEquals(postConstructMethods.get(0).getJavaMethod().getName(), "doPostConstruct");
- List<MethodMetadataProvider> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
+ List<MethodMetadata> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
assertEquals(true, preDestroyMethods.size() == 1);
assertEquals(preDestroyMethods.get(0).getJavaMethod().getName(), "doPreDestroy");
- List<MethodMetadataProvider> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
+ List<MethodMetadata> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
assertEquals(true, aroundInvokeMethods.size() == 1);
assertEquals(aroundInvokeMethods.get(0).getJavaMethod().getName(), "doAroundInvoke");
- List<MethodMetadataProvider> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
+ List<MethodMetadata> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
assertEquals(true, postActivateMethods.size() == 1);
assertEquals(postActivateMethods.get(0).getJavaMethod().getName(), "doPostActivate");
- List<MethodMetadataProvider> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
+ List<MethodMetadata> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
assertEquals(true, prePassivateMethods.size() == 1);
assertEquals(prePassivateMethods.get(0).getJavaMethod().getName(), "doPrePassivate");
@@ -76,24 +74,24 @@
@Test
public void testInterceptorWithSomeMethods()
{
- InterceptorMetadata interceptorClassMetadata = interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadataProvider.of(InterceptorWithSomeMethods.class));
+ InterceptorMetadata interceptorClassMetadata = interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadata.of(InterceptorWithSomeMethods.class));
- List<MethodMetadataProvider> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
+ List<MethodMetadata> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
assertEquals(true, postConstructMethods.size() == 0);
- List<MethodMetadataProvider> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
+ List<MethodMetadata> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
assertEquals(true, preDestroyMethods.size() == 1);
assertEquals(preDestroyMethods.get(0).getJavaMethod().getName(), "doPreDestroy");
- List<MethodMetadataProvider> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
+ List<MethodMetadata> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
assertEquals(true, aroundInvokeMethods.size() == 1);
assertEquals(aroundInvokeMethods.get(0).getJavaMethod().getName(), "doAroundInvoke");
- List<MethodMetadataProvider> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
+ List<MethodMetadata> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
assertEquals(true, postActivateMethods.size() == 1);
assertEquals(postActivateMethods.get(0).getJavaMethod().getName(), "doPostActivate");
- List<MethodMetadataProvider> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
+ List<MethodMetadata> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
assertEquals(true, prePassivateMethods.size() == 0);
}
@@ -101,23 +99,23 @@
@Test
public void testSimpleInheritance()
{
- InterceptorMetadata interceptorClassMetadata = interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadataProvider.of(SimpleInheritanceChildInterceptor.class));
+ InterceptorMetadata interceptorClassMetadata = interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadata.of(SimpleInheritanceChildInterceptor.class));
- List<MethodMetadataProvider> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
+ List<MethodMetadata> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
assertEquals(1, postConstructMethods.size());
assertEquals(postConstructMethods.get(0).getJavaMethod().getName(), "doPostConstruct");
- List<MethodMetadataProvider> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
+ List<MethodMetadata> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
assertEquals(true, preDestroyMethods.size() == 0);
- List<MethodMetadataProvider> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
+ List<MethodMetadata> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
assertEquals(true, aroundInvokeMethods.size() == 1);
assertEquals(aroundInvokeMethods.get(0).getJavaMethod().getName(), "doAroundInvoke");
- List<MethodMetadataProvider> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
+ List<MethodMetadata> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
assertEquals(true, postActivateMethods.size() == 0);
- List<MethodMetadataProvider> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
+ List<MethodMetadata> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
assertEquals(true, prePassivateMethods.size() == 0);
}
@@ -125,25 +123,25 @@
@Test
public void testInheritanceWithAndWithoutOverriding()
{
- InterceptorMetadata interceptorClassMetadata = interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadataProvider.of(OverrideChildInterceptor.class));
+ InterceptorMetadata interceptorClassMetadata = interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadata.of(OverrideChildInterceptor.class));
- List<MethodMetadataProvider> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
+ List<MethodMetadata> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
assertEquals(true, postConstructMethods.size() == 1);
assertEquals(postConstructMethods.get(0).getJavaMethod().getName(), "methodOverriddenAndUsedAsInterceptor");
- List<MethodMetadataProvider> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
+ List<MethodMetadata> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
assertEquals(true, preDestroyMethods.size() == 0);
- List<MethodMetadataProvider> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
+ List<MethodMetadata> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
assertEquals(true, aroundInvokeMethods.size() == 2);
assertEquals(aroundInvokeMethods.get(0).getJavaMethod().getName(), "methodDefinedOnParentAndUsedAsInterceptor");
assertEquals(aroundInvokeMethods.get(1).getJavaMethod().getName(), "methodDefinedOnChildAndUsedAsInterceptor");
- List<MethodMetadataProvider> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
+ List<MethodMetadata> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
assertEquals(true, postActivateMethods.size() == 0);
- List<MethodMetadataProvider> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
+ List<MethodMetadata> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
assertEquals(true, prePassivateMethods.size() == 0);
}
@@ -151,7 +149,7 @@
@Test(expected = InterceptorMetadataException.class)
public void testDuplicateAnnotations()
{
- InterceptorMetadata interceptorClassMetadata = interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadataProvider.of(InterceptorWithDuplicateAnnotations.class));
+ InterceptorMetadata interceptorClassMetadata = interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadata.of(InterceptorWithDuplicateAnnotations.class));
}
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-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTestCase.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -21,18 +21,18 @@
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.Map;
import javassist.util.proxy.MethodHandler;
-import org.jboss.interceptor.model.InterceptionModel;
-import org.jboss.interceptor.model.registry.InterceptionModelRegistry;
-import org.jboss.interceptor.model.builder.InterceptionModelBuilder;
-import org.jboss.interceptor.model.metadata.reader.ReflectiveClassMetadataProvider;
-import org.jboss.interceptor.model.metadata.registry.InterceptorMetadataRegistry;
-import org.jboss.interceptor.model.metadata.registry.SimpleInterceptorMetadataRegistry;
+import org.jboss.interceptor.builder.InterceptionModelBuilder;
+import org.jboss.interceptor.metadataregistry.InterceptorMetadataRegistry;
+import org.jboss.interceptor.metadataregistry.SimpleInterceptorMetadataRegistry;
import org.jboss.interceptor.proxy.DirectClassInterceptionHandlerFactory;
import org.jboss.interceptor.proxy.InterceptorProxyCreator;
import org.jboss.interceptor.proxy.InterceptorProxyCreatorImpl;
-import org.jboss.interceptor.model.metadata.reader.SimpleInterceptorMetadataReader;
+import org.jboss.interceptor.reader.ReflectiveClassMetadata;
+import org.jboss.interceptor.spi.model.InterceptionModel;
import org.jboss.interceptor.util.InterceptionUtils;
import org.junit.Assert;
import org.junit.Before;
@@ -90,7 +90,7 @@
"org.jboss.interceptors.proxy.FootballTeam_getName",
};
- private InterceptionModelRegistry<Class<?>, Class<?>> interceptionModelRegistry;
+ private Map<Class<?>, InterceptionModel<?,?>> interceptionModelRegistry;
private DirectClassInterceptionHandlerFactory interceptionHandlerFactory;
@@ -99,7 +99,7 @@
@Before
public void setUp()
{
- interceptorMetadataRegistry = new SimpleInterceptorMetadataRegistry(SimpleInterceptorMetadataReader.getInstance());
+ interceptorMetadataRegistry = new SimpleInterceptorMetadataRegistry();
interceptionHandlerFactory = new DirectClassInterceptionHandlerFactory(interceptorMetadataRegistry);
}
@@ -112,8 +112,8 @@
builder.interceptPreDestroy().with(SecondInterceptor.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel;
interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
}
@@ -126,8 +126,8 @@
builder.interceptAll().with(FirstInterceptor.class, SecondInterceptor.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel;
interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>,InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
}
@@ -141,8 +141,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(SecondInterceptor.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel;
interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>,InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
}
@@ -157,8 +157,8 @@
builder.ignoreGlobalInterceptors(FootballTeam.class.getMethod("getName"));
InterceptionModel<Class<?>, Class<?>> interceptionModel;
interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
}
@@ -234,8 +234,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("echo", String.class)).with(ParameterOverridingInterceptor.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
Assert.assertEquals(42, proxy.echo("1"));
@@ -250,8 +250,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoInt", int.class)).with(ParameterOverridingInterceptorWithInteger.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
Assert.assertEquals(42, proxy.echoInt(1));
@@ -266,8 +266,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLongAsObject", Long.class)).with(ParameterOverridingInterceptorWithInteger.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
Assert.assertEquals(new Long(42), proxy.echoLongAsObject(1l));
@@ -282,8 +282,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLongAsObject", Long.class)).with(ParameterOverridingInterceptorWithLong.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
Assert.assertEquals(new Long(42), proxy.echoLongAsObject(1l));
@@ -298,8 +298,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLong", long.class)).with(ParameterOverridingInterceptorWithInteger.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
Assert.assertEquals(42, proxy.echoLong(1));
@@ -314,8 +314,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoInt", int.class)).with(ParameterOverridingInterceptorWithLong.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
FootballTeam proxy =proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
Assert.assertEquals(42, proxy.echoInt(1));
@@ -330,8 +330,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoObjectArray", Object[].class)).with(ParameterOverridingInterceptorWithLongArray.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
Assert.assertEquals(new Long[]{42l}, proxy.echoObjectArray(new Object[]{}));
@@ -346,8 +346,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoStringArray", String[].class)).with(ParameterOverridingInterceptorWithLongArray.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
Assert.assertEquals(new Long[]{42l}, proxy.echoStringArray(new String[]{}));
@@ -363,8 +363,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("echo2", ValueBearer.class)).with(ParameterOverridingInterceptor2.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
proxy.doNothing();
@@ -385,8 +385,8 @@
private <T> T proxifyInstance(T instance, Class<? extends T> targetClass)
{
- InterceptorProxyCreator ipc = new InterceptorProxyCreatorImpl(interceptionModelRegistry, interceptionHandlerFactory);
- MethodHandler methodHandler = ipc.createMethodHandler(instance, targetClass, interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadataProvider.of(targetClass), true));
+ InterceptorProxyCreator ipc = new InterceptorProxyCreatorImpl(interceptionHandlerFactory, ((InterceptionModel<Class<?>, ?>) interceptionModelRegistry.get(targetClass)));
+ MethodHandler methodHandler = ipc.createMethodHandler(instance, targetClass, interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadata.of(targetClass), true));
return ipc.createProxyInstance(InterceptionUtils.createProxyClassWithHandler(targetClass, methodHandler), methodHandler);
}
}
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-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/SubclassingInterceptionTestCase.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -21,19 +21,19 @@
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.Map;
import javassist.util.proxy.ProxyObject;
-import org.jboss.interceptor.model.metadata.reader.ReflectiveClassMetadataProvider;
-import org.jboss.interceptor.model.metadata.reader.SimpleInterceptorMetadataReader;
-import org.jboss.interceptor.proxy.javassist.CompositeHandler;
-import org.jboss.interceptor.model.InterceptionModel;
-import org.jboss.interceptor.model.builder.InterceptionModelBuilder;
-import org.jboss.interceptor.model.metadata.registry.InterceptorMetadataRegistry;
-import org.jboss.interceptor.model.metadata.registry.SimpleInterceptorMetadataRegistry;
-import org.jboss.interceptor.model.registry.InterceptionModelRegistry;
+import org.jboss.interceptor.builder.InterceptionModelBuilder;
+import org.jboss.interceptor.metadataregistry.InterceptorMetadataRegistry;
+import org.jboss.interceptor.metadataregistry.SimpleInterceptorMetadataRegistry;
import org.jboss.interceptor.proxy.DirectClassInterceptionHandlerFactory;
import org.jboss.interceptor.proxy.InterceptorProxyCreator;
import org.jboss.interceptor.proxy.InterceptorProxyCreatorImpl;
+import org.jboss.interceptor.proxy.javassist.CompositeHandler;
+import org.jboss.interceptor.reader.ReflectiveClassMetadata;
+import org.jboss.interceptor.spi.model.InterceptionModel;
import org.jboss.interceptor.util.InterceptionUtils;
import org.junit.Assert;
import org.junit.Before;
@@ -92,7 +92,7 @@
"org.jboss.interceptors.proxy.FootballTeam_getName",
};
- private InterceptionModelRegistry<Class<?>, Class<?>> interceptionModelRegistry;
+ private Map<Class<?>, InterceptionModel<?,?>> interceptionModelRegistry;
private DirectClassInterceptionHandlerFactory interceptionHandlerFactory;
@@ -101,7 +101,7 @@
@Before
public void setUp()
{
- interceptorMetadataRegistry = new SimpleInterceptorMetadataRegistry(SimpleInterceptorMetadataReader.getInstance());
+ interceptorMetadataRegistry = new SimpleInterceptorMetadataRegistry();
interceptionHandlerFactory = new DirectClassInterceptionHandlerFactory(interceptorMetadataRegistry);
}
@@ -114,8 +114,8 @@
builder.interceptPreDestroy().with(SecondInterceptor.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel;
interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
}
@@ -128,8 +128,8 @@
builder.interceptAll().with(FirstInterceptor.class, SecondInterceptor.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel;
interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
}
@@ -143,8 +143,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(SecondInterceptor.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel;
interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
}
@@ -159,8 +159,8 @@
builder.ignoreGlobalInterceptors(FootballTeam.class.getMethod("getName"));
InterceptionModel<Class<?>, Class<?>> interceptionModel;
interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
}
@@ -254,8 +254,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("echo", String.class)).with(ParameterOverridingInterceptor.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
Assert.assertEquals(42, proxy.echo("1"));
@@ -270,8 +270,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoInt", int.class)).with(ParameterOverridingInterceptorWithInteger.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
Assert.assertEquals(42, proxy.echoInt(1));
@@ -286,8 +286,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLongAsObject", Long.class)).with(ParameterOverridingInterceptorWithInteger.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
Assert.assertEquals(new Long(42), proxy.echoLongAsObject(1l));
@@ -302,8 +302,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLongAsObject", Long.class)).with(ParameterOverridingInterceptorWithLong.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
Assert.assertEquals(new Long(42), proxy.echoLongAsObject(1l));
@@ -318,8 +318,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLong", long.class)).with(ParameterOverridingInterceptorWithInteger.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
Assert.assertEquals(42, proxy.echoLong(1));
@@ -334,8 +334,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoInt", int.class)).with(ParameterOverridingInterceptorWithLong.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
Assert.assertEquals(42, proxy.echoInt(1));
@@ -350,8 +350,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoObjectArray", Object[].class)).with(ParameterOverridingInterceptorWithLongArray.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
Assert.assertEquals(new Long[]{42l}, proxy.echoObjectArray(new Object[]{}));
@@ -366,8 +366,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoStringArray", String[].class)).with(ParameterOverridingInterceptorWithLongArray.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- this.interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
Assert.assertEquals(new Long[]{42l}, proxy.echoStringArray(new String[]{}));
@@ -383,8 +383,8 @@
builder.interceptAroundInvoke(FootballTeam.class.getMethod("echo2", ValueBearer.class)).with(ParameterOverridingInterceptor2.class);
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- this.interceptionModelRegistry = new InterceptionModelRegistry<Class<?>, Class<?>>();
- interceptionModelRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+ this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+ interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
proxy.doNothing();
@@ -417,8 +417,8 @@
private <T> T createAdvisedSubclassedInstance(Class<? extends T> targetClass, Object... args)
{
- InterceptorProxyCreator ipc = new InterceptorProxyCreatorImpl(interceptionModelRegistry, interceptionHandlerFactory);
- return ipc.createProxyFromClass(targetClass, new Class<?>[]{String.class},args, interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadataProvider.of(targetClass), true));
+ InterceptorProxyCreator ipc = new InterceptorProxyCreatorImpl(interceptionHandlerFactory, ((InterceptionModel<Class<?>, ?>) interceptionModelRegistry.get(targetClass)));
+ return ipc.createProxyFromClass(targetClass, new Class<?>[]{String.class},args, interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadata.of(targetClass), true));
}
}
\ No newline at end of file
Added: projects/interceptors/trunk/jboss-interceptor-api/pom.xml
===================================================================
--- projects/interceptors/trunk/jboss-interceptor-api/pom.xml (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor-api/pom.xml 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>jboss-interceptor-parent</artifactId>
+ <groupId>org.jboss.interceptor</groupId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>jboss-interceptor-api</artifactId>
+ <name>JBoss EJB 3.1 Common Interceptor Library API</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.spec.javax.interceptor</groupId>
+ <artifactId>jboss-interceptors-api_1.1_spec</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
Copied: projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/handler/InterceptionHandler.java (from rev 106491, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionHandler.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/handler/InterceptionHandler.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/handler/InterceptionHandler.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,30 @@
+/*
+ * 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.spi.handler;
+
+import javax.interceptor.InvocationContext;
+
+import org.jboss.interceptor.spi.model.InterceptionType;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public interface InterceptionHandler
+{
+ public Object intercept(Object target, InterceptionType interceptionType, InvocationContext invocationContext) throws Exception;
+}
+
Copied: projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/handler/InterceptionHandlerFactory.java (from rev 106491, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionHandlerFactory.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/handler/InterceptionHandlerFactory.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/handler/InterceptionHandlerFactory.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,25 @@
+/*
+ * 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.spi.handler;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public interface InterceptionHandlerFactory<I> {
+
+ InterceptionHandler createFor(I clazz);
+}
Copied: projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/ClassMetadata.java (from rev 106491, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/reader/ClassMetadataProvider.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/ClassMetadata.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/ClassMetadata.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,39 @@
+/*
+ * 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.metadata;
+
+import java.io.Serializable;
+
+/**
+ * Abstraction of class metadata. Allows for the framework client to configure
+ * their own way of reading information about a class, rather than relying exclusively
+ * on Java reflection.
+ *
+ * @author Marius Bogoevici
+ */
+public interface ClassMetadata extends Serializable
+{
+ Iterable<MethodMetadata> getDeclaredMethods();
+
+ Class<?> getJavaClass();
+
+ String getClassName();
+
+ ClassMetadata getSuperclass();
+
+}
Copied: projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/InterceptorMetadata.java (from rev 106491, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/InterceptorMetadata.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/InterceptorMetadata.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/InterceptorMetadata.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -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.spi.metadata;
+
+import java.util.List;
+
+import org.jboss.interceptor.spi.model.InterceptionType;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public interface InterceptorMetadata
+{
+ ClassMetadata getInterceptorClass();
+
+ /**
+ * Returns the list of interceptor methods of this class for a given
+ * interception type.
+ *
+ * @param interceptionType
+ * @return a list of methods
+ */
+ List<MethodMetadata> getInterceptorMethods(InterceptionType interceptionType);
+
+ boolean isTargetClass();
+}
Copied: projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/InterceptorMetadataReader.java (from rev 106491, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/reader/InterceptorMetadataReader.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/InterceptorMetadataReader.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/InterceptorMetadataReader.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,31 @@
+/*
+ * 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.metadata;
+
+
+/**
+ * Reads interceptor metadata from a class
+ *
+ * @author Marius Bogoevici
+ */
+public interface InterceptorMetadataReader
+{
+ InterceptorMetadata readForInterceptorClass(ClassMetadata clazz);
+
+ InterceptorMetadata readForTargetClass(ClassMetadata clazz);
+}
Copied: projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/MethodMetadata.java (from rev 106491, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/reader/MethodMetadataProvider.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/MethodMetadata.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/MethodMetadata.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,38 @@
+/*
+ * 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.metadata;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+/**
+ * Abstraction of a source of metadata information about a method. Allows the framework client
+ * to configure their own way of providing method metadata, rather than relying exclusively on
+ * Java reflection.
+ *
+ * @author Marius Bogoevici
+ */
+public interface MethodMetadata
+{
+ Method getJavaMethod();
+
+ Annotation getAnnotation(Class<? extends Annotation> annotationClass);
+
+ ClassMetadata getReturnType();
+
+}
Copied: projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/model/InterceptionModel.java (from rev 106491, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptionModel.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/model/InterceptionModel.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/model/InterceptionModel.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,58 @@
+/*
+ * 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.spi.model;
+
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Set;
+import java.io.Serializable;
+
+/**
+ * Describes the interceptors that apply to a particular entity.
+ *
+ * Interceptors and intercepted entities are parametrized.
+ *
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public interface InterceptionModel<T, I> extends Serializable
+{
+
+ /**
+ * Returns the interceptors applicable for the given interception type and method
+ *
+ * @param interceptionType
+ * @param method - null if the interception type is lifecycle
+ * @return list of interceptors
+ * @throws IllegalArgumentException if interceptionType is business method or around timeout
+ * but method is null, as well as if interceptionType is callback and method is not null
+ */
+ public List<I> getInterceptors(InterceptionType interceptionType, Method method);
+
+ /**
+ * Returns all interceptor classes that are applicable to the given intercepted entity
+ * @return all interceptors
+ */
+ public Set<I> getAllInterceptors();
+
+ /**
+ *
+ * @return the intercepted entity
+ */
+ public T getInterceptedEntity();
+
+}
Copied: projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/model/InterceptionType.java (from rev 106491, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptionType.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/model/InterceptionType.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/model/InterceptionType.java 2010-07-12 14:54:45 UTC (rev 106596)
@@ -0,0 +1,52 @@
+/*
+ * 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.spi.model;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public enum InterceptionType
+{
+
+ AROUND_INVOKE(false, "javax.interceptor.AroundInvoke"),
+ AROUND_TIMEOUT(false, "javax.interceptor.AroundTimeout"),
+ POST_CONSTRUCT(true, "javax.annotation.PostConstruct"),
+ PRE_DESTROY(true, "javax.annotation.PreDestroy"),
+ POST_ACTIVATE(true, "javax.ejb.PostActivate"),
+ PRE_PASSIVATE(true, "javax.ejb.PrePassivate");
+
+ private boolean lifecycleCallback;
+
+ private String annotationClassName;
+
+ InterceptionType(boolean lifecycleCallback, String annotationClassName)
+ {
+ this.lifecycleCallback = lifecycleCallback;
+ this.annotationClassName = annotationClassName;
+ }
+
+ public boolean isLifecycleCallback()
+ {
+ return lifecycleCallback;
+ }
+
+ public String annotationClassName()
+ {
+ return annotationClassName;
+ }
+}
Modified: projects/interceptors/trunk/pom.xml
===================================================================
--- projects/interceptors/trunk/pom.xml 2010-07-12 14:39:15 UTC (rev 106595)
+++ projects/interceptors/trunk/pom.xml 2010-07-12 14:54:45 UTC (rev 106596)
@@ -11,11 +11,11 @@
<groupId>org.jboss.interceptor</groupId>
<artifactId>jboss-interceptor-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
- <name>JBoss Interceptors Parent</name>
- <description>JBoss Interceptors Parent</description>
+ <name>JBoss EJB 3.1 Common Interceptor Library Parent</name>
+ <description>JBoss EJB 3.1 Common Interceptor Library Parent</description>
<scm>
<connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/interceptors/trunk/</connection>
@@ -31,6 +31,7 @@
</properties>
<modules>
+ <module>jboss-interceptor-api</module>
<module>jboss-interceptor</module>
</modules>
@@ -176,11 +177,17 @@
<dependency>
<groupId>org.jboss.interceptor</groupId>
- <artifactId>jboss-interceptor</artifactId>
+ <artifactId>jboss-interceptor-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.jboss.interceptor</groupId>
+ <artifactId>jboss-interceptor-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-api</artifactId>
<version>3.1.0</version>
More information about the jboss-cvs-commits
mailing list