[weld-commits] Weld SVN: r5720 - in core/trunk: impl/src/main/java/org/jboss/weld/bean and 4 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Thu Feb 4 01:10:56 EST 2010


Author: marius.bogoevici
Date: 2010-02-04 01:10:55 -0500 (Thu, 04 Feb 2010)
New Revision: 5720

Added:
   core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptionMetadataService.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldClassReference.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldInterceptorMetadata.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldMetadataReader.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldMethodReference.java
Modified:
   core/trunk/bom/pom.xml
   core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/ClassInterceptionHandlerFactory.java
   core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/interceptors/InterceptorExtensionTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/resolution/AccessibleManagerResolutionTest.java
Log:
WELD-312


Modified: core/trunk/bom/pom.xml
===================================================================
--- core/trunk/bom/pom.xml	2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/bom/pom.xml	2010-02-04 06:10:55 UTC (rev 5720)
@@ -78,7 +78,7 @@
       <javassist.version>3.11.0.GA</javassist.version>
       <cdi.tck.version>1.0.1-CR1</cdi.tck.version>
       <atinject.tck.version>1.0.0-PFD-3</atinject.tck.version>
-      <jboss.interceptor.version>1.0.0-CR10</jboss.interceptor.version>
+      <jboss.interceptor.version>1.0.0-CR11</jboss.interceptor.version>
       <slf4j.version>1.5.10</slf4j.version>
       <cal10n.version>0.7.2</cal10n.version>
    </properties>

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java	2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java	2010-02-04 06:10:55 UTC (rev 5720)
@@ -50,10 +50,11 @@
 
 import org.jboss.interceptor.model.InterceptionModel;
 import org.jboss.interceptor.model.InterceptionModelBuilder;
-import org.jboss.interceptor.model.InterceptorClassMetadata;
-import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
+import org.jboss.interceptor.model.InterceptorMetadata;
 import org.jboss.interceptor.util.InterceptionUtils;
 import org.jboss.interceptor.util.proxy.TargetInstanceProxy;
+import org.jboss.weld.bean.interceptor.InterceptionMetadataService;
+import org.jboss.weld.bean.interceptor.WeldClassReference;
 import org.jboss.weld.bean.proxy.DecorationHelper;
 import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
 import org.jboss.weld.context.SerializableContextualImpl;
@@ -572,7 +573,7 @@
             }
          }
          InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-         InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(getType(), true);
+         InterceptorMetadata interceptorClassMetadata = beanManager.getServices().get(InterceptionMetadataService.class).getInterceptorMetadataRegistry().getInterceptorClassMetadata(WeldClassReference.of(getWeldAnnotated()), true);
          hasSerializationOrInvocationInterceptorMethods = !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.AROUND_INVOKE).isEmpty() || !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.AROUND_TIMEOUT).isEmpty() || !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.PRE_PASSIVATE).isEmpty() || !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.POST_ACTIVATE).isEmpty();
          if (interceptionModel.getAllInterceptors().size() > 0 || hasSerializationOrInvocationInterceptorMethods)
          {
@@ -581,7 +582,7 @@
       }
       else
       {
-         InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(getType(), true);
+         InterceptorMetadata interceptorClassMetadata =  beanManager.getServices().get(InterceptionMetadataService.class).getInterceptorMetadataRegistry().getInterceptorClassMetadata(WeldClassReference.of(getWeldAnnotated()), true);
          hasSerializationOrInvocationInterceptorMethods = !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.AROUND_INVOKE).isEmpty() || !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.AROUND_TIMEOUT).isEmpty() || !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.PRE_PASSIVATE).isEmpty() || !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.POST_ACTIVATE).isEmpty();
       }
    }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java	2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java	2010-02-04 06:10:55 UTC (rev 5720)
@@ -28,9 +28,10 @@
 import javax.enterprise.inject.spi.Interceptor;
 import javax.interceptor.InvocationContext;
 
-import org.jboss.interceptor.model.InterceptorClassMetadata;
+import org.jboss.interceptor.model.InterceptorMetadata;
 import org.jboss.interceptor.proxy.DirectClassInterceptionHandler;
-import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
+import org.jboss.weld.bean.interceptor.InterceptionMetadataService;
+import org.jboss.weld.bean.interceptor.WeldClassReference;
 import org.jboss.weld.exceptions.DeploymentException;
 import org.jboss.weld.exceptions.WeldException;
 import org.jboss.weld.introspector.WeldClass;
@@ -43,7 +44,7 @@
 public class InterceptorImpl<T> extends ManagedBean<T> implements Interceptor<T>
 {
    
-   private final InterceptorClassMetadata interceptorClassMetadata;
+   private final InterceptorMetadata interceptorClassMetadata;
 
    private final Set<Annotation> interceptorBindingTypes;
    
@@ -57,7 +58,7 @@
    protected InterceptorImpl(WeldClass<T> type, BeanManagerImpl beanManager)
    {
       super(type, new StringBuilder().append(Interceptor.class.getSimpleName()).append(BEAN_ID_SEPARATOR).append(type.getName()).toString(), beanManager);
-      this.interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(type.getJavaClass());
+      this.interceptorClassMetadata = beanManager.getServices().get(InterceptionMetadataService.class).getInterceptorMetadataRegistry().getInterceptorClassMetadata(WeldClassReference.of(type));
       this.serializable = type.isSerializable();
       this.interceptorBindingTypes = new HashSet<Annotation>();
       interceptorBindingTypes.addAll(flattenInterceptorBindings(beanManager, getWeldAnnotated().getAnnotations()));
@@ -84,7 +85,7 @@
    {
       try
       {
-         return new DirectClassInterceptionHandler<T>(instance, getType()).invoke(ctx.getTarget(), org.jboss.interceptor.model.InterceptionType.valueOf(type.name()), ctx);
+         return new DirectClassInterceptionHandler<T>(instance, interceptorClassMetadata).invoke(ctx.getTarget(), org.jboss.interceptor.model.InterceptionType.valueOf(type.name()), ctx);
       } catch (Exception e)
       {
          throw new WeldException(e);

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java	2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java	2010-02-04 06:10:55 UTC (rev 5720)
@@ -50,6 +50,8 @@
 import org.jboss.weld.Container;
 import org.jboss.weld.bean.interceptor.CdiInterceptorHandlerFactory;
 import org.jboss.weld.bean.interceptor.ClassInterceptionHandlerFactory;
+import org.jboss.weld.bean.interceptor.InterceptionMetadataService;
+import org.jboss.weld.bean.interceptor.WeldClassReference;
 import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
 import org.jboss.weld.exceptions.DefinitionException;
 import org.jboss.weld.exceptions.DeploymentException;
@@ -577,8 +579,8 @@
          if (interceptionRegistries.size() > 0)
          {
             InterceptorProxyCreatorImpl interceptorProxyCreator = new InterceptorProxyCreatorImpl(interceptionRegistries, interceptionHandlerFactories);
-            MethodHandler methodHandler = new CleanableMethodHandler(interceptorProxyCreator.getMethodHandler(instance, getType()));
-            instance = interceptorProxyCreator.createProxyInstance(InterceptorProxyCreatorImpl.createProxyClassWithHandler(getType(), methodHandler), methodHandler);
+            MethodHandler methodHandler = new CleanableMethodHandler(interceptorProxyCreator.createMethodHandler(instance, getType(), getBeanManager().getServices().get(InterceptionMetadataService.class).getInterceptorMetadataRegistry().getInterceptorClassMetadata(WeldClassReference.of(getWeldAnnotated()), true)));
+            instance = interceptorProxyCreator.createProxyInstance(InterceptionUtils.createProxyClassWithHandler(getType(), methodHandler), methodHandler);
          }
 
       }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java	2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java	2010-02-04 06:10:55 UTC (rev 5720)
@@ -20,6 +20,7 @@
 
 import javax.enterprise.inject.spi.Interceptor;
 
+import org.jboss.interceptor.model.InterceptorMetadata;
 import org.jboss.interceptor.proxy.AbstractClassInterceptionHandler;
 import org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance;
 
@@ -33,9 +34,9 @@
    
    private final SerializableContextualInstance<Interceptor<T>, T> serializableContextualInstance;
 
-   public CdiInterceptorHandler(SerializableContextualInstance<Interceptor<T>, T> serializableContextualInstance, Class<?> clazz)
+   public CdiInterceptorHandler(SerializableContextualInstance<Interceptor<T>, T> serializableContextualInstance, Class<?> clazz, InterceptorMetadata interceptorMetadata)
    {
-      super(clazz);
+      super(interceptorMetadata);
       this.serializableContextualInstance = serializableContextualInstance;
    }
 

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java	2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java	2010-02-04 06:10:55 UTC (rev 5720)
@@ -20,6 +20,8 @@
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Interceptor;
 
+import org.jboss.interceptor.model.InterceptorMetadata;
+import org.jboss.interceptor.model.metadata.ReflectiveClassReference;
 import org.jboss.interceptor.proxy.InterceptionHandler;
 import org.jboss.interceptor.proxy.InterceptionHandlerFactory;
 import org.jboss.weld.context.SerializableContextualInstanceImpl;
@@ -48,7 +50,8 @@
    public InterceptionHandler createFor(final SerializableContextual<Interceptor<T>, T> serializableContextual)
    {
       T instance = (T) getManager().getReference(serializableContextual.get(), creationalContext, false);
-      return new CdiInterceptorHandler<T>(new SerializableContextualInstanceImpl<Interceptor<T>, T>(serializableContextual, instance, creationalContext), serializableContextual.get().getBeanClass());
+      InterceptorMetadata interceptionMetadata = getManager().getServices().get(InterceptionMetadataService.class).getInterceptorMetadataRegistry().getInterceptorClassMetadata(ReflectiveClassReference.of(serializableContextual.get().getBeanClass()), false);
+      return new CdiInterceptorHandler<T>(new SerializableContextualInstanceImpl<Interceptor<T>, T>(serializableContextual, instance, creationalContext), serializableContextual.get().getBeanClass(), interceptionMetadata);
    }
 
 }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/ClassInterceptionHandlerFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/ClassInterceptionHandlerFactory.java	2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/ClassInterceptionHandlerFactory.java	2010-02-04 06:10:55 UTC (rev 5720)
@@ -21,6 +21,8 @@
 
 import javax.enterprise.context.spi.CreationalContext;
 
+import org.jboss.interceptor.model.InterceptorMetadata;
+import org.jboss.interceptor.model.metadata.ReflectiveClassReference;
 import org.jboss.interceptor.proxy.DirectClassInterceptionHandler;
 import org.jboss.interceptor.proxy.InterceptionHandler;
 import org.jboss.interceptor.proxy.InterceptionHandlerFactory;
@@ -51,7 +53,8 @@
          T interceptorInstance = SecureReflections.ensureAccessible(constructor).newInstance();
          // inject
          manager.createInjectionTarget(manager.createAnnotatedType(clazz)).inject(interceptorInstance, creationalContext);
-         return new DirectClassInterceptionHandler<T>(interceptorInstance, clazz);
+         InterceptorMetadata interceptionMetadata = manager.getServices().get(InterceptionMetadataService.class).getInterceptorMetadataRegistry().getInterceptorClassMetadata(ReflectiveClassReference.of(clazz), false);
+         return new DirectClassInterceptionHandler<T>(interceptorInstance, interceptionMetadata);
       }
       catch (Exception e)
       {

Added: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptionMetadataService.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptionMetadataService.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptionMetadataService.java	2010-02-04 06:10:55 UTC (rev 5720)
@@ -0,0 +1,44 @@
+/*
+ * 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.weld.bean.interceptor;
+
+import org.jboss.interceptor.registry.InterceptorMetadataRegistry;
+import org.jboss.weld.bootstrap.api.Service;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class InterceptionMetadataService implements Service
+{
+   private InterceptorMetadataRegistry interceptorMetadataRegistry;
+
+   public InterceptionMetadataService()
+   {
+       interceptorMetadataRegistry = new InterceptorMetadataRegistry(new WeldMetadataReader());
+   }
+
+   public InterceptorMetadataRegistry getInterceptorMetadataRegistry()
+   {
+      return interceptorMetadataRegistry;
+   }
+
+   public void cleanup()
+   {
+      interceptorMetadataRegistry.cleanup();
+   }
+}

Added: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldClassReference.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldClassReference.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldClassReference.java	2010-02-04 06:10:55 UTC (rev 5720)
@@ -0,0 +1,84 @@
+/*
+ * 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.weld.bean.interceptor;
+
+import java.util.Iterator;
+
+import org.jboss.interceptor.model.metadata.ClassReference;
+import org.jboss.interceptor.model.metadata.ImmutableIteratorWrapper;
+import org.jboss.interceptor.model.metadata.MethodReference;
+import org.jboss.weld.introspector.WeldClass;
+import org.jboss.weld.introspector.WeldMethod;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class WeldClassReference implements ClassReference
+{
+   private WeldClass<?> weldClass;
+
+   private WeldClassReference(WeldClass<?> weldClass)
+   {
+      this.weldClass = weldClass;
+   }
+
+   public static ClassReference of(WeldClass<?> weldClass)
+   {
+      return new WeldClassReference(weldClass);
+   }
+
+   public String getClassName()
+   {
+      return weldClass.getName();
+   }
+
+   public Iterable<MethodReference> getDeclaredMethods()
+   {
+      return new Iterable<MethodReference>()
+      {
+         public Iterator<MethodReference> iterator()
+         {
+            return new ImmutableIteratorWrapper<WeldMethod<?,?>>(weldClass.getDeclaredWeldMethods().iterator())
+            {
+               @Override protected MethodReference wrapObject(WeldMethod<?,?> weldMethod)
+               {
+                  return WeldMethodReference.of(weldMethod);
+               }
+            };
+         }
+      };
+   }
+
+   public Class<?> getJavaClass()
+   {
+      return weldClass.getJavaClass();
+   }
+
+   public ClassReference getSuperclass()
+   {
+      WeldClass<?> weldSuperclass = weldClass.getWeldSuperclass();
+      if (weldSuperclass != null)
+      {
+         return WeldClassReference.of(weldSuperclass);
+      }
+      else
+      {
+         return null;
+      }
+   }
+}

Added: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldInterceptorMetadata.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldInterceptorMetadata.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldInterceptorMetadata.java	2010-02-04 06:10:55 UTC (rev 5720)
@@ -0,0 +1,101 @@
+/*
+ * 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.weld.bean.interceptor;
+
+import org.jboss.interceptor.model.InterceptorMetadata;
+import org.jboss.interceptor.model.metadata.AbstractInterceptorMetadata;
+import org.jboss.interceptor.model.metadata.AbstractInterceptorMetadataSerializationProxy;
+import org.jboss.interceptor.model.metadata.ClassReference;
+import org.jboss.interceptor.model.metadata.MethodReference;
+import org.jboss.weld.Container;
+import org.jboss.weld.exceptions.WeldException;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class WeldInterceptorMetadata extends AbstractInterceptorMetadata
+{
+   public WeldInterceptorMetadata(ClassReference interceptorClass, boolean targetClass)
+   {
+      super(interceptorClass, targetClass);
+   }
+
+   private Object writeReplace()
+   {
+      return createSerializableProxy();
+   }
+
+   @Override protected Object createSerializableProxy()
+   {
+      return new WeldInterceptorMetadataSerializationProxy(getInterceptorClass().getClassName(), isTargetClass());
+   }
+
+   public static class WeldInterceptorMetadataSerializationProxy extends AbstractInterceptorMetadataSerializationProxy
+   {
+      protected WeldInterceptorMetadataSerializationProxy(String className, boolean interceptionTargetClass)
+      {
+         super(className, interceptionTargetClass);
+      }
+
+      @Override protected InterceptorMetadata loadInterceptorMetadata() throws ClassNotFoundException
+      {
+         //Class<?> clazz = Container.instance().services().get(ResourceLoader.class).classForName(getClassName());
+
+         return Container.instance().services().get(InterceptionMetadataService.class)
+               .getInterceptorMetadataRegistry().getInterceptorClassMetadata(new ClassReferenceStub(), isInterceptionTargetClass());
+      }
+
+      private Object readResolve()
+      {
+         try
+         {
+            return loadInterceptorMetadata();
+         }
+         catch (ClassNotFoundException e)
+         {
+            throw new WeldException(e);
+         }
+      }
+
+      /**
+       * ClassReference stub - we are assuming that the interceptor metadata is loaded already
+       */
+      private class ClassReferenceStub implements ClassReference
+      {
+         public String getClassName()
+         {
+            return WeldInterceptorMetadataSerializationProxy.this.getClassName();
+         }
+
+         public Iterable<MethodReference> getDeclaredMethods()
+         {
+            throw new UnsupportedOperationException("");
+         }
+
+         public Class<?> getJavaClass()
+         {
+            throw new UnsupportedOperationException("");
+         }
+
+         public ClassReference getSuperclass()
+         {
+            throw new UnsupportedOperationException("");
+         }
+      }
+   }
+}

Added: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldMetadataReader.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldMetadataReader.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldMetadataReader.java	2010-02-04 06:10:55 UTC (rev 5720)
@@ -0,0 +1,33 @@
+/*
+ * 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.weld.bean.interceptor;
+
+import org.jboss.interceptor.model.InterceptorMetadata;
+import org.jboss.interceptor.model.metadata.ClassReference;
+import org.jboss.interceptor.registry.ClassMetadataReader;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class WeldMetadataReader implements ClassMetadataReader
+{
+   public InterceptorMetadata getInterceptorMetadata(ClassReference clazz, boolean isTargetClass)
+   {
+      return new WeldInterceptorMetadata(clazz, isTargetClass);
+   }
+}

Added: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldMethodReference.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldMethodReference.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldMethodReference.java	2010-02-04 06:10:55 UTC (rev 5720)
@@ -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.weld.bean.interceptor;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+import org.jboss.interceptor.model.metadata.ClassReference;
+import org.jboss.interceptor.model.metadata.MethodReference;
+import org.jboss.interceptor.model.metadata.ReflectiveClassReference;
+import org.jboss.weld.introspector.WeldMethod;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class WeldMethodReference implements MethodReference
+{
+   private WeldMethod<?,?> weldMethod;
+
+   public WeldMethodReference(WeldMethod<?,?> weldMethod)
+   {
+      this.weldMethod = weldMethod;
+   }
+
+   public static MethodReference of(WeldMethod<?,?> weldMethod)
+   {
+      return new WeldMethodReference(weldMethod);
+   }
+
+   public Annotation getAnnotation(Class<? extends Annotation> annotationClass)
+   {
+      return weldMethod.getAnnotation(annotationClass);
+   }
+
+   public Method getJavaMethod()
+   {
+      return weldMethod.getJavaMember();
+   }
+
+   public ClassReference getReturnType()
+   {
+      return ReflectiveClassReference.of(weldMethod.getJavaMember().getReturnType());
+   }
+}

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java	2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java	2010-02-04 06:10:55 UTC (rev 5720)
@@ -41,6 +41,7 @@
 import org.jboss.weld.Container;
 import org.jboss.weld.ContainerState;
 import org.jboss.weld.bean.builtin.BeanManagerBean;
+import org.jboss.weld.bean.interceptor.InterceptionMetadataService;
 import org.jboss.weld.bootstrap.api.Bootstrap;
 import org.jboss.weld.bootstrap.api.Environment;
 import org.jboss.weld.bootstrap.api.Lifecycle;
@@ -321,6 +322,7 @@
       services.add(ContextualStore.class, new ContextualStoreImpl());
       services.add(ServiceLoaderFactory.class, new DefaultServiceLoaderFactory());
       services.add(JavassistCleaner.class, new JavassistCleaner());
+      services.add(InterceptionMetadataService.class, new InterceptionMetadataService());
       services.add(CurrentInjectionPoint.class, new CurrentInjectionPoint());
       return services;
    }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/interceptors/InterceptorExtensionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/interceptors/InterceptorExtensionTest.java	2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/interceptors/InterceptorExtensionTest.java	2010-02-04 06:10:55 UTC (rev 5720)
@@ -43,7 +43,7 @@
 @Classes(packages = { "org.jboss.weld.tests.util.annotated" })
 public class InterceptorExtensionTest extends AbstractWeldTest
 {
-   @Test(groups={"broken"})
+   @Test
    public void testInterceptorCalled()
    {
       NumberSource ng = getReference(NumberSource.class);
@@ -51,7 +51,7 @@
       assert IncrementingInterceptor.isDoAroundCalled();
    }
 
-   @Test(groups={"broken"})
+   @Test
    @SuppressWarnings("unchecked")
    public void testLifecycleInterceptor()
    {

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/resolution/AccessibleManagerResolutionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/resolution/AccessibleManagerResolutionTest.java	2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/resolution/AccessibleManagerResolutionTest.java	2010-02-04 06:10:55 UTC (rev 5720)
@@ -23,6 +23,7 @@
 import org.jboss.weld.Container;
 import org.jboss.weld.bean.ManagedBean;
 import org.jboss.weld.bean.RIBean;
+import org.jboss.weld.bean.interceptor.InterceptionMetadataService;
 import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
 import org.jboss.weld.bootstrap.api.ServiceRegistry;
 import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
@@ -51,6 +52,8 @@
       this.services = new SimpleServiceRegistry();
       this.services.add(MetaAnnotationStore.class, new MetaAnnotationStore(classTransformer));
       this.services.add(ContextualStore.class, new ContextualStoreImpl());
+      this.services.add(InterceptionMetadataService.class, new InterceptionMetadataService());
+      this.services.add(ClassTransformer.class, classTransformer);
    }
    
    private void addBean(BeanManagerImpl manager, Class<?> c)



More information about the weld-commits mailing list