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

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Thu Oct 15 02:46:15 EDT 2009


Author: marius.bogoevici
Date: 2009-10-15 02:46:13 -0400 (Thu, 15 Oct 2009)
New Revision: 4106

Added:
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/Ball.java
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/Defender.java
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/InterceptorWithNonSerializableFieldOnPassivatingBean.java
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/Pass.java
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/Team.java
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/Ball.java
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/Defender.java
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/NonPassivatingInterceptorOnPassivatingBean.java
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/Pass.java
   core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/passivation/broken/
   core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/
   core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/beans.xml
   core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/
   core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/beans.xml
Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/Validator.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
Log:
Enforcing serializability check for interceptors on passivating beans + tests + factoring out injection points test.

Modified: core/trunk/impl/src/main/java/org/jboss/weld/Validator.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/Validator.java	2009-10-15 06:25:02 UTC (rev 4105)
+++ core/trunk/impl/src/main/java/org/jboss/weld/Validator.java	2009-10-15 06:46:13 UTC (rev 4106)
@@ -118,7 +118,7 @@
                   for (InjectionPoint ij : decorator.getInjectionPoints())
                   {
                      Bean<?> resolvedBean = beanManager.resolve(beanManager.getInjectableBeans(ij));
-                     validateInjectionPointPassivationCapable(ij, resolvedBean, beanManager);
+                     Beans.validateInjectionPointPassivationCapable(ij, resolvedBean, beanManager);
                   }
                }
             }
@@ -176,22 +176,10 @@
       }
       if (ij.getBean() != null && Beans.isPassivatingScope(ij.getBean(), beanManager) && (!ij.isTransient()) && !Beans.isPassivationCapableBean(resolvedBean))
       {
-         validateInjectionPointPassivationCapable(ij, resolvedBean, beanManager);
+         Beans.validateInjectionPointPassivationCapable(ij, resolvedBean, beanManager);
       }
    }
    
-   public void validateInjectionPointPassivationCapable(InjectionPoint ij, Bean<?> resolvedBean, BeanManagerImpl beanManager)
-   {
-      if (!ij.isTransient() && !Beans.isPassivationCapableBean(resolvedBean))
-      {
-         if (resolvedBean.getScope().equals(Dependent.class) && resolvedBean instanceof AbstractProducerBean<?, ?,?>)
-         {
-            throw new IllegalProductException("The bean " + ij.getBean() + " declares a passivating scope but the producer returned a non-serializable bean for injection: " + resolvedBean);
-         }
-         throw new UnserializableDependencyException("The bean " + ij.getBean() + " declares a passivating scope but has non-serializable dependency: " + resolvedBean);
-      }
-   }
-   
    public void validateDeployment(BeanManagerImpl manager, BeanDeployerEnvironment environment)
    {
       validateBeans(manager.getDecorators(), new ArrayList<RIBean<?>>(), manager);

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	2009-10-15 06:25:02 UTC (rev 4105)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java	2009-10-15 06:46:13 UTC (rev 4106)
@@ -24,6 +24,7 @@
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.Collection;
 
 import javassist.util.proxy.ProxyFactory;
 import javassist.util.proxy.ProxyObject;
@@ -37,6 +38,7 @@
 import javax.enterprise.inject.spi.InjectionTarget;
 import javax.enterprise.inject.spi.InterceptionType;
 import javax.enterprise.inject.spi.Interceptor;
+import javax.enterprise.inject.spi.Bean;
 import javax.inject.Scope;
 
 import org.jboss.interceptor.model.InterceptionModelBuilder;
@@ -57,6 +59,7 @@
 import org.jboss.weld.util.Beans;
 import org.jboss.weld.util.Proxies;
 import org.jboss.weld.util.Strings;
+import org.jboss.weld.util.Reflections;
 
 /**
  * An abstract bean representation common for class-based beans
@@ -412,7 +415,8 @@
    {
       if (manager.getBoundInterceptorsRegistry().getInterceptionModel(getType()) == null)
       {
-         InterceptionModelBuilder<Class<?>, SerializableContextual<Interceptor<?>, ?>> builder = InterceptionModelBuilder.newBuilderFor(getType(), (Class) SerializableContextual.class);
+         InterceptionModelBuilder<Class<?>, SerializableContextual<Interceptor<?>, ?>> builder =
+               InterceptionModelBuilder.newBuilderFor(getType(), (Class) SerializableContextual.class);
          Set<Annotation> classBindingAnnotations = flattenInterceptorBindings(manager, getAnnotatedItem().getAnnotations());
          for (Class<? extends Annotation> annotation : getStereotypes())
          {
@@ -422,11 +426,26 @@
          {
             if (Beans.findInterceptorBindingConflicts(manager, classBindingAnnotations))
                throw new DeploymentException("Conflicting interceptor bindings found on " + getType());
+
             Annotation[] classBindingAnnotationsArray = classBindingAnnotations.toArray(new Annotation[0]);
-            builder.interceptPostConstruct().with(toSerializableContextualArray(manager.resolveInterceptors(InterceptionType.POST_CONSTRUCT, classBindingAnnotationsArray)));
-            builder.interceptPreDestroy().with(toSerializableContextualArray(manager.resolveInterceptors(InterceptionType.PRE_DESTROY, classBindingAnnotationsArray)));
-            builder.interceptPrePassivate().with(toSerializableContextualArray(manager.resolveInterceptors(InterceptionType.PRE_PASSIVATE, classBindingAnnotationsArray)));
-            builder.interceptPostActivate().with(toSerializableContextualArray(manager.resolveInterceptors(InterceptionType.POST_ACTIVATE, classBindingAnnotationsArray)));
+
+            List<Interceptor<?>> resolvedPostConstructInterceptors = manager.resolveInterceptors(InterceptionType.POST_CONSTRUCT, classBindingAnnotationsArray);
+            validateSerializableInterceptors(resolvedPostConstructInterceptors);
+            builder.interceptPostConstruct().with(toSerializableContextualArray(resolvedPostConstructInterceptors));
+
+            List<Interceptor<?>> resolvedPreDestroyInterceptors = manager.resolveInterceptors(InterceptionType.PRE_DESTROY, classBindingAnnotationsArray);
+            validateSerializableInterceptors(resolvedPreDestroyInterceptors);
+            builder.interceptPreDestroy().with(toSerializableContextualArray(resolvedPreDestroyInterceptors));
+
+
+            List<Interceptor<?>> resolvedPrePassivateInterceptors = manager.resolveInterceptors(InterceptionType.PRE_PASSIVATE, classBindingAnnotationsArray);
+            validateSerializableInterceptors(resolvedPrePassivateInterceptors);
+            builder.interceptPrePassivate().with(toSerializableContextualArray(resolvedPrePassivateInterceptors));
+
+            List<Interceptor<?>> resolvedPostActivateInterceptors = manager.resolveInterceptors(InterceptionType.POST_ACTIVATE, classBindingAnnotationsArray);
+            validateSerializableInterceptors(resolvedPostActivateInterceptors);
+            builder.interceptPostActivate().with(toSerializableContextualArray(resolvedPostActivateInterceptors));
+
          }
          List<WeldMethod<?, ?>> businessMethods = Beans.getInterceptableBusinessMethods(getAnnotatedItem());
          for (WeldMethod<?, ?> method : businessMethods)
@@ -438,12 +457,33 @@
                if (Beans.findInterceptorBindingConflicts(manager, classBindingAnnotations))
                   throw new DeploymentException("Conflicting interceptor bindings found on " + getType() + "." + method.getName() + "()");
                List<Interceptor<?>> methodBoundInterceptors = manager.resolveInterceptors(InterceptionType.AROUND_INVOKE, methodBindingAnnotations.toArray(new Annotation[]{}));
+               validateSerializableInterceptors(methodBoundInterceptors);
                builder.interceptAroundInvoke(((AnnotatedMethod) method).getJavaMember()).with(toSerializableContextualArray(methodBoundInterceptors));
             }
          }
          manager.getBoundInterceptorsRegistry().registerInterceptionModel(getType(), builder.build());
       }
    }
+
+   private void validateSerializableInterceptors(Collection<Interceptor<?>> interceptors)
+   {
+      if (Beans.isPassivationCapableBean(this))
+      {
+         for (Interceptor<?> interceptor: interceptors)
+         {
+            if (!Reflections.isSerializable(interceptor.getBeanClass()))
+            {
+               throw new DeploymentException("The bean " + this + " declared a passivating scope, " +
+                     "but has a non-serializable interceptor: "  + interceptor);
+            }
+            for (InjectionPoint injectionPoint: interceptor.getInjectionPoints())
+            {
+               Bean<?> resolvedBean = manager.resolve(manager.getInjectableBeans(injectionPoint));
+               Beans.validateInjectionPointPassivationCapable(injectionPoint, resolvedBean, manager);
+            }
+         }
+      }
+   }
    
    public void setInjectionTarget(InjectionTarget<T> injectionTarget)
    {

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	2009-10-15 06:25:02 UTC (rev 4105)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java	2009-10-15 06:46:13 UTC (rev 4106)
@@ -28,6 +28,7 @@
 import javax.enterprise.inject.spi.Decorator;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.InjectionTarget;
+import javax.enterprise.inject.spi.Bean;
 
 import org.jboss.interceptor.model.InterceptionModelBuilder;
 import org.jboss.interceptor.model.InterceptorClassMetadataImpl;
@@ -418,7 +419,7 @@
       return !Beans.isInterceptor(getAnnotatedItem()) && !Beans.isDecorator(getAnnotatedItem());
    }
 
-   private boolean hasBoundInterceptors()
+   public boolean hasBoundInterceptors()
    {
       if (manager.getBoundInterceptorsRegistry().getInterceptionModel(getType()) != null)
          return manager.getBoundInterceptorsRegistry().getInterceptionModel(getType()).getAllInterceptors().size() > 0;
@@ -472,6 +473,10 @@
             Annotation interceptorsAnnotation = getType().getAnnotation(InterceptionUtils.getInterceptorsAnnotationClass());
             classDeclaredInterceptors = Reflections.extractValues(interceptorsAnnotation);
          }
+
+         validatePassivatingInterceptors(classDeclaredInterceptors);
+
+
          if (classDeclaredInterceptors != null)
          {
             builder.interceptPostConstruct().with(classDeclaredInterceptors);
@@ -489,6 +494,7 @@
             {
                methodDeclaredInterceptors = Reflections.extractValues(method.getAnnotation(InterceptionUtils.getInterceptorsAnnotationClass()));
             }
+            validatePassivatingInterceptors(methodDeclaredInterceptors);
             if (!excludeClassInterceptors && classDeclaredInterceptors != null)
             {
                builder.interceptAroundInvoke(((AnnotatedMethod) method).getJavaMember()).with(classDeclaredInterceptors);
@@ -504,4 +510,25 @@
       }
    }
 
+   private void validatePassivatingInterceptors(Class<?>[] classDeclaredInterceptors)
+   {
+      if (classDeclaredInterceptors != null && Beans.isPassivationCapableBean(this))
+      {
+         for (Class<?> interceptorClass: classDeclaredInterceptors)
+         {
+            if (!Reflections.isSerializable(interceptorClass))
+            {
+               throw new DeploymentException("The bean " + this + " declared a passivating scope, " +
+                     "but has a non-serializable interceptor class: " + interceptorClass.getName());
+            }
+            InjectionTarget<Object> injectionTarget = (InjectionTarget<Object>) manager.createInjectionTarget(manager.createAnnotatedType(interceptorClass));
+            for (InjectionPoint injectionPoint: injectionTarget.getInjectionPoints())
+            {
+               Bean<?> resolvedBean = manager.resolve(manager.getInjectableBeans(injectionPoint));
+               Beans.validateInjectionPointPassivationCapable(injectionPoint, resolvedBean, manager);
+            }
+         }
+      }
+   }
+
 }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java	2009-10-15 06:25:02 UTC (rev 4105)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java	2009-10-15 06:46:13 UTC (rev 4106)
@@ -34,17 +34,21 @@
 import javax.decorator.Decorator;
 import javax.enterprise.context.spi.Contextual;
 import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.context.Dependent;
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.CreationException;
 import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.IllegalProductException;
 import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
 import javax.inject.Inject;
 
 import org.jboss.interceptor.model.InterceptionType;
 import org.jboss.interceptor.model.InterceptionTypeRegistry;
 import org.jboss.weld.BeanManagerImpl;
 import org.jboss.weld.DefinitionException;
+import org.jboss.weld.UnserializableDependencyException;
 import org.jboss.weld.bean.AbstractProducerBean;
 import org.jboss.weld.bean.RIBean;
 import org.jboss.weld.bean.SessionBean;
@@ -128,6 +132,18 @@
       }
    }
 
+   public static void validateInjectionPointPassivationCapable(InjectionPoint ij, Bean<?> resolvedBean, BeanManagerImpl beanManager)
+   {
+      if (!ij.isTransient() && !Beans.isPassivationCapableBean(resolvedBean))
+      {
+         if (resolvedBean.getScope().equals(Dependent.class) && resolvedBean instanceof AbstractProducerBean<?, ?, ?>)
+         {
+            throw new IllegalProductException("The bean " + ij.getBean() + " declares a passivating scope but the producer returned a non-serializable bean for injection: " + resolvedBean);
+         }
+         throw new UnserializableDependencyException("The bean " + ij.getBean() + " declares a passivating scope but has non-serializable dependency: " + resolvedBean);
+      }
+   }
+
    /**
     * Indicates if a bean is proxyable
     * 

Added: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/Ball.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/Ball.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/Ball.java	2009-10-15 06:46:13 UTC (rev 4106)
@@ -0,0 +1,38 @@
+/*
+ * 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.weld.test.unit.interceptor.passivation.broken.interceptorWithNonSerializableField;
+
+import java.io.Serializable;
+
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+
+public class Ball implements Serializable
+{
+   public void shoot()
+   {
+   }
+
+   @Pass
+   public void pass()
+   {
+   }
+
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/Defender.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/Defender.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/Defender.java	2009-10-15 06:46:13 UTC (rev 4106)
@@ -0,0 +1,26 @@
+package org.jboss.weld.test.unit.interceptor.passivation.broken.interceptorWithNonSerializableField;
+
+import java.io.Serializable;
+
+import javax.interceptor.Interceptor;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+import javax.inject.Inject;
+
+/**
+ * @author Marius Bogoevici
+ */
+ at Interceptor @Pass
+public class Defender implements Serializable
+{
+
+   @Inject
+   Team team;
+
+   @AroundInvoke
+   public Object defend(InvocationContext invocationContext) throws Exception
+   {
+      return invocationContext.proceed();
+   }
+
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/InterceptorWithNonSerializableFieldOnPassivatingBean.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/InterceptorWithNonSerializableFieldOnPassivatingBean.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/InterceptorWithNonSerializableFieldOnPassivatingBean.java	2009-10-15 06:46:13 UTC (rev 4106)
@@ -0,0 +1,50 @@
+/*
+ * 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.weld.test.unit.interceptor.passivation.broken.interceptorWithNonSerializableField;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ByteArrayInputStream;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.jboss.weld.test.unit.interceptor.passivation.Ball;
+import org.jboss.weld.test.unit.interceptor.passivation.PassivationActivationInterceptor;
+import org.jboss.weld.DeploymentException;
+
+import org.testng.annotations.Test;
+
+/**
+ * @author Marius Bogoevici
+ */
+ at Artifact
+ at BeansXml("beans.xml")
+public class InterceptorWithNonSerializableFieldOnPassivatingBean extends AbstractWeldTest
+{
+   @Test
+   public void testNonPassivatingField() throws Exception
+   {
+      assert false;
+   }
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/Pass.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/Pass.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/Pass.java	2009-10-15 06:46:13 UTC (rev 4106)
@@ -0,0 +1,38 @@
+/*
+ * 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.weld.test.unit.interceptor.passivation.broken.interceptorWithNonSerializableField;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import javax.interceptor.InterceptorBinding;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at InterceptorBinding
+ at Retention(RUNTIME)
+ at Target({ElementType.METHOD, ElementType.TYPE})
+ at Documented
+public @interface Pass
+{
+
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/Team.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/Team.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/Team.java	2009-10-15 06:46:13 UTC (rev 4106)
@@ -0,0 +1,9 @@
+package org.jboss.weld.test.unit.interceptor.passivation.broken.interceptorWithNonSerializableField;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class Team
+{
+   
+}

Copied: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/Ball.java (from rev 4102, core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Ball.java)
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/Ball.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/Ball.java	2009-10-15 06:46:13 UTC (rev 4106)
@@ -0,0 +1,38 @@
+/*
+ * 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.weld.test.unit.interceptor.passivation.broken.nonSerializableInterceptor;
+
+import java.io.Serializable;
+
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+
+public class Ball implements Serializable
+{
+   public void shoot()
+   {
+   }
+
+   @Pass
+   public void pass()
+   {
+   }
+
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/Defender.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/Defender.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/Defender.java	2009-10-15 06:46:13 UTC (rev 4106)
@@ -0,0 +1,20 @@
+package org.jboss.weld.test.unit.interceptor.passivation.broken.nonSerializableInterceptor;
+
+import javax.interceptor.Interceptor;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+
+/**
+ * @author Marius Bogoevici
+ */
+ at Interceptor @Pass
+public class Defender
+{
+   @AroundInvoke
+   public Object defend(InvocationContext invocationContext) throws Exception
+   {
+      return invocationContext.proceed();
+   }
+   
+}

Copied: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/NonPassivatingInterceptorOnPassivatingBean.java (from rev 4102, core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/PassivationActivationTest.java)
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/NonPassivatingInterceptorOnPassivatingBean.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/NonPassivatingInterceptorOnPassivatingBean.java	2009-10-15 06:46:13 UTC (rev 4106)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.weld.test.unit.interceptor.passivation.broken.nonSerializableInterceptor;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ByteArrayInputStream;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.jboss.weld.test.unit.interceptor.passivation.Ball;
+import org.jboss.weld.test.unit.interceptor.passivation.PassivationActivationInterceptor;
+import org.jboss.weld.DeploymentException;
+
+import org.testng.annotations.Test;
+
+/**
+ * @author Marius Bogoevici
+ */
+ at Artifact
+ at BeansXml("beans.xml")
+ at ExpectedDeploymentException(DeploymentException.class)
+public class NonPassivatingInterceptorOnPassivatingBean extends AbstractWeldTest
+{
+   @Test
+   public void testNonPassivatingInterceptor() throws Exception
+   {
+      assert false;
+   }
+}
\ No newline at end of file

Copied: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/Pass.java (from rev 4102, core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Pass.java)
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/Pass.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/Pass.java	2009-10-15 06:46:13 UTC (rev 4106)
@@ -0,0 +1,38 @@
+/*
+ * 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.weld.test.unit.interceptor.passivation.broken.nonSerializableInterceptor;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import javax.interceptor.InterceptorBinding;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at InterceptorBinding
+ at Retention(RUNTIME)
+ at Target({ElementType.METHOD, ElementType.TYPE})
+ at Documented
+public @interface Pass
+{
+   
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/beans.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/beans.xml	                        (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/passivation/broken/interceptorWithNonSerializableField/beans.xml	2009-10-15 06:46:13 UTC (rev 4106)
@@ -0,0 +1,5 @@
+<beans>
+  <interceptors>
+    <class>org.jboss.weld.test.unit.interceptor.passivation.broken.interceptorWithNonSerializableField.Defender</class>
+  </interceptors>
+</beans>
\ No newline at end of file

Added: core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/beans.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/beans.xml	                        (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/passivation/broken/nonSerializableInterceptor/beans.xml	2009-10-15 06:46:13 UTC (rev 4106)
@@ -0,0 +1,5 @@
+<beans>
+  <interceptors>
+    <class>org.jboss.weld.test.unit.interceptor.passivation.broken.nonSerializableInterceptor.Defender</class>
+  </interceptors>
+</beans>
\ No newline at end of file



More information about the weld-commits mailing list