[webbeans-commits] Webbeans SVN: r1272 - ri/trunk/jboss-as.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-01-28 20:22:11 -0500 (Wed, 28 Jan 2009)
New Revision: 1272
Modified:
ri/trunk/jboss-as/build.properties
Log:
Update to EJB3 1.0.0
Modified: ri/trunk/jboss-as/build.properties
===================================================================
--- ri/trunk/jboss-as/build.properties 2009-01-29 01:06:27 UTC (rev 1271)
+++ ri/trunk/jboss-as/build.properties 2009-01-29 01:22:11 UTC (rev 1272)
@@ -1,4 +1,4 @@
#jboss.home=/Applications/jboss-5.0.0.GA
webbeans-ri-int.version=5.2.0-SNAPSHOT
webbeans-ri.version=1.0.0-SNAPSHOT
-jboss-ejb3.version=1.0.0-Alpha1
+jboss-ejb3.version=1.0.0
16 years, 8 months
[webbeans-commits] Webbeans SVN: r1271 - doc/trunk/reference/ko-KR.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-01-28 20:06:27 -0500 (Wed, 28 Jan 2009)
New Revision: 1271
Modified:
doc/trunk/reference/ko-KR/intro.po
Log:
fix build
Modified: doc/trunk/reference/ko-KR/intro.po
===================================================================
--- doc/trunk/reference/ko-KR/intro.po 2009-01-29 00:51:35 UTC (rev 1270)
+++ doc/trunk/reference/ko-KR/intro.po 2009-01-29 01:06:27 UTC (rev 1271)
@@ -64,7 +64,7 @@
"into other Web Beans, configuring them via the Web Beans XML configuration "
"facility, even adding interceptors and decorators to them — without "
"touching your existing code."
-msgstr "특정한 예외 상항에서 매개 변수가 없는 것을 허용하는 생성자와 함께하는 모든 Java 클래스는 Web Bean입니다. 이에는 모든 JavaBean이 포함됩니다. 이에 더하여 모든 EJB 3-스타일 세션 빈도 Web Bean입니다. 물론 매일 작성하셨던 JavaBeans 및 EJB는 Web Beans 사양에 의해 정의된 새로운 서비스의 장점을 취할 수 없지만, Web Beans으로서 기존 코드를 변경하지 않고 이 모든 것을 사용하실 수 있습니다 — 기타 다른 Web Beans로의 삽입, Web Beans XML 설정 기능을 통한 설정, 인터셉터 및 데코레이터 추가 등— "
+msgstr "특정한 예외 상항에서 매개 변수가 없는 것을 허용하는 생성자와 함께하는 모든 Java 클래스는 Web Bean입니다. 이에는 모든 JavaBean이 포함됩니다. 이에 더하여 모든 EJB 3-스타일 세션 빈도 Web Bean입니다. 물론 매일 작성하셨던 JavaBeans 및 EJB는 Web Beans 사양에 의해 정의된 새로운 서비스의 장점을 취할 수 없지만, Web Beans으로서 기존 코드를 변경하지 않고 이 모든 것을 사용하실 수 있습니다 — 기타 다른 Web Beans로의 삽입, Web Beans XML 설정 기능을 통한 설정, 인터셉터 및 데코레이터 추가 등— "
#. Tag: para
#: intro.xml:25
16 years, 8 months
[webbeans-commits] Webbeans SVN: r1270 - ri/trunk/jboss-as.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-01-28 19:51:35 -0500 (Wed, 28 Jan 2009)
New Revision: 1270
Modified:
ri/trunk/jboss-as/build.xml
Log:
Fix locations of jars
Modified: ri/trunk/jboss-as/build.xml
===================================================================
--- ri/trunk/jboss-as/build.xml 2009-01-29 00:43:25 UTC (rev 1269)
+++ ri/trunk/jboss-as/build.xml 2009-01-29 00:51:35 UTC (rev 1270)
@@ -63,7 +63,6 @@
<include name="webbeans-ri.jar" />
<include name="webbeans-ri-int-jbossas.jar" />
<include name="webbeans-api.jar" />
- <include name="webbeans-ri-spi.jar" />
</fileset>
</copy>
@@ -71,7 +70,8 @@
<fileset dir="target/webbeans.deployer">
<include name="**/*.xml" />
<include name="webbeans-ri-int-microcontainer.jar" />
- <include name="webbeans-ri-int-jboss-ejb.jar" />
+ <include name="webbeans-ri-int-jboss-ejb.jar" />
+ <include name="webbeans-ri-spi.jar" />
<include name="google*.jar" />
</fileset>
</copy>
16 years, 8 months
[webbeans-commits] Webbeans SVN: r1269 - doc/trunk/reference.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-01-28 19:43:25 -0500 (Wed, 28 Jan 2009)
New Revision: 1269
Modified:
doc/trunk/reference/pom.xml
Log:
minor
Modified: doc/trunk/reference/pom.xml
===================================================================
--- doc/trunk/reference/pom.xml 2009-01-29 00:29:21 UTC (rev 1268)
+++ doc/trunk/reference/pom.xml 2009-01-29 00:43:25 UTC (rev 1269)
@@ -198,17 +198,5 @@
<connection>scm:svn:http://anonsvn.jboss.org/repos/webbeans/doc</connection>
<developerConnection>scm:svn:https://svn.jboss.org/repos/webbeans/doc</developerConnection>
<url>http://fisheye.jboss.org/browse/WebBeans/doc</url>
- </scm>
-
- <distributionManagement>
- <repository>
- <!-- Copy the dist to the local checkout of the JBoss maven2 repo ${maven.repository.root} -->
-
- <!-- It is anticipated that ${maven.repository.root} be set in user's settings.xml -->
- <!-- todo : replace this with direct svn access once the svnkit providers are available -->
- </repository>
- <snapshotRepository>
- </snapshotRepository>
- </distributionManagement>
-
+ </scm>
</project>
\ No newline at end of file
16 years, 8 months
[webbeans-commits] Webbeans SVN: r1268 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event and 9 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-01-28 19:29:21 -0500 (Wed, 28 Jan 2009)
New Revision: 1268
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/Exceptions.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/ExceptionHandlingTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/FooException.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/Lorry_Broken.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/Ship.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/ShipProducer_Broken.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/FooException.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/Lorry.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/LorryProducer_Broken.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/Ship.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/ShipProducer_Broken.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/FooException.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/Lorry_Broken.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/Van_Broken.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ConstructorInjectionPoint.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/FieldInjectionPoint.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedConstructor.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedField.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedConstructor.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedField.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedMethod.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/ProducerMethodLifecycleTest.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/SimpleBeanLifecycleTest.java
Log:
WBRI-120
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java 2009-01-28 23:42:07 UTC (rev 1267)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -50,4 +50,10 @@
// No-op
}
+ @Override
+ public boolean isSerializable()
+ {
+ return true;
+ }
+
}
\ No newline at end of file
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2009-01-28 23:42:07 UTC (rev 1267)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -18,7 +18,6 @@
package org.jboss.webbeans.event;
import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
@@ -33,7 +32,6 @@
import javax.event.Observes;
import javax.inject.DefinitionException;
import javax.inject.Disposes;
-import javax.inject.ExecutionException;
import javax.inject.Initializer;
import javax.inject.Produces;
import javax.inject.manager.Bean;
@@ -213,24 +211,9 @@
}
else
{
- observerMethod.invokeWithSpecialValue(instance, Observes.class, event, manager, null);
+ observerMethod.invokeWithSpecialValue(instance, Observes.class, event, manager, null, ObserverException.class);
}
}
- catch (ExecutionException e)
- {
- if ((e.getCause() != null) && (e.getCause() instanceof InvocationTargetException))
- {
- InvocationTargetException wrappedException = (InvocationTargetException) e.getCause();
- if ((wrappedException.getCause() != null) && (RuntimeException.class.isAssignableFrom(wrappedException.getCause().getClass())))
- {
- throw (RuntimeException) wrappedException.getCause();
- }
- else
- {
- throw new ObserverException(wrappedException.getCause().getMessage(), wrappedException.getCause());
- }
- }
- }
finally
{
if (Dependent.class.equals(observerBean.getScopeType()))
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ConstructorInjectionPoint.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ConstructorInjectionPoint.java 2009-01-28 23:42:07 UTC (rev 1267)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ConstructorInjectionPoint.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -1,7 +1,10 @@
package org.jboss.webbeans.injection;
+import static org.jboss.webbeans.injection.Exceptions.rethrowException;
+
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.util.AbstractList;
import java.util.Iterator;
import java.util.List;
@@ -78,7 +81,27 @@
public T newInstance(ManagerImpl manager, CreationalContext<?> creationalContext)
{
- return delegate().newInstance(getParameterValues(getParameters(), null, null, manager, creationalContext));
+ try
+ {
+ return delegate().newInstance(getParameterValues(getParameters(), null, null, manager, creationalContext));
+ }
+ catch (IllegalArgumentException e)
+ {
+ rethrowException(e);
+ }
+ catch (InstantiationException e)
+ {
+ rethrowException(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ rethrowException(e);
+ }
+ catch (InvocationTargetException e)
+ {
+ rethrowException(e);
+ }
+ return null;
}
@Override
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/Exceptions.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/Exceptions.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/Exceptions.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -0,0 +1,82 @@
+package org.jboss.webbeans.injection;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.inject.CreationException;
+import javax.inject.ExecutionException;
+
+class Exceptions
+{
+
+ private static void rethrowException(Throwable t, Class<? extends RuntimeException> exceptionToThrow)
+ {
+ if (t instanceof RuntimeException)
+ {
+ throw (RuntimeException) t;
+ }
+ else
+ {
+ RuntimeException e;
+ try
+ {
+ e = exceptionToThrow.newInstance();
+ }
+ catch (InstantiationException e1)
+ {
+ throw new ExecutionException(e1);
+ }
+ catch (IllegalAccessException e1)
+ {
+ throw new ExecutionException(e1);
+ }
+ e.initCause(t);
+ throw e;
+ }
+ }
+
+ private static void rethrowException(Throwable t)
+ {
+ rethrowException(t, CreationException.class);
+ }
+
+ public static void rethrowException(IllegalArgumentException e)
+ {
+ rethrowException(e.getCause());
+ }
+
+ public static void rethrowException(IllegalArgumentException e, Class<? extends RuntimeException> exceptionToThrow)
+ {
+ rethrowException(e.getCause(), exceptionToThrow);
+ }
+
+ public static void rethrowException(InstantiationException e, Class<? extends RuntimeException> exceptionToThrow)
+ {
+ rethrowException(e.getCause(), exceptionToThrow);
+ }
+
+ public static void rethrowException(InstantiationException e)
+ {
+ rethrowException(e.getCause());
+ }
+
+ public static void rethrowException(IllegalAccessException e)
+ {
+ rethrowException(e.getCause());
+ }
+
+ public static void rethrowException(IllegalAccessException e, Class<? extends RuntimeException> exceptionToThrow)
+ {
+ rethrowException(e.getCause(), exceptionToThrow);
+ }
+
+ public static void rethrowException(InvocationTargetException e, Class<? extends RuntimeException> exceptionToThrow)
+ {
+ rethrowException(e.getCause(), exceptionToThrow);
+ }
+
+ public static void rethrowException(InvocationTargetException e)
+ {
+ rethrowException(e.getCause());
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/Exceptions.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/FieldInjectionPoint.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/FieldInjectionPoint.java 2009-01-28 23:42:07 UTC (rev 1267)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/FieldInjectionPoint.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -1,5 +1,7 @@
package org.jboss.webbeans.injection;
+import static org.jboss.webbeans.injection.Exceptions.rethrowException;
+
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.Set;
@@ -53,7 +55,34 @@
public void inject(Object declaringInstance, ManagerImpl manager, CreationalContext<?> creationalContext)
{
- delegate().inject(declaringInstance, manager.getInstanceToInject(this, creationalContext));
+ try
+ {
+ delegate().set(declaringInstance, manager.getInstanceToInject(this, creationalContext));
+ }
+ catch (IllegalArgumentException e)
+ {
+ rethrowException(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ rethrowException(e);
+ }
}
+
+ public void inject(Object declaringInstance, Object value)
+ {
+ try
+ {
+ delegate().set(declaringInstance, value);
+ }
+ catch (IllegalArgumentException e)
+ {
+ rethrowException(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ rethrowException(e);
+ }
+ }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java 2009-01-28 23:42:07 UTC (rev 1267)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -1,6 +1,9 @@
package org.jboss.webbeans.injection;
+import static org.jboss.webbeans.injection.Exceptions.rethrowException;
+
import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.AbstractList;
import java.util.Iterator;
@@ -78,12 +81,44 @@
public T invoke(Object declaringInstance, ManagerImpl manager, CreationalContext<?> creationalContext)
{
- return delegate().invoke(declaringInstance, getParameterValues(getParameters(), null, null, manager, creationalContext));
+ try
+ {
+ return delegate().invoke(declaringInstance, getParameterValues(getParameters(), null, null, manager, creationalContext));
+ }
+ catch (IllegalArgumentException e)
+ {
+ rethrowException(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ rethrowException(e);
+ }
+ catch (InvocationTargetException e)
+ {
+ rethrowException(e);
+ }
+ return null;
}
- public T invokeWithSpecialValue(Object declaringInstance, Class<? extends Annotation> annotatedParameter, Object parameter, ManagerImpl manager, CreationalContext<?> creationalContext)
+ public T invokeWithSpecialValue(Object declaringInstance, Class<? extends Annotation> annotatedParameter, Object parameter, ManagerImpl manager, CreationalContext<?> creationalContext, Class<? extends RuntimeException> exceptionTypeToThrow)
{
- return delegate().invoke(declaringInstance, getParameterValues(getParameters(), annotatedParameter, parameter, manager, creationalContext));
+ try
+ {
+ return delegate().invoke(declaringInstance, getParameterValues(getParameters(), annotatedParameter, parameter, manager, creationalContext));
+ }
+ catch (IllegalArgumentException e)
+ {
+ rethrowException(e, exceptionTypeToThrow);
+ }
+ catch (IllegalAccessException e)
+ {
+ rethrowException(e, exceptionTypeToThrow);
+ }
+ catch (InvocationTargetException e)
+ {
+ rethrowException(e, exceptionTypeToThrow);
+ }
+ return null;
}
@Override
@@ -110,7 +145,22 @@
public void inject(Object declaringInstance, Object value)
{
- delegate().invoke(declaringInstance, value);
+ try
+ {
+ delegate().invoke(declaringInstance, value);
+ }
+ catch (IllegalArgumentException e)
+ {
+ rethrowException(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ rethrowException(e);
+ }
+ catch (InvocationTargetException e)
+ {
+ rethrowException(e);
+ }
}
/**
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedConstructor.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedConstructor.java 2009-01-28 23:42:07 UTC (rev 1267)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedConstructor.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -19,6 +19,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.util.List;
/**
@@ -53,7 +54,7 @@
*
* @return The created instance
*/
- public T newInstance(Object... parameters);
+ public T newInstance(Object... parameters) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException;
/**
* Gets the declaring class of the annotation
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedField.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedField.java 2009-01-28 23:42:07 UTC (rev 1267)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedField.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -45,19 +45,19 @@
* @param declaringInstance The instance to inject into
* @param value The value to inject
*/
- public void inject(Object declaringInstance, Object value);
+ public void set(Object declaringInstance, Object value) throws IllegalArgumentException, IllegalAccessException;
/**
* Injects into the field using the value provided by the manager
*
- * Unlike {@link #inject(Object, Manager)} the field injected into is
+ * Unlike {@link #set(Object, Manager)} the field injected into is
* discovered from the declaring instance. This is slower, but safe to use
* with proxies.
*
* @param declaringInstance The instance to inject into
* @param value The value to inject
*/
- public void injectIntoInstance(Object declaringInstance, Object value);
+ public void setOnInstance(Object declaringInstance, Object value) throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException;
public T get(Object instance);
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java 2009-01-28 23:42:07 UTC (rev 1267)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -18,6 +18,7 @@
package org.jboss.webbeans.introspector;
import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashSet;
@@ -74,7 +75,7 @@
* @param parameters The method parameters
* @return A reference to the instance
*/
- public T invoke(Object instance, Object... parameters);
+ public T invoke(Object instance, Object... parameters) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException;
/**
* Invokes the method on the class of the passed instance, not the declaring
@@ -84,7 +85,7 @@
* @param manager The Web Beans manager
* @return A reference to the instance
*/
- public T invokeOnInstance(Object instance, Object... parameters);
+ public T invokeOnInstance(Object instance, Object... parameters) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException;
/**
* Gets the declaring class
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedConstructor.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedConstructor.java 2009-01-28 23:42:07 UTC (rev 1267)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedConstructor.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -18,6 +18,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Set;
@@ -42,7 +43,7 @@
return delegate().getParameters();
}
- public T newInstance(Object... parameters)
+ public T newInstance(Object... parameters) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
{
return delegate().newInstance(parameters);
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedField.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedField.java 2009-01-28 23:42:07 UTC (rev 1267)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedField.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -46,14 +46,14 @@
return delegate().getPropertyName();
}
- public void inject(Object declaringInstance, Object value)
+ public void set(Object declaringInstance, Object value) throws IllegalArgumentException, IllegalAccessException
{
- delegate().inject(declaringInstance, value);
+ delegate().set(declaringInstance, value);
}
- public void injectIntoInstance(Object declaringInstance, Object value)
+ public void setOnInstance(Object declaringInstance, Object value) throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException
{
- delegate().injectIntoInstance(declaringInstance, value);
+ delegate().setOnInstance(declaringInstance, value);
}
public boolean isTransient()
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedMethod.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedMethod.java 2009-01-28 23:42:07 UTC (rev 1267)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedMethod.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -17,12 +17,11 @@
package org.jboss.webbeans.introspector;
import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Set;
-import org.jboss.webbeans.ManagerImpl;
-
public abstract class ForwardingAnnotatedMethod<T> extends ForwardingAnnotatedMember<T, Method> implements AnnotatedMethod<T>
{
@@ -59,17 +58,12 @@
return delegate().getPropertyName();
}
- public T invoke(Object instance, ManagerImpl manager)
+ public T invoke(Object instance, Object... parameters) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
{
- return delegate().invoke(instance, manager);
- }
-
- public T invoke(Object instance, Object... parameters)
- {
return delegate().invoke(instance, parameters);
}
- public T invokeOnInstance(Object instance, Object... parameters)
+ public T invokeOnInstance(Object instance, Object... parameters) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
{
return delegate().invokeOnInstance(instance, parameters);
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2009-01-28 23:42:07 UTC (rev 1267)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -26,8 +26,6 @@
import java.util.List;
import java.util.Set;
-import javax.inject.ExecutionException;
-
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedConstructor;
import org.jboss.webbeans.introspector.AnnotatedParameter;
@@ -189,31 +187,16 @@
*
* @param manager The Web Beans manager
* @return An instance
+ * @throws InvocationTargetException
+ * @throws IllegalAccessException
+ * @throws InstantiationException
+ * @throws IllegalArgumentException
*
* @see org.jboss.webbeans.introspector.AnnotatedConstructor#newInstance(ManagerImpl)
*/
- public T newInstance(Object... parameters)
+ public T newInstance(Object... parameters) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
{
- try
- {
- return getDelegate().newInstance(parameters);
- }
- catch (IllegalArgumentException e)
- {
- throw new ExecutionException("Error instantiating " + toString, e);
- }
- catch (InstantiationException e)
- {
- throw new ExecutionException("Error instantiating " + toString, e);
- }
- catch (IllegalAccessException e)
- {
- throw new ExecutionException("Error instantiating " + toString, e);
- }
- catch (InvocationTargetException e)
- {
- throw new ExecutionException("Error instantiating " + toString, e);
- }
+ return getDelegate().newInstance(parameters);
}
/**
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java 2009-01-28 23:42:07 UTC (rev 1267)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -113,14 +113,14 @@
return actualTypeArguments;
}
- public void inject(Object instance, Object value)
+ public void set(Object instance, Object value) throws IllegalArgumentException, IllegalAccessException
{
- Reflections.setAndWrap(getDelegate(), instance, value);
+ field.set(instance, value);
}
- public void injectIntoInstance(Object instance, Object value)
+ public void setOnInstance(Object instance, Object value) throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException
{
- Reflections.setAndWrap(getName(), instance, value);
+ instance.getClass().getField(getName()).set(instance, value);
}
@SuppressWarnings("unchecked")
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2009-01-28 23:42:07 UTC (rev 1267)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -18,6 +18,7 @@
package org.jboss.webbeans.introspector.jlr;
import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@@ -84,6 +85,7 @@
{
super(AnnotationStore.of(method), method);
this.method = method;
+ this.method.setAccessible(true);
this.declaringClass = declaringClass;
if (method.getGenericReturnType() instanceof ParameterizedType)
{
@@ -236,17 +238,17 @@
return getDelegate().hashCode();
}
- public T invokeOnInstance(Object instance, Object...parameters)
+ public T invokeOnInstance(Object instance, Object...parameters) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
{
@SuppressWarnings("unchecked")
- T result = (T) Reflections.invokeAndWrap(getName(), getParameterTypesAsArray(), instance, parameters);
+ T result = (T) instance.getClass().getMethod(getName(), getParameterTypesAsArray()).invoke(instance, parameters);
return result;
}
- public T invoke(Object instance, Object... parameters)
+ public T invoke(Object instance, Object... parameters) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
{
@SuppressWarnings("unchecked")
- T result = (T) Reflections.invokeAndWrap(getDelegate(), instance, parameters);
+ T result = (T) method.invoke(instance, parameters);
return result;
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java 2009-01-28 23:42:07 UTC (rev 1267)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -18,11 +18,13 @@
package org.jboss.webbeans.metadata;
import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
import java.util.Set;
import javax.annotation.NonBinding;
import javax.inject.BindingType;
import javax.inject.DefinitionException;
+import javax.inject.ExecutionException;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.util.Reflections;
@@ -130,12 +132,28 @@
{
if (!nonBindingTypes.contains(annotatedMethod))
{
- Object thisValue = annotatedMethod.invoke(instance);
- Object thatValue = annotatedMethod.invoke(other);
- if (!thisValue.equals(thatValue))
+ try
{
- return false;
+ Object thisValue = annotatedMethod.invoke(instance);
+ Object thatValue = annotatedMethod.invoke(other);
+ if (!thisValue.equals(thatValue))
+ {
+ return false;
+ }
}
+ catch (IllegalArgumentException e)
+ {
+ throw new ExecutionException(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new ExecutionException(e);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new ExecutionException(e);
+ }
+
}
}
return true;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-01-28 23:42:07 UTC (rev 1267)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -436,97 +436,6 @@
}
/**
- * Invokes a method and wraps exceptions
- *
- * @param methodName The method name to find on the instance and invoke
- * @param parameterTypes The method name to find on the instance and invoke
- * @param instance The instance to invoke on
- * @param parameterValues The parameters values
- * @return The return value
- */
- public static Object invokeAndWrap(String methodName, Class<?>[] parameterTypes, Object instance, Object[] parameterValues)
- {
- try
- {
- return instance.getClass().getMethod(methodName, parameterTypes).invoke(instance, parameterValues);
- }
- catch (IllegalArgumentException e)
- {
- throw new ExecutionException("Error invoking method " + methodName + " on " + instance.getClass(), e);
- }
- catch (IllegalAccessException e)
- {
- throw new ExecutionException("Error invoking method " + methodName + " on " + instance.getClass(), e);
- }
- catch (InvocationTargetException e)
- {
- throw new ExecutionException("Error invoking method " + methodName + " on " + instance.getClass(), e);
- }
- catch (SecurityException e)
- {
- throw new ExecutionException("Error invoking method " + methodName + " on " + instance.getClass(), e);
- }
- catch (NoSuchMethodException e)
- {
- throw new ExecutionException("Error invoking method " + methodName + " on " + instance.getClass(), e);
- }
- }
-
- /**
- * Sets value of a field and wraps exceptions
- *
- * @param field The field to set on
- * @param target The instance to set on
- * @param value The value to set
- */
- public static void setAndWrap(Field field, Object target, Object value)
- {
- try
- {
- field.set(target, value);
- }
- catch (IllegalArgumentException e)
- {
- throw new ExecutionException("Error setting field " + field.getName() + " on " + field.getDeclaringClass(), e);
- }
- catch (IllegalAccessException e)
- {
- throw new ExecutionException("Error setting field " + field.getName() + " on " + field.getDeclaringClass(), e);
- }
- }
-
- /**
- * Sets value of a field and wraps exceptions
- *
- * @param field The field to set on
- * @param target The instance to set on
- * @param value The value to set
- */
- public static void setAndWrap(String fieldName, Object target, Object value)
- {
- try
- {
- target.getClass().getField(fieldName).set(target, value);
- }
- catch (IllegalArgumentException e)
- {
- throw new ExecutionException("Error setting field " + fieldName + " on " + target.getClass(), e);
- }
- catch (IllegalAccessException e)
- {
- throw new ExecutionException("Error setting field " + fieldName + " on " + target.getClass(), e);
- }
- catch (SecurityException e)
- {
- throw new ExecutionException("Error setting field " + fieldName + " on " + target.getClass(), e);
- }
- catch (NoSuchFieldException e)
- {
- throw new ExecutionException("Error setting field " + fieldName + " on " + target.getClass(), e);
- }
- }
-
- /**
* Gets value of a field and wraps exceptions
*
* @param field The field to set on
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/ExceptionHandlingTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/ExceptionHandlingTest.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/ExceptionHandlingTest.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -0,0 +1,64 @@
+package org.jboss.webbeans.test.unit.implementation.exceptions;
+
+import javax.inject.CreationException;
+
+import org.jboss.webbeans.test.unit.AbstractTest;
+import org.testng.annotations.Test;
+
+public class ExceptionHandlingTest extends AbstractTest
+{
+
+ @Test(expectedExceptions=FooException.class)
+ public void testCreationExceptionWrapsRealExceptionForSimpleBean() throws Exception
+ {
+ deployBeans(Lorry_Broken.class);
+ new RunInDependentContext()
+ {
+
+ @Override
+ protected void execute() throws Exception
+ {
+ try
+ {
+ manager.getInstanceByType(Lorry_Broken.class);
+ }
+ catch (Exception e)
+ {
+ if (e instanceof CreationException)
+ {
+ throw (Exception) e.getCause();
+ }
+ }
+ }
+
+ }.run();
+ }
+
+
+ @Test(expectedExceptions=FooException.class)
+ public void testCreationExceptionWrapsRealExceptionForProducerBean() throws Exception
+ {
+ deployBeans(ShipProducer_Broken.class);
+ new RunInDependentContext()
+ {
+
+ @Override
+ protected void execute() throws Exception
+ {
+ try
+ {
+ manager.getInstanceByType(Ship.class);
+ }
+ catch (Exception e)
+ {
+ if (e instanceof CreationException)
+ {
+ throw (Exception) e.getCause();
+ }
+ }
+ }
+
+ }.run();
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/ExceptionHandlingTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/FooException.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/FooException.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/FooException.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.unit.implementation.exceptions;
+
+public class FooException extends Exception
+{
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/FooException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/Lorry_Broken.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/Lorry_Broken.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/Lorry_Broken.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.test.unit.implementation.exceptions;
+
+class Lorry_Broken
+{
+
+ public Lorry_Broken() throws Exception
+ {
+ throw new FooException();
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/Lorry_Broken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/Ship.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/Ship.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/Ship.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.unit.implementation.exceptions;
+
+class Ship
+{
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/Ship.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/ShipProducer_Broken.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/ShipProducer_Broken.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/ShipProducer_Broken.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -0,0 +1,14 @@
+package org.jboss.webbeans.test.unit.implementation.exceptions;
+
+import javax.inject.Produces;
+
+public class ShipProducer_Broken
+{
+
+ @Produces
+ public Ship produceShip() throws FooException
+ {
+ throw new FooException();
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/implementation/exceptions/ShipProducer_Broken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/FooException.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/FooException.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/FooException.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.tck.unit.implementation.producer.method;
+
+class FooException extends RuntimeException
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/FooException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/Lorry.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/Lorry.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/Lorry.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.tck.unit.implementation.producer.method;
+
+class Lorry
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/Lorry.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/LorryProducer_Broken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/LorryProducer_Broken.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/LorryProducer_Broken.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -0,0 +1,14 @@
+package org.jboss.webbeans.tck.unit.implementation.producer.method;
+
+import javax.inject.Produces;
+
+class LorryProducer_Broken
+{
+
+ @Produces
+ public Lorry produceLorry() throws Exception
+ {
+ throw new Exception();
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/LorryProducer_Broken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/ProducerMethodLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/ProducerMethodLifecycleTest.java 2009-01-28 23:42:07 UTC (rev 1267)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/ProducerMethodLifecycleTest.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -2,6 +2,7 @@
import java.lang.reflect.Method;
+import javax.inject.CreationException;
import javax.inject.IllegalProductException;
import javax.inject.manager.Bean;
@@ -73,4 +74,34 @@
createProducerMethodBean(method, spiderProducer).create(new MockCreationalContext<Object>());
}
+ @Test(expectedExceptions=CreationException.class)
+ public void testCreationExceptionWrapsCheckedExceptionThrownFromCreate() throws Exception
+ {
+ deployBeans(LorryProducer_Broken.class);
+ new RunInDependentContext()
+ {
+
+ protected void execute() throws Exception
+ {
+ manager.getInstanceByType(Lorry.class);
+ }
+
+ }.run();
+ }
+
+ @Test(expectedExceptions=FooException.class)
+ public void testUncheckedExceptionThrownFromCreateNotWrapped() throws Exception
+ {
+ deployBeans(ShipProducer_Broken.class);
+ new RunInDependentContext()
+ {
+
+ protected void execute() throws Exception
+ {
+ manager.getInstanceByType(Ship.class);
+ }
+
+ }.run();
+ }
+
}
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/Ship.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/Ship.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/Ship.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.tck.unit.implementation.producer.method;
+
+class Ship
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/Ship.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/ShipProducer_Broken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/ShipProducer_Broken.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/ShipProducer_Broken.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -0,0 +1,14 @@
+package org.jboss.webbeans.tck.unit.implementation.producer.method;
+
+import javax.inject.Produces;
+
+class ShipProducer_Broken
+{
+
+ @Produces
+ public Ship produceShip() throws FooException
+ {
+ throw new FooException();
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/ShipProducer_Broken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/FooException.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/FooException.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/FooException.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.tck.unit.implementation.simple;
+
+class FooException extends RuntimeException
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/FooException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/Lorry_Broken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/Lorry_Broken.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/Lorry_Broken.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.tck.unit.implementation.simple;
+
+class Lorry_Broken
+{
+
+ public Lorry_Broken() throws Exception
+ {
+ throw new Exception();
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/Lorry_Broken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/SimpleBeanLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/SimpleBeanLifecycleTest.java 2009-01-28 23:42:07 UTC (rev 1267)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/SimpleBeanLifecycleTest.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -3,6 +3,7 @@
import java.lang.annotation.Annotation;
import java.util.List;
+import javax.inject.CreationException;
import javax.inject.manager.Bean;
import org.jboss.webbeans.tck.AbstractTest;
@@ -190,5 +191,35 @@
TunaFarm tunaFarm = tunaFarmBean.create(new MockCreationalContext<TunaFarm>());
assert tunaFarm.notInjectedTuna != manager.getInstance(tunaBean);
}
+
+ @Test(expectedExceptions=CreationException.class)
+ public void testCreationExceptionWrapsCheckedExceptionThrownFromCreate() throws Exception
+ {
+ deployBeans(Lorry_Broken.class);
+ new RunInDependentContext()
+ {
+
+ protected void execute() throws Exception
+ {
+ manager.getInstanceByType(Lorry_Broken.class);
+ }
+
+ }.run();
+ }
+
+ @Test(expectedExceptions=FooException.class)
+ public void testUncheckedExceptionThrownFromCreateNotWrapped() throws Exception
+ {
+ deployBeans(Van_Broken.class);
+ new RunInDependentContext()
+ {
+
+ protected void execute() throws Exception
+ {
+ manager.getInstanceByType(Van_Broken.class);
+ }
+
+ }.run();
+ }
}
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/Van_Broken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/Van_Broken.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/Van_Broken.java 2009-01-29 00:29:21 UTC (rev 1268)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.tck.unit.implementation.simple;
+
+class Van_Broken
+{
+
+ public Van_Broken() throws Exception
+ {
+ throw new FooException();
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/Van_Broken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 8 months
[webbeans-commits] Webbeans SVN: r1267 - in tck/trunk/impl/src/main/java/org/jboss/webbeans/tck: integration/lookup/byname and 1 other directories.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-01-28 18:42:07 -0500 (Wed, 28 Jan 2009)
New Revision: 1267
Removed:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/SpecVersion.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/lookup/byname/ResolutionByNameTest.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/lookup/non/contextual/NonContextualInjectionTest.java
Log:
removed @SpecVersion
Deleted: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/SpecVersion.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/SpecVersion.java 2009-01-28 22:58:12 UTC (rev 1266)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/SpecVersion.java 2009-01-28 23:42:07 UTC (rev 1267)
@@ -1,13 +0,0 @@
-package org.jboss.webbeans.tck.impl;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Target;
-
-@Documented
-(a)Target(ElementType.TYPE)
-public @interface SpecVersion {
-
- String value();
-
-}
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/lookup/byname/ResolutionByNameTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/lookup/byname/ResolutionByNameTest.java 2009-01-28 22:58:12 UTC (rev 1266)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/lookup/byname/ResolutionByNameTest.java 2009-01-28 23:42:07 UTC (rev 1267)
@@ -2,20 +2,23 @@
import org.jboss.webbeans.tck.AbstractTest;
import org.jboss.webbeans.tck.impl.SpecAssertion;
-import org.jboss.webbeans.tck.impl.SpecVersion;
import org.testng.annotations.Test;
-@SpecVersion("20081206")
+/**
+ *
+ * Spec version: PRD2
+ *
+ */
public class ResolutionByNameTest extends AbstractTest
{
- @Test(groups={"stub", "el"}) @SpecAssertion(section="5.11.2")
+ @Test(groups={"stub", "el"}) @SpecAssertion(section="5.10")
public void testELResolverRegisteredWithJsf()
{
assert false;
}
- @Test(groups={"stub", "el"}) @SpecAssertion(section="5.11.2")
+ @Test(groups={"stub", "el"}) @SpecAssertion(section="5.10")
public void testELResolverRegisteredWithServlet()
{
assert false;
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/lookup/non/contextual/NonContextualInjectionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/lookup/non/contextual/NonContextualInjectionTest.java 2009-01-28 22:58:12 UTC (rev 1266)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/lookup/non/contextual/NonContextualInjectionTest.java 2009-01-28 23:42:07 UTC (rev 1267)
@@ -1,10 +1,13 @@
package org.jboss.webbeans.tck.integration.lookup.non.contextual;
import org.jboss.webbeans.tck.AbstractTest;
-import org.jboss.webbeans.tck.impl.SpecVersion;
import org.testng.annotations.Test;
-@SpecVersion("PRD2")
+/**
+ *
+ * Spec version: PRD2
+ *
+ */
public class NonContextualInjectionTest extends AbstractTest
{
16 years, 8 months
[webbeans-commits] Webbeans SVN: r1266 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean and 4 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-01-28 17:58:12 -0500 (Wed, 28 Jan 2009)
New Revision: 1266
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyProvider.java
Removed:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exception/
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/CreationalContextImpl.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/lookup/circular/CircularDependencyTest.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/EventTest.java
Log:
better circular dependencies support
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-01-28 21:20:19 UTC (rev 1265)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-01-28 22:58:12 UTC (rev 1266)
@@ -56,7 +56,7 @@
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.NewEnterpriseBean;
import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.bean.proxy.ProxyPool;
+import org.jboss.webbeans.bean.proxy.ClientProxyProvider;
import org.jboss.webbeans.context.ContextMap;
import org.jboss.webbeans.context.CreationalContextImpl;
import org.jboss.webbeans.ejb.EjbDescriptorCache;
@@ -107,7 +107,7 @@
// The registered contexts
private transient final ContextMap contextMap;
// The client proxy pool
- private transient final ProxyPool proxyPool;
+ private transient final ClientProxyProvider clientProxyProvider;
// The registered beans
private transient List<Bean<?>> beans;
// The registered beans, mapped by implementation class
@@ -145,7 +145,7 @@
this.newEnterpriseBeanMap = new ConcurrentHashMap<Class<?>, EnterpriseBean<?>>();
this.enterpriseBeanMap = new ConcurrentHashMap<Class<?>, EnterpriseBean<?>>();
this.resolver = new Resolver(this);
- this.proxyPool = new ProxyPool();
+ this.clientProxyProvider = new ClientProxyProvider();
this.decorators = new HashSet<Decorator>();
this.interceptors = new HashSet<Interceptor>();
this.contextMap = new ContextMap();
@@ -580,7 +580,14 @@
}
else if (MetaDataCache.instance().getScopeModel(bean.getScopeType()).isNormal())
{
- return (T) proxyPool.getClientProxy(bean, creationalContext != null);
+ if (creationalContext != null || (creationalContext == null && getContext(bean.getScopeType()).get(bean) != null))
+ {
+ return (T) clientProxyProvider.getClientProxy(bean);
+ }
+ else
+ {
+ return null;
+ }
}
else
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-01-28 21:20:19 UTC (rev 1265)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-01-28 22:58:12 UTC (rev 1266)
@@ -37,6 +37,7 @@
import javax.inject.manager.InjectionPoint;
import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.context.CreationalContextImpl;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -285,8 +286,20 @@
*
* @return The receiver
*/
- protected Object getReceiver()
+ protected Object getReceiver(CreationalContext<?> creationalContext)
{
+ // This is a bit dangerous, as it means that producer methods can end of
+ // executing on partially constructed instances. Also, it's not required
+ // by the spec...
+ if (creationalContext instanceof CreationalContextImpl)
+ {
+ CreationalContextImpl<?> creationalContextImpl = (CreationalContextImpl<?>) creationalContext;
+ if (creationalContextImpl.containsIncompleteInstance(getDeclaringBean()))
+ {
+ log.warn("Executing producer method on incomplete declaring bean due to circular injection");
+ return creationalContextImpl.getIncompleteInstance(getDeclaringBean());
+ }
+ }
return getAnnotatedItem().isStatic() ? null : manager.getInstance(getDeclaringBean());
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-01-28 21:20:19 UTC (rev 1265)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-01-28 22:58:12 UTC (rev 1266)
@@ -82,7 +82,7 @@
@Override
protected T produceInstance(CreationalContext<T> creationalContext)
{
- return field.get(getReceiver());
+ return field.get(getReceiver(creationalContext));
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-01-28 21:20:19 UTC (rev 1265)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-01-28 22:58:12 UTC (rev 1266)
@@ -78,7 +78,7 @@
protected T produceInstance(CreationalContext<T> creationalContext)
{
- return method.invoke(getReceiver(), manager, creationalContext);
+ return method.invoke(getReceiver(creationalContext), manager, creationalContext);
}
/**
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java 2009-01-28 21:20:19 UTC (rev 1265)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java 2009-01-28 22:58:12 UTC (rev 1266)
@@ -38,7 +38,7 @@
*
* @author Nicklas Karlsson
*
- * @see org.jboss.webbeans.bean.proxy.ProxyPool
+ * @see org.jboss.webbeans.bean.proxy.ClientProxyProvider
*/
public class ClientProxyMethodHandler implements MethodHandler, Serializable
{
@@ -49,6 +49,8 @@
private transient Bean<?> bean;
// The bean index in the manager
private int beanIndex;
+
+ private static final ThreadLocal<CreationalContextImpl<?>> currentCreationalContext = new ThreadLocal<CreationalContextImpl<?>>();
/**
* Constructor
@@ -97,8 +99,28 @@
private <T> T getProxiedInstance(Bean<T> bean)
{
- Context context = CurrentManager.rootManager().getContext(bean.getScopeType());
- return context.get(bean, new CreationalContextImpl<T>(bean));
+ CreationalContextImpl<T> creationalContext;
+ if (currentCreationalContext.get() == null)
+ {
+ creationalContext = new CreationalContextImpl<T>(bean);
+ currentCreationalContext.set(creationalContext);
+ }
+ else
+ {
+ creationalContext = currentCreationalContext.get().getCreationalContext(bean);
+ }
+ try
+ {
+ Context context = CurrentManager.rootManager().getContext(bean.getScopeType());
+ return context.get(bean, creationalContext);
+ }
+ finally
+ {
+ if (creationalContext.isOuter())
+ {
+ currentCreationalContext.remove();
+ }
+ }
}
/**
Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyProvider.java (from rev 1263, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyProvider.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyProvider.java 2009-01-28 22:58:12 UTC (rev 1266)
@@ -0,0 +1,142 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.bean.proxy;
+
+import java.io.Serializable;
+import java.lang.reflect.Type;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+import javassist.util.proxy.ProxyFactory;
+
+import javax.inject.DefinitionException;
+import javax.inject.manager.Bean;
+
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.util.ConcurrentCache;
+import org.jboss.webbeans.util.Proxies;
+
+/**
+ * A proxy pool for holding scope adaptors (client proxies)
+ *
+ * @author Nicklas Karlsson
+ *
+ * @see org.jboss.webbeans.bean.proxy.ProxyMethodHandler
+ */
+public class ClientProxyProvider
+{
+ private static final long serialVersionUID = 9029999149357529341L;
+
+ /**
+ * A container/cache for previously created proxies
+ *
+ * @author Nicklas Karlsson
+ */
+ private ConcurrentCache<Bean<? extends Object>, Object> pool;
+
+ /**
+ * Constructor
+ */
+ public ClientProxyProvider()
+ {
+ this.pool = new ConcurrentCache<Bean<? extends Object>, Object>();
+ }
+
+ /**
+ * Creates a Javassist scope adaptor (client proxy) for a bean
+ *
+ * Creates a Javassist proxy factory. Gets the type info. Sets the interfaces
+ * and superclass to the factory. Hooks in the MethodHandler and creates the
+ * proxy.
+ *
+ * @param bean The bean to proxy
+ * @param beanIndex The index to the bean in the manager bean list
+ * @return A Javassist proxy
+ * @throws InstantiationException When the proxy couldn't be created
+ * @throws IllegalAccessException When the proxy couldn't be created
+ */
+ private static <T> T createClientProxy(Bean<T> bean, int beanIndex) throws RuntimeException
+ {
+
+ try
+ {
+ ClientProxyMethodHandler proxyMethodHandler = new ClientProxyMethodHandler(bean, beanIndex);
+ Set<Type> classes = new LinkedHashSet<Type>(bean.getTypes());
+ classes.add(Serializable.class);
+ ProxyFactory proxyFactory = Proxies.getProxyFactory(classes);
+ proxyFactory.setHandler(proxyMethodHandler);
+ Class<?> clazz = proxyFactory.createClass();
+
+ @SuppressWarnings("unchecked")
+ T instance = (T) clazz.newInstance();
+
+ return instance;
+ }
+ catch (InstantiationException e)
+ {
+ throw new RuntimeException("Could not instantiate client proxy for " + bean, e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new RuntimeException("Could not access bean correctly when creating client proxy for " + bean, e);
+ }
+ }
+
+ /**
+ * Gets a client proxy for a bean
+ *
+ * Looks for a proxy in the pool. If not found, one is created and added to
+ * the pool if the create argument is true.
+ *
+ * @param bean The bean to get a proxy to
+ * @param create Flag indicating if the proxy should be created if it does
+ * not already exist
+ * @return the client proxy for the bean
+ */
+ @SuppressWarnings("unchecked")
+ public <T> T getClientProxy(final Bean<T> bean)
+ {
+ return pool.putIfAbsent(bean, new Callable<T>()
+ {
+
+ public T call() throws Exception
+ {
+ int beanIndex = CurrentManager.rootManager().getBeans().indexOf(bean);
+ if (beanIndex < 0)
+ {
+ throw new DefinitionException(bean + " is not known to the manager");
+ }
+ return createClientProxy(bean, beanIndex);
+ }
+
+ });
+ }
+
+ /**
+ * Gets a string representation
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ return "Proxy pool with " + pool.size() + " proxies";
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyProvider.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java 2009-01-28 21:20:19 UTC (rev 1265)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java 2009-01-28 22:58:12 UTC (rev 1266)
@@ -1,149 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.bean.proxy;
-
-import java.io.Serializable;
-import java.lang.reflect.Type;
-import java.util.LinkedHashSet;
-import java.util.Set;
-import java.util.concurrent.Callable;
-
-import javassist.util.proxy.ProxyFactory;
-
-import javax.inject.DefinitionException;
-import javax.inject.manager.Bean;
-
-import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.util.ConcurrentCache;
-import org.jboss.webbeans.util.Proxies;
-
-/**
- * A proxy pool for holding scope adaptors (client proxies)
- *
- * @author Nicklas Karlsson
- *
- * @see org.jboss.webbeans.bean.proxy.ProxyMethodHandler
- */
-public class ProxyPool
-{
- private static final long serialVersionUID = 9029999149357529341L;
-
- /**
- * A container/cache for previously created proxies
- *
- * @author Nicklas Karlsson
- */
- private ConcurrentCache<Bean<? extends Object>, Object> pool;
-
- /**
- * Constructor
- */
- public ProxyPool()
- {
- this.pool = new ConcurrentCache<Bean<? extends Object>, Object>();
- }
-
- /**
- * Creates a Javassist scope adaptor (client proxy) for a bean
- *
- * Creates a Javassist proxy factory. Gets the type info. Sets the interfaces
- * and superclass to the factory. Hooks in the MethodHandler and creates the
- * proxy.
- *
- * @param bean The bean to proxy
- * @param beanIndex The index to the bean in the manager bean list
- * @return A Javassist proxy
- * @throws InstantiationException When the proxy couldn't be created
- * @throws IllegalAccessException When the proxy couldn't be created
- */
- private static <T> T createClientProxy(Bean<T> bean, int beanIndex) throws RuntimeException
- {
-
- try
- {
- ClientProxyMethodHandler proxyMethodHandler = new ClientProxyMethodHandler(bean, beanIndex);
- Set<Type> classes = new LinkedHashSet<Type>(bean.getTypes());
- classes.add(Serializable.class);
- ProxyFactory proxyFactory = Proxies.getProxyFactory(classes);
- proxyFactory.setHandler(proxyMethodHandler);
- Class<?> clazz = proxyFactory.createClass();
-
- @SuppressWarnings("unchecked")
- T instance = (T) clazz.newInstance();
-
- return instance;
- }
- catch (InstantiationException e)
- {
- throw new RuntimeException("Could not instantiate client proxy for " + bean, e);
- }
- catch (IllegalAccessException e)
- {
- throw new RuntimeException("Could not access bean correctly when creating client proxy for " + bean, e);
- }
- }
-
- /**
- * Gets a client proxy for a bean
- *
- * Looks for a proxy in the pool. If not found, one is created and added to
- * the pool if the create argument is true.
- *
- * @param bean The bean to get a proxy to
- * @param create Flag indicating if the proxy should be created if it does
- * not already exist
- * @return the client proxy for the bean
- */
- @SuppressWarnings("unchecked")
- public <T> T getClientProxy(final Bean<T> bean, boolean create)
- {
- if (create)
- {
- return pool.putIfAbsent(bean, new Callable<T>()
- {
-
- public T call() throws Exception
- {
- int beanIndex = CurrentManager.rootManager().getBeans().indexOf(bean);
- if (beanIndex < 0)
- {
- throw new DefinitionException(bean + " is not known to the manager");
- }
- return createClientProxy(bean, beanIndex);
- }
-
- });
- }
- else
- {
- return (T)pool.getValue(bean);
- }
- }
-
- /**
- * Gets a string representation
- *
- * @return The string representation
- */
- @Override
- public String toString()
- {
- return "Proxy pool with " + pool.size() + " proxies";
- }
-
-}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/CreationalContextImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/CreationalContextImpl.java 2009-01-28 21:20:19 UTC (rev 1265)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/CreationalContextImpl.java 2009-01-28 22:58:12 UTC (rev 1266)
@@ -11,17 +11,20 @@
private final Map<Bean<?>, Object> incompleteInstances;
private final Bean<T> bean;
+ private final boolean outer;
public CreationalContextImpl(Bean<T> bean)
{
this.incompleteInstances = new HashMap<Bean<?>, Object>();
this.bean = bean;
+ this.outer = true;
}
private CreationalContextImpl(Bean<T> bean, Map<Bean<?>, Object> incompleteInstances)
{
this.incompleteInstances = incompleteInstances;
this.bean = bean;
+ this.outer = false;
}
public void push(T incompleteInstance)
@@ -44,4 +47,9 @@
return incompleteInstances.containsKey(bean);
}
+ public boolean isOuter()
+ {
+ return outer;
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/lookup/circular/CircularDependencyTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/lookup/circular/CircularDependencyTest.java 2009-01-28 21:20:19 UTC (rev 1265)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/lookup/circular/CircularDependencyTest.java 2009-01-28 22:58:12 UTC (rev 1266)
@@ -7,7 +7,7 @@
{
- @Test(groups="broken", timeOut=1000)
+ @Test
public void testCircularInjectionOnTwoNormalBeans() throws Exception
{
deployBeans(Pig.class, Food.class);
@@ -73,7 +73,7 @@
}.run();
}
- @Test(groups="broken", timeOut=1000)
+ @Test(timeOut=1000)
public void testDependentProducerMethodDeclaredOnDependentBeanWhichInjectsProducedBean() throws Exception
{
deployBeans(DependentSelfConsumingDependentProducer.class);
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/EventTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/EventTest.java 2009-01-28 21:20:19 UTC (rev 1265)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/EventTest.java 2009-01-28 22:58:12 UTC (rev 1266)
@@ -432,6 +432,7 @@
activateDependentContext();
RecluseSpider bean = manager.getInstanceByType(RecluseSpider.class);
assert bean != null;
+ bean.toString();
manager.fireEvent("Another event");
assert RecluseSpider.notified;
16 years, 8 months
[webbeans-commits] Webbeans SVN: r1265 - in ri/trunk/jboss-as: resources and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: alesj
Date: 2009-01-28 16:20:19 -0500 (Wed, 28 Jan 2009)
New Revision: 1265
Added:
ri/trunk/jboss-as/resources/webbeans-ejb-jboss-beans.xml
Modified:
ri/trunk/jboss-as/build.xml
Log:
Make JBossEjb MC bean.
Modified: ri/trunk/jboss-as/build.xml
===================================================================
--- ri/trunk/jboss-as/build.xml 2009-01-28 16:13:08 UTC (rev 1264)
+++ ri/trunk/jboss-as/build.xml 2009-01-28 21:20:19 UTC (rev 1265)
@@ -51,6 +51,7 @@
<copy todir="target/webbeans.deployer/META-INF">
<fileset dir="${basedir}/resources">
<include name="webbeans-deployers-jboss-beans.xml"/>
+ <include name="webbeans-ejb-jboss-beans.xml"/>
<include name="jboss-structure.xml"/>
</fileset>
</copy>
@@ -61,7 +62,6 @@
<fileset dir="target/webbeans.deployer">
<include name="webbeans-ri.jar" />
<include name="webbeans-ri-int-jbossas.jar" />
- <include name="webbeans-ri-int-jboss-ejb.jar" />
<include name="webbeans-api.jar" />
<include name="webbeans-ri-spi.jar" />
</fileset>
@@ -71,6 +71,7 @@
<fileset dir="target/webbeans.deployer">
<include name="**/*.xml" />
<include name="webbeans-ri-int-microcontainer.jar" />
+ <include name="webbeans-ri-int-jboss-ejb.jar" />
<include name="google*.jar" />
</fileset>
</copy>
Added: ri/trunk/jboss-as/resources/webbeans-ejb-jboss-beans.xml
===================================================================
--- ri/trunk/jboss-as/resources/webbeans-ejb-jboss-beans.xml (rev 0)
+++ ri/trunk/jboss-as/resources/webbeans-ejb-jboss-beans.xml 2009-01-28 21:20:19 UTC (rev 1265)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Web Beans RI + JBossEJB
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <beanfactory name="JBossEjbResolver" class="org.jboss.webbeans.integration.ejb.JBossEjbResolver"/>
+
+ <beanfactory name="JBossEjbDiscovery" class="org.jboss.webbeans.integration.ejb.JBossEjbDiscovery"/>
+
+</deployment>
16 years, 8 months
[webbeans-commits] Webbeans SVN: r1264 - in ri/trunk/webbeans-ri/src: main/java/org/jboss/webbeans/bean and 7 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-01-28 11:13:08 -0500 (Wed, 28 Jan 2009)
New Revision: 1264
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/Resolver.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/AnnotationModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/MetaDataCache.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/ScopeModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/StereotypeModel.java
Removed:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exception/NotAScopeException.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/lookup/
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/AnnotationModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/ScopeModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/StereotypeModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/context/PassivatingContextTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/definition/StereotypesTest.java
Log:
tidy up
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-01-28 15:49:28 UTC (rev 1263)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -40,6 +40,7 @@
import org.jboss.webbeans.bean.NewSimpleBean;
import org.jboss.webbeans.bean.ProducerMethodBean;
import org.jboss.webbeans.bean.RIBean;
+import org.jboss.webbeans.metadata.MetaDataCache;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.ListComparator;
import org.jboss.webbeans.util.Proxies;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-01-28 15:49:28 UTC (rev 1263)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -63,11 +63,12 @@
import org.jboss.webbeans.ejb.spi.EjbResolver;
import org.jboss.webbeans.event.EventManager;
import org.jboss.webbeans.event.ObserverImpl;
+import org.jboss.webbeans.injection.Resolver;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
-import org.jboss.webbeans.lookup.Resolver;
+import org.jboss.webbeans.metadata.MetaDataCache;
import org.jboss.webbeans.resources.spi.NamingContext;
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.util.Beans;
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java 2009-01-28 15:49:28 UTC (rev 1263)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -1,142 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, 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.webbeans;
-
-import java.lang.annotation.Annotation;
-import java.util.concurrent.Callable;
-
-import org.jboss.webbeans.model.BindingTypeModel;
-import org.jboss.webbeans.model.ScopeModel;
-import org.jboss.webbeans.model.StereotypeModel;
-import org.jboss.webbeans.util.ConcurrentCache;
-
-/**
- * Metadata singleton for holding EJB metadata, scope models etc.
- *
- * @author Pete Muir
- *
- */
-public class MetaDataCache
-{
- // The singleton instance
- private static MetaDataCache instance;
-
- /**
- * Gets the singleton
- *
- * @return The instance
- */
- public static MetaDataCache instance()
- {
- return instance;
- }
-
- static
- {
- instance = new MetaDataCache();
- }
-
- // The stereotype models
- private ConcurrentCache<Class<? extends Annotation>, StereotypeModel<?>> stereotypes = new ConcurrentCache<Class<? extends Annotation>, StereotypeModel<?>>();
- // The scope models
- private ConcurrentCache<Class<? extends Annotation>, ScopeModel<?>> scopes = new ConcurrentCache<Class<? extends Annotation>, ScopeModel<?>>();
- // The binding type models
- private ConcurrentCache<Class<? extends Annotation>, BindingTypeModel<?>> bindingTypes = new ConcurrentCache<Class<? extends Annotation>, BindingTypeModel<?>>();
-
- /**
- * Gets a stereotype model
- *
- * Adds the model if it is not present.
- *
- * @param <T> The type
- * @param stereotype The stereotype
- * @return The stereotype model
- */
- public <T extends Annotation> StereotypeModel<T> getStereotype(final Class<T> stereotype)
- {
- return stereotypes.putIfAbsent(stereotype, new Callable<StereotypeModel<T>>()
- {
-
- public StereotypeModel<T> call() throws Exception
- {
- return new StereotypeModel<T>(stereotype);
- }
- });
- }
-
- /**
- * Gets a scope model
- *
- * Adds the model if it is not present.
- *
- * @param <T> The type
- * @param scopeType The scope type
- * @return The scope type model
- */
- public <T extends Annotation> ScopeModel<T> getScopeModel(final Class<T> scopeType)
- {
- return scopes.putIfAbsent(scopeType, new Callable<ScopeModel<T>>()
- {
-
- public ScopeModel<T> call() throws Exception
- {
- return new ScopeModel<T>(scopeType);
- }
-
- });
- }
-
- /**
- * Gets a binding type model.
- *
- * Adds the model if it is not present.
- *
- * @param <T> The type
- * @param bindingType The binding type
- * @return The binding type model
- */
- public <T extends Annotation> BindingTypeModel<T> getBindingTypeModel(final Class<T> bindingType)
- {
- return bindingTypes.putIfAbsent(bindingType, new Callable<BindingTypeModel<T>>()
- {
-
- public BindingTypeModel<T> call() throws Exception
- {
- return new BindingTypeModel<T>(bindingType);
- }
-
- });
- }
-
- /**
- * Gets a string representation
- *
- * @return A string representation
- */
- @Override
- public String toString()
- {
- StringBuilder buffer = new StringBuilder();
- buffer.append("Metadata cache\n");
- buffer.append("Registered binding type models: " + bindingTypes.size() + "\n");
- buffer.append("Registered scope type models: " + scopes.size() + "\n");
- buffer.append("Registered stereotype models: " + stereotypes.size() + "\n");
- return buffer.toString();
- }
-
-}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-01-28 15:49:28 UTC (rev 1263)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -42,7 +42,7 @@
import org.jboss.webbeans.literal.CurrentLiteral;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
-import org.jboss.webbeans.model.MergedStereotypes;
+import org.jboss.webbeans.metadata.MergedStereotypes;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Reflections;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-01-28 15:49:28 UTC (rev 1263)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -37,10 +37,10 @@
import javax.inject.manager.InjectionPoint;
import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.MetaDataCache;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.metadata.MetaDataCache;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Names;
import org.jboss.webbeans.util.Reflections;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-01-28 15:49:28 UTC (rev 1263)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -27,12 +27,12 @@
import javax.inject.Disposes;
import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.MetaDataCache;
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.injection.ParameterInjectionPoint;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.introspector.jlr.AnnotatedMethodImpl;
+import org.jboss.webbeans.metadata.MetaDataCache;
import org.jboss.webbeans.util.Names;
/**
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-01-28 15:49:28 UTC (rev 1263)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -32,7 +32,6 @@
import javax.persistence.PersistenceContextType;
import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.MetaDataCache;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.injection.AnnotatedInjectionPoint;
import org.jboss.webbeans.injection.ConstructorInjectionPoint;
@@ -47,6 +46,7 @@
import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.metadata.MetaDataCache;
import org.jboss.webbeans.util.Names;
import org.jboss.webbeans.util.Reflections;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java 2009-01-28 15:49:28 UTC (rev 1263)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -25,7 +25,7 @@
import javax.inject.Current;
import javax.inject.DuplicateBindingTypeException;
-import org.jboss.webbeans.MetaDataCache;
+import org.jboss.webbeans.metadata.MetaDataCache;
import org.jboss.webbeans.util.Reflections;
import org.jboss.webbeans.util.Strings;
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exception/NotAScopeException.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exception/NotAScopeException.java 2009-01-28 15:49:28 UTC (rev 1263)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exception/NotAScopeException.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.exception;
-
-import javax.inject.DefinitionException;
-
-/**
- * Exception for incorrect scope usage
- *
- * @author Pete Muir
- */
-public class NotAScopeException extends DefinitionException
-{
- private static final long serialVersionUID = 1L;
-
- /**
- * Constructor
- */
- public NotAScopeException()
- {
- super();
- }
-
- /**
- * Constructor
- *
- * @param message The exception message
- * @param throwable The root exception
- */
- public NotAScopeException(String message, Throwable throwable)
- {
- super(message, throwable);
- }
-
- /**
- * Constructor
- *
- * @param message The exception message
- */
- public NotAScopeException(String message)
- {
- super(message);
- }
-
- /**
- * Constructor
- *
- * @param throwable The root exception
- */
- public NotAScopeException(Throwable throwable)
- {
- super(throwable);
- }
-
-}
Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/Resolver.java (from rev 1263, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/lookup/Resolver.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/Resolver.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/Resolver.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -0,0 +1,380 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.injection;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.Callable;
+
+import javax.inject.TypeLiteral;
+import javax.inject.manager.Bean;
+import javax.inject.manager.Decorator;
+import javax.inject.manager.InterceptionType;
+import javax.inject.manager.Interceptor;
+
+import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.introspector.AnnotatedItem;
+import org.jboss.webbeans.introspector.ForwardingAnnotatedItem;
+import org.jboss.webbeans.metadata.BindingTypeModel;
+import org.jboss.webbeans.metadata.MetaDataCache;
+import org.jboss.webbeans.util.ConcurrentCache;
+import org.jboss.webbeans.util.ListComparator;
+
+/**
+ * Implementation of Web Beans type safe and name based bean resolution
+ *
+ * @author Pete Muir
+ */
+public class Resolver
+{
+ private static final long serialVersionUID = 1L;
+
+ private static final Class<AnnotatedItem<Object, Object>> ANNOTATED_ITEM_GENERIFIED_WITH_OBJECT_OBJECT = new TypeLiteral<AnnotatedItem<Object, Object>>(){}.getRawType();
+ private static final Class<Set<Bean<Object>>> BEAN_SET_GENERIFIED_WITH_OBJECT = new TypeLiteral<Set<Bean<Object>>>(){}.getRawType();
+ private static final Class<Set<Bean<?>>> BEAN_SET_GENERIFIED_WITH_WILDCARD = new TypeLiteral<Set<Bean<?>>>(){}.getRawType();
+
+ /**
+ * Extension of an element which bases equality not only on type, but also on
+ * binding type
+ */
+ private abstract class ResolvableAnnotatedItem<T, S> extends ForwardingAnnotatedItem<T, S>
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public boolean equals(Object other)
+ {
+ if (other instanceof AnnotatedItem)
+ {
+ AnnotatedItem<?, ?> that = (AnnotatedItem<?, ?>) other;
+ return delegate().isAssignableFrom(that) && that.getBindingTypes().equals(this.getBindingTypes());
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return delegate().hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Resolvable annotated item for " + delegate();
+ }
+
+ }
+
+ // The resolved injection points
+ private ConcurrentCache<ResolvableAnnotatedItem<?, ?>, Set<Bean<?>>> resolvedInjectionPoints;
+ // The registerd injection points
+ private Set<AnnotatedItem<?, ?>> injectionPoints;
+ // The resolved names
+ private ConcurrentCache<String, Set<Bean<?>>> resolvedNames;
+ // The Web Beans manager
+ private ManagerImpl manager;
+
+ /**
+ * Constructor
+ *
+ * @param manager The Web Beans manager
+ */
+ public Resolver(ManagerImpl manager)
+ {
+ this.injectionPoints = new HashSet<AnnotatedItem<?, ?>>();
+ this.resolvedInjectionPoints = new ConcurrentCache<ResolvableAnnotatedItem<?, ?>, Set<Bean<?>>>();
+ this.resolvedNames = new ConcurrentCache<String, Set<Bean<?>>>();
+ this.manager = manager;
+ }
+
+ /**
+ * Add multiple injection points for later resolving using
+ * {@link #registerInjectionPoint(AnnotatedItem)}. Useful during bootstrap.
+ *
+ * @param elements The injection points to add
+ */
+ public void addInjectionPoints(Collection<? extends AnnotatedItem<?, ?>> elements)
+ {
+ injectionPoints.addAll(elements);
+ }
+
+ /**
+ * Registers an injection point
+ *
+ * @param <T>
+ * @param <S>
+ * @param element The injection point to add
+ * @return A set of matching beans for the injection point
+ */
+ private <T, S> Set<Bean<T>> registerInjectionPoint(final ResolvableAnnotatedItem<T, S> element)
+ {
+ Callable<Set<Bean<T>>> callable = new Callable<Set<Bean<T>>>()
+ {
+
+ public Set<Bean<T>> call() throws Exception
+ {
+ return retainHighestPrecedenceBeans(getMatchingBeans(element, manager.getBeans()), manager.getEnabledDeploymentTypes());
+ }
+
+ };
+ return resolvedInjectionPoints.putIfAbsent(element, callable);
+ }
+
+ /**
+ * Reset all cached injection points. You must reset all cached injection
+ * points when you add a bean to the manager
+ */
+ public void clear()
+ {
+ this.resolvedInjectionPoints = new ConcurrentCache<ResolvableAnnotatedItem<?, ?>, Set<Bean<?>>>();
+ resolvedNames = new ConcurrentCache<String, Set<Bean<?>>>();
+ }
+
+ /**
+ * Resolve all injection points added using
+ * {@link #addInjectionPoints(Collection)}
+ */
+ public void resolveInjectionPoints()
+ {
+ for (final AnnotatedItem<? extends Object, ? extends Object> injectable : injectionPoints)
+ {
+
+ registerInjectionPoint(new ResolvableAnnotatedItem<Object, Object>()
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public AnnotatedItem<Object, Object> delegate()
+ {
+ return ANNOTATED_ITEM_GENERIFIED_WITH_OBJECT_OBJECT.cast(injectable);
+ }
+ });
+ }
+ }
+
+ /**
+ * Get the possible beans for the given element
+ *
+ * @param key The resolving criteria
+ * @return An unmodifiable set of matching beans
+ */
+ public <T, S> Set<Bean<T>> get(final AnnotatedItem<T, S> key)
+ {
+ Set<Bean<T>> beans = new HashSet<Bean<T>>();
+
+ final ResolvableAnnotatedItem<T, S> element = new ResolvableAnnotatedItem<T, S>()
+ {
+
+ @Override
+ public AnnotatedItem<T, S> delegate()
+ {
+ return key;
+ }
+
+ };
+ beans = registerInjectionPoint(element);
+ return Collections.unmodifiableSet(beans);
+ }
+
+ /**
+ * Get the possible beans for the given name
+ *
+ * @param name The name to match
+ * @return The set of matching beans
+ */
+ public Set<Bean<? extends Object>> get(final String name)
+ {
+ return resolvedNames.putIfAbsent(name, new Callable<Set<Bean<?>>>()
+ {
+
+ public Set<Bean<? extends Object>> call() throws Exception
+ {
+
+ Set<Bean<?>> beans = new HashSet<Bean<?>>();
+ for (Bean<?> bean : manager.getBeans())
+ {
+ if ((bean.getName() == null && name == null) || (bean.getName() != null && bean.getName().equals(name)))
+ {
+ beans.add(bean);
+ }
+ }
+ return retainHighestPrecedenceBeans(beans, manager.getEnabledDeploymentTypes());
+ }
+
+ // Helper method to deal with dynamic casts being needed
+ private Set<Bean<?>> retainHighestPrecedenceBeans(Set<Bean<?>> beans, List<Class<? extends Annotation>> enabledDeploymentTypes)
+ {
+ return BEAN_SET_GENERIFIED_WITH_WILDCARD.cast(Resolver.retainHighestPrecedenceBeans(BEAN_SET_GENERIFIED_WITH_OBJECT.cast(beans), enabledDeploymentTypes));
+ }
+
+ });
+ }
+
+
+
+ /**
+ * Filters out the beans with the highest enabled deployment type
+ *
+ * @param <T>
+ * @param beans The beans to filter
+ * @param enabledDeploymentTypes The enabled deployment types
+ * @return The filtered beans
+ */
+ private static <T> Set<Bean<T>> retainHighestPrecedenceBeans(Set<Bean<T>> beans, List<Class<? extends Annotation>> enabledDeploymentTypes)
+ {
+ if (beans.size() > 0)
+ {
+ SortedSet<Class<? extends Annotation>> possibleDeploymentTypes = new TreeSet<Class<? extends Annotation>>(new ListComparator<Class<? extends Annotation>>(enabledDeploymentTypes));
+ for (Bean<?> bean : beans)
+ {
+ possibleDeploymentTypes.add(bean.getDeploymentType());
+ }
+ possibleDeploymentTypes.retainAll(enabledDeploymentTypes);
+ Set<Bean<T>> trimmed = new HashSet<Bean<T>>();
+ if (possibleDeploymentTypes.size() > 0)
+ {
+ Class<? extends Annotation> highestPrecedencePossibleDeploymentType = possibleDeploymentTypes.last();
+
+ for (Bean<T> bean : beans)
+ {
+ if (bean.getDeploymentType().equals(highestPrecedencePossibleDeploymentType))
+ {
+ trimmed.add(bean);
+ }
+ }
+ }
+ return trimmed;
+ }
+ else
+ {
+ return beans;
+ }
+ }
+
+ /**
+ * Gets the matching beans for binding criteria from a list of beans
+ *
+ * @param <T> The type of the beans
+ * @param element The binding criteria
+ * @param beans The beans to filter
+ * @return A set of filtered beans
+ */
+ private <T> Set<Bean<T>> getMatchingBeans(AnnotatedItem<T, ?> element, List<Bean<?>> beans)
+ {
+ Set<Bean<T>> resolvedBeans = new HashSet<Bean<T>>();
+ for (Bean<?> bean : beans)
+ {
+ if (element.isAssignableFrom(bean.getTypes()) && containsAllBindingBindingTypes(element, bean.getBindings()))
+ {
+ @SuppressWarnings("unchecked")
+ Bean<T> b = (Bean<T>) bean;
+ resolvedBeans.add(b);
+ }
+ }
+ return resolvedBeans;
+ }
+
+ /**
+ * Checks if binding criteria fulfill all binding types
+ *
+ * @param element The binding criteria to check
+ * @param bindingTypes The binding types to check
+ * @return True if all matches, false otherwise
+ */
+ private boolean containsAllBindingBindingTypes(AnnotatedItem<?, ?> element, Set<Annotation> bindingTypes)
+ {
+ for (Annotation bindingType : element.getBindingTypes())
+ {
+ BindingTypeModel<?> bindingTypeModel = MetaDataCache.instance().getBindingTypeModel(bindingType.annotationType());
+ if (bindingTypeModel.getNonBindingTypes().size() > 0)
+ {
+ boolean matchFound = false;
+ for (Annotation otherBindingType : bindingTypes)
+ {
+ if (bindingTypeModel.isEqual(bindingType, otherBindingType))
+ {
+ matchFound = true;
+ }
+ }
+ if (!matchFound)
+ {
+ return false;
+ }
+ }
+ else if (!bindingTypes.contains(bindingType))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Resolves decorators according to binding criteria
+ *
+ * @param types The set of API types to match
+ * @param bindingTypes The binding types to match
+ * @return The set of matching decorators
+ */
+ public List<Decorator> resolveDecorators(Set<Type> types, Annotation[] bindingTypes)
+ {
+ // TODO Implement decorators
+ return Collections.emptyList();
+ }
+
+ /**
+ * Resolves interceptors according to binding criteria
+ *
+ * @param types The set of API types to match
+ * @param bindingTypes The binding types to match
+ * @return The set of matching interceptors
+ */
+ public List<Interceptor> resolveInterceptors(InterceptionType type, Annotation[] interceptorBindings)
+ {
+ // TODO Implement interceptors
+ return null;
+ }
+
+ /**
+ * Gets a string representation
+ *
+ * @return A string representation
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("Resolver\n");
+ buffer.append("Injection points: " + injectionPoints.size() + "\n");
+ buffer.append("Resolved injection points: " + resolvedInjectionPoints.size() + "\n");
+ buffer.append("Resolved names points: " + resolvedNames.size() + "\n");
+ return buffer.toString();
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/Resolver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata (from rev 1259, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model)
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/AnnotationModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AnnotationModel.java 2009-01-28 09:00:59 UTC (rev 1259)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/AnnotationModel.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -1,126 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.model;
-
-import java.lang.annotation.Annotation;
-
-import javax.inject.DefinitionException;
-
-import org.jboss.webbeans.introspector.AnnotatedAnnotation;
-import org.jboss.webbeans.introspector.jlr.AnnotatedAnnotationImpl;
-
-/**
- * Abstract representation of an annotation model
- *
- * @author Pete Muir
- */
-public abstract class AnnotationModel<T extends Annotation>
-{
- // The underlying annotation
- private AnnotatedAnnotation<T> annotatedAnnotation;
- // Is the data valid?
- private boolean valid;
-
- /**
- * Constructor
- *
- * @param type The annotation type
- */
- public AnnotationModel(Class<T> type)
- {
- this.annotatedAnnotation = new AnnotatedAnnotationImpl<T>(type);
- init();
- }
-
- /**
- * Initializes the type and validates it
- */
- protected void init()
- {
- initType();
- initValid();
- }
-
- /**
- * Initializes the type
- */
- protected void initType()
- {
- if (!Annotation.class.isAssignableFrom(getType()))
- {
- throw new DefinitionException(getMetaAnnotation().toString() + " can only be applied to an annotation, it was applied to " + getType());
- }
- }
-
- /**
- * Validates the data for correct annotation
- */
- protected void initValid()
- {
- this.valid = annotatedAnnotation.isAnnotationPresent(getMetaAnnotation());
- }
-
- /**
- * Gets the type of the annotation
- *
- * @return The type
- */
- public Class<T> getType()
- {
- return annotatedAnnotation.getType();
- }
-
- /**
- * Gets the meta-annotation that should be present
- *
- * @return
- */
- protected abstract Class<? extends Annotation> getMetaAnnotation();
-
- /**
- * Indicates if the annotation is valid
- *
- * @return True if valid, false otherwise
- */
- public boolean isValid()
- {
- return valid;
- }
-
- /**
- * Gets the annotated annotation
- *
- * @return The annotation
- */
- protected AnnotatedAnnotation<T> getAnnotatedAnnotation()
- {
- return annotatedAnnotation;
- }
-
- /**
- * Gets a string representation of the annotation model
- *
- * @return The string representation
- */
- @Override
- public String toString()
- {
- return (isValid() ? "Valid" : "Invalid") + " annotation model for " + getType();
- }
-
-}
\ No newline at end of file
Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/AnnotationModel.java (from rev 1263, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AnnotationModel.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/AnnotationModel.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/AnnotationModel.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.metadata;
+
+import java.lang.annotation.Annotation;
+
+import javax.inject.DefinitionException;
+
+import org.jboss.webbeans.introspector.AnnotatedAnnotation;
+import org.jboss.webbeans.introspector.jlr.AnnotatedAnnotationImpl;
+
+/**
+ * Abstract representation of an annotation model
+ *
+ * @author Pete Muir
+ */
+public abstract class AnnotationModel<T extends Annotation>
+{
+ // The underlying annotation
+ private AnnotatedAnnotation<T> annotatedAnnotation;
+ // Is the data valid?
+ private boolean valid;
+
+ /**
+ * Constructor
+ *
+ * @param type The annotation type
+ */
+ public AnnotationModel(Class<T> type)
+ {
+ this.annotatedAnnotation = new AnnotatedAnnotationImpl<T>(type);
+ init();
+ }
+
+ /**
+ * Initializes the type and validates it
+ */
+ protected void init()
+ {
+ initType();
+ initValid();
+ }
+
+ /**
+ * Initializes the type
+ */
+ protected void initType()
+ {
+ if (!Annotation.class.isAssignableFrom(getType()))
+ {
+ throw new DefinitionException(getMetaAnnotation().toString() + " can only be applied to an annotation, it was applied to " + getType());
+ }
+ }
+
+ /**
+ * Validates the data for correct annotation
+ */
+ protected void initValid()
+ {
+ this.valid = annotatedAnnotation.isAnnotationPresent(getMetaAnnotation());
+ }
+
+ /**
+ * Gets the type of the annotation
+ *
+ * @return The type
+ */
+ public Class<T> getType()
+ {
+ return annotatedAnnotation.getType();
+ }
+
+ /**
+ * Gets the meta-annotation that should be present
+ *
+ * @return
+ */
+ protected abstract Class<? extends Annotation> getMetaAnnotation();
+
+ /**
+ * Indicates if the annotation is valid
+ *
+ * @return True if valid, false otherwise
+ */
+ public boolean isValid()
+ {
+ return valid;
+ }
+
+ /**
+ * Gets the annotated annotation
+ *
+ * @return The annotation
+ */
+ protected AnnotatedAnnotation<T> getAnnotatedAnnotation()
+ {
+ return annotatedAnnotation;
+ }
+
+ /**
+ * Gets a string representation of the annotation model
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ return (isValid() ? "Valid" : "Invalid") + " annotation model for " + getType();
+ }
+
+}
\ No newline at end of file
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/BindingTypeModel.java 2009-01-28 09:00:59 UTC (rev 1259)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -1,157 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.model;
-
-import java.lang.annotation.Annotation;
-import java.util.Set;
-
-import javax.annotation.NonBinding;
-import javax.inject.BindingType;
-import javax.inject.DefinitionException;
-
-import org.jboss.webbeans.introspector.AnnotatedMethod;
-import org.jboss.webbeans.util.Reflections;
-
-/**
- *
- * Model of a binding type
- *
- * @author Pete Muir
- *
- */
-public class BindingTypeModel<T extends Annotation> extends AnnotationModel<T>
-{
- // The non-binding types
- private Set<AnnotatedMethod<?>> nonBindingTypes;
-
- /**
- * Constructor
- *
- * @param type The type
- */
- public BindingTypeModel(Class<T> type)
- {
- super(type);
- }
-
- /**
- * Initializes the non-binding types and validates the members
- */
- @Override
- protected void init()
- {
- super.init();
- initNonBindingTypes();
- checkArrayAndAnnotationValuedMembers();
- }
-
- /**
- * Validates the members
- */
- private void checkArrayAndAnnotationValuedMembers()
- {
- for (AnnotatedMethod<?> annotatedMethod : getAnnotatedAnnotation().getMembers())
- {
- if ((Reflections.isArrayType(annotatedMethod.getType()) || Annotation.class.isAssignableFrom(annotatedMethod.getType())) && !nonBindingTypes.contains(annotatedMethod))
- {
- throw new DefinitionException("Member of array type or annotation type must be annotated @NonBinding " + annotatedMethod);
- }
- }
-
- }
-
- /**
- * Gets the meta-annotation type
- *
- * @return The BindingType class
- */
- @Override
- protected Class<? extends Annotation> getMetaAnnotation()
- {
- return BindingType.class;
- }
-
- /**
- * Indicates if there are non-binding types present
- *
- * @return True if present, false otherwise
- */
- public boolean hasNonBindingTypes()
- {
- return nonBindingTypes.size() > 0;
- }
-
- /**
- * Gets the non-binding types
- *
- * @return A set of non-binding types, or an empty set if there are none
- * present
- */
- public Set<AnnotatedMethod<?>> getNonBindingTypes()
- {
- return nonBindingTypes;
- }
-
- /**
- * Initializes the non-binding types
- */
- protected void initNonBindingTypes()
- {
- nonBindingTypes = getAnnotatedAnnotation().getAnnotatedMembers(NonBinding.class);
- }
-
- /**
- * Comparator for checking equality
- *
- * @param instance The instance to check against
- * @param other The other binding type
- * @return True if equal, false otherwise
- */
- public boolean isEqual(Annotation instance, Annotation other)
- {
- if (instance.annotationType().equals(getType()) && other.annotationType().equals(getType()))
- {
- for (AnnotatedMethod<?> annotatedMethod : getAnnotatedAnnotation().getMembers())
- {
- if (!nonBindingTypes.contains(annotatedMethod))
- {
- Object thisValue = annotatedMethod.invoke(instance);
- Object thatValue = annotatedMethod.invoke(other);
- if (!thisValue.equals(thatValue))
- {
- return false;
- }
- }
- }
- return true;
- }
- return false;
- }
-
- /**
- * Gets a string representation of the binding type model
- *
- * @return The string representation
- */
- @Override
- public String toString()
- {
- return (isValid() ? "Valid" : "Invalid") + " binding type model for " + getType() + " with non-binding types " + getNonBindingTypes();
- }
-
-}
Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java (from rev 1263, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/BindingTypeModel.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.metadata;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+import javax.annotation.NonBinding;
+import javax.inject.BindingType;
+import javax.inject.DefinitionException;
+
+import org.jboss.webbeans.introspector.AnnotatedMethod;
+import org.jboss.webbeans.util.Reflections;
+
+/**
+ *
+ * Model of a binding type
+ *
+ * @author Pete Muir
+ *
+ */
+public class BindingTypeModel<T extends Annotation> extends AnnotationModel<T>
+{
+ // The non-binding types
+ private Set<AnnotatedMethod<?>> nonBindingTypes;
+
+ /**
+ * Constructor
+ *
+ * @param type The type
+ */
+ public BindingTypeModel(Class<T> type)
+ {
+ super(type);
+ }
+
+ /**
+ * Initializes the non-binding types and validates the members
+ */
+ @Override
+ protected void init()
+ {
+ super.init();
+ initNonBindingTypes();
+ checkArrayAndAnnotationValuedMembers();
+ }
+
+ /**
+ * Validates the members
+ */
+ private void checkArrayAndAnnotationValuedMembers()
+ {
+ for (AnnotatedMethod<?> annotatedMethod : getAnnotatedAnnotation().getMembers())
+ {
+ if ((Reflections.isArrayType(annotatedMethod.getType()) || Annotation.class.isAssignableFrom(annotatedMethod.getType())) && !nonBindingTypes.contains(annotatedMethod))
+ {
+ throw new DefinitionException("Member of array type or annotation type must be annotated @NonBinding " + annotatedMethod);
+ }
+ }
+
+ }
+
+ /**
+ * Gets the meta-annotation type
+ *
+ * @return The BindingType class
+ */
+ @Override
+ protected Class<? extends Annotation> getMetaAnnotation()
+ {
+ return BindingType.class;
+ }
+
+ /**
+ * Indicates if there are non-binding types present
+ *
+ * @return True if present, false otherwise
+ */
+ public boolean hasNonBindingTypes()
+ {
+ return nonBindingTypes.size() > 0;
+ }
+
+ /**
+ * Gets the non-binding types
+ *
+ * @return A set of non-binding types, or an empty set if there are none
+ * present
+ */
+ public Set<AnnotatedMethod<?>> getNonBindingTypes()
+ {
+ return nonBindingTypes;
+ }
+
+ /**
+ * Initializes the non-binding types
+ */
+ protected void initNonBindingTypes()
+ {
+ nonBindingTypes = getAnnotatedAnnotation().getAnnotatedMembers(NonBinding.class);
+ }
+
+ /**
+ * Comparator for checking equality
+ *
+ * @param instance The instance to check against
+ * @param other The other binding type
+ * @return True if equal, false otherwise
+ */
+ public boolean isEqual(Annotation instance, Annotation other)
+ {
+ if (instance.annotationType().equals(getType()) && other.annotationType().equals(getType()))
+ {
+ for (AnnotatedMethod<?> annotatedMethod : getAnnotatedAnnotation().getMembers())
+ {
+ if (!nonBindingTypes.contains(annotatedMethod))
+ {
+ Object thisValue = annotatedMethod.invoke(instance);
+ Object thatValue = annotatedMethod.invoke(other);
+ if (!thisValue.equals(thatValue))
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Gets a string representation of the binding type model
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ return (isValid() ? "Valid" : "Invalid") + " binding type model for " + getType() + " with non-binding types " + getNonBindingTypes();
+ }
+
+}
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/MergedStereotypes.java 2009-01-28 09:00:59 UTC (rev 1259)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -1,164 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.model;
-
-import java.lang.annotation.Annotation;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.webbeans.MetaDataCache;
-import org.jboss.webbeans.introspector.AnnotationStore.AnnotationMap;
-
-/**
- * Meta model for the merged stereotype for a bean
- *
- * @author Pete Muir
- */
-public class MergedStereotypes<T, E>
-{
- // The possible deployment types
- private AnnotationMap possibleDeploymentTypes;
- // The possible scope types
- private Set<Annotation> possibleScopeTypes;
- // Is the bean name defaulted?
- private boolean beanNameDefaulted;
- // The required types
- private Set<Class<?>> requiredTypes;
- // The supported scopes
- private Set<Class<? extends Annotation>> supportedScopes;
-
- /**
- * Constructor
- *
- * @param stereotypeAnnotations The stereotypes to merge
- */
- public MergedStereotypes(Set<Annotation> stereotypeAnnotations)
- {
- possibleDeploymentTypes = new AnnotationMap();
- possibleScopeTypes = new HashSet<Annotation>();
- requiredTypes = new HashSet<Class<?>>();
- supportedScopes = new HashSet<Class<? extends Annotation>>();
- merge(stereotypeAnnotations);
- }
-
- /**
- * Perform the merge
- *
- * @param stereotypeAnnotations The stereotype annotations
- */
- protected void merge(Set<Annotation> stereotypeAnnotations)
- {
- for (Annotation stereotypeAnnotation : stereotypeAnnotations)
- {
- // Retrieve and merge all metadata from stereotypes
- StereotypeModel<?> stereotype = MetaDataCache.instance().getStereotype(stereotypeAnnotation.annotationType());
- if (stereotype == null)
- {
- throw new IllegalStateException("Stereotype " + stereotypeAnnotation + " not registered with container");
- }
- if (stereotype.getDefaultDeploymentType() != null)
- {
- possibleDeploymentTypes.put(stereotype.getDefaultDeploymentType().annotationType(), stereotype.getDefaultDeploymentType());
- }
- if (stereotype.getDefaultScopeType() != null)
- {
- possibleScopeTypes.add(stereotype.getDefaultScopeType());
- }
- requiredTypes.addAll(stereotype.getRequiredTypes());
- supportedScopes.addAll(stereotype.getSupportedScopes());
- if (stereotype.isBeanNameDefaulted())
- {
- beanNameDefaulted = true;
- }
- }
- }
-
- /**
- * Returns the possible deployment typess
- *
- * @return The deployment types
- */
- public AnnotationMap getPossibleDeploymentTypes()
- {
- return possibleDeploymentTypes;
- }
-
- /**
- * Returns the possible scope types
- *
- * @return The scope types
- */
- public Set<Annotation> getPossibleScopeTypes()
- {
- return possibleScopeTypes;
- }
-
- /**
- * Indicates if the name i defaulted
- *
- * @return True if defaulted, false if not
- */
- public boolean isBeanNameDefaulted()
- {
- return beanNameDefaulted;
- }
-
- /**
- * Returns the required types
- *
- * @return The required types
- */
- public Set<Class<?>> getRequiredTypes()
- {
- return requiredTypes;
- }
-
- /**
- * Returns the supported scopes
- *
- * @return The supported scopes
- */
- public Set<Class<? extends Annotation>> getSupportedScopes()
- {
- return supportedScopes;
- }
-
- /**
- * Indicates if the bean was declared in XML
- *
- * @return True if declared in XML, else false
- */
- public boolean isDeclaredInXml()
- {
- return false;
- }
-
- /**
- * Gets a string representation of the merged stereotypes
- *
- * @return The string representation
- */
- @Override
- public String toString()
- {
- return "Merged stereotype model with possible deployment types " +
- possibleDeploymentTypes + ", required types " + requiredTypes +
- ", possible scopes " + possibleScopeTypes + " and supported scopes " + supportedScopes;
- }
-
-}
Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java (from rev 1263, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/MergedStereotypes.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -0,0 +1,163 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.metadata;
+
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.webbeans.introspector.AnnotationStore.AnnotationMap;
+
+/**
+ * Meta model for the merged stereotype for a bean
+ *
+ * @author Pete Muir
+ */
+public class MergedStereotypes<T, E>
+{
+ // The possible deployment types
+ private AnnotationMap possibleDeploymentTypes;
+ // The possible scope types
+ private Set<Annotation> possibleScopeTypes;
+ // Is the bean name defaulted?
+ private boolean beanNameDefaulted;
+ // The required types
+ private Set<Class<?>> requiredTypes;
+ // The supported scopes
+ private Set<Class<? extends Annotation>> supportedScopes;
+
+ /**
+ * Constructor
+ *
+ * @param stereotypeAnnotations The stereotypes to merge
+ */
+ public MergedStereotypes(Set<Annotation> stereotypeAnnotations)
+ {
+ possibleDeploymentTypes = new AnnotationMap();
+ possibleScopeTypes = new HashSet<Annotation>();
+ requiredTypes = new HashSet<Class<?>>();
+ supportedScopes = new HashSet<Class<? extends Annotation>>();
+ merge(stereotypeAnnotations);
+ }
+
+ /**
+ * Perform the merge
+ *
+ * @param stereotypeAnnotations The stereotype annotations
+ */
+ protected void merge(Set<Annotation> stereotypeAnnotations)
+ {
+ for (Annotation stereotypeAnnotation : stereotypeAnnotations)
+ {
+ // Retrieve and merge all metadata from stereotypes
+ StereotypeModel<?> stereotype = MetaDataCache.instance().getStereotype(stereotypeAnnotation.annotationType());
+ if (stereotype == null)
+ {
+ throw new IllegalStateException("Stereotype " + stereotypeAnnotation + " not registered with container");
+ }
+ if (stereotype.getDefaultDeploymentType() != null)
+ {
+ possibleDeploymentTypes.put(stereotype.getDefaultDeploymentType().annotationType(), stereotype.getDefaultDeploymentType());
+ }
+ if (stereotype.getDefaultScopeType() != null)
+ {
+ possibleScopeTypes.add(stereotype.getDefaultScopeType());
+ }
+ requiredTypes.addAll(stereotype.getRequiredTypes());
+ supportedScopes.addAll(stereotype.getSupportedScopes());
+ if (stereotype.isBeanNameDefaulted())
+ {
+ beanNameDefaulted = true;
+ }
+ }
+ }
+
+ /**
+ * Returns the possible deployment typess
+ *
+ * @return The deployment types
+ */
+ public AnnotationMap getPossibleDeploymentTypes()
+ {
+ return possibleDeploymentTypes;
+ }
+
+ /**
+ * Returns the possible scope types
+ *
+ * @return The scope types
+ */
+ public Set<Annotation> getPossibleScopeTypes()
+ {
+ return possibleScopeTypes;
+ }
+
+ /**
+ * Indicates if the name i defaulted
+ *
+ * @return True if defaulted, false if not
+ */
+ public boolean isBeanNameDefaulted()
+ {
+ return beanNameDefaulted;
+ }
+
+ /**
+ * Returns the required types
+ *
+ * @return The required types
+ */
+ public Set<Class<?>> getRequiredTypes()
+ {
+ return requiredTypes;
+ }
+
+ /**
+ * Returns the supported scopes
+ *
+ * @return The supported scopes
+ */
+ public Set<Class<? extends Annotation>> getSupportedScopes()
+ {
+ return supportedScopes;
+ }
+
+ /**
+ * Indicates if the bean was declared in XML
+ *
+ * @return True if declared in XML, else false
+ */
+ public boolean isDeclaredInXml()
+ {
+ return false;
+ }
+
+ /**
+ * Gets a string representation of the merged stereotypes
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ return "Merged stereotype model with possible deployment types " +
+ possibleDeploymentTypes + ", required types " + requiredTypes +
+ ", possible scopes " + possibleScopeTypes + " and supported scopes " + supportedScopes;
+ }
+
+}
Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/MetaDataCache.java (from rev 1259, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/MetaDataCache.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/MetaDataCache.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.metadata;
+
+import java.lang.annotation.Annotation;
+import java.util.concurrent.Callable;
+
+import org.jboss.webbeans.util.ConcurrentCache;
+
+/**
+ * Metadata singleton for holding EJB metadata, scope models etc.
+ *
+ * @author Pete Muir
+ *
+ */
+public class MetaDataCache
+{
+ // The singleton instance
+ private static MetaDataCache instance;
+
+ /**
+ * Gets the singleton
+ *
+ * @return The instance
+ */
+ public static MetaDataCache instance()
+ {
+ return instance;
+ }
+
+ static
+ {
+ instance = new MetaDataCache();
+ }
+
+ // The stereotype models
+ private ConcurrentCache<Class<? extends Annotation>, StereotypeModel<?>> stereotypes = new ConcurrentCache<Class<? extends Annotation>, StereotypeModel<?>>();
+ // The scope models
+ private ConcurrentCache<Class<? extends Annotation>, ScopeModel<?>> scopes = new ConcurrentCache<Class<? extends Annotation>, ScopeModel<?>>();
+ // The binding type models
+ private ConcurrentCache<Class<? extends Annotation>, BindingTypeModel<?>> bindingTypes = new ConcurrentCache<Class<? extends Annotation>, BindingTypeModel<?>>();
+
+ /**
+ * Gets a stereotype model
+ *
+ * Adds the model if it is not present.
+ *
+ * @param <T> The type
+ * @param stereotype The stereotype
+ * @return The stereotype model
+ */
+ public <T extends Annotation> StereotypeModel<T> getStereotype(final Class<T> stereotype)
+ {
+ return stereotypes.putIfAbsent(stereotype, new Callable<StereotypeModel<T>>()
+ {
+
+ public StereotypeModel<T> call() throws Exception
+ {
+ return new StereotypeModel<T>(stereotype);
+ }
+ });
+ }
+
+ /**
+ * Gets a scope model
+ *
+ * Adds the model if it is not present.
+ *
+ * @param <T> The type
+ * @param scopeType The scope type
+ * @return The scope type model
+ */
+ public <T extends Annotation> ScopeModel<T> getScopeModel(final Class<T> scopeType)
+ {
+ return scopes.putIfAbsent(scopeType, new Callable<ScopeModel<T>>()
+ {
+
+ public ScopeModel<T> call() throws Exception
+ {
+ return new ScopeModel<T>(scopeType);
+ }
+
+ });
+ }
+
+ /**
+ * Gets a binding type model.
+ *
+ * Adds the model if it is not present.
+ *
+ * @param <T> The type
+ * @param bindingType The binding type
+ * @return The binding type model
+ */
+ public <T extends Annotation> BindingTypeModel<T> getBindingTypeModel(final Class<T> bindingType)
+ {
+ return bindingTypes.putIfAbsent(bindingType, new Callable<BindingTypeModel<T>>()
+ {
+
+ public BindingTypeModel<T> call() throws Exception
+ {
+ return new BindingTypeModel<T>(bindingType);
+ }
+
+ });
+ }
+
+ /**
+ * Gets a string representation
+ *
+ * @return A string representation
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("Metadata cache\n");
+ buffer.append("Registered binding type models: " + bindingTypes.size() + "\n");
+ buffer.append("Registered scope type models: " + scopes.size() + "\n");
+ buffer.append("Registered stereotype models: " + stereotypes.size() + "\n");
+ return buffer.toString();
+ }
+
+}
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/ScopeModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/ScopeModel.java 2009-01-28 09:00:59 UTC (rev 1259)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/ScopeModel.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -1,88 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.model;
-
-import java.lang.annotation.Annotation;
-
-import javax.context.ScopeType;
-
-/**
- *
- * Model of a scope
- *
- * @author Pete Muir
- *
- */
-public class ScopeModel<T extends Annotation> extends AnnotationModel<T>
-{
- /**
- * Constrctor
- *
- * @param scope The scope type
- */
- public ScopeModel(Class<T> scope)
- {
- super(scope);
- }
-
- /**
- * Indicates if the scope is "normal"
- *
- * @return True if normal, false otherwise
- */
- public boolean isNormal()
- {
- return getAnnotatedAnnotation().getAnnotation(ScopeType.class).normal();
- }
-
- /**
- * Indicates if the scope is "passivating"
- *
- * @return True if passivating, false otherwise
- */
- public boolean isPassivating()
- {
- return getAnnotatedAnnotation().getAnnotation(ScopeType.class).passivating();
- }
-
- /**
- * Gets the corresponding meta-annotation type class
- *
- * @return The ScopeType class
- */
- @Override
- protected Class<? extends Annotation> getMetaAnnotation()
- {
- return ScopeType.class;
- }
-
- /**
- * Gets a string representation of the scope model
- *
- * @return The string representation
- */
- @Override
- public String toString()
- {
- String valid = isValid() ? "Valid " : "Invalid";
- String normal = isNormal() ? "normal " : "non-normal ";
- String passivating = isPassivating() ? "passivating " : "pon-passivating ";
- return valid + normal + passivating + " scope model for " + getType();
- }
-
-}
Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/ScopeModel.java (from rev 1263, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/ScopeModel.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/ScopeModel.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/ScopeModel.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.metadata;
+
+import java.lang.annotation.Annotation;
+
+import javax.context.ScopeType;
+
+/**
+ *
+ * Model of a scope
+ *
+ * @author Pete Muir
+ *
+ */
+public class ScopeModel<T extends Annotation> extends AnnotationModel<T>
+{
+ /**
+ * Constrctor
+ *
+ * @param scope The scope type
+ */
+ public ScopeModel(Class<T> scope)
+ {
+ super(scope);
+ }
+
+ /**
+ * Indicates if the scope is "normal"
+ *
+ * @return True if normal, false otherwise
+ */
+ public boolean isNormal()
+ {
+ return getAnnotatedAnnotation().getAnnotation(ScopeType.class).normal();
+ }
+
+ /**
+ * Indicates if the scope is "passivating"
+ *
+ * @return True if passivating, false otherwise
+ */
+ public boolean isPassivating()
+ {
+ return getAnnotatedAnnotation().getAnnotation(ScopeType.class).passivating();
+ }
+
+ /**
+ * Gets the corresponding meta-annotation type class
+ *
+ * @return The ScopeType class
+ */
+ @Override
+ protected Class<? extends Annotation> getMetaAnnotation()
+ {
+ return ScopeType.class;
+ }
+
+ /**
+ * Gets a string representation of the scope model
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ String valid = isValid() ? "Valid " : "Invalid";
+ String normal = isNormal() ? "normal " : "non-normal ";
+ String passivating = isPassivating() ? "passivating " : "pon-passivating ";
+ return valid + normal + passivating + " scope model for " + getType();
+ }
+
+}
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/StereotypeModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/StereotypeModel.java 2009-01-28 09:00:59 UTC (rev 1259)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/StereotypeModel.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -1,258 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.model;
-
-import java.lang.annotation.Annotation;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.annotation.Named;
-import javax.annotation.Stereotype;
-import javax.context.ScopeType;
-import javax.inject.BindingType;
-import javax.inject.DefinitionException;
-import javax.inject.DeploymentType;
-import javax.interceptor.InterceptorBindingType;
-
-/**
- * A meta model for a stereotype, allows us to cache a stereotype and to
- * validate it
- *
- * @author Pete Muir
- *
- */
-public class StereotypeModel<T extends Annotation> extends AnnotationModel<T>
-{
- // The default deployment type
- private Annotation defaultDeploymentType;
- // The default scope type
- private Annotation defaultScopeType;
- // Is the bean name defaulted
- private boolean beanNameDefaulted;
- // The supported scopes
- private Set<Class<? extends Annotation>> supportedScopes;
- // The required types
- private Set<Class<?>> requiredTypes;
- // The interceptor bindings
- private Set<Annotation> interceptorBindings;
-
- /**
- * Constructor
- *
- * @param sterotype The stereotype
- */
- public StereotypeModel(Class<T> sterotype)
- {
- super(sterotype);
- initDefaultDeploymentType();
- initDefaultScopeType();
- initBeanNameDefaulted();
- initSupportedScopes();
- initRequiredTypes();
- initInterceptorBindings();
- checkBindingTypes();
- }
-
- /**
- * Validates the binding types
- */
- private void checkBindingTypes()
- {
- Set<Annotation> bindingTypes = getAnnotatedAnnotation().getMetaAnnotations(BindingType.class);
- if (bindingTypes.size() > 0)
- {
- throw new DefinitionException("Cannot declare binding types on a stereotype " + getAnnotatedAnnotation());
- }
- }
-
- /**
- * Initializes the interceptor bindings
- */
- private void initInterceptorBindings()
- {
- interceptorBindings = getAnnotatedAnnotation().getMetaAnnotations(InterceptorBindingType.class);
- }
-
- /**
- * Initializes the supported scopes
- */
- private void initSupportedScopes()
- {
- this.supportedScopes = new HashSet<Class<? extends Annotation>>();
- Class<? extends Annotation>[] supportedScopes = getAnnotatedAnnotation().getAnnotation(Stereotype.class).supportedScopes();
- if (supportedScopes.length > 0)
- {
- this.supportedScopes.addAll(Arrays.asList(supportedScopes));
- }
- }
-
- /**
- * Initializes the required types
- */
- private void initRequiredTypes()
- {
- this.requiredTypes = new HashSet<Class<?>>();
- Class<?>[] requiredTypes = getAnnotatedAnnotation().getAnnotation(Stereotype.class).requiredTypes();
- if (requiredTypes.length > 0)
- {
- this.requiredTypes.addAll(Arrays.asList(requiredTypes));
- }
- }
-
- /**
- * Initializes the bean name defaulted
- */
- private void initBeanNameDefaulted()
- {
- if (getAnnotatedAnnotation().isAnnotationPresent(Named.class))
- {
- if (!"".equals(getAnnotatedAnnotation().getAnnotation(Named.class).value()))
- {
- throw new DefinitionException("Cannot specify a value for a @Named stereotype " + getAnnotatedAnnotation());
- }
- beanNameDefaulted = true;
- }
- }
-
- /**
- * Initializes the default scope type
- */
- private void initDefaultScopeType()
- {
- Set<Annotation> scopeTypes = getAnnotatedAnnotation().getMetaAnnotations(ScopeType.class);
- if (scopeTypes.size() > 1)
- {
- throw new DefinitionException("At most one scope type may be specified for " + getAnnotatedAnnotation());
- }
- else if (scopeTypes.size() == 1)
- {
- this.defaultScopeType = scopeTypes.iterator().next();
- }
- }
-
- /**
- * Initializes the default deployment type
- */
- private void initDefaultDeploymentType()
- {
- Set<Annotation> deploymentTypes = getAnnotatedAnnotation().getMetaAnnotations(DeploymentType.class);
- if (deploymentTypes.size() > 1)
- {
- throw new DefinitionException("At most one deployment type may be specified on " + getAnnotatedAnnotation());
- }
- else if (deploymentTypes.size() == 1)
- {
- this.defaultDeploymentType = deploymentTypes.iterator().next();
- }
- }
-
- /**
- * Get the default deployment type the stereotype specifies
- *
- * @return The default deployment type, or null if none is specified
- */
- public Annotation getDefaultDeploymentType()
- {
- return defaultDeploymentType;
- }
-
- /**
- * Get the default scope type the stereotype specifies
- *
- * @return The default scope type, or null if none is specified
- */
- public Annotation getDefaultScopeType()
- {
- return defaultScopeType;
- }
-
- /**
- * Get any interceptor bindings the the stereotype specifies
- *
- * @return The interceptor bindings, or an empty set if none are specified.
- */
- public Set<Annotation> getInterceptorBindings()
- {
- return interceptorBindings;
- }
-
- /**
- * Indicates if the bean name is defaulted
- *
- * @return True if defaulted, false otherwise
- */
- public boolean isBeanNameDefaulted()
- {
- return beanNameDefaulted;
- }
-
- /**
- * Gets the supported scopes
- *
- * @return A set of supported scopes, or an empty set if none are specified
- */
- public Set<Class<? extends Annotation>> getSupportedScopes()
- {
- return supportedScopes;
- }
-
- /**
- * Gets the required types
- *
- * @return A set of required types, or an empty set if none are specified
- */
- public Set<Class<?>> getRequiredTypes()
- {
- return requiredTypes;
- }
-
- /**
- * Gets the type
- *
- * @return The type
- */
- @Deprecated
- public Class<? extends Annotation> getStereotypeClass()
- {
- return getType();
- }
-
- /**
- * Gets a string representation of the stereotype
- *
- * @return The string representation
- */
- @Override
- public String toString()
- {
- return "Stereotype model with required types " + requiredTypes + " and supported scopes " + supportedScopes;
- }
-
- /**
- * Gets the meta-annotation type
- *
- * @return The Stereotype class
- */
- @Override
- protected Class<? extends Annotation> getMetaAnnotation()
- {
- return Stereotype.class;
- }
-
-}
Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/StereotypeModel.java (from rev 1263, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/StereotypeModel.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/StereotypeModel.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/metadata/StereotypeModel.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -0,0 +1,258 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.metadata;
+
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.annotation.Named;
+import javax.annotation.Stereotype;
+import javax.context.ScopeType;
+import javax.inject.BindingType;
+import javax.inject.DefinitionException;
+import javax.inject.DeploymentType;
+import javax.interceptor.InterceptorBindingType;
+
+/**
+ * A meta model for a stereotype, allows us to cache a stereotype and to
+ * validate it
+ *
+ * @author Pete Muir
+ *
+ */
+public class StereotypeModel<T extends Annotation> extends AnnotationModel<T>
+{
+ // The default deployment type
+ private Annotation defaultDeploymentType;
+ // The default scope type
+ private Annotation defaultScopeType;
+ // Is the bean name defaulted
+ private boolean beanNameDefaulted;
+ // The supported scopes
+ private Set<Class<? extends Annotation>> supportedScopes;
+ // The required types
+ private Set<Class<?>> requiredTypes;
+ // The interceptor bindings
+ private Set<Annotation> interceptorBindings;
+
+ /**
+ * Constructor
+ *
+ * @param sterotype The stereotype
+ */
+ public StereotypeModel(Class<T> sterotype)
+ {
+ super(sterotype);
+ initDefaultDeploymentType();
+ initDefaultScopeType();
+ initBeanNameDefaulted();
+ initSupportedScopes();
+ initRequiredTypes();
+ initInterceptorBindings();
+ checkBindingTypes();
+ }
+
+ /**
+ * Validates the binding types
+ */
+ private void checkBindingTypes()
+ {
+ Set<Annotation> bindingTypes = getAnnotatedAnnotation().getMetaAnnotations(BindingType.class);
+ if (bindingTypes.size() > 0)
+ {
+ throw new DefinitionException("Cannot declare binding types on a stereotype " + getAnnotatedAnnotation());
+ }
+ }
+
+ /**
+ * Initializes the interceptor bindings
+ */
+ private void initInterceptorBindings()
+ {
+ interceptorBindings = getAnnotatedAnnotation().getMetaAnnotations(InterceptorBindingType.class);
+ }
+
+ /**
+ * Initializes the supported scopes
+ */
+ private void initSupportedScopes()
+ {
+ this.supportedScopes = new HashSet<Class<? extends Annotation>>();
+ Class<? extends Annotation>[] supportedScopes = getAnnotatedAnnotation().getAnnotation(Stereotype.class).supportedScopes();
+ if (supportedScopes.length > 0)
+ {
+ this.supportedScopes.addAll(Arrays.asList(supportedScopes));
+ }
+ }
+
+ /**
+ * Initializes the required types
+ */
+ private void initRequiredTypes()
+ {
+ this.requiredTypes = new HashSet<Class<?>>();
+ Class<?>[] requiredTypes = getAnnotatedAnnotation().getAnnotation(Stereotype.class).requiredTypes();
+ if (requiredTypes.length > 0)
+ {
+ this.requiredTypes.addAll(Arrays.asList(requiredTypes));
+ }
+ }
+
+ /**
+ * Initializes the bean name defaulted
+ */
+ private void initBeanNameDefaulted()
+ {
+ if (getAnnotatedAnnotation().isAnnotationPresent(Named.class))
+ {
+ if (!"".equals(getAnnotatedAnnotation().getAnnotation(Named.class).value()))
+ {
+ throw new DefinitionException("Cannot specify a value for a @Named stereotype " + getAnnotatedAnnotation());
+ }
+ beanNameDefaulted = true;
+ }
+ }
+
+ /**
+ * Initializes the default scope type
+ */
+ private void initDefaultScopeType()
+ {
+ Set<Annotation> scopeTypes = getAnnotatedAnnotation().getMetaAnnotations(ScopeType.class);
+ if (scopeTypes.size() > 1)
+ {
+ throw new DefinitionException("At most one scope type may be specified for " + getAnnotatedAnnotation());
+ }
+ else if (scopeTypes.size() == 1)
+ {
+ this.defaultScopeType = scopeTypes.iterator().next();
+ }
+ }
+
+ /**
+ * Initializes the default deployment type
+ */
+ private void initDefaultDeploymentType()
+ {
+ Set<Annotation> deploymentTypes = getAnnotatedAnnotation().getMetaAnnotations(DeploymentType.class);
+ if (deploymentTypes.size() > 1)
+ {
+ throw new DefinitionException("At most one deployment type may be specified on " + getAnnotatedAnnotation());
+ }
+ else if (deploymentTypes.size() == 1)
+ {
+ this.defaultDeploymentType = deploymentTypes.iterator().next();
+ }
+ }
+
+ /**
+ * Get the default deployment type the stereotype specifies
+ *
+ * @return The default deployment type, or null if none is specified
+ */
+ public Annotation getDefaultDeploymentType()
+ {
+ return defaultDeploymentType;
+ }
+
+ /**
+ * Get the default scope type the stereotype specifies
+ *
+ * @return The default scope type, or null if none is specified
+ */
+ public Annotation getDefaultScopeType()
+ {
+ return defaultScopeType;
+ }
+
+ /**
+ * Get any interceptor bindings the the stereotype specifies
+ *
+ * @return The interceptor bindings, or an empty set if none are specified.
+ */
+ public Set<Annotation> getInterceptorBindings()
+ {
+ return interceptorBindings;
+ }
+
+ /**
+ * Indicates if the bean name is defaulted
+ *
+ * @return True if defaulted, false otherwise
+ */
+ public boolean isBeanNameDefaulted()
+ {
+ return beanNameDefaulted;
+ }
+
+ /**
+ * Gets the supported scopes
+ *
+ * @return A set of supported scopes, or an empty set if none are specified
+ */
+ public Set<Class<? extends Annotation>> getSupportedScopes()
+ {
+ return supportedScopes;
+ }
+
+ /**
+ * Gets the required types
+ *
+ * @return A set of required types, or an empty set if none are specified
+ */
+ public Set<Class<?>> getRequiredTypes()
+ {
+ return requiredTypes;
+ }
+
+ /**
+ * Gets the type
+ *
+ * @return The type
+ */
+ @Deprecated
+ public Class<? extends Annotation> getStereotypeClass()
+ {
+ return getType();
+ }
+
+ /**
+ * Gets a string representation of the stereotype
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ return "Stereotype model with required types " + requiredTypes + " and supported scopes " + supportedScopes;
+ }
+
+ /**
+ * Gets the meta-annotation type
+ *
+ * @return The Stereotype class
+ */
+ @Override
+ protected Class<? extends Annotation> getMetaAnnotation()
+ {
+ return Stereotype.class;
+ }
+
+}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java 2009-01-28 15:49:28 UTC (rev 1263)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -21,9 +21,9 @@
import javax.inject.manager.Bean;
-import org.jboss.webbeans.MetaDataCache;
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.RIBean;
+import org.jboss.webbeans.metadata.MetaDataCache;
/**
* Helper class for bean inspection
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/context/PassivatingContextTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/context/PassivatingContextTest.java 2009-01-28 15:49:28 UTC (rev 1263)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/context/PassivatingContextTest.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -5,7 +5,7 @@
import javax.context.RequestScoped;
import javax.context.SessionScoped;
-import org.jboss.webbeans.MetaDataCache;
+import org.jboss.webbeans.metadata.MetaDataCache;
import org.testng.annotations.Test;
public class PassivatingContextTest extends org.jboss.webbeans.test.unit.AbstractTest
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/definition/StereotypesTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/definition/StereotypesTest.java 2009-01-28 15:49:28 UTC (rev 1263)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/definition/StereotypesTest.java 2009-01-28 16:13:08 UTC (rev 1264)
@@ -4,7 +4,7 @@
import javax.context.RequestScoped;
-import org.jboss.webbeans.model.StereotypeModel;
+import org.jboss.webbeans.metadata.StereotypeModel;
import org.jboss.webbeans.test.unit.AbstractTest;
import org.testng.annotations.Test;
16 years, 8 months
[webbeans-commits] Webbeans SVN: r1263 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean and 10 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-01-28 10:49:28 -0500 (Wed, 28 Jan 2009)
New Revision: 1263
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/RIBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/AbstractStandardBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java
Removed:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/InjectionPointBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/InjectionPointProvider.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ConstructorInjectionPoint.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/lookup/Resolver.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/bootstrap/BootstrapTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/lookup/circular/CircularDependencyTest.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/lookup/injectionpoint/InjectionPointTest.java
Log:
use getInstanceForInjection to find injection point, better hierachy for standard beans, enable a couple of TCK tests
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -35,11 +35,11 @@
import javax.inject.manager.Bean;
import javax.inject.manager.InjectionPoint;
-import org.jboss.webbeans.bean.AbstractBean;
import org.jboss.webbeans.bean.AbstractProducerBean;
import org.jboss.webbeans.bean.NewEnterpriseBean;
import org.jboss.webbeans.bean.NewSimpleBean;
import org.jboss.webbeans.bean.ProducerMethodBean;
+import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.ListComparator;
import org.jboss.webbeans.util.Proxies;
@@ -117,9 +117,9 @@
throw new UnsupportedOperationException("Not yet implemented");
}
}
- if (bean instanceof AbstractBean && !(bean instanceof NewSimpleBean) && !(bean instanceof NewEnterpriseBean))
+ if (bean instanceof RIBean && !(bean instanceof NewSimpleBean) && !(bean instanceof NewEnterpriseBean))
{
- AbstractBean<?, ?> abstractBean = (AbstractBean<?, ?>) bean;
+ RIBean<?> abstractBean = (RIBean<?>) bean;
if (abstractBean.isSpecializing())
{
if (!hasHigherPrecedence(bean.getDeploymentType(), abstractBean.getSpecializedBean().getDeploymentType()))
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -53,9 +53,9 @@
import javax.inject.manager.Interceptor;
import javax.inject.manager.Manager;
-import org.jboss.webbeans.bean.AbstractBean;
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.NewEnterpriseBean;
+import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.bean.proxy.ProxyPool;
import org.jboss.webbeans.context.ContextMap;
import org.jboss.webbeans.context.CreationalContextImpl;
@@ -63,7 +63,6 @@
import org.jboss.webbeans.ejb.spi.EjbResolver;
import org.jboss.webbeans.event.EventManager;
import org.jboss.webbeans.event.ObserverImpl;
-import org.jboss.webbeans.injection.InjectionPointProvider;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedMethod;
@@ -83,7 +82,6 @@
* @author Pete Muir
*
*/
-@Standard
public class ManagerImpl implements Manager, Serializable
{
@@ -98,8 +96,9 @@
private transient List<Class<? extends Annotation>> enabledDeploymentTypes;
// The Web Beans event manager
private transient final EventManager eventManager;
+
// An injection point metadata beans factory
- private transient final InjectionPointProvider injectionPointProvider;
+ private transient final ThreadLocal<InjectionPoint> currentInjectionPoint;
// The bean resolver
private transient final Resolver resolver;
@@ -130,8 +129,6 @@
private transient final NamingContext namingContext;
private final transient Map<Bean<?>, Bean<?>> specializedBeans;
-
- private final transient ThreadLocal<Map<Bean<?>, ?>> incompleteInstances;
/**
* Create a new manager
@@ -153,18 +150,8 @@
this.contextMap = new ContextMap();
this.eventManager = new EventManager();
this.ejbDescriptorCache = new EjbDescriptorCache();
- this.injectionPointProvider = new InjectionPointProvider();
+ this.currentInjectionPoint = new ThreadLocal<InjectionPoint>();
this.specializedBeans = new HashMap<Bean<?>, Bean<?>>();
- this.incompleteInstances = new ThreadLocal<Map<Bean<?>,?>>()
- {
-
- @Override
- protected Map<Bean<?>, ?> initialValue()
- {
- return new HashMap<Bean<?>, Object>();
- }
-
- };
List<Class<? extends Annotation>> defaultEnabledDeploymentTypes = new ArrayList<Class<? extends Annotation>>();
defaultEnabledDeploymentTypes.add(0, Standard.class);
defaultEnabledDeploymentTypes.add(1, Production.class);
@@ -350,12 +337,12 @@
* @return A reference to the manager
*/
// TODO Build maps in the deployer :-)
- public void setBeans(Set<AbstractBean<?, ?>> beans)
+ public void setBeans(Set<RIBean<?>> beans)
{
synchronized (beans)
{
this.beans = new CopyOnWriteArrayList<Bean<?>>(beans);
- for (AbstractBean<?, ?> bean : beans)
+ for (RIBean<?> bean : beans)
{
if (bean instanceof NewEnterpriseBean)
{
@@ -602,35 +589,47 @@
public <T> T getInstanceToInject(InjectionPoint injectionPoint)
{
- return getInstanceToInject(AnnotatedClassImpl.of((Class<T>) injectionPoint.getType(), injectionPoint.getBindings().toArray(new Annotation[0])), null);
+ return this.<T>getInstanceToInject(injectionPoint, null);
}
public <T> T getInstanceToInject(InjectionPoint injectionPoint, CreationalContext<?> creationalContext)
{
- return getInstanceToInject(AnnotatedClassImpl.of((Class<T>) injectionPoint.getType(), injectionPoint.getBindings().toArray(new Annotation[0])), creationalContext);
- }
-
- private <T> T getInstanceToInject(AnnotatedItem<T, ?> element, CreationalContext<?> creationalContext)
- {
- Bean<T> bean = getBeanByType(element, element.getBindingTypesAsArray());
- if (creationalContext instanceof CreationalContextImpl)
+ boolean registerInjectionPoint = !injectionPoint.getType().equals(InjectionPoint.class);
+ try
{
- CreationalContextImpl<?> ctx = (CreationalContextImpl<?>) creationalContext;
- if (ctx.containsIncompleteInstance(bean))
+ if (registerInjectionPoint)
{
- return ctx.getIncompleteInstance(bean);
+ currentInjectionPoint.set(injectionPoint);
}
+ AnnotatedItem<T, ?> element = AnnotatedClassImpl.of((Class<T>) injectionPoint.getType(), injectionPoint.getBindings().toArray(new Annotation[0]));
+ Bean<T> bean = getBeanByType(element, element.getBindingTypesAsArray());
+ if (creationalContext instanceof CreationalContextImpl)
+ {
+ CreationalContextImpl<?> ctx = (CreationalContextImpl<?>) creationalContext;
+ if (ctx.containsIncompleteInstance(bean))
+ {
+ return ctx.getIncompleteInstance(bean);
+ }
+ else
+ {
+ return getInstance(bean, ctx.getCreationalContext(bean));
+ }
+ }
else
{
- return getInstance(bean, ctx.getCreationalContext(bean));
+ return getInstance(bean);
}
}
- else
+ finally
{
- return getInstance(bean);
+ if (registerInjectionPoint)
+ {
+ currentInjectionPoint.remove();
+ }
}
}
+
/**
* Gets an instance by name, returning null if none is found and throwing an
* exception if too many beans match
@@ -871,9 +870,9 @@
*
* @return the factory
*/
- public InjectionPointProvider getInjectionPointProvider()
+ public InjectionPoint getInjectionPoint()
{
- return injectionPointProvider;
+ return currentInjectionPoint.get();
}
/**
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -54,7 +54,7 @@
* @param <T> the type of bean
* @param <E> the Class<?> of the bean type
*/
-public abstract class AbstractBean<T, E> extends Bean<T>
+public abstract class AbstractBean<T, E> extends RIBean<T>
{
@SuppressWarnings("unchecked")
@@ -417,7 +417,7 @@
*
* @return The set of merged stereotypes
*/
- public MergedStereotypes<T, E> getMergedStereotypes()
+ protected MergedStereotypes<T, E> getMergedStereotypes()
{
return mergedStereotypes;
}
@@ -542,6 +542,7 @@
}
@Override
+ // TODO Fix this!!!
public boolean equals(Object other)
{
if (other instanceof AbstractBean)
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -35,7 +35,6 @@
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.injection.FieldInjectionPoint;
-import org.jboss.webbeans.injection.InjectionPointProvider;
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.injection.ParameterInjectionPoint;
import org.jboss.webbeans.introspector.AnnotatedClass;
@@ -98,18 +97,9 @@
*/
protected void injectBoundFields(T instance, CreationalContext<T> creationalContext)
{
- InjectionPointProvider injectionPointProvider = manager.getInjectionPointProvider();
for (FieldInjectionPoint<?> injectableField : injectableFields)
{
- injectionPointProvider.pushInjectionPoint(injectableField);
- try
- {
- injectableField.inject(instance, manager, creationalContext);
- }
- finally
- {
- injectionPointProvider.popInjectionPoint();
- }
+ injectableField.inject(instance, manager, creationalContext);
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -194,7 +194,7 @@
{
throw new IllegalProductException("Producers cannot declare passivating scope and return a non-serializable class");
}
- InjectionPoint injectionPoint = manager.getInjectionPointProvider().getCurrentInjectionPoint();
+ InjectionPoint injectionPoint = manager.getInjectionPoint();
if (injectionPoint == null)
{
return;
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/InjectionPointBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/InjectionPointBean.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/InjectionPointBean.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.bean;
-
-import javax.context.CreationalContext;
-
-import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.introspector.AnnotatedItem;
-
-/**
- * Bean for InjectionPoint metadata
- *
- * @author David Allen
- *
- */
-public class InjectionPointBean<T, S> extends AbstractFacadeBean<T, S, Object>
-{
-
- /**
- * Creates an InjectionPoint Web Bean for the injection of the containing bean owning
- * the field, constructor or method for the annotated item
- *
- * @param <T> must be InjectionPoint
- * @param <S>
- * @param field The annotated member field/parameter for the injection
- * @param manager The RI manager implementation
- * @return a new bean for this injection point
- */
- public static <T, S> InjectionPointBean<T, S> of(AnnotatedItem<T, S> field, ManagerImpl manager)
- {
- return new InjectionPointBean<T, S>(field, manager);
- }
-
- protected InjectionPointBean(AnnotatedItem<T, S> field, ManagerImpl manager)
- {
- super(field, manager);
- }
-
- public T create(CreationalContext<T> creationalContext)
- {
- // TODO Why do we need to cast here?
- return getType().cast(manager.getInjectionPointProvider().getPreviousInjectionPoint());
- }
-
- public void destroy(T instance)
- {
- // The instance is always in the Dependent context and can be garbage
- // collected
- }
-
-}
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/RIBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/RIBean.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/RIBean.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -0,0 +1,45 @@
+package org.jboss.webbeans.bean;
+
+import java.util.Set;
+
+import javax.context.Dependent;
+import javax.inject.manager.Bean;
+
+import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.injection.AnnotatedInjectionPoint;
+
+public abstract class RIBean<T> extends Bean<T>
+{
+
+ private final ManagerImpl manager;
+
+ protected RIBean(ManagerImpl manager)
+ {
+ super(manager);
+ this.manager = manager;
+ }
+
+ @Override
+ protected ManagerImpl getManager()
+ {
+ return manager;
+ }
+
+ public abstract Class<T> getType();
+
+ public abstract boolean isSpecializing();
+
+ public boolean isDependent()
+ {
+ return getScopeType().equals(Dependent.class);
+ }
+
+ public abstract boolean isProxyable();
+
+ public abstract boolean isPrimitive();
+
+ public abstract Set<AnnotatedInjectionPoint<?, ?>> getInjectionPoints();
+
+ public abstract RIBean<?> getSpecializedBean();
+
+}
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/RIBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -37,7 +37,6 @@
import org.jboss.webbeans.injection.AnnotatedInjectionPoint;
import org.jboss.webbeans.injection.ConstructorInjectionPoint;
import org.jboss.webbeans.injection.FieldInjectionPoint;
-import org.jboss.webbeans.injection.InjectionPointProvider;
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.injection.ParameterInjectionPoint;
import org.jboss.webbeans.introspector.AnnotatedClass;
@@ -125,7 +124,6 @@
try
{
DependentContext.INSTANCE.setActive(true);
- InjectionPointProvider injectionPointProvider = manager.getInjectionPointProvider();
T instance = null;
try
{
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/AbstractStandardBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/AbstractStandardBean.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/AbstractStandardBean.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -0,0 +1,94 @@
+package org.jboss.webbeans.bean.standard;
+
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.context.Dependent;
+import javax.inject.Standard;
+
+import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.bean.RIBean;
+import org.jboss.webbeans.injection.AnnotatedInjectionPoint;
+import org.jboss.webbeans.literal.CurrentLiteral;
+
+public abstract class AbstractStandardBean<T> extends RIBean<T>
+{
+
+ protected AbstractStandardBean(ManagerImpl manager)
+ {
+ super(manager);
+ }
+
+ private static final Annotation[] DEFAULT_BINDING_ARRAY = { new CurrentLiteral() };
+ private static final Set<Annotation> DEFAULT_BINDING = new HashSet<Annotation>(Arrays.asList(DEFAULT_BINDING_ARRAY));
+
+ @Override
+ public Set<Annotation> getBindings()
+ {
+ return DEFAULT_BINDING;
+ }
+
+ @Override
+ public Class<? extends Annotation> getDeploymentType()
+ {
+ return Standard.class;
+ }
+
+ @Override
+ public Class<? extends Annotation> getScopeType()
+ {
+ return Dependent.class;
+ }
+
+ @Override
+ public RIBean<?> getSpecializedBean()
+ {
+ return null;
+ }
+
+ @Override
+ public String getName()
+ {
+ return null;
+ }
+
+ @Override
+ public Set<AnnotatedInjectionPoint<?, ?>> getInjectionPoints()
+ {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public boolean isNullable()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isPrimitive()
+ {
+ return false;
+ }
+
+ @Override
+ public boolean isSerializable()
+ {
+ return false;
+ }
+
+ @Override
+ public boolean isSpecializing()
+ {
+ return false;
+ }
+
+ @Override
+ public boolean isProxyable()
+ {
+ return false;
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/AbstractStandardBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java (from rev 1259, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/InjectionPointBean.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.bean.standard;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.context.CreationalContext;
+import javax.inject.manager.InjectionPoint;
+
+import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
+import org.jboss.webbeans.literal.CurrentLiteral;
+
+/**
+ * Bean for InjectionPoint metadata
+ *
+ * @author David Allen
+ *
+ */
+public class InjectionPointBean extends AbstractStandardBean<InjectionPoint>
+{
+
+ private static final Annotation[] DEFAULT_BINDING_ARRAY = { new CurrentLiteral() };
+ private static final Set<Annotation> DEFAULT_BINDING = new HashSet<Annotation>(Arrays.asList(DEFAULT_BINDING_ARRAY));
+ private static final Set<Type> TYPES = new HashSet<Type>(Arrays.asList(InjectionPoint.class));
+
+ /**
+ * Creates an InjectionPoint Web Bean for the injection of the containing bean owning
+ * the field, constructor or method for the annotated item
+ *
+ * @param <T> must be InjectionPoint
+ * @param <S>
+ * @param field The annotated member field/parameter for the injection
+ * @param manager The RI manager implementation
+ * @return a new bean for this injection point
+ */
+ public static InjectionPointBean of(ManagerImpl manager)
+ {
+ return new InjectionPointBean(AnnotatedClassImpl.of(InjectionPoint.class), manager);
+ }
+
+ protected InjectionPointBean(AnnotatedClass<InjectionPoint> clazz, ManagerImpl manager)
+ {
+ super(manager);
+ }
+
+ public InjectionPoint create(CreationalContext<InjectionPoint> creationalContext)
+ {
+ return getManager().getInjectionPoint();
+ }
+
+ public void destroy(InjectionPoint instance)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Class<InjectionPoint> getType()
+ {
+ return InjectionPoint.class;
+ }
+
+ @Override
+ public Set<Type> getTypes()
+ {
+ return TYPES;
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -0,0 +1,53 @@
+/**
+ *
+ */
+package org.jboss.webbeans.bean.standard;
+
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.context.CreationalContext;
+import javax.inject.manager.Manager;
+
+import org.jboss.webbeans.ManagerImpl;
+
+public class ManagerBean extends AbstractStandardBean<ManagerImpl>
+{
+
+ private static final Set<Type> TYPES = new HashSet<Type>(Arrays.asList(ManagerImpl.class, Manager.class));
+
+ public static final ManagerBean of(ManagerImpl manager)
+ {
+ return new ManagerBean(manager);
+ }
+
+ protected ManagerBean(ManagerImpl manager)
+ {
+ super(manager);
+ }
+
+ public ManagerImpl create(CreationalContext<ManagerImpl> creationalContext)
+ {
+ return getManager();
+ }
+
+ @Override
+ public Class<ManagerImpl> getType()
+ {
+ return ManagerImpl.class;
+ }
+
+ @Override
+ public Set<Type> getTypes()
+ {
+ return TYPES;
+ }
+
+ public void destroy(ManagerImpl instance)
+ {
+ // No-op
+ }
+
+}
\ No newline at end of file
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -18,7 +18,6 @@
import javax.inject.Realizes;
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.EventBean;
@@ -27,6 +26,7 @@
import org.jboss.webbeans.bean.NewSimpleBean;
import org.jboss.webbeans.bean.ProducerFieldBean;
import org.jboss.webbeans.bean.ProducerMethodBean;
+import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.bean.SimpleBean;
import org.jboss.webbeans.ejb.EJBApiAbstraction;
import org.jboss.webbeans.event.ObserverImpl;
@@ -50,19 +50,19 @@
private static final Set<Annotation> EMPTY_BINDINGS = Collections.emptySet();
- private final Set<AbstractBean<?, ?>> beans;
+ private final Set<RIBean<?>> beans;
private final Set<AnnotatedClass<?>> deferredClasses;
private final ManagerImpl manager;
public BeanDeployer(ManagerImpl manager)
{
this.manager = manager;
- this.beans = new HashSet<AbstractBean<?,?>>();
+ this.beans = new HashSet<RIBean<?>>();
this.deferredClasses = new HashSet<AnnotatedClass<?>>();
}
- public void addBean(AbstractBean<?, ?> bean)
+ public void addBean(RIBean<?> bean)
{
this.beans.add(bean);
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -17,19 +17,16 @@
package org.jboss.webbeans.bootstrap;
-import java.util.Collections;
-import javax.context.CreationalContext;
import org.jboss.webbeans.BeanValidator;
import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.bean.standard.InjectionPointBean;
+import org.jboss.webbeans.bean.standard.ManagerBean;
import org.jboss.webbeans.bootstrap.spi.EjbDiscovery;
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
import org.jboss.webbeans.ejb.spi.EjbResolver;
-import org.jboss.webbeans.introspector.AnnotatedClass;
-import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
import org.jboss.webbeans.literal.DeployedLiteral;
import org.jboss.webbeans.literal.InitializedLiteral;
import org.jboss.webbeans.log.LogProvider;
@@ -47,38 +44,6 @@
public abstract class WebBeansBootstrap
{
- private static class ManagerBean extends SimpleBean<ManagerImpl>
- {
-
- public static final SimpleBean<ManagerImpl> of(ManagerImpl manager)
- {
- return new ManagerBean(AnnotatedClassImpl.of(ManagerImpl.class), manager);
- }
-
- protected ManagerBean(AnnotatedClass<ManagerImpl> type, ManagerImpl manager)
- {
- super(type, manager);
- }
-
- @Override
- protected void initConstructor()
- {
- // No - op, no constructor needed
- }
-
- @Override
- protected void initInjectionPoints()
- {
- injectionPoints = Collections.emptySet();
- }
-
- public ManagerImpl create(CreationalContext<ManagerImpl> creationalContext)
- {
- return manager;
- }
-
- }
-
// The log provider
private static LogProvider log = Logging.getLogProvider(WebBeansBootstrap.class);
@@ -130,6 +95,7 @@
BeanDeployer beanDeployer = new BeanDeployer(manager);
beanDeployer.addClasses(classes);
beanDeployer.addBean(ManagerBean.of(manager));
+ beanDeployer.addBean(InjectionPointBean.of(manager));
beanDeployer.addClass(Transaction.class);
beanDeployer.deploy();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -43,6 +43,7 @@
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.AbstractBean;
import org.jboss.webbeans.bean.AbstractClassBean;
+import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.introspector.AnnotatedMethod;
@@ -196,7 +197,7 @@
Object dependentsCollector = new Object();
try
{
- if (Dependent.class.equals(observerBean.getScopeType()) && observerBean instanceof AbstractBean)
+ if (Dependent.class.equals(observerBean.getScopeType()) && observerBean instanceof RIBean)
{
DependentContext.INSTANCE.setCurrentInjectionInstance(dependentsCollector);
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ConstructorInjectionPoint.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ConstructorInjectionPoint.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ConstructorInjectionPoint.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -8,7 +8,6 @@
import java.util.Set;
import javax.context.CreationalContext;
-import javax.inject.Produces;
import javax.inject.manager.Bean;
import org.jboss.webbeans.ManagerImpl;
@@ -120,8 +119,6 @@
protected Object[] getParameterValues(List<ParameterInjectionPoint<?>> parameters, Object specialVal, Class<? extends Annotation> specialParam, ManagerImpl manager, CreationalContext<?> creationalContext)
{
Object[] parameterValues = new Object[parameters.size()];
- boolean producerMethod = this.isAnnotationPresent(Produces.class);
- InjectionPointProvider injectionPointProvider = manager.getInjectionPointProvider();
Iterator<ParameterInjectionPoint<?>> iterator = parameters.iterator();
for (int i = 0; i < parameterValues.length; i++)
{
@@ -132,21 +129,7 @@
}
else
{
- if (!producerMethod)
- {
- injectionPointProvider.pushInjectionPoint(param);
- }
- try
- {
- parameterValues[i] = param.getValueToInject(manager, creationalContext);
- }
- finally
- {
- if (!producerMethod)
- {
- injectionPointProvider.popInjectionPoint();
- }
- }
+ parameterValues[i] = param.getValueToInject(manager, creationalContext);
}
}
return parameterValues;
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/InjectionPointProvider.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/InjectionPointProvider.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/InjectionPointProvider.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -1,83 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.injection;
-
-import java.util.Stack;
-
-import javax.inject.manager.InjectionPoint;
-
-/**
- * Provides injection point metadata
- *
- * @author David Allen
- * @author Nicklas Karlsson
- */
-public class InjectionPointProvider
-{
- // The stack of injection points
- private final Stack<InjectionPoint> injectionPoints = new Stack<InjectionPoint>();
-
- /**
- * Pushes an injection point to the stack
- *
- * @param injectionPoint The injection point to push
- */
- public void pushInjectionPoint(AnnotatedInjectionPoint<?, ?> injectionPoint)
- {
- injectionPoints.push(injectionPoint);
- }
-
- /**
- * Pops an injection point
- */
- public void popInjectionPoint()
- {
- if (injectionPoints.isEmpty())
- {
- return;
- }
- injectionPoints.pop();
- }
-
- /**
- * Gets the current injection point
- *
- * @return The current injection point or null if there is none on the stack
- */
- public InjectionPoint getCurrentInjectionPoint()
- {
- return injectionPoints.isEmpty() ? null : injectionPoints.peek();
- }
-
- /**
- * Gets the previous injection point
- *
- * @return The previous injection point or null if there is none on the stack
- */
- public InjectionPoint getPreviousInjectionPoint()
- {
- return injectionPoints.size() < 2 ? null : injectionPoints.elementAt(injectionPoints.size() - 2);
- }
-
- @Override
- public String toString()
- {
- return "InjectionPoint stack = " + injectionPoints.toString();
- }
-
-}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -8,7 +8,6 @@
import java.util.Set;
import javax.context.CreationalContext;
-import javax.inject.Produces;
import javax.inject.manager.Bean;
import org.jboss.webbeans.ManagerImpl;
@@ -125,8 +124,6 @@
protected Object[] getParameterValues(List<ParameterInjectionPoint<?>> parameters, Class<? extends Annotation> specialParam, Object specialVal, ManagerImpl manager, CreationalContext<?> creationalContext)
{
Object[] parameterValues = new Object[parameters.size()];
- boolean producerMethod = this.isAnnotationPresent(Produces.class);
- InjectionPointProvider injectionPointProvider = manager.getInjectionPointProvider();
Iterator<ParameterInjectionPoint<?>> iterator = parameters.iterator();
for (int i = 0; i < parameterValues.length; i++)
{
@@ -137,21 +134,7 @@
}
else
{
- if (!producerMethod)
- {
- injectionPointProvider.pushInjectionPoint(param);
- }
- try
- {
- parameterValues[i] = param.getValueToInject(manager, creationalContext);
- }
- finally
- {
- if (!producerMethod)
- {
- injectionPointProvider.popInjectionPoint();
- }
- }
+ parameterValues[i] = param.getValueToInject(manager, creationalContext);
}
}
return parameterValues;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -165,7 +165,7 @@
{
return toString;
}
- toString = "Annotated field " + Names.fieldToString(field);
+ toString = Names.fieldToString(field) + " on " + getDeclaringClass();
return toString;
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/lookup/Resolver.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/lookup/Resolver.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/lookup/Resolver.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -31,13 +31,11 @@
import javax.inject.TypeLiteral;
import javax.inject.manager.Bean;
import javax.inject.manager.Decorator;
-import javax.inject.manager.InjectionPoint;
import javax.inject.manager.InterceptionType;
import javax.inject.manager.Interceptor;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.MetaDataCache;
-import org.jboss.webbeans.bean.InjectionPointBean;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.ForwardingAnnotatedItem;
import org.jboss.webbeans.model.BindingTypeModel;
@@ -200,15 +198,7 @@
}
};
-
- if (InjectionPoint.class.isAssignableFrom(element.getType()))
- {
- beans.add(InjectionPointBean.of(key, manager));
- }
- else
- {
- beans = registerInjectionPoint(element);
- }
+ beans = registerInjectionPoint(element);
return Collections.unmodifiableSet(beans);
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -22,8 +22,8 @@
import javax.inject.manager.Bean;
import org.jboss.webbeans.MetaDataCache;
-import org.jboss.webbeans.bean.AbstractBean;
import org.jboss.webbeans.bean.EnterpriseBean;
+import org.jboss.webbeans.bean.RIBean;
/**
* Helper class for bean inspection
@@ -60,9 +60,9 @@
*/
public static boolean isBeanProxyable(Bean<?> bean)
{
- if (bean instanceof AbstractBean)
+ if (bean instanceof RIBean)
{
- return ((AbstractBean<?, ?>) bean).isProxyable();
+ return ((RIBean<?>) bean).isProxyable();
}
else
{
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/bootstrap/BootstrapTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/bootstrap/BootstrapTest.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/bootstrap/BootstrapTest.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -6,9 +6,9 @@
import javax.inject.manager.Bean;
-import org.jboss.webbeans.bean.AbstractBean;
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.ProducerMethodBean;
+import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.bean.SimpleBean;
import org.jboss.webbeans.test.mock.MockBootstrap;
import org.jboss.webbeans.test.unit.AbstractTest;
@@ -24,9 +24,9 @@
Map<Class<?>, Bean<?>> classes = new HashMap<Class<?>, Bean<?>>();
for (Bean<?> bean : beans)
{
- if (bean instanceof AbstractBean)
+ if (bean instanceof RIBean)
{
- classes.put(((AbstractBean<?, ?>) bean).getType(), bean);
+ classes.put(((RIBean<?>) bean).getType(), bean);
}
}
assert classes.containsKey(Tuna.class);
@@ -40,9 +40,9 @@
Map<Class<?>, Bean<?>> classes = new HashMap<Class<?>, Bean<?>>();
for (Bean<?> bean : beans)
{
- if (bean instanceof AbstractBean)
+ if (bean instanceof RIBean)
{
- classes.put(((AbstractBean<?, ?>) bean).getType(), bean);
+ classes.put(((RIBean<?>) bean).getType(), bean);
}
}
assert classes.containsKey(Hound.class);
@@ -56,9 +56,9 @@
Map<Class<?>, Bean<?>> classes = new HashMap<Class<?>, Bean<?>>();
for (Bean<?> bean : beans)
{
- if (bean instanceof AbstractBean)
+ if (bean instanceof RIBean)
{
- classes.put(((AbstractBean<?, ?>) bean).getType(), bean);
+ classes.put(((RIBean<?>) bean).getType(), bean);
}
}
assert classes.containsKey(Tuna.class);
@@ -80,9 +80,9 @@
Map<Class<?>, Bean<?>> classes = new HashMap<Class<?>, Bean<?>>();
for (Bean<?> bean : beans)
{
- if (bean instanceof AbstractBean)
+ if (bean instanceof RIBean)
{
- classes.put(((AbstractBean<?, ?>) bean).getType(), bean);
+ classes.put(((RIBean<?>) bean).getType(), bean);
}
}
assert classes.containsKey(TarantulaProducer.class);
@@ -100,9 +100,9 @@
Map<Class<?>, Bean<?>> classes = new HashMap<Class<?>, Bean<?>>();
for (Bean<?> bean : beans)
{
- if (bean instanceof AbstractBean)
+ if (bean instanceof RIBean)
{
- classes.put(((AbstractBean<?, ?>) bean).getType(), bean);
+ classes.put(((RIBean<?>) bean).getType(), bean);
}
}
assert classes.containsKey(Hound.class);
@@ -124,9 +124,9 @@
Map<Class<?>, Bean<?>> classes = new HashMap<Class<?>, Bean<?>>();
for (Bean<?> bean : beans)
{
- if (bean instanceof AbstractBean)
+ if (bean instanceof RIBean)
{
- classes.put(((AbstractBean<?, ?>) bean).getType(), bean);
+ classes.put(((RIBean<?>) bean).getType(), bean);
}
}
assert classes.containsKey(Hound.class);
@@ -155,9 +155,9 @@
Map<Class<?>, Bean<?>> classes = new HashMap<Class<?>, Bean<?>>();
for (Bean<?> bean : manager.getBeans())
{
- if (bean instanceof AbstractBean)
+ if (bean instanceof RIBean)
{
- classes.put(((AbstractBean<?, ?>) bean).getType(), bean);
+ classes.put(((RIBean<?>) bean).getType(), bean);
}
}
assert classes.containsKey(TarantulaProducer.class);
@@ -175,9 +175,9 @@
Map<Class<?>, Bean<?>> classes = new HashMap<Class<?>, Bean<?>>();
for (Bean<?> bean : manager.getBeans())
{
- if (bean instanceof AbstractBean)
+ if (bean instanceof RIBean)
{
- classes.put(((AbstractBean<?, ?>) bean).getType(), bean);
+ classes.put(((RIBean<?>) bean).getType(), bean);
}
}
assert classes.containsKey(Hound.class);
@@ -215,9 +215,9 @@
Map<Class<?>, Bean<?>> classes = new HashMap<Class<?>, Bean<?>>();
for (Bean<?> bean : manager.getBeans())
{
- if (bean instanceof AbstractBean)
+ if (bean instanceof RIBean)
{
- classes.put(((AbstractBean<?, ?>) bean).getType(), bean);
+ classes.put(((RIBean<?>) bean).getType(), bean);
}
}
assert classes.containsKey(Hound.class);
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/lookup/circular/CircularDependencyTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/lookup/circular/CircularDependencyTest.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/lookup/circular/CircularDependencyTest.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -16,7 +16,7 @@
assert Food.success;
}
- @Test
+ @Test(timeOut=1000)
public void testCircularInjectionOnOneNormalAndOneDependentBean() throws Exception
{
deployBeans(Car.class, Petrol.class);
@@ -35,7 +35,7 @@
}
- @Test
+ @Test(timeOut=1000)
public void testCircularInjectionOnOneDependentAndOneNormalBean() throws Exception
{
deployBeans(Car.class, Petrol.class);
@@ -89,7 +89,7 @@
}.run();
}
- @Test
+ @Test(timeOut=1000)
public void testNormalProducerMethodDeclaredOnNormalBeanWhichInjectsProducedBean() throws Exception
{
deployBeans(NormalSelfConsumingNormalProducer.class);
@@ -105,7 +105,7 @@
}.run();
}
- @Test
+ @Test(timeOut=1000)
public void testNormalProducerMethodDeclaredOnDependentBeanWhichInjectsProducedBean() throws Exception
{
deployBeans(DependentSelfConsumingNormalProducer.class);
@@ -121,7 +121,7 @@
}.run();
}
- @Test
+ @Test(timeOut=1000)
public void testDependentProducerMethodDeclaredOnNormalBeanWhichInjectsProducedBean() throws Exception
{
deployBeans(NormalSelfConsumingDependentProducer.class);
@@ -137,7 +137,7 @@
}.run();
}
- @Test
+ @Test(timeOut=1000)
public void testNormalSelfConsumingProducer() throws Exception
{
deployBeans(NormalLoopingProducer.class);
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/lookup/injectionpoint/InjectionPointTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/lookup/injectionpoint/InjectionPointTest.java 2009-01-28 14:14:12 UTC (rev 1262)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/lookup/injectionpoint/InjectionPointTest.java 2009-01-28 15:49:28 UTC (rev 1263)
@@ -32,7 +32,6 @@
import org.jboss.webbeans.tck.AbstractTest;
import org.jboss.webbeans.tck.impl.SpecAssertion;
-import org.jboss.webbeans.tck.impl.SpecVersion;
import org.jboss.webbeans.tck.impl.literals.CurrentBinding;
import org.testng.annotations.Test;
@@ -232,46 +231,42 @@
}
}
- @Test(groups = { "injectionPoint", "broken" })
+ @Test(groups = { "injectionPoint" })
@SpecAssertion(section = "5.6")
- public void testStandardDeployment()
+ public void testStandardDeployment() throws Exception
{
- deployBeans(FieldInjectionPointBean.class, BeanWithInjectionPointMetadata.class);
+ deployBeans();
- // Get an instance of the bean which has another bean injected into it
- try
+ new RunInDependentContext()
{
- activateDependentContext();
- FieldInjectionPointBean beanWithInjectedBean = manager.getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
- BeanWithInjectionPointMetadata beanWithInjectionPoint = beanWithInjectedBean.getInjectedBean();
- assert beanWithInjectionPoint.getInjectedMetadata() != null;
- assert beanWithInjectionPoint.getInjectedMetadata().getClass().isAnnotationPresent(Standard.class);
- }
- finally
- {
- deactivateDependentContext();
- }
+
+ @Override
+ protected void execute() throws Exception
+ {
+ assert manager.resolveByType(InjectionPoint.class).size() == 1;
+ assert manager.resolveByType(InjectionPoint.class).iterator().next().getDeploymentType().equals(Standard.class);
+ }
+
+ }.run();
}
- @Test(groups = { "injectionPoint", "broken" })
+ @Test(groups = { "injectionPoint" })
@SpecAssertion(section = "5.6")
- public void testDependentScope()
+ public void testDependentScope() throws Exception
{
- deployBeans(FieldInjectionPointBean.class, BeanWithInjectionPointMetadata.class);
+ deployBeans();
- // Get an instance of the bean which has another bean injected into it
- try
+ new RunInDependentContext()
{
- activateDependentContext();
- FieldInjectionPointBean beanWithInjectedBean = manager.getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
- BeanWithInjectionPointMetadata beanWithInjectionPoint = beanWithInjectedBean.getInjectedBean();
- assert beanWithInjectionPoint.getInjectedMetadata() != null;
- assert beanWithInjectionPoint.getInjectedMetadata().getClass().isAnnotationPresent(Dependent.class);
- }
- finally
- {
- deactivateDependentContext();
- }
+
+ @Override
+ protected void execute() throws Exception
+ {
+ assert manager.resolveByType(InjectionPoint.class).size() == 1;
+ assert manager.resolveByType(InjectionPoint.class).iterator().next().getScopeType().equals(Dependent.class);
+ }
+
+ }.run();
}
@Test(groups = { "injectionPoint" })
16 years, 8 months