Author: marius.bogoevici
Date: 2009-10-12 13:34:43 -0400 (Mon, 12 Oct 2009)
New Revision: 3973
Added:
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/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTest.java
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ejb3InterceptionModelTest.java
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/
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/Defender.java
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Goalkeeper.java
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/PassivationActivation.java
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/PassivationActivationInterceptor.java
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/Shot.java
core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/passivation/
core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/passivation/beans.xml
Removed:
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorInterceptionHandlerFactory.java
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTests.java
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ejb3InterceptionModelTests.java
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.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/bean/SessionBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorBindingsAdapter.java
core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstance.java
core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ball.java
Log:
Add serialization capability and passivation/activation interception.
Modified: core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java 2009-10-12 17:29:09
UTC (rev 3972)
+++ core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java 2009-10-12 17:34:43
UTC (rev 3973)
@@ -64,6 +64,7 @@
import org.jboss.weld.bootstrap.api.ServiceRegistry;
import org.jboss.weld.context.CreationalContextImpl;
import org.jboss.weld.context.WeldCreationalContext;
+import org.jboss.weld.context.SerializableContextual;
import org.jboss.weld.ejb.EjbDescriptors;
import org.jboss.weld.ejb.spi.EjbDescriptor;
import org.jboss.weld.el.Namespace;
@@ -261,7 +262,7 @@
/**
* Interception model
*/
- private transient final InterceptorRegistry<Class<?>,
Interceptor<?>> boundInterceptorsRegistry = new
InterceptorRegistry<Class<?>, Interceptor<?>>();
+ private transient final InterceptorRegistry<Class<?>,
SerializableContextual<Interceptor<?>, ?>> boundInterceptorsRegistry = new
InterceptorRegistry<Class<?>,
SerializableContextual<Interceptor<?>,?>>();
private transient final InterceptorRegistry<Class<?>, Class<?>>
declaredInterceptorsRegistry = new InterceptorRegistry<Class<?>,
Class<?>>();
/**
@@ -1389,7 +1390,7 @@
this.currentInjectionPoint.remove();
}
- public InterceptorRegistry<Class<?>, Interceptor<?>>
getBoundInterceptorsRegistry()
+ public InterceptorRegistry<Class<?>,
SerializableContextual<Interceptor<?>, ?>> getBoundInterceptorsRegistry()
{
return boundInterceptorsRegistry;
}
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-12
17:29:09 UTC (rev 3972)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -45,6 +45,7 @@
import org.jboss.weld.bean.proxy.DecoratorProxyMethodHandler;
import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
import org.jboss.weld.context.SerializableContextualInstance;
+import org.jboss.weld.context.SerializableContextual;
import org.jboss.weld.injection.FieldInjectionPoint;
import org.jboss.weld.injection.MethodInjectionPoint;
import org.jboss.weld.introspector.WeldClass;
@@ -408,7 +409,7 @@
{
if (manager.getBoundInterceptorsRegistry().getInterceptionModel(getType()) ==
null)
{
- InterceptionModelBuilder<Class<?>, Interceptor<?>> builder =
InterceptionModelBuilder.newBuilderFor(getType(), (Class) Interceptor.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())
@@ -416,8 +417,11 @@
classBindingAnnotations.addAll(flattenInterceptorBindings(manager,
manager.getStereotypeDefinition(annotation)));
}
-
builder.interceptPostConstruct().with(manager.resolveInterceptors(InterceptionType.POST_CONSTRUCT,
classBindingAnnotations.toArray(new Annotation[0])).toArray(new
Interceptor<?>[]{}));
-
builder.interceptPreDestroy().with(manager.resolveInterceptors(InterceptionType.PRE_DESTROY,
classBindingAnnotations.toArray(new Annotation[0])).toArray(new
Interceptor<?>[]{}));
+ 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<WeldMethod<?, ?>> businessMethods =
Beans.getInterceptableBusinessMethods(getAnnotatedItem());
for (WeldMethod<?, ?> method : businessMethods)
@@ -425,7 +429,7 @@
List<Annotation> methodBindingAnnotations = new
ArrayList<Annotation>(classBindingAnnotations);
methodBindingAnnotations.addAll(flattenInterceptorBindings(manager,
method.getAnnotations()));
List<Interceptor<?>> methodBoundInterceptors =
manager.resolveInterceptors(InterceptionType.AROUND_INVOKE,
methodBindingAnnotations.toArray(new Annotation[]{}));
- builder.interceptAroundInvoke(((AnnotatedMethod)
method).getJavaMember()).with(methodBoundInterceptors.toArray(new Interceptor[]{}));
+ builder.interceptAroundInvoke(((AnnotatedMethod)
method).getJavaMember()).with(toSerializableContextualArray(methodBoundInterceptors));
}
manager.getBoundInterceptorsRegistry().registerInterceptionModel(getType(),
builder.build());
}
@@ -479,5 +483,15 @@
}
}
}
-
+
+ private static SerializableContextual[]
toSerializableContextualArray(List<Interceptor<?>> interceptors)
+ {
+ List<SerializableContextual> serializableContextuals = new
ArrayList<SerializableContextual>();
+ for (Interceptor<?> interceptor: interceptors)
+ {
+ serializableContextuals.add(new SerializableContextual(interceptor));
+ }
+ return serializableContextuals.toArray(new SerializableContextual[]{});
+ }
+
}
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-12 17:29:09
UTC (rev 3972)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java 2009-10-12 17:34:43
UTC (rev 3973)
@@ -30,6 +30,8 @@
import javax.enterprise.inject.spi.InjectionTarget;
import org.jboss.interceptor.model.InterceptionModelBuilder;
+import org.jboss.interceptor.model.InterceptorClassMetadataImpl;
+import org.jboss.interceptor.model.InterceptionModel;
import org.jboss.interceptor.proxy.InterceptionHandlerFactory;
import org.jboss.interceptor.proxy.InterceptorProxyCreatorImpl;
import org.jboss.interceptor.registry.InterceptorRegistry;
@@ -38,7 +40,7 @@
import org.jboss.weld.DefinitionException;
import org.jboss.weld.DeploymentException;
import org.jboss.weld.bean.interceptor.ClassInterceptionHandlerFactory;
-import org.jboss.weld.bean.interceptor.InterceptorInterceptionHandlerFactory;
+import org.jboss.weld.bean.interceptor.CdiInterceptorHandlerFactory;
import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
import org.jboss.weld.injection.ConstructorInjectionPoint;
import org.jboss.weld.injection.InjectionContextImpl;
@@ -443,7 +445,7 @@
if (hasBoundInterceptors())
{
interceptionRegistries.add(manager.getBoundInterceptorsRegistry());
- interceptionHandlerFactories.add(new
InterceptorInterceptionHandlerFactory(creationalContext, manager));
+ interceptionHandlerFactories.add(new
CdiInterceptorHandlerFactory(creationalContext, manager));
}
if (interceptionRegistries.size() > 0)
instance = new InterceptorProxyCreatorImpl(interceptionRegistries,
interceptionHandlerFactories).createProxyFromInstance(instance, getType());
@@ -471,6 +473,8 @@
{
builder.interceptPostConstruct().with(classDeclaredInterceptors);
builder.interceptPreDestroy().with(classDeclaredInterceptors);
+ builder.interceptPrePassivate().with(classDeclaredInterceptors);
+ builder.interceptPostActivate().with(classDeclaredInterceptors);
}
List<WeldMethod<?, ?>> businessMethods =
Beans.getInterceptableBusinessMethods(getAnnotatedItem());
@@ -491,7 +495,9 @@
builder.interceptAroundInvoke(((AnnotatedMethod)
method).getJavaMember()).with(methodDeclaredInterceptors);
}
}
- manager.getDeclaredInterceptorsRegistry().registerInterceptionModel(getType(),
builder.build());
+ InterceptionModel<Class<?>, Class<?>> interceptionModel =
builder.build();
+ if (interceptionModel.getAllInterceptors().size() > 0 || new
InterceptorClassMetadataImpl(getType()).isInterceptor())
+
manager.getDeclaredInterceptorsRegistry().registerInterceptionModel(getType(),
builder.build());
}
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java 2009-10-12 17:29:09
UTC (rev 3972)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java 2009-10-12 17:34:43
UTC (rev 3973)
@@ -40,6 +40,7 @@
import org.jboss.interceptor.model.InterceptionModel;
import org.jboss.weld.BeanManagerImpl;
import org.jboss.weld.DefinitionException;
+import org.jboss.weld.context.SerializableContextual;
import org.jboss.weld.bean.interceptor.InterceptorBindingsAdapter;
import org.jboss.weld.bean.proxy.EnterpriseBeanInstance;
import org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler;
@@ -421,7 +422,7 @@
private void registerInterceptors()
{
-
InterceptionModel<Class<?>,javax.enterprise.inject.spi.Interceptor<?>>
model =
manager.getBoundInterceptorsRegistry().getInterceptionModel(ejbDescriptor.getBeanClass());
+ InterceptionModel<Class<?>,
SerializableContextual<javax.enterprise.inject.spi.Interceptor<?>, ?>>
model =
manager.getBoundInterceptorsRegistry().getInterceptionModel(ejbDescriptor.getBeanClass());
if (model != null)
getManager().getServices().get(EjbServices.class).registerInterceptors(getEjbDescriptor(),
new InterceptorBindingsAdapter(model));
}
Added:
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
(rev 0)
+++
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -0,0 +1,28 @@
+package org.jboss.weld.bean.interceptor;
+
+import java.io.Serializable;
+
+import javax.enterprise.inject.spi.Interceptor;
+
+import org.jboss.interceptor.proxy.AbstractClassInterceptionHandler;
+import org.jboss.weld.context.SerializableContextualInstance;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class CdiInterceptorHandler extends AbstractClassInterceptionHandler implements
Serializable
+{
+
+ private final SerializableContextualInstance<Interceptor<Object>, Object>
serializableContextualInstance;
+
+ public
CdiInterceptorHandler(SerializableContextualInstance<Interceptor<Object>,
Object> serializableContextualInstance, Class<?> clazz)
+ {
+ super(clazz);
+ this.serializableContextualInstance = serializableContextualInstance;
+ }
+
+ public Object getInterceptorInstance()
+ {
+ return serializableContextualInstance.getInstance();
+ }
+}
Copied:
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java
(from rev 3961,
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorInterceptionHandlerFactory.java)
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java
(rev 0)
+++
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -0,0 +1,55 @@
+/*
+ * 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.bean.interceptor;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Interceptor;
+
+import org.jboss.interceptor.proxy.InterceptionHandler;
+import org.jboss.interceptor.proxy.InterceptionHandlerFactory;
+import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.context.SerializableContextualInstance;
+import org.jboss.weld.context.SerializableContextual;
+
+/**
+ * @author Marius Bogoevici
+*/
+public class CdiInterceptorHandlerFactory implements
InterceptionHandlerFactory<SerializableContextual<Interceptor<Object>,
Object>>
+{
+ private final CreationalContext creationalContext;
+ private BeanManagerImpl manager;
+
+ public CdiInterceptorHandlerFactory(CreationalContext creationalContext,
BeanManagerImpl manager)
+ {
+ this.creationalContext = creationalContext;
+ this.manager = manager;
+ }
+
+ public BeanManagerImpl getManager()
+ {
+ return manager;
+ }
+
+ public InterceptionHandler createFor(final
SerializableContextual<Interceptor<Object>, Object> serializableContextual)
+ {
+ Object instance = getManager().getReference(serializableContextual.get(),
creationalContext);
+ return new CdiInterceptorHandler(new
SerializableContextualInstance<Interceptor<Object>,
Object>(serializableContextual, instance, creationalContext),
+ serializableContextual.get().getBeanClass());
+ }
+
+}
Property changes on:
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorBindingsAdapter.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorBindingsAdapter.java 2009-10-12
17:29:09 UTC (rev 3972)
+++
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorBindingsAdapter.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -23,12 +23,14 @@
import java.util.HashSet;
import java.util.Collections;
import java.util.Arrays;
+import java.util.ArrayList;
import java.lang.reflect.Method;
import javax.enterprise.inject.spi.Interceptor;
import javax.enterprise.inject.spi.InterceptionType;
import org.jboss.weld.ejb.spi.InterceptorBindings;
+import org.jboss.weld.context.SerializableContextual;
import org.jboss.interceptor.model.InterceptionModel;
/**
@@ -37,9 +39,9 @@
public class InterceptorBindingsAdapter implements InterceptorBindings
{
- private InterceptionModel<Class<?>, Interceptor<?>>
interceptionModel;
+ private InterceptionModel<Class<?>,
SerializableContextual<Interceptor<?>, ?>> interceptionModel;
- public InterceptorBindingsAdapter(InterceptionModel<Class<?>,
Interceptor<?>> interceptionModel)
+ public InterceptorBindingsAdapter(InterceptionModel<Class<?>,
SerializableContextual<Interceptor<?>, ?>> interceptionModel)
{
if (interceptionModel == null)
{
@@ -50,7 +52,8 @@
public Collection<Interceptor<?>> getAllInterceptors()
{
- return interceptionModel.getAllInterceptors();
+ Collection<SerializableContextual<Interceptor<?>, ?>>
contextualSet = interceptionModel.getAllInterceptors();
+ return toInterceptorList(contextualSet);
}
public List<Interceptor<?>> getMethodInterceptors(InterceptionType
interceptionType, Method method)
@@ -72,7 +75,7 @@
throw new IllegalArgumentException("Interception type must not be
lifecycle, but it is " + interceptionType.name());
}
- return interceptionModel.getInterceptors(internalInterceptionType, method);
+ return
toInterceptorList(interceptionModel.getInterceptors(internalInterceptionType, method));
}
@@ -90,6 +93,17 @@
throw new IllegalArgumentException("Interception type must be lifecycle,
but it is " + interceptionType.name());
}
- return interceptionModel.getInterceptors(internalInterceptionType, null);
+ return
toInterceptorList(interceptionModel.getInterceptors(internalInterceptionType, null));
}
+
+ private List<Interceptor<?>>
toInterceptorList(Collection<SerializableContextual<Interceptor<?>, ?>>
contextualSet)
+ {
+ ArrayList<Interceptor<?>> interceptors = new
ArrayList<Interceptor<?>>();
+ for (SerializableContextual<Interceptor<?>, ?> serializableContextual :
contextualSet)
+ {
+ interceptors.add(serializableContextual.get());
+ }
+ return interceptors;
+ }
+
}
Deleted:
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorInterceptionHandlerFactory.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorInterceptionHandlerFactory.java 2009-10-12
17:29:09 UTC (rev 3972)
+++
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorInterceptionHandlerFactory.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -1,53 +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.weld.bean.interceptor;
-
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.Interceptor;
-
-import org.jboss.interceptor.proxy.DirectClassInterceptionHandler;
-import org.jboss.interceptor.proxy.InterceptionHandler;
-import org.jboss.interceptor.proxy.InterceptionHandlerFactory;
-import org.jboss.weld.BeanManagerImpl;
-
-/**
- * @author Marius Bogoevici
-*/
-public class InterceptorInterceptionHandlerFactory implements
InterceptionHandlerFactory<Interceptor<?>>
-{
- private final CreationalContext creationalContext;
- private BeanManagerImpl manager;
-
- public InterceptorInterceptionHandlerFactory(CreationalContext creationalContext,
BeanManagerImpl manager)
- {
- this.creationalContext = creationalContext;
- this.manager = manager;
- }
-
- public BeanManagerImpl getManager()
- {
- return manager;
- }
-
- public InterceptionHandler createFor(final Interceptor interceptor)
- {
- Object instance = getManager().getReference(interceptor, creationalContext);
- return new DirectClassInterceptionHandler(instance, interceptor.getBeanClass());
- }
-
-}
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstance.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstance.java 2009-10-12
17:29:09 UTC (rev 3972)
+++
core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstance.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -39,6 +39,13 @@
this.creationalContext = creationalContext;
}
+ public SerializableContextualInstance(SerializableContextual<C, I> contextual, I
instance, CreationalContext<I> creationalContext)
+ {
+ this.contextual = contextual;
+ this.instance = instance;
+ this.creationalContext = creationalContext;
+ }
+
public SerializableContextual<C, I> getContextual()
{
return contextual;
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-12 17:29:09 UTC
(rev 3972)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java 2009-10-12 17:34:43 UTC
(rev 3973)
@@ -234,10 +234,7 @@
boolean businessMethod = !annotatedMethod.isStatic()
&& (Modifier.isPublic(modifiers)
|| Modifier.isProtected(modifiers))
- && !annotatedMethod.isAnnotationPresent(Inject.class)
- && !annotatedMethod.isAnnotationPresent(Produces.class)
- &&
annotatedMethod.getAnnotatedWBParameters(Disposes.class).isEmpty()
- &&
annotatedMethod.getAnnotatedWBParameters(Observes.class).isEmpty();
+ && !annotatedMethod.isAnnotationPresent(Inject.class);
if (businessMethod)
{
Copied:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTest.java
(from rev 3961,
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTests.java)
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTest.java
(rev 0)
+++
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTest.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -0,0 +1,49 @@
+package org.jboss.weld.test.unit.interceptor.ejb;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Arrays;
+
+
+import javax.enterprise.inject.spi.InterceptionType;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.jboss.weld.bean.SessionBean;
+import org.jboss.weld.bean.interceptor.InterceptorBindingsAdapter;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.jboss.weld.ejb.spi.InterceptorBindings;
+
+import org.testng.annotations.Test;
+
+@Artifact
+(a)Packaging(PackagingType.EAR)
+(a)BeansXml("beans.xml")
+public class EnterpriseBeanInterceptionTest extends AbstractWeldTest
+{
+
+ @Test(groups = { "interceptors"})
+ public void testEnterpriseBeanInterceptionMetadataAdded() throws Exception
+ {
+ SessionBean<Ball> ballSessionBean =
(SessionBean<Ball>)getCurrentManager().getBeans(Ball.class).iterator().next();
+ InterceptorBindings interceptorBindings = new
InterceptorBindingsAdapter(getCurrentManager().getBoundInterceptorsRegistry().getInterceptionModel(ballSessionBean.getType()));
+ List<javax.enterprise.inject.spi.Interceptor> interceptors =
+ new
ArrayList<javax.enterprise.inject.spi.Interceptor>(interceptorBindings.getAllInterceptors());
+
+ assert interceptors.size() == 2;
+ List<Class<?>> expectedInterceptors =
Arrays.<Class<?>>asList(Goalkeeper.class, Defender.class);
+ assert expectedInterceptors.contains(interceptors.get(0).getBeanClass());
+ assert expectedInterceptors.contains(interceptors.get(1).getBeanClass());
+
+
+ assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE,
ballSessionBean.getType().getMethod("shoot")).size() == 1;
+ assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE,
ballSessionBean.getType().getMethod("shoot")).get(0).getBeanClass().equals(Goalkeeper.class);
+
+ assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE,
ballSessionBean.getType().getMethod("pass")).size() == 1;
+ assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE,
ballSessionBean.getType().getMethod("pass")).get(0).getBeanClass().equals(Defender.class);
+
+ }
+
+}
Property changes on:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTests.java
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTests.java 2009-10-12
17:29:09 UTC (rev 3972)
+++
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTests.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -1,45 +0,0 @@
-package org.jboss.weld.test.unit.interceptor.ejb;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.enterprise.inject.spi.Interceptor;
-
-import org.jboss.interceptor.model.InterceptionModel;
-import static org.jboss.interceptor.model.InterceptionType.AROUND_INVOKE;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.Packaging;
-import org.jboss.testharness.impl.packaging.PackagingType;
-import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
-import org.jboss.weld.bean.SessionBean;
-import org.jboss.weld.test.AbstractWeldTest;
-
-import org.testng.annotations.Test;
-
-@Artifact
-(a)Packaging(PackagingType.EAR)
-(a)BeansXml("beans.xml")
-public class EnterpriseBeanInterceptionTests extends AbstractWeldTest
-{
-
- @Test(groups = { "interceptors"})
- public void testEnterpriseBeanInterceptionMetadataAdded() throws Exception
- {
- SessionBean<Ball> ballSessionBean =
(SessionBean<Ball>)getCurrentManager().getBeans(Ball.class).iterator().next();
- InterceptionModel<Class<?>, Interceptor<?>> interceptionModel =
getCurrentManager().getBoundInterceptorsRegistry().getInterceptionModel(ballSessionBean.getType());
- List<javax.enterprise.inject.spi.Interceptor> interceptors =
- new
ArrayList<javax.enterprise.inject.spi.Interceptor>(interceptionModel.getAllInterceptors());
-
- assert interceptors.size() == 2;
- assert interceptors.get(0).getBeanClass().equals(Goalkeeper.class);
- assert interceptors.get(1).getBeanClass().equals(Defender.class);
-
- assert interceptionModel.getInterceptors(AROUND_INVOKE,
ballSessionBean.getType().getMethod("shoot")).size() == 1;
- assert interceptionModel.getInterceptors(AROUND_INVOKE,
ballSessionBean.getType().getMethod("shoot")).get(0).getBeanClass().equals(Goalkeeper.class);
-
- assert interceptionModel.getInterceptors(AROUND_INVOKE,
ballSessionBean.getType().getMethod("pass")).size() == 1;
- assert interceptionModel.getInterceptors(AROUND_INVOKE,
ballSessionBean.getType().getMethod("pass")).get(0).getBeanClass().equals(Defender.class);
-
- }
-
-}
Modified:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ball.java
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ball.java 2009-10-12
17:29:09 UTC (rev 3972)
+++
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ball.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -19,6 +19,8 @@
import javax.interceptor.Interceptors;
import javax.interceptor.ExcludeClassInterceptors;
+import javax.interceptor.InvocationContext;
+import javax.interceptor.AroundInvoke;
/**
* @author Marius Bogoevici
@@ -27,6 +29,8 @@
public class Ball
{
public static boolean played = false;
+
+ public static boolean aroundInvoke = false;
@ExcludeClassInterceptors
@Interceptors(Defender.class)
@@ -45,4 +49,11 @@
{
played = true;
}
+
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext invocationContext) throws Exception
+ {
+ aroundInvoke = true;
+ return invocationContext.proceed();
+ }
}
Copied:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ejb3InterceptionModelTest.java
(from rev 3961,
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ejb3InterceptionModelTests.java)
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ejb3InterceptionModelTest.java
(rev 0)
+++
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ejb3InterceptionModelTest.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -0,0 +1,86 @@
+/*
+ * 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.ejb3model;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.weld.test.AbstractWeldTest;
+
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.BeforeMethod;
+
+
+/**
+ * @author Marius Bogoevici
+ */
+@Artifact
+public class Ejb3InterceptionModelTest extends AbstractWeldTest
+{
+ @BeforeMethod
+ public void reset()
+ {
+ Ball.played = false;
+ Goalkeeper.caught = false;
+ Defender.defended = false;
+ Ball.aroundInvoke = false;
+ }
+
+ @Test
+ public void testSimpleInterceptor()
+ {
+ Bean bean = getCurrentManager().getBeans(Ball.class).iterator().next();
+ CreationalContext creationalContext =
getCurrentManager().createCreationalContext(bean);
+ Ball ball = (Ball) bean.create(creationalContext);
+ ball.shoot();
+ assert Defender.defended;
+ assert Ball.played;
+ assert !Goalkeeper.caught;
+ assert Ball.aroundInvoke;
+ }
+
+
+ @Test
+ public void testSimpleInterceptor2()
+ {
+ Bean bean = getCurrentManager().getBeans(Ball.class).iterator().next();
+ CreationalContext creationalContext =
getCurrentManager().createCreationalContext(bean);
+ Ball ball = (Ball) bean.create(creationalContext);
+ ball.pass();
+ assert Defender.defended;
+ assert Ball.played;
+ assert Goalkeeper.caught;
+ assert Ball.aroundInvoke;
+ }
+
+ @Test
+ public void testSimpleInterceptor3()
+ {
+ Bean bean = getCurrentManager().getBeans(Ball.class).iterator().next();
+ CreationalContext creationalContext =
getCurrentManager().createCreationalContext(bean);
+ Ball ball = (Ball) bean.create(creationalContext);
+ ball.lob();
+ assert !Defender.defended;
+ assert Ball.played;
+ assert Goalkeeper.caught;
+ assert Ball.aroundInvoke;
+ }
+
+}
Property changes on:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ejb3InterceptionModelTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ejb3InterceptionModelTests.java
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ejb3InterceptionModelTests.java 2009-10-12
17:29:09 UTC (rev 3972)
+++
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ejb3InterceptionModelTests.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -1,82 +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.weld.test.unit.interceptor.ejb3model;
-
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.context.spi.CreationalContext;
-
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.weld.test.AbstractWeldTest;
-
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.BeforeMethod;
-
-
-/**
- * @author Marius Bogoevici
- */
-@Artifact
-public class Ejb3InterceptionModelTests extends AbstractWeldTest
-{
- @BeforeMethod
- public void reset()
- {
- Ball.played = false;
- Goalkeeper.caught = false;
- Defender.defended = false;
- }
-
- @Test
- public void testSimpleInterceptor()
- {
- Bean bean = getCurrentManager().getBeans(Ball.class).iterator().next();
- CreationalContext creationalContext =
getCurrentManager().createCreationalContext(bean);
- Ball ball = (Ball) bean.create(creationalContext);
- ball.shoot();
- assert Defender.defended;
- assert Ball.played;
- assert !Goalkeeper.caught;
- }
-
-
- @Test
- public void testSimpleInterceptor2()
- {
- Bean bean = getCurrentManager().getBeans(Ball.class).iterator().next();
- CreationalContext creationalContext =
getCurrentManager().createCreationalContext(bean);
- Ball ball = (Ball) bean.create(creationalContext);
- ball.pass();
- assert Defender.defended;
- assert Ball.played;
- assert Goalkeeper.caught;
- }
-
- @Test
- public void testSimpleInterceptor3()
- {
- Bean bean = getCurrentManager().getBeans(Ball.class).iterator().next();
- CreationalContext creationalContext =
getCurrentManager().createCreationalContext(bean);
- Ball ball = (Ball) bean.create(creationalContext);
- ball.lob();
- assert !Defender.defended;
- assert Ball.played;
- assert Goalkeeper.caught;
- }
-
-}
Copied:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Ball.java
(from rev 3922,
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/BallImpl.java)
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Ball.java
(rev 0)
+++
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Ball.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -0,0 +1,39 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:mariusb@redhat.com">Marius
Bogoevici</a>
+ */
+
+@PassivationActivation
+public class Ball implements Serializable
+{
+ @Shot
+ public void shoot()
+ {
+ }
+
+ @Pass
+ public void pass()
+ {
+ }
+
+}
\ No newline at end of file
Property changes on:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Ball.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Defender.java
(from rev 3922,
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/Defender.java)
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Defender.java
(rev 0)
+++
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Defender.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.weld.test.unit.interceptor.passivation;
+
+import java.io.Serializable;
+
+import javax.interceptor.Interceptor;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+import org.jboss.weld.test.unit.interceptor.ejb.*;
+import org.jboss.weld.test.unit.interceptor.ejb.Pass;
+
+/**
+ * @author <a href="mailto:mariusb@redhat.com">Marius
Bogoevici</a>
+ */
+@Pass
+@Interceptor
+public class Defender implements Serializable
+{
+ @AroundInvoke
+ public Object defend(InvocationContext context) throws Exception
+ {
+ return context.proceed();
+ }
+}
\ No newline at end of file
Copied:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Goalkeeper.java
(from rev 3922,
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/Goalkeeper.java)
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Goalkeeper.java
(rev 0)
+++
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Goalkeeper.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -0,0 +1,42 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+
+import javax.interceptor.Interceptor;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+import org.jboss.weld.test.unit.interceptor.ejb.*;
+import org.jboss.weld.test.unit.interceptor.ejb.Shot;
+
+/**
+ * @author <a href="mailto:mariusb@redhat.com">Marius
Bogoevici</a>
+ */
+@Shot
+@Interceptor
+public class Goalkeeper implements Serializable
+{
+
+ @AroundInvoke
+ public Object catchBall(InvocationContext invocationContext) throws Exception
+ {
+ return invocationContext.proceed();
+ }
+}
\ No newline at end of file
Copied:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Pass.java
(from rev 3922,
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/Pass.java)
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Pass.java
(rev 0)
+++
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Pass.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+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@redhat.com">Marius
Bogoevici</a>
+ */
+@InterceptorBinding
+@Retention(RUNTIME)
+(a)Target({ElementType.METHOD, ElementType.TYPE})
+@Documented
+public @interface Pass
+{
+}
\ No newline at end of file
Added:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/PassivationActivation.java
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/PassivationActivation.java
(rev 0)
+++
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/PassivationActivation.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+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 Marius Bogoevici
+ */
+@InterceptorBinding
+@Retention(RUNTIME)
+(a)Target({ElementType.TYPE})
+@Documented
+public @interface PassivationActivation
+{
+}
Added:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/PassivationActivationInterceptor.java
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/PassivationActivationInterceptor.java
(rev 0)
+++
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/PassivationActivationInterceptor.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -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;
+
+import java.io.Serializable;
+
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+import javax.ejb.PrePassivate;
+import javax.ejb.PostActivate;
+
+/**
+ * @author Marius Bogoevici
+ */
+@Interceptor @PassivationActivation
+public class PassivationActivationInterceptor implements Serializable
+{
+ public static boolean prePassivateInvoked;
+ public static boolean postActivateInvoked;
+
+ @PrePassivate
+ public void prePassivate(InvocationContext invocationContext) throws Exception
+ {
+ prePassivateInvoked = true;
+ invocationContext.proceed();
+ }
+
+
+ @PostActivate
+ public void postActivate(InvocationContext invocationContext) throws Exception
+ {
+ postActivateInvoked = true;
+ invocationContext.proceed();
+ }
+
+}
Added:
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/PassivationActivationTest.java
(rev 0)
+++
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/PassivationActivationTest.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+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.jsr299.BeansXml;
+import org.jboss.weld.test.AbstractWeldTest;
+
+import org.testng.annotations.Test;
+
+/**
+ * @author Marius Bogoevici
+ */
+@Artifact
+(a)BeansXml("beans.xml")
+public class PassivationActivationTest extends AbstractWeldTest
+{
+
+ @Test
+ public void testPassivationAndActivation() throws Exception
+ {
+ Bean bean = getCurrentManager().getBeans(Ball.class).iterator().next();
+ CreationalContext creationalContext =
getCurrentManager().createCreationalContext(bean);
+ Ball ball = (Ball) bean.create(creationalContext);
+
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ new ObjectOutputStream(byteArrayOutputStream).writeObject(ball);
+
+ assert PassivationActivationInterceptor.prePassivateInvoked;
+ assert !PassivationActivationInterceptor.postActivateInvoked;
+
+ PassivationActivationInterceptor.prePassivateInvoked = false;
+ PassivationActivationInterceptor.postActivateInvoked = false;
+
+ ball = (Ball)new ObjectInputStream(new
ByteArrayInputStream(byteArrayOutputStream.toByteArray())).readObject();
+
+ assert !PassivationActivationInterceptor.prePassivateInvoked;
+ assert PassivationActivationInterceptor.postActivateInvoked;
+
+ }
+}
Copied:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Shot.java
(from rev 3922,
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/Shot.java)
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Shot.java
(rev 0)
+++
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/passivation/Shot.java 2009-10-12
17:34:43 UTC (rev 3973)
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+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@redhat.com">Marius
Bogoevici</a>
+ */
+@InterceptorBinding
+@Retention(RUNTIME)
+(a)Target({ElementType.METHOD, ElementType.TYPE})
+@Documented
+public @interface Shot
+{
+}
\ No newline at end of file
Copied:
core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/passivation/beans.xml
(from rev 3922,
core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/ejb/beans.xml)
===================================================================
---
core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/passivation/beans.xml
(rev 0)
+++
core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/passivation/beans.xml 2009-10-12
17:34:43 UTC (rev 3973)
@@ -0,0 +1,7 @@
+<beans>
+ <interceptors>
+
<class>org.jboss.weld.test.unit.interceptor.passivation.Goalkeeper</class>
+ <class>org.jboss.weld.test.unit.interceptor.passivation.Defender</class>
+
<class>org.jboss.weld.test.unit.interceptor.passivation.PassivationActivationInterceptor</class>
+ </interceptors>
+</beans>