Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor to remove *Model and *Constructor and xmlAnnotatedItem, part 2
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@285 1c488680-804c-0410-94cd-c6b725194a0e
- Loading branch information
Showing
4 changed files
with
51 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 38 additions & 38 deletions
76
webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockObserverImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
package org.jboss.webbeans.test.mock; | ||
|
||
import org.jboss.webbeans.event.ObserverImpl; | ||
import org.jboss.webbeans.injectable.InjectableMethod; | ||
import org.jboss.webbeans.model.bean.BeanModel; | ||
|
||
/** | ||
* An implementation used for unit testing only. | ||
* @author David Allen | ||
* | ||
*/ | ||
public class MockObserverImpl<T> extends ObserverImpl<T> { | ||
|
||
private Object specializedInstance; | ||
|
||
public MockObserverImpl(BeanModel<?, ?> beanModel, | ||
InjectableMethod<Object> observer, Class<T> eventType) | ||
{ | ||
super(beanModel, observer, eventType); | ||
} | ||
|
||
@Override | ||
protected final Object getInstance() { | ||
return specializedInstance; | ||
} | ||
|
||
/** | ||
* The most specialized instance of this observer type. | ||
* @param instance The instance to use for testing | ||
*/ | ||
public final void setInstance(Object instance) | ||
{ | ||
specializedInstance = instance; | ||
} | ||
|
||
} | ||
package org.jboss.webbeans.test.mock; | ||
|
||
import org.jboss.webbeans.bean.EventBean; | ||
import org.jboss.webbeans.event.ObserverImpl; | ||
import org.jboss.webbeans.introspector.impl.InjectableMethod; | ||
|
||
/** | ||
* An implementation used for unit testing only. | ||
* @author David Allen | ||
* | ||
*/ | ||
public class MockObserverImpl<T> extends ObserverImpl<T> { | ||
|
||
private Object specializedInstance; | ||
|
||
public MockObserverImpl(EventBean<T> beanModel, | ||
InjectableMethod<Object> observer, Class<T> eventType) | ||
{ | ||
super(beanModel, observer, eventType); | ||
} | ||
|
||
@Override | ||
protected final Object getInstance() { | ||
return specializedInstance; | ||
} | ||
|
||
/** | ||
* The most specialized instance of this observer type. | ||
* @param instance The instance to use for testing | ||
*/ | ||
public final void setInstance(Object instance) | ||
{ | ||
specializedInstance = instance; | ||
} | ||
|
||
} |
70 changes: 6 additions & 64 deletions
70
webbeans-ri/src/test/java/org/jboss/webbeans/test/util/Util.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,28 @@ | ||
package org.jboss.webbeans.test.util; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.Method; | ||
import java.util.HashMap; | ||
|
||
import org.jboss.webbeans.ManagerImpl; | ||
import org.jboss.webbeans.bean.AbstractBean; | ||
import org.jboss.webbeans.bean.AbstractClassBean; | ||
import org.jboss.webbeans.bean.EnterpriseBean; | ||
import org.jboss.webbeans.bean.ProducerMethodBean; | ||
import org.jboss.webbeans.bean.SimpleBean; | ||
import org.jboss.webbeans.introspector.AnnotatedClass; | ||
import org.jboss.webbeans.introspector.AnnotatedMethod; | ||
import org.jboss.webbeans.introspector.impl.SimpleAnnotatedClass; | ||
import org.jboss.webbeans.introspector.impl.SimpleAnnotatedMethod; | ||
import org.jboss.webbeans.model.bean.EnterpriseBeanModel; | ||
import org.jboss.webbeans.model.bean.ProducerMethodBeanModel; | ||
import org.jboss.webbeans.model.bean.SimpleBeanModel; | ||
|
||
public class Util | ||
{ | ||
public static <T> SimpleBean<T> createSimpleWebBean(Class<T> clazz, ManagerImpl manager) | ||
public static <T> SimpleBean<T> createSimpleBean(Class<T> clazz, ManagerImpl manager) | ||
{ | ||
return new SimpleBean<T>(createSimpleModel(clazz, manager), manager); | ||
return new SimpleBean<T>(clazz, manager); | ||
} | ||
|
||
public static <T> EnterpriseBean<T> createEnterpriseBean(Class<T> clazz, ManagerImpl manager) | ||
{ | ||
return new EnterpriseBean<T>(createEnterpriseBeanModel(clazz, manager), manager); | ||
return new EnterpriseBean<T>(clazz, manager); | ||
} | ||
|
||
public static <T> SimpleBeanModel<T> createSimpleModel(Class<T> clazz, ManagerImpl manager) | ||
public static <T> ProducerMethodBean<T> createProducerMethodBean(Class<T> type, Method method, ManagerImpl manager, AbstractClassBean<?> declaringBean) | ||
{ | ||
return new SimpleBeanModel<T>(new SimpleAnnotatedClass<T>(clazz), null, manager); | ||
return new ProducerMethodBean<T>(method, declaringBean, manager); | ||
} | ||
|
||
public static <T> SimpleBeanModel<T> createSimpleModel(Class<T> clazz, AnnotatedClass<T> xmlAnnotatedType, ManagerImpl manager) | ||
{ | ||
return new SimpleBeanModel<T>(new SimpleAnnotatedClass<T>(clazz), xmlAnnotatedType, manager); | ||
} | ||
|
||
private static <T> EnterpriseBeanModel<T> createEnterpriseBeanModel(Class<T> clazz, ManagerImpl manager) | ||
{ | ||
return new EnterpriseBeanModel<T>(new SimpleAnnotatedClass<T>(clazz), null, manager); | ||
} | ||
|
||
private static <T> EnterpriseBeanModel<T> createEnterpriseBeanModel(Class<T> clazz, AnnotatedClass<T> xmlAnnotatedType, ManagerImpl manager) | ||
{ | ||
return new EnterpriseBeanModel<T>(new SimpleAnnotatedClass<T>(clazz), xmlAnnotatedType, manager); | ||
} | ||
|
||
public static <T> ProducerMethodBean<T> createProducerMethodBean(Class<T> type, Method method, ManagerImpl manager, AbstractBean<?> declaringBean) | ||
{ | ||
return new ProducerMethodBean<T>(createProducerMethodBeanModel(type, method, null, manager, declaringBean), manager); | ||
} | ||
|
||
public static <T> ProducerMethodBean<T> createProducerMethodBean(Class<T> type, Method method, ManagerImpl manager) | ||
{ | ||
return createProducerMethodBean(type, method, manager, null); | ||
} | ||
|
||
private static <T> ProducerMethodBeanModel<T> createProducerMethodBeanModel(Class<T> type, Method method, ManagerImpl manager) | ||
{ | ||
return createProducerMethodBeanModel(type, method, null, manager); | ||
} | ||
|
||
private static <T> ProducerMethodBeanModel<T> createProducerMethodBeanModel(Class<T> type, Method method, AnnotatedMethod<T> xmlAnnotatedMethod, ManagerImpl manager, AbstractBean<?> declaringBean) | ||
{ | ||
return new ProducerMethodBeanModel<T>(new SimpleAnnotatedMethod<T>(method), xmlAnnotatedMethod, manager, declaringBean); | ||
} | ||
|
||
@Deprecated | ||
public static <T> ProducerMethodBeanModel<T> createProducerMethodBeanModel(Class<T> type, Method method, AnnotatedMethod<T> xmlAnnotatedMethod, ManagerImpl manager) | ||
{ | ||
return createProducerMethodBeanModel(type, method, xmlAnnotatedMethod, manager, null); | ||
} | ||
|
||
@Deprecated | ||
public static <T> AnnotatedClass<T> getEmptyAnnotatedType(Class<T> type) | ||
{ | ||
return new SimpleAnnotatedClass<T>(type, new HashMap<Class<? extends Annotation>, Annotation>()); | ||
} | ||
|
||
|
||
|
||
} |