[weld-commits] Weld SVN: r6416 - in extensions/trunk/src: test/java/org/jboss/weld/extensions/test/managedproducer and 1 other directory.
weld-commits at lists.jboss.org
weld-commits at lists.jboss.org
Tue Jun 8 23:43:03 EDT 2010
Author: swd847
Date: 2010-06-08 23:43:02 -0400 (Tue, 08 Jun 2010)
New Revision: 6416
Added:
extensions/trunk/src/test/java/org/jboss/weld/extensions/test/managedproducer/Lion.java
extensions/trunk/src/test/java/org/jboss/weld/extensions/test/managedproducer/LionTamer.java
Modified:
extensions/trunk/src/main/java/org/jboss/weld/extensions/managedproducer/ManagedProducerBean.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/managedproducer/ManagedProducerExtension.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/managedproducer/ManagedProducerInvocationHandler.java
extensions/trunk/src/test/java/org/jboss/weld/extensions/test/managedproducer/ManagedProducerTest.java
Log:
some clean up
Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/managedproducer/ManagedProducerBean.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/managedproducer/ManagedProducerBean.java 2010-06-08 23:58:08 UTC (rev 6415)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/managedproducer/ManagedProducerBean.java 2010-06-09 03:43:02 UTC (rev 6416)
@@ -51,19 +51,19 @@
public class ManagedProducerBean<M> implements Bean<M>
{
- final Class<?> beanClass;
+ final private Class<?> beanClass;
- final String name;
+ final private String name;
- final Set<Annotation> qualifiers;
+ final private Set<Annotation> qualifiers;
- final Set<Type> types;
+ final private Set<Type> types;
- final Class<?> proxyClass;
+ final private Class<M> proxyClass;
- final BeanManager manager;
+ final private BeanManager manager;
- final AnnotatedMethod<?> method;
+ final private AnnotatedMethod<?> method;
public ManagedProducerBean(AnnotatedMethod<?> method, BeanManager manager)
{
@@ -200,10 +200,10 @@
Set<Bean<?>> beans = manager.getBeans(InjectionPoint.class, quals);
Bean<?> injectionPointBean = (Bean<?>) beans.iterator().next();
InjectionPoint injectionPoint = (InjectionPoint) manager.getReference(injectionPointBean, InjectionPoint.class, creationalContext);
- ManagedProducerInvocationHandler<?> hdl = new ManagedProducerInvocationHandler(manager, this.method, this, injectionPoint);
+ ManagedProducerInvocationHandler hdl = new ManagedProducerInvocationHandler(manager, this.method, this, injectionPoint);
try
{
- M obj = (M) proxyClass.newInstance();
+ M obj = proxyClass.newInstance();
((ProxyObject) obj).setHandler(hdl);
creationalContext.push(obj);
return obj;
Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/managedproducer/ManagedProducerExtension.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/managedproducer/ManagedProducerExtension.java 2010-06-08 23:58:08 UTC (rev 6415)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/managedproducer/ManagedProducerExtension.java 2010-06-09 03:43:02 UTC (rev 6416)
@@ -37,7 +37,7 @@
public class ManagedProducerExtension implements Extension
{
- Set<ManagedProducerBean<?>> beans = new HashSet<ManagedProducerBean<?>>();
+ final private Set<ManagedProducerBean<?>> beans = new HashSet<ManagedProducerBean<?>>();
public void processAnnotatedType(@Observes ProcessAnnotatedType<?> type, BeanManager manager)
{
@@ -46,8 +46,7 @@
if (m.isAnnotationPresent(ManagedProducer.class))
{
// we have a managed producer
- // lets make a not of it and register it later
-
+ // lets make a note of it and register it later
beans.add(new ManagedProducerBean(m, manager));
}
}
Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/managedproducer/ManagedProducerInvocationHandler.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/managedproducer/ManagedProducerInvocationHandler.java 2010-06-08 23:58:08 UTC (rev 6415)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/managedproducer/ManagedProducerInvocationHandler.java 2010-06-09 03:43:02 UTC (rev 6416)
@@ -37,17 +37,17 @@
import org.jboss.weld.extensions.bean.InjectionPointImpl;
-public class ManagedProducerInvocationHandler<T> implements MethodHandler
+public class ManagedProducerInvocationHandler implements MethodHandler
{
- final BeanManager manager;
- final AnnotatedMethod<?> annotatedMethod;
- final Method method;
- final Bean<?> bean;
- final InjectionPoint[] injectionPoints;
- final Map<Method, Method> methods = Collections.synchronizedMap(new HashMap<Method, Method>());
- final Bean<?> mainClassBean;
- final InjectionPoint injectionPoint;
+ final private BeanManager manager;
+ final private AnnotatedMethod<?> annotatedMethod;
+ final private Method method;
+ final private Bean<?> bean;
+ final private InjectionPoint[] injectionPoints;
+ final private Map<Method, Method> methods = Collections.synchronizedMap(new HashMap<Method, Method>());
+ final private Bean<?> mainClassBean;
+ final private InjectionPoint injectionPoint;
public ManagedProducerInvocationHandler(BeanManager manager, AnnotatedMethod<?> method, Bean<?> bean, InjectionPoint injectionPoint)
Added: extensions/trunk/src/test/java/org/jboss/weld/extensions/test/managedproducer/Lion.java
===================================================================
--- extensions/trunk/src/test/java/org/jboss/weld/extensions/test/managedproducer/Lion.java (rev 0)
+++ extensions/trunk/src/test/java/org/jboss/weld/extensions/test/managedproducer/Lion.java 2010-06-09 03:43:02 UTC (rev 6416)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.extensions.test.managedproducer;
+
+import org.jboss.weld.extensions.core.Veto;
+
+ at Veto
+public class Lion
+{
+ private final String name;
+
+ public Lion()
+ {
+ name = "default lion";
+ }
+
+ public Lion(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
Added: extensions/trunk/src/test/java/org/jboss/weld/extensions/test/managedproducer/LionTamer.java
===================================================================
--- extensions/trunk/src/test/java/org/jboss/weld/extensions/test/managedproducer/LionTamer.java (rev 0)
+++ extensions/trunk/src/test/java/org/jboss/weld/extensions/test/managedproducer/LionTamer.java 2010-06-09 03:43:02 UTC (rev 6416)
@@ -0,0 +1,43 @@
+package org.jboss.weld.extensions.test.managedproducer;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.jboss.weld.extensions.managedproducer.ManagedProducer;
+
+import com.google.inject.name.Named;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.
+ */
+ at ApplicationScoped
+public class LionTamer
+{
+
+ private Lion lion = new Lion("lion one");
+
+ public void changeLion()
+ {
+ lion = new Lion("lion two");
+ }
+
+ @ManagedProducer
+ @Named("lion")
+ public Lion produceLion()
+ {
+ return lion;
+ }
+
+}
Modified: extensions/trunk/src/test/java/org/jboss/weld/extensions/test/managedproducer/ManagedProducerTest.java
===================================================================
--- extensions/trunk/src/test/java/org/jboss/weld/extensions/test/managedproducer/ManagedProducerTest.java 2010-06-08 23:58:08 UTC (rev 6415)
+++ extensions/trunk/src/test/java/org/jboss/weld/extensions/test/managedproducer/ManagedProducerTest.java 2010-06-09 03:43:02 UTC (rev 6416)
@@ -24,10 +24,21 @@
public class ManagedProducerTest extends AbstractWeldTest
{
@Test
- public void testManagedProducers()
+ public void testManagedProducersInjectionPoint()
{
ManagedReciever bean = getReference(ManagedReciever.class);
assert bean.bean1.getValue().equals("bean1") : " value: " + bean.bean1.getValue();
assert bean.bean2.getValue().equals("bean2") : " value: " + bean.bean1.getValue();
}
+
+ @Test
+ public void testManagedProducers()
+ {
+ Lion lion = getReference(Lion.class);
+ LionTamer lionTamer = getReference(LionTamer.class);
+ assert lion.getName().equals("lion one");
+ lionTamer.changeLion();
+ assert lion.getName().equals("lion two");
+ }
+
}
More information about the weld-commits
mailing list