[webbeans-commits] Webbeans SVN: r3612 - in tck/trunk/impl/src/main: java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/addDefinitionError and 3 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-08-27 19:07:26 -0400 (Thu, 27 Aug 2009)
New Revision: 3612
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/DeploymentTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/ExtensionsTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/ManagerObserver.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/addDefinitionError/AddDefinitionErrorTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java
tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
Log:
Rename methods, mappings
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/DeploymentTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/DeploymentTest.java 2009-08-27 23:05:37 UTC (rev 3611)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/DeploymentTest.java 2009-08-27 23:07:26 UTC (rev 3612)
@@ -46,12 +46,12 @@
@Test(groups="rewrite")
@SpecAssertions({
@SpecAssertion(section = "11.5.2", id = "a"),
- @SpecAssertion(section = "11.5.3", id = "a")
+ @SpecAssertion(section = "11.5.3", id = "a"),
+ @SpecAssertion(section = "12.2", id = "g")
})
public void testDeployedManagerEvent()
{
- assert ManagerObserver.isManagerDeployed();
-
+ assert ManagerObserver.isAfterDeploymentValidationCalled();
// Make sure the manager does accept requests now
getCurrentManager().fireEvent("event");
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/ExtensionsTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/ExtensionsTest.java 2009-08-27 23:05:37 UTC (rev 3611)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/ExtensionsTest.java 2009-08-27 23:07:26 UTC (rev 3612)
@@ -21,6 +21,7 @@
import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.test.audit.annotations.SpecVersion;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.IntegrationTest;
@@ -41,7 +42,11 @@
{
@Test
- @SpecAssertion(section="11.5.1", id="a")
+ @SpecAssertions({
+ @SpecAssertion(section="11.5.1", id="a"),
+ @SpecAssertion(section="12.2", id="b"),
+ @SpecAssertion(section="12.2", id="c")
+ })
public void testBeforeBeanDiscoveryEventIsCalled()
{
assert BeforeBeanDiscoveryObserver.isObserved();
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/ManagerObserver.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/ManagerObserver.java 2009-08-27 23:05:37 UTC (rev 3611)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/ManagerObserver.java 2009-08-27 23:07:26 UTC (rev 3612)
@@ -9,38 +9,34 @@
public class ManagerObserver implements Extension
{
- private static boolean managerInitialized = false;
- private static boolean managerDeployed = false;
+ private static boolean afterBeanDiscoveryCalled = false;
+ private static boolean afterDeploymentValidationCalled = false;
public void managerInitialized(@Observes AfterBeanDiscovery event, @Current BeanManager beanManager)
{
- managerInitialized = true;
+ afterBeanDiscoveryCalled = true;
}
public void managerDeployed(@Observes AfterDeploymentValidation event, @Current BeanManager beanManager)
{
- assert managerInitialized : "Manager should have been initialized before deployed";
- managerDeployed = true;
+ assert afterBeanDiscoveryCalled : "AfterBeanDiscovery should have been called before AfterDeploymentValidation";
+ afterDeploymentValidationCalled = true;
}
- public static boolean isManagerInitialized()
+ public static boolean isAfterBeanDiscoveryCalled()
{
- return managerInitialized;
+ return afterBeanDiscoveryCalled;
}
- public static void setManagerInitialized(boolean managerInitialized)
+ public static void reset()
{
- ManagerObserver.managerInitialized = managerInitialized;
+ ManagerObserver.afterBeanDiscoveryCalled = false;
+ ManagerObserver.afterDeploymentValidationCalled = false;
}
- public static boolean isManagerDeployed()
+ public static boolean isAfterDeploymentValidationCalled()
{
- return managerDeployed;
+ return afterDeploymentValidationCalled;
}
- public static void setManagerDeployed(boolean managerDeployed)
- {
- ManagerObserver.managerDeployed = managerDeployed;
- }
-
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/addDefinitionError/AddDefinitionErrorTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/addDefinitionError/AddDefinitionErrorTest.java 2009-08-27 23:05:37 UTC (rev 3611)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/addDefinitionError/AddDefinitionErrorTest.java 2009-08-27 23:07:26 UTC (rev 3612)
@@ -1,9 +1,10 @@
package org.jboss.jsr299.tck.tests.deployment.lifecycle.broken.addDefinitionError;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.DefinitionError;
import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.test.audit.annotations.SpecVersion;
-import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.jsr299.tck.DefinitionError;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
import org.jboss.testharness.impl.packaging.IntegrationTest;
@@ -28,9 +29,12 @@
@SpecVersion(spec="cdi", version="1.0.20090625")
public class AddDefinitionErrorTest extends AbstractJSR299Test
{
- @Test(groups="jboss-as-broken")
+ @Test(groups={"jboss-as-broken", "rewrite"})
// WBRI-312
- @SpecAssertion(section = "11.5.2", id = "ca")
+ @SpecAssertions({
+ @SpecAssertion(section = "11.5.2", id = "ca"),
+ @SpecAssertion(section = "12.2", id = "c")
+ })
public void testObserverDefinitionErrorTreatedAsDefinitionError()
{
assert false;
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java 2009-08-27 23:05:37 UTC (rev 3611)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java 2009-08-27 23:07:26 UTC (rev 3612)
@@ -45,7 +45,8 @@
@SpecAssertion(section = "7.3.2", id = "aa"),
@SpecAssertion(section = "7.3.2", id = "bb"),
@SpecAssertion(section = "7.3.3", id = "b"),
- @SpecAssertion(section = "6.5.3", id = "b")
+ @SpecAssertion(section = "6.5.3", id = "b"),
+ @SpecAssertion(section = "12.1", id="bba")
})
public void testCreateSFSB() throws Exception
{
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java 2009-08-27 23:05:37 UTC (rev 3611)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java 2009-08-27 23:07:26 UTC (rev 3612)
@@ -168,7 +168,8 @@
@SpecAssertion(section = "3.7.1", id = "a"),
@SpecAssertion(section="2.3.4", id="a"),
@SpecAssertion(section="3.7", id="aa"),
- @SpecAssertion(section="3.7", id="ab")
+ @SpecAssertion(section="3.7", id="ab"),
+ @SpecAssertion(section="12.1", id="bca")
})
public void testCreateInjectsFieldsDeclaredInJava()
{
Modified: tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2009-08-27 23:05:37 UTC (rev 3611)
+++ tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2009-08-27 23:07:26 UTC (rev 3612)
@@ -5230,12 +5230,12 @@
<assertion id="a" testable="false">
<text>A library jar, EJB jar or rar archive is a bean deployment archive if it has a file named |beans.xml| in the |META-INF| directory. The |WEB-INF/classes| directory of a war is a bean deployment archive if there is a file named |beans.xml| in the |WEBINF| directory of the war. A directory in the JVM classpath is a bean deployment archive if it has a file named |beans.xml| in the |META-INF| directory.</text>
- <note>Covered by b* assertions</note>
+ <note>covered in bb*, bc*, bd*</note>
</assertion>
- <assertion id="ba">
+ <assertion id="ba" testable="false">
<text>The container searches for beans in bean deployment archives in the application classpath.</text>
- <note>Check for a jar installed as a library</note>
+ <note>covered in bb*, bc*, bd*</note>
</assertion>
<group>
@@ -5244,16 +5244,19 @@
<text>Check an EJB jar in an EAR</text>
</assertion>
<assertion id="bbb">
- <text>Check a library in an EAR</text>
+ <text>Check a bundled library in an EAR</text>
</assertion>
<assertion id="bbc">
- <text>Check a library in a WAR</text>
+ <text>Check a bundled library in a WAR</text>
</assertion>
<assertion id="bbd">
<text>Check a rar</text>
</assertion>
<assertion id="bbe">
<text>Check a war in an ear</text>
+ </assertion>
+ <assertion id="bbf">
+ <text>Check for a jar installed as a library</text>
</assertion>
</group>
@@ -5262,8 +5265,11 @@
<assertion id="bca">
<text>Check classes in the war</text>
</assertion>
- <assertion id="bca">
- <text>Check libraries in the war</text>
+ <assertion id="bcb">
+ <text>Check bundled libraries in the war</text>
+ </assertion>
+ <assertion id="bcc">
+ <text>Check for a jar installed as a library</text>
</assertion>
</group>
@@ -5283,8 +5289,9 @@
</assertion>
</group>
- <assertion id="be">
+ <assertion id="be" testable="false">
<text>When searching for beans, the container considers any Java class in any bean deployment archive, and any |ejb-jar.xml| file in the metadata directory of any EJB bean deployment archive.</text>
+ <note>covered in bb*, bc*, bd*</note>
</assertion>
<assertion id="ca">
15 years, 3 months
[webbeans-commits] Webbeans SVN: r3611 - tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-08-27 19:05:37 -0400 (Thu, 27 Aug 2009)
New Revision: 3611
Modified:
tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/Beans.java
Log:
Remove uneeded methods
Modified: tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/Beans.java
===================================================================
--- tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/Beans.java 2009-08-27 16:30:29 UTC (rev 3610)
+++ tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/Beans.java 2009-08-27 23:05:37 UTC (rev 3611)
@@ -19,39 +19,6 @@
public static final String PROPERTY_NAME = Beans.class.getName();
/**
- * Tests whether the given class is declaring an Enterprise Bean.
- *
- * @param clazz the type of bean being tested
- *
- * @return true only if class declares an Enterprise Bean
- */
- public boolean isEnterpriseBean(Class<?> clazz);
-
- /**
- * Tests whether the given class is declaring a stateful session bean.
- *
- * @param clazz the type being tested
- * @return true only if class declares a stateful session bean
- */
- public boolean isStatefulBean(Class<?> clazz);
-
- /**
- * Tests whether the given class is declaring a stateless session bean.
- *
- * @param clazz the type being tested
- * @return true only if class declares a stateless session bean
- */
- public boolean isStatelessBean(Class<?> clazz);
-
- /**
- * Tests whether the given class is declaring an entity bean.
- *
- * @param clazz the type being tested
- * @return true only if class declares an entity bean
- */
- public boolean isEntityBean(Class<?> clazz);
-
- /**
* Determines if the object instance is actually a proxy object.
*
* @param instance The object which might be a proxy
@@ -59,15 +26,4 @@
*/
public boolean isProxy(Object instance);
- /**
- * Retrieves the EJB which implements the local interface provided.
- *
- * @param <T> The local interface type
- * @param beanType The class of the EJB implementing bean
- * @param localInterface The business interface of the bean proxy to return
- * @return the EJB proxy from the container
- */
- @Deprecated
- public <T> T getEnterpriseBean(Class<? extends T> beanType, Class<T> localInterface);
-
}
15 years, 3 months
[webbeans-commits] Webbeans SVN: r3610 - in extensions/trunk/bean-utils: src and 12 other directories.
by webbeans-commits@lists.jboss.org
Author: kabir.khan(a)jboss.com
Date: 2009-08-27 12:30:29 -0400 (Thu, 27 Aug 2009)
New Revision: 3610
Added:
extensions/trunk/bean-utils/pom.xml
extensions/trunk/bean-utils/src/
extensions/trunk/bean-utils/src/main/
extensions/trunk/bean-utils/src/main/java/
extensions/trunk/bean-utils/src/main/java/org/
extensions/trunk/bean-utils/src/main/java/org/jboss/
extensions/trunk/bean-utils/src/main/java/org/jboss/webbeans/
extensions/trunk/bean-utils/src/main/java/org/jboss/webbeans/beanutils/
extensions/trunk/bean-utils/src/main/java/org/jboss/webbeans/beanutils/BeanDescriber.java
extensions/trunk/bean-utils/src/main/java/org/jboss/webbeans/beanutils/BeanDescriberXXX.java
extensions/trunk/bean-utils/src/main/resources/
extensions/trunk/bean-utils/src/test/
extensions/trunk/bean-utils/src/test/java/
extensions/trunk/bean-utils/src/test/java/org/
extensions/trunk/bean-utils/src/test/java/org/jboss/
extensions/trunk/bean-utils/src/test/java/org/jboss/webbeans/
extensions/trunk/bean-utils/src/test/java/org/jboss/webbeans/beanutils/
extensions/trunk/bean-utils/src/test/java/org/jboss/webbeans/beanutils/impl/
Log:
Add bean-utils
Added: extensions/trunk/bean-utils/pom.xml
===================================================================
--- extensions/trunk/bean-utils/pom.xml (rev 0)
+++ extensions/trunk/bean-utils/pom.xml 2009-08-27 16:30:29 UTC (rev 3610)
@@ -0,0 +1,103 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>webbeans-parent</artifactId>
+ <groupId>org.jboss.webbeans</groupId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-bean-utils</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <name>Web Beans Utilities For Managing Beans</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <classifier>jdk15</classifier>
+ <exclusions>
+ <exclusion>
+ <artifactId>junit</artifactId>
+ <groupId>junit</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-logging</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness</artifactId>
+ <scope>test</scope>
+ </dependency>
+<!--
+ <dependency>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness-jboss-as-50</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-core-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-api</artifactId>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>jboss-jaxrpc</artifactId>
+ <groupId>jbossws</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jboss-transaction-api</artifactId>
+ <groupId>org.jboss.javaee</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jboss-jaxrpc</artifactId>
+ <groupId>jboss.jbossws</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+-->
+ </dependencies>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/webbeans/extensions</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/webbeans/extensions</developerConnection>
+ <url>http://viewvc.jboss.org/cgi-bin/viewvc.cgi/webbeans/extensions</url>
+ </scm>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <configuration>
+ <tagBase>https://svn.jboss.org/repos/webbeans/extensions/tags</tagBase>
+ <autoVersionSubmodules>true</autoVersionSubmodules>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: extensions/trunk/bean-utils/src/main/java/org/jboss/webbeans/beanutils/BeanDescriber.java
===================================================================
--- extensions/trunk/bean-utils/src/main/java/org/jboss/webbeans/beanutils/BeanDescriber.java (rev 0)
+++ extensions/trunk/bean-utils/src/main/java/org/jboss/webbeans/beanutils/BeanDescriber.java 2009-08-27 16:30:29 UTC (rev 3610)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.webbeans.beanutils;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.introspector.jlr.WBClassImpl;
+import org.jboss.webbeans.resources.ClassTransformer;
+
+/**
+ *
+ * @author <a href="kabir.khan(a)jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class BeanDescriber<T>
+{
+ public static <T> Bean<T> describeBean(AnnotatedType<T> type, BeanManager beanManager)
+ {
+ if (type == null)
+ throw new IllegalArgumentException("Null type");
+ if (beanManager == null)
+ throw new IllegalArgumentException("Null beanManager");
+ if (beanManager instanceof BeanManagerImpl == false)
+ throw new IllegalArgumentException("BeanManager is not an instance of BeanManagerImpl");
+
+ WBClass<T> clazz = type instanceof WBClass ?
+ (WBClass<T>)type :
+ WBClassImpl.of(type, ((BeanManagerImpl)beanManager).getServices().get(ClassTransformer.class));
+
+ Bean<T> bean = SimpleBean.of(clazz, (BeanManagerImpl)beanManager);
+
+ //TODO How to get BeanDeployerEnvironment?
+ ((SimpleBean<T>)bean).initialize(null);
+ return bean;
+ }
+}
Added: extensions/trunk/bean-utils/src/main/java/org/jboss/webbeans/beanutils/BeanDescriberXXX.java
===================================================================
--- extensions/trunk/bean-utils/src/main/java/org/jboss/webbeans/beanutils/BeanDescriberXXX.java (rev 0)
+++ extensions/trunk/bean-utils/src/main/java/org/jboss/webbeans/beanutils/BeanDescriberXXX.java 2009-08-27 16:30:29 UTC (rev 3610)
@@ -0,0 +1,192 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.webbeans.beanutils;
+
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.ScopeType;
+import javax.enterprise.inject.BindingType;
+import javax.enterprise.inject.Policy;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.stereotype.Stereotype;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bean.AbstractClassBean;
+import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.literal.AnyLiteral;
+import org.jboss.webbeans.literal.CurrentLiteral;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.metadata.cache.MergedStereotypes;
+
+/**
+ *
+ * @author <a href="kabir.khan(a)jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class BeanDescriberXXX<T, E>
+{
+ // Logger
+ private static final LogProvider log = Logging.getLogProvider(AbstractClassBean.class);
+
+ WBClass<T> type;
+
+ BeanManagerImpl beanManager;
+
+ private MergedStereotypes<T, E> mergedStereotypes;
+
+ private static final Annotation ANY_LITERAL = new AnyLiteral();
+
+ private static final Annotation CURRENT_LITERAL = new CurrentLiteral();
+
+
+ public BeanDescriberXXX(AnnotatedType<T> type, BeanManager beanManager)
+ {
+ if (type == null)
+ throw new IllegalArgumentException("Null type");
+ if (beanManager == null)
+ throw new IllegalArgumentException("Null beanManager");
+ if (type instanceof WBClass == false)
+ throw new IllegalArgumentException("Type is not an instance of WBType");
+ if (beanManager instanceof BeanManagerImpl == false)
+ throw new IllegalArgumentException("BeanManaget is not an instance of BeanManagerImpl");
+
+ this.type = (WBClass<T>)type;
+ this.beanManager = (BeanManagerImpl)beanManager;
+
+
+ }
+
+
+ public Class<? extends Annotation> determineScopeType(AnnotatedType<?> annotatedType)
+ {
+ if (annotatedType instanceof WBClass == false)
+ throw new IllegalArgumentException("Annotated type is not an instance of WBType");
+
+ final WBClass<?> type = (WBClass<?>)annotatedType;
+ Class<? extends Annotation> scopeType = null;
+
+ for (WBClass<?> clazz = type; clazz != null; clazz = clazz.getWBSuperclass())
+ {
+ Set<Annotation> scopeTypes = clazz.getDeclaredMetaAnnotations(ScopeType.class);
+ scopeTypes = clazz.getDeclaredMetaAnnotations(ScopeType.class);
+ if (scopeTypes.size() == 1)
+ {
+ if (type.isAnnotationPresent(scopeTypes.iterator().next().annotationType()))
+ {
+ scopeType = scopeTypes.iterator().next().annotationType();
+ log.trace("Scope " + scopeType + " specified by annotation");
+ }
+ break;
+ }
+ else if (scopeTypes.size() > 1)
+ {
+ throw new DefinitionException("At most one scope may be specified on " + type);
+ }
+ }
+
+ if (scopeType == null)
+ {
+ scopeType = initScopeTypeFromStereotype();
+ }
+
+ if (scopeType == null)
+ {
+ scopeType = Dependent.class;
+ log.trace("Using default @Dependent scope");
+ }
+ return scopeType;
+ }
+
+ public Set<Annotation> determineBindings(boolean includeDefaultBindings)
+ {
+ Set<Annotation> bindings = new HashSet<Annotation>();
+ bindings.addAll(type.getMetaAnnotations(BindingType.class));
+ if (includeDefaultBindings)
+ initDefaultBindings(bindings);
+ log.trace("Using binding types " + bindings + " specified by annotations");
+ return bindings;
+ }
+
+
+ public Set<Class<? extends Annotation>> determineStereotypes()
+ {
+ return getMergedStereotypes().getStereotypes();
+ }
+
+ public boolean determinePolicy()
+ {
+ if (type.isAnnotationPresent(Policy.class))
+ {
+ return true;
+ }
+ else
+ {
+ return getMergedStereotypes().isPolicy();
+ }
+ }
+
+
+ protected Class<? extends Annotation> initScopeTypeFromStereotype()
+ {
+ Class<? extends Annotation> scopeType = null;
+ Set<Annotation> possibleScopeTypes = getMergedStereotypes().getPossibleScopeTypes();
+ if (possibleScopeTypes.size() == 1)
+ {
+ scopeType = possibleScopeTypes.iterator().next().annotationType();
+ if (log.isTraceEnabled())
+ log.trace("Scope " + scopeType + " specified by stereotype");
+ return scopeType;
+ }
+ else if (possibleScopeTypes.size() > 1)
+ {
+ throw new DefinitionException("All stereotypes must specify the same scope OR a scope must be specified on " + type);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ protected MergedStereotypes<T, E> getMergedStereotypes()
+ {
+ if (mergedStereotypes == null)
+ mergedStereotypes = new MergedStereotypes<T, E>(type.getMetaAnnotations(Stereotype.class), beanManager);
+
+ return mergedStereotypes;
+ }
+
+ protected void initDefaultBindings(Set<Annotation> bindings)
+ {
+ if (bindings.size() == 0)
+ {
+ log.trace("Adding default @Current binding type");
+ bindings.add(CURRENT_LITERAL);
+ }
+ bindings.add(ANY_LITERAL);
+ }
+}
15 years, 3 months
[webbeans-commits] Webbeans SVN: r3608 - ri/trunk/jboss-as.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-08-27 09:53:37 -0400 (Thu, 27 Aug 2009)
New Revision: 3608
Modified:
ri/trunk/jboss-as/build.xml
Log:
remove bv update
Modified: ri/trunk/jboss-as/build.xml
===================================================================
--- ri/trunk/jboss-as/build.xml 2009-08-27 13:53:23 UTC (rev 3607)
+++ ri/trunk/jboss-as/build.xml 2009-08-27 13:53:37 UTC (rev 3608)
@@ -13,7 +13,7 @@
<delete dir="target" failonerror="false" />
</target>
- <target name="update" depends="install-webbeans.deployer, install-javassist-update, install-validation-update" description="Update JBoss 5.x or 6.x for Web Beans" />
+ <target name="update" depends="install-webbeans.deployer, install-javassist-update" description="Update JBoss 5.x or 6.x for Web Beans" />
<target name="install-webbeans.deployer">
<echo message="Installing Web Beans ${webbeans.version} to ${jboss.home}" />
15 years, 3 months
[webbeans-commits] Webbeans SVN: r3607 - ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-08-27 09:53:23 -0400 (Thu, 27 Aug 2009)
New Revision: 3607
Removed:
ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/JpaServices.java
Log:
Tidy up
Deleted: ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/JpaServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/JpaServices.java 2009-08-27 13:52:38 UTC (rev 3606)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/JpaServices.java 2009-08-27 13:53:23 UTC (rev 3607)
@@ -1,65 +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.persistence.spi;
-
-import javax.enterprise.inject.spi.InjectionPoint;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-
-import org.jboss.webbeans.bootstrap.api.Service;
-
-/**
- * A container should implement this interface to allow the Web Beans RI to
- * resolve JPA persistence units and discover entities
- *
- * @author Pete Muir
- *
- */
-public interface JpaServices extends Service
-{
-
- /**
- * Resolve the value for the given @PersistenceContext injection point
- *
- * @param injectionPoint
- * the injection point metadata
- * @return an instance of the entity manager
- * @throws IllegalArgumentException
- * if the injection point is not annotated with
- * @PersistenceContext, or, if the injection point is a method
- * that doesn't follow JavaBean conventions
- * @throws IllegalStateException
- * if no suitable persistence units can be resolved for injection
- */
- public EntityManager resolvePersistenceContext(InjectionPoint injectionPoint);
-
- /**
- * Resolve the value for the given @PersistenceUnit injection point
- *
- * @param injectionPoint
- * the injection point metadata
- * @return an instance of the entity manager
- * @throws IllegalArgumentException
- * if the injection point is not annotated with
- * @PersistenceUnit, or, if the injection point is a method
- * that doesn't follow JavaBean conventions
- * @throws IllegalStateException
- * if no suitable persistence units can be resolved for injection
- */
- public EntityManagerFactory resolvePersistenceUnit(InjectionPoint injectionPoint);
-
-}
15 years, 3 months
[webbeans-commits] Webbeans SVN: r3606 - ri/trunk/impl/src/main/java/org/jboss/webbeans and 22 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-08-27 09:52:38 -0400 (Thu, 27 Aug 2009)
New Revision: 3606
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/AbstractWebBeansELResolver.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/InjectionContextImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfWebBeansELResolver.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/EjbInjectionServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionContext.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/JpaInjectionServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/ResourceInjectionServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/AbstractResourceServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingJpaInjectionServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingResourceInjectionServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbInjectionServices.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjbInjectionServices.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/CheckableInjectionServices.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/InjectionServicesTest.java
Removed:
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolverImpl.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/jsf/spi/
ri/trunk/spi/src/main/java/org/jboss/webbeans/messaging/spi/
ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/helpers/
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractResourceServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/ForwardingResourceServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJSFServices.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockConversationManager.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJSFServices.java
Modified:
doc/trunk/reference/en-US/ri-spi.xml
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/SimpleInjectionTarget.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfHelper.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansApplication.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsp/JspInitialization.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java
Log:
WBRI-373, WBRI-352
Modified: doc/trunk/reference/en-US/ri-spi.xml
===================================================================
--- doc/trunk/reference/en-US/ri-spi.xml 2009-08-27 12:43:59 UTC (rev 3605)
+++ doc/trunk/reference/en-US/ri-spi.xml 2009-08-27 13:52:38 UTC (rev 3606)
@@ -384,16 +384,6 @@
</para>
</listitem>
</varlistentry>
- <varlistentry>
- <term><literal>JSFServices.getBeanDeploymentArchive(Application application)</literal></term>
- <listitem>
- <para>
- Identify the WAR in use. The
- <literal>Application</literal> is provided for
- additional context.
- </para>
- </listitem>
- </varlistentry>
</variablelist>
</section>
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -70,7 +70,7 @@
import org.jboss.webbeans.context.CreationalContextImpl;
import org.jboss.webbeans.context.WBCreationalContext;
import org.jboss.webbeans.el.Namespace;
-import org.jboss.webbeans.el.WebBeansELResolverImpl;
+import org.jboss.webbeans.el.WebBeansELResolver;
import org.jboss.webbeans.introspector.WBAnnotated;
import org.jboss.webbeans.literal.AnyLiteral;
import org.jboss.webbeans.literal.CurrentLiteral;
@@ -405,7 +405,7 @@
this.decoratorResolver = new TypeSafeDecoratorResolver(this, createDynamicAccessibleIterable(Transform.DECORATOR_BEAN));
this.observerResolver = new TypeSafeObserverResolver(this, createDynamicAccessibleIterable(Transform.EVENT_OBSERVER));
this.nameBasedResolver = new NameBasedResolver(this, createDynamicAccessibleIterable(Transform.BEAN));
- this.webbeansELResolver = new WebBeansELResolverImpl(this);
+ this.webbeansELResolver = new WebBeansELResolver(this);
this.childActivities = new CopyOnWriteArraySet<BeanManagerImpl>();
this.currentInjectionPoint = new ThreadLocal<Stack<InjectionPoint>>()
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/SimpleInjectionTarget.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/SimpleInjectionTarget.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/SimpleInjectionTarget.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -20,13 +20,14 @@
import java.util.Set;
import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.CreationException;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.InjectionTarget;
import org.jboss.webbeans.injection.ConstructorInjectionPoint;
import org.jboss.webbeans.injection.FieldInjectionPoint;
+import org.jboss.webbeans.injection.InjectionContextImpl;
import org.jboss.webbeans.injection.MethodInjectionPoint;
+import org.jboss.webbeans.injection.WBInjectionPoint;
import org.jboss.webbeans.introspector.WBClass;
import org.jboss.webbeans.introspector.WBMethod;
import org.jboss.webbeans.util.Beans;
@@ -46,6 +47,10 @@
private final WBMethod<?, ?> postConstruct;
private final WBMethod<?, ?> preDestroy;
private final Set<InjectionPoint> injectionPoints;
+ private final Set<WBInjectionPoint<?, ?>> ejbInjectionPoints;
+ private final Set<WBInjectionPoint<?, ?>> persistenceContextInjectionPoints;
+ private final Set<WBInjectionPoint<?, ?>> persistenceUnitInjectionPoints;
+ private final Set<WBInjectionPoint<?, ?>> resourceInjectionPoints;
public SimpleInjectionTarget(WBClass<T> type, BeanManagerImpl beanManager)
{
@@ -62,6 +67,10 @@
this.injectionPoints.addAll(Beans.getParameterInjectionPoints(null, initializerMethods));
this.postConstruct = Beans.getPostConstruct(type);
this.preDestroy = Beans.getPreDestroy(type);
+ this.ejbInjectionPoints = Beans.getEjbInjectionPoints(null, type, beanManager);
+ this.persistenceContextInjectionPoints = Beans.getPersistenceContextInjectionPoints(null, type, beanManager);
+ this.persistenceUnitInjectionPoints = Beans.getPersistenceUnitInjectionPoints(null, type, beanManager);
+ this.resourceInjectionPoints = Beans.getResourceInjectionPoints(null, type, beanManager);
}
public T produce(CreationalContext<T> ctx)
@@ -69,16 +78,20 @@
return constructor.newInstance(beanManager, ctx);
}
- public void inject(T instance, CreationalContext<T> ctx)
+ public void inject(final T instance, final CreationalContext<T> ctx)
{
- for (FieldInjectionPoint<?, ?> injectionPoint : injectableFields)
+ new InjectionContextImpl<T>(beanManager, this, instance)
{
- injectionPoint.inject(instance, beanManager, ctx);
- }
- for (MethodInjectionPoint<?, ?> injectionPoint : initializerMethods)
- {
- injectionPoint.invoke(instance, beanManager, ctx, CreationException.class);
- }
+
+ public void proceed()
+ {
+ Beans.injectEEFields(instance, beanManager, ejbInjectionPoints, persistenceContextInjectionPoints, persistenceUnitInjectionPoints, resourceInjectionPoints);
+ Beans.injectBoundFields(instance, ctx, beanManager, injectableFields);
+ Beans.callInitializers(instance, ctx, beanManager, initializerMethods);
+ }
+
+ }.run();
+
}
public void postConstruct(T instance)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -31,7 +31,6 @@
import javax.enterprise.context.Dependent;
import javax.enterprise.context.ScopeType;
import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.CreationException;
import javax.enterprise.inject.spi.Decorator;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.InjectionTarget;
@@ -200,33 +199,7 @@
{
return Collections.unmodifiableList(decorators);
}
-
- /**
- * Injects bound fields
- *
- * @param instance The instance to inject into
- */
- protected void injectBoundFields(T instance, CreationalContext<T> creationalContext)
- {
- for (FieldInjectionPoint<?, ?> injectableField : injectableFields)
- {
- injectableField.inject(instance, manager, creationalContext);
- }
- }
- /**
- * Calls all initializers of the bean
- *
- * @param instance The bean instance
- */
- protected void callInitializers(T instance, CreationalContext<T> creationalContext)
- {
- for (MethodInjectionPoint<?, ?> initializer : getInitializerMethods())
- {
- initializer.invoke(instance, manager, creationalContext, CreationException.class);
- }
- }
-
public void dispose(T instance)
{
// No-op for class beans
@@ -345,9 +318,17 @@
*/
public Set<? extends MethodInjectionPoint<?, ?>> getInitializerMethods()
{
- return initializerMethods;
+ return Collections.unmodifiableSet(initializerMethods);
}
+ /**
+ * @return the injectableFields
+ */
+ public Set<FieldInjectionPoint<?, ?>> getInjectableFields()
+ {
+ return Collections.unmodifiableSet(injectableFields);
+ }
+
// TODO maybe a better way to expose this?
public Set<String> getSuperclasses()
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -50,6 +50,7 @@
import org.jboss.webbeans.introspector.WBMethod;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Proxies;
/**
@@ -332,8 +333,8 @@
public void postConstruct(T instance, CreationalContext<T> creationalContext)
{
- injectBoundFields(instance, creationalContext);
- callInitializers(instance, creationalContext);
+ Beans.injectBoundFields(instance, creationalContext, getManager(), getInjectableFields());
+ Beans.callInitializers(instance, creationalContext, getManager(), getInitializerMethods());
}
public void preDestroy(CreationalContext<T> creationalContext)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -16,8 +16,6 @@
*/
package org.jboss.webbeans.bean;
-import java.lang.annotation.Annotation;
-import java.util.HashSet;
import java.util.Set;
import javax.enterprise.context.spi.CreationalContext;
@@ -29,10 +27,8 @@
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.DefinitionException;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.ejb.EJBApiAbstraction;
-import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.injection.ConstructorInjectionPoint;
-import org.jboss.webbeans.injection.FieldInjectionPoint;
+import org.jboss.webbeans.injection.InjectionContextImpl;
import org.jboss.webbeans.injection.WBInjectionPoint;
import org.jboss.webbeans.introspector.WBClass;
import org.jboss.webbeans.introspector.WBConstructor;
@@ -41,9 +37,6 @@
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
-import org.jboss.webbeans.persistence.PersistenceApiAbstraction;
-import org.jboss.webbeans.persistence.spi.JpaServices;
-import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Names;
import org.jboss.webbeans.util.Reflections;
@@ -69,7 +62,7 @@
private Set<WBInjectionPoint<?, ?>> ejbInjectionPoints;
private Set<WBInjectionPoint<?, ?>> persistenceContextInjectionPoints;
- private HashSet<WBInjectionPoint<?, ?>> persistenceUnitInjectionPoints;
+ private Set<WBInjectionPoint<?, ?>> persistenceUnitInjectionPoints;
private Set<WBInjectionPoint<?, ?>> resourceInjectionPoints;
private SimpleBean<?> specializedBean;
@@ -137,11 +130,20 @@
return instance;
}
- public void inject(T instance, CreationalContext<T> ctx)
+ public void inject(final T instance, final CreationalContext<T> ctx)
{
- injectEjbAndCommonFields(instance);
- injectBoundFields(instance, ctx);
- callInitializers(instance, ctx);
+ new InjectionContextImpl<T>(getManager(), this, instance)
+ {
+
+ public void proceed()
+ {
+ Beans.injectEEFields(instance, getManager(), ejbInjectionPoints, persistenceContextInjectionPoints, persistenceUnitInjectionPoints, resourceInjectionPoints);
+ Beans.injectBoundFields(instance, ctx, getManager(), getInjectableFields());
+ Beans.callInitializers(instance, ctx, getManager(), getInitializerMethods());
+ }
+
+ }.run();
+
}
public void postConstruct(T instance)
@@ -212,87 +214,7 @@
}
}
- protected void initEjbInjectionPoints()
- {
- Class<? extends Annotation> ejbAnnotationType = manager.getServices().get(EJBApiAbstraction.class).EJB_ANNOTATION_CLASS;
- this.ejbInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
- for (WBField<?, ?> field : annotatedItem.getAnnotatedWBFields(ejbAnnotationType))
- {
- this.ejbInjectionPoints.add(FieldInjectionPoint.of(this, field));
- }
- }
-
- protected void initJpaInjectionPoints()
- {
- this.persistenceContextInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
- this.persistenceUnitInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
-
- Class<? extends Annotation> persistenceContextAnnotationType = manager.getServices().get(PersistenceApiAbstraction.class).PERSISTENCE_CONTEXT_ANNOTATION_CLASS;
- for (WBField<?, ?> field : annotatedItem.getAnnotatedWBFields(persistenceContextAnnotationType))
- {
- this.persistenceContextInjectionPoints.add(FieldInjectionPoint.of(this, field));
- }
-
- Class<? extends Annotation> persistenceUnitAnnotationType = manager.getServices().get(PersistenceApiAbstraction.class).PERSISTENCE_UNIT_ANNOTATION_CLASS;
- for (WBField<?, ?> field : annotatedItem.getAnnotatedWBFields(persistenceUnitAnnotationType))
- {
- this.persistenceUnitInjectionPoints.add(FieldInjectionPoint.of(this, field));
- }
- }
-
- protected void initResourceInjectionPoints()
- {
- Class<? extends Annotation> resourceAnnotationType = manager.getServices().get(EJBApiAbstraction.class).RESOURCE_ANNOTATION_CLASS;
- this.resourceInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
- for (WBField<?, ?> field : annotatedItem.getAnnotatedWBFields(resourceAnnotationType))
- {
- this.resourceInjectionPoints.add(FieldInjectionPoint.of(this, field));
- }
- }
-
/**
- * Injects EJBs and common fields
- */
- protected void injectEjbAndCommonFields(T beanInstance)
- {
- EjbServices ejbServices = manager.getServices().get(EjbServices.class);
- JpaServices jpaServices = manager.getServices().get(JpaServices.class);
- ResourceServices resourceServices = manager.getServices().get(ResourceServices.class);
-
- if (ejbServices != null)
- {
- for (WBInjectionPoint<?, ?> injectionPoint : ejbInjectionPoints)
- {
- Object ejbInstance = ejbServices.resolveEjb(injectionPoint);
- injectionPoint.inject(beanInstance, ejbInstance);
- }
- }
-
- if (jpaServices != null)
- {
- for (WBInjectionPoint<?, ?> injectionPoint : persistenceContextInjectionPoints)
- {
- Object pcInstance = jpaServices.resolvePersistenceContext(injectionPoint);
- injectionPoint.inject(beanInstance, pcInstance);
- }
- for (WBInjectionPoint<?, ?> injectionPoint : persistenceUnitInjectionPoints)
- {
- Object puInstance = jpaServices.resolvePersistenceUnit(injectionPoint);
- injectionPoint.inject(beanInstance, puInstance);
- }
- }
-
- if (resourceServices != null)
- {
- for (WBInjectionPoint<?, ?> injectionPoint : resourceInjectionPoints)
- {
- Object resourceInstance = resourceServices.resolveResource(injectionPoint);
- injectionPoint.inject(beanInstance, resourceInstance);
- }
- }
- }
-
- /**
* Initializes the bean and its metadata
*/
@Override
@@ -305,21 +227,18 @@
super.initialize(environment);
initPostConstruct();
initPreDestroy();
- if (getManager().getServices().contains(EjbServices.class))
- {
- initEjbInjectionPoints();
- }
- if (getManager().getServices().contains(JpaServices.class))
- {
- initJpaInjectionPoints();
- }
- if (getManager().getServices().contains(ResourceServices.class))
- {
- initResourceInjectionPoints();
- }
+ initEEInjectionPoints();
}
}
+ private void initEEInjectionPoints()
+ {
+ this.ejbInjectionPoints = Beans.getEjbInjectionPoints(this, getAnnotatedItem(), getManager());
+ this.persistenceContextInjectionPoints = Beans.getPersistenceContextInjectionPoints(this, getAnnotatedItem(), getManager());
+ this.persistenceUnitInjectionPoints = Beans.getPersistenceUnitInjectionPoints(this, getAnnotatedItem(), getManager());
+ this.resourceInjectionPoints = Beans.getResourceInjectionPoints(this, getAnnotatedItem(), manager);
+ }
+
/**
* Validates the type
*/
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -49,17 +49,17 @@
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.ejb.EJBApiAbstraction;
import org.jboss.webbeans.ejb.spi.EjbServices;
+import org.jboss.webbeans.injection.spi.JpaInjectionServices;
+import org.jboss.webbeans.injection.spi.ResourceInjectionServices;
import org.jboss.webbeans.jsf.JsfApiAbstraction;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.metadata.TypeStore;
import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
import org.jboss.webbeans.persistence.PersistenceApiAbstraction;
-import org.jboss.webbeans.persistence.spi.JpaServices;
import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.resources.DefaultResourceLoader;
import org.jboss.webbeans.resources.spi.ResourceLoader;
-import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.servlet.ServletApiAbstraction;
import org.jboss.webbeans.transaction.spi.TransactionServices;
import org.jboss.webbeans.util.serviceProvider.ServiceLoader;
@@ -166,11 +166,11 @@
{
log.info("EJB services not available. Session beans will be simple beans, CDI-style injection into non-contextual EJBs, injection of remote EJBs and injection of @EJB in simple beans will not be available");
}
- if (!deployment.getServices().contains(JpaServices.class))
+ if (!deployment.getServices().contains(JpaInjectionServices.class))
{
log.info("JPA services not available. Injection of @PersistenceContext will not occur. Entity beans will be discovered as simple beans.");
}
- if (!deployment.getServices().contains(ResourceServices.class))
+ if (!deployment.getServices().contains(ResourceInjectionServices.class))
{
log.info("@Resource injection not available.");
}
Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/AbstractWebBeansELResolver.java (from rev 3567, ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolverImpl.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/AbstractWebBeansELResolver.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/AbstractWebBeansELResolver.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,175 @@
+/*
+ * 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.el;
+
+import java.beans.FeatureDescriptor;
+import java.util.Iterator;
+import java.util.concurrent.Callable;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.CurrentManager;
+
+/**
+ * An EL-resolver against the named beans
+ *
+ * @author Pete Muir
+ */
+public abstract class AbstractWebBeansELResolver extends ELResolver
+{
+
+ private static final Contextual<?> CONTEXTUAL = new Contextual<Object>()
+ {
+
+ public Object create(CreationalContext<Object> creationalContext)
+ {
+ return null;
+ }
+
+ public void destroy(Object instance, CreationalContext<Object> creationalContext) {}
+
+ };
+
+ protected abstract BeanManagerImpl getManager(ELContext context);
+
+ @Override
+ public Class<?> getCommonPropertyType(ELContext context, Object base)
+ {
+ return null;
+ }
+
+ @Override
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
+ {
+ return null;
+ }
+
+ @Override
+ public Class<?> getType(ELContext context, Object base, Object property)
+ {
+ return null;
+ }
+
+ @Override
+ public Object getValue(final ELContext context, Object base, Object property)
+ {
+ if (property != null)
+ {
+ String propertyString = property.toString();
+ Namespace namespace = null;
+ if (base == null)
+ {
+ if (getManager(context).getRootNamespace().contains(propertyString))
+ {
+ context.setPropertyResolved(true);
+ return getManager(context).getRootNamespace().get(propertyString);
+ }
+ }
+ else if (base instanceof Namespace)
+ {
+ namespace = (Namespace) base;
+ // We're definitely the responsible party
+ context.setPropertyResolved(true);
+ if (namespace.contains(propertyString))
+ {
+ // There is a child namespace
+ return namespace.get(propertyString);
+ }
+ }
+ else
+ {
+ // let the standard EL resolver chain handle the property
+ return null;
+ }
+ final String name;
+ if (namespace != null)
+ {
+ // Try looking in the manager for a bean
+ name = namespace.qualifyName(propertyString);
+ }
+ else
+ {
+ name = propertyString;
+ }
+ Object value = null;
+ try
+ {
+ final Bean<?> bean = getManager(context).resolve(getManager(context).getBeans(name));
+ final ELCreationalContext<?> creationalContext = getCreationalContextStore(context).peek();
+ if (bean != null)
+ {
+ value = creationalContext.putIfAbsent(bean, new Callable<Object>()
+ {
+
+ public Object call() throws Exception
+ {
+ return getManager(context).getReference(bean, creationalContext);
+ }
+
+ });
+ }
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Error resolving property " + propertyString + " against base " + base, e);
+ }
+ if (value != null)
+ {
+ context.setPropertyResolved(true);
+ return value;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isReadOnly(ELContext context, Object base, Object property)
+ {
+ return false;
+ }
+
+ @Override
+ public void setValue(ELContext context, Object base, Object property, Object value)
+ {
+ }
+
+ private static ELCreationalContextStack getCreationalContextStore(ELContext context)
+ {
+ Object o = context.getContext(ELCreationalContextStack.class);
+
+ if (!(o instanceof ELCreationalContextStack))
+ {
+ ELCreationalContextStack store = ELCreationalContextStack.addToContext(context);
+ o = store;
+ }
+ ELCreationalContextStack store = (ELCreationalContextStack) o;
+ if (store.isEmpty())
+ {
+ // TODO need to use correct manager for module
+ ELCreationalContext<?> creationalContext = ELCreationalContext.of(CurrentManager.rootManager().createCreationalContext(CONTEXTUAL));
+ store.push(creationalContext);
+ }
+ return (ELCreationalContextStack) o;
+ }
+
+}
+
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,43 @@
+/*
+ * 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.el;
+
+import javax.el.ELContext;
+
+import org.jboss.webbeans.BeanManagerImpl;
+
+/**
+ * @author pmuir
+ *
+ */
+public class WebBeansELResolver extends AbstractWebBeansELResolver
+{
+
+ private final BeanManagerImpl beanManager;
+
+ public WebBeansELResolver(BeanManagerImpl beanManager)
+ {
+ this.beanManager = beanManager;
+ }
+
+ @Override
+ protected BeanManagerImpl getManager(ELContext context)
+ {
+ return beanManager;
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolverImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolverImpl.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolverImpl.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -1,180 +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.el;
-
-import java.beans.FeatureDescriptor;
-import java.util.Iterator;
-import java.util.concurrent.Callable;
-
-import javax.el.ELContext;
-import javax.el.ELResolver;
-import javax.enterprise.context.spi.Contextual;
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.Bean;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.CurrentManager;
-
-/**
- * An EL-resolver against the named beans
- *
- * @author Pete Muir
- */
-public class WebBeansELResolverImpl extends ELResolver
-{
-
- private static final Contextual<?> CONTEXTUAL = new Contextual<Object>()
- {
-
- public Object create(CreationalContext<Object> creationalContext)
- {
- return null;
- }
-
- public void destroy(Object instance, CreationalContext<Object> creationalContext) {}
-
- };
-
- private final BeanManagerImpl manager;
-
- public WebBeansELResolverImpl(BeanManagerImpl manager)
- {
- this.manager = manager;
- }
-
- @Override
- public Class<?> getCommonPropertyType(ELContext context, Object base)
- {
- return null;
- }
-
- @Override
- public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
- {
- return null;
- }
-
- @Override
- public Class<?> getType(ELContext context, Object base, Object property)
- {
- return null;
- }
-
- @Override
- public Object getValue(ELContext context, Object base, Object property)
- {
- if (property != null)
- {
- String propertyString = property.toString();
- Namespace namespace = null;
- if (base == null)
- {
- if (manager.getRootNamespace().contains(propertyString))
- {
- context.setPropertyResolved(true);
- return manager.getRootNamespace().get(propertyString);
- }
- }
- else if (base instanceof Namespace)
- {
- namespace = (Namespace) base;
- // We're definitely the responsible party
- context.setPropertyResolved(true);
- if (namespace.contains(propertyString))
- {
- // There is a child namespace
- return namespace.get(propertyString);
- }
- }
- else
- {
- // let the standard EL resolver chain handle the property
- return null;
- }
- final String name;
- if (namespace != null)
- {
- // Try looking in the manager for a bean
- name = namespace.qualifyName(propertyString);
- }
- else
- {
- name = propertyString;
- }
- Object value = null;
- try
- {
- final Bean<?> bean = manager.resolve(manager.getBeans(name));
- final ELCreationalContext<?> creationalContext = getCreationalContextStore(context).peek();
- if (bean != null)
- {
- value = creationalContext.putIfAbsent(bean, new Callable<Object>()
- {
-
- public Object call() throws Exception
- {
- return manager.getReference(bean, creationalContext);
- }
-
- });
- }
- }
- catch (Exception e)
- {
- throw new RuntimeException("Error resolving property " + propertyString + " against base " + base, e);
- }
- if (value != null)
- {
- context.setPropertyResolved(true);
- return value;
- }
- }
- return null;
- }
-
- @Override
- public boolean isReadOnly(ELContext context, Object base, Object property)
- {
- return false;
- }
-
- @Override
- public void setValue(ELContext context, Object base, Object property, Object value)
- {
- }
-
- private static ELCreationalContextStack getCreationalContextStore(ELContext context)
- {
- Object o = context.getContext(ELCreationalContextStack.class);
-
- if (!(o instanceof ELCreationalContextStack))
- {
- ELCreationalContextStack store = ELCreationalContextStack.addToContext(context);
- o = store;
- }
- ELCreationalContextStack store = (ELCreationalContextStack) o;
- if (store.isEmpty())
- {
- // TODO need to use correct manager for module
- ELCreationalContext<?> creationalContext = ELCreationalContext.of(CurrentManager.rootManager().createCreationalContext(CONTEXTUAL));
- store.push(creationalContext);
- }
- return (ELCreationalContextStack) o;
- }
-
-}
-
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/InjectionContextImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/InjectionContextImpl.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/InjectionContextImpl.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,65 @@
+/*
+ * 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 javax.enterprise.inject.spi.InjectionTarget;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.injection.spi.InjectionContext;
+import org.jboss.webbeans.injection.spi.InjectionServices;
+
+/**
+ * @author pmuir
+ *
+ */
+public abstract class InjectionContextImpl<T> implements InjectionContext<T>
+{
+
+ private final BeanManagerImpl beanManager;
+ private final InjectionTarget<T> injectionTarget;
+ private final T target;
+
+ public InjectionContextImpl(BeanManagerImpl beanManager, InjectionTarget<T> injectionTarget, T target)
+ {
+ this.beanManager = beanManager;
+ this.injectionTarget = injectionTarget;
+ this.target = target;
+ }
+
+ public void run()
+ {
+ if (beanManager.getServices().contains(InjectionServices.class))
+ {
+ beanManager.getServices().get(InjectionServices.class).aroundInject(this);
+ }
+ else
+ {
+ proceed();
+ }
+ }
+
+ public InjectionTarget<T> getInjectionTarget()
+ {
+ return injectionTarget;
+ }
+
+ public T getTarget()
+ {
+ return target;
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/InjectionContextImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfHelper.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfHelper.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfHelper.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -17,17 +17,16 @@
package org.jboss.webbeans.jsf;
import javax.enterprise.inject.AnnotationLiteral;
-import javax.faces.application.Application;
import javax.faces.context.FacesContext;
+import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.webbeans.conversation.ConversationIdName;
-import org.jboss.webbeans.jsf.spi.JSFServices;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.servlet.ServletHelper;
import org.jboss.webbeans.util.Reflections;
/**
@@ -107,17 +106,14 @@
public static BeanManagerImpl getModuleBeanManager(FacesContext facesContext)
{
- return getModuleBeanManager(facesContext.getApplication());
- }
-
- public static BeanManagerImpl getModuleBeanManager(Application application)
- {
- if (application == null)
+ if (facesContext.getExternalContext().getContext() instanceof ServletContext)
{
- throw new IllegalArgumentException("Must provide the JSF Application");
+ return ServletHelper.getModuleBeanManager((ServletContext) facesContext.getExternalContext().getContext());
}
- BeanDeploymentArchive beanDeploymentArchive = CurrentManager.rootManager().getServices().get(JSFServices.class).getBeanDeploymentArchive(application);
- return CurrentManager.getBeanDeploymentArchives().get(beanDeploymentArchive).getCurrent();
+ else
+ {
+ throw new IllegalStateException("Web Beans doesn not support using JSF in an non-servlet environment");
+ }
}
}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfWebBeansELResolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfWebBeansELResolver.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfWebBeansELResolver.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,45 @@
+/*
+ * 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.jsf;
+
+import javax.el.ELContext;
+import javax.faces.context.FacesContext;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.el.AbstractWebBeansELResolver;
+
+/**
+ * @author pmuir
+ *
+ */
+public class JsfWebBeansELResolver extends AbstractWebBeansELResolver
+{
+
+ @Override
+ protected BeanManagerImpl getManager(ELContext context)
+ {
+ if (context.getContext(FacesContext.class) == null)
+ {
+ throw new IllegalStateException("Cannot use " + getClass().getSimpleName() + " outside JSF");
+ }
+ else
+ {
+ return JsfHelper.getModuleBeanManager((FacesContext) context.getContext(FacesContext.class));
+ }
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfWebBeansELResolver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansApplication.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansApplication.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansApplication.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -23,12 +23,8 @@
import javax.el.ExpressionFactory;
import javax.faces.application.Application;
-import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.webbeans.el.WebBeansELContextListener;
-import org.jboss.webbeans.el.WebBeansELResolverImpl;
import org.jboss.webbeans.el.WebBeansExpressionFactory;
-import org.jboss.webbeans.jsf.spi.JSFServices;
/**
* @author pmuir
@@ -47,8 +43,7 @@
this.application = application;
this.elContextListeners = new ArrayList<ELContextListener>();
this.elContextListeners.add(new WebBeansELContextListener());
- BeanDeploymentArchive beanDeploymentArchive = CurrentManager.rootManager().getServices().get(JSFServices.class).getBeanDeploymentArchive(application);
- application.addELResolver(new WebBeansELResolverImpl(CurrentManager.getBeanDeploymentArchives().get(beanDeploymentArchive).getCurrent()));
+ application.addELResolver(new JsfWebBeansELResolver());
}
@Override
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/jsp/JspInitialization.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/jsp/JspInitialization.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/jsp/JspInitialization.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -20,7 +20,6 @@
import javax.servlet.jsp.JspApplicationContext;
import javax.servlet.jsp.JspFactory;
-import org.jboss.webbeans.el.WebBeansELResolverImpl;
import org.jboss.webbeans.servlet.ServletHelper;
/**
@@ -42,7 +41,7 @@
JspApplicationContext jspAppContext = JspFactory.getDefaultFactory().getJspApplicationContext(context);
// register compositeELResolver with JSP
- jspAppContext.addELResolver(new WebBeansELResolverImpl(ServletHelper.getModuleBeanManager(context)));
+ jspAppContext.addELResolver(ServletHelper.getModuleBeanManager(context).getELResolver());
// DOesn't really achieve much :-(
//jspAppContext.addELContextListener(new WebBeansELContextListener());
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -18,6 +18,7 @@
import java.lang.annotation.Annotation;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -26,8 +27,10 @@
import javax.annotation.PreDestroy;
import javax.decorator.Decorates;
import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.BindingType;
+import javax.enterprise.inject.CreationException;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Initializer;
import javax.enterprise.inject.Produces;
@@ -38,10 +41,15 @@
import org.jboss.webbeans.bean.AbstractProducerBean;
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.RIBean;
+import org.jboss.webbeans.ejb.EJBApiAbstraction;
import org.jboss.webbeans.injection.ConstructorInjectionPoint;
import org.jboss.webbeans.injection.FieldInjectionPoint;
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.injection.ParameterInjectionPoint;
+import org.jboss.webbeans.injection.WBInjectionPoint;
+import org.jboss.webbeans.injection.spi.EjbInjectionServices;
+import org.jboss.webbeans.injection.spi.JpaInjectionServices;
+import org.jboss.webbeans.injection.spi.ResourceInjectionServices;
import org.jboss.webbeans.introspector.WBClass;
import org.jboss.webbeans.introspector.WBConstructor;
import org.jboss.webbeans.introspector.WBField;
@@ -51,6 +59,7 @@
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.metadata.cache.BindingTypeModel;
import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
+import org.jboss.webbeans.persistence.PersistenceApiAbstraction;
/**
* Helper class for bean inspection
@@ -179,6 +188,79 @@
}
}
+
+ public static Set<WBInjectionPoint<?, ?>> getEjbInjectionPoints(Bean<?> declaringBean, WBClass<?> type, BeanManagerImpl manager)
+ {
+ if (manager.getServices().contains(EjbInjectionServices.class))
+ {
+ Class<? extends Annotation> ejbAnnotationType = manager.getServices().get(EJBApiAbstraction.class).EJB_ANNOTATION_CLASS;
+ Set<WBInjectionPoint<?, ?>> ejbInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
+ for (WBField<?, ?> field : type.getAnnotatedWBFields(ejbAnnotationType))
+ {
+ ejbInjectionPoints.add(FieldInjectionPoint.of(declaringBean, field));
+ }
+ return ejbInjectionPoints;
+ }
+ else
+ {
+ return Collections.emptySet();
+ }
+ }
+
+ public static Set<WBInjectionPoint<?, ?>> getPersistenceContextInjectionPoints(Bean<?> declaringBean, WBClass<?> type, BeanManagerImpl manager)
+ {
+ if (manager.getServices().contains(JpaInjectionServices.class))
+ {
+ Set<WBInjectionPoint<?, ?>> jpaInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
+ Class<? extends Annotation> persistenceContextAnnotationType = manager.getServices().get(PersistenceApiAbstraction.class).PERSISTENCE_CONTEXT_ANNOTATION_CLASS;
+ for (WBField<?, ?> field : type.getAnnotatedWBFields(persistenceContextAnnotationType))
+ {
+ jpaInjectionPoints.add(FieldInjectionPoint.of(declaringBean, field));
+ }
+ return jpaInjectionPoints;
+ }
+ else
+ {
+ return Collections.emptySet();
+ }
+ }
+
+ public static Set<WBInjectionPoint<?, ?>> getPersistenceUnitInjectionPoints(Bean<?> declaringBean, WBClass<?> type, BeanManagerImpl manager)
+ {
+ if (manager.getServices().contains(JpaInjectionServices.class))
+ {
+ Set<WBInjectionPoint<?, ?>> jpaInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
+ Class<? extends Annotation> persistenceUnitAnnotationType = manager.getServices().get(PersistenceApiAbstraction.class).PERSISTENCE_UNIT_ANNOTATION_CLASS;
+ for (WBField<?, ?> field : type.getAnnotatedWBFields(persistenceUnitAnnotationType))
+ {
+ jpaInjectionPoints.add(FieldInjectionPoint.of(declaringBean, field));
+ }
+ return jpaInjectionPoints;
+ }
+ else
+ {
+ return Collections.emptySet();
+ }
+ }
+
+ public static Set<WBInjectionPoint<?, ?>> getResourceInjectionPoints(Bean<?> declaringBean, WBClass<?> type, BeanManagerImpl manager)
+ {
+ if (manager.getServices().contains(ResourceInjectionServices.class))
+ {
+ Class<? extends Annotation> resourceAnnotationType = manager.getServices().get(EJBApiAbstraction.class).RESOURCE_ANNOTATION_CLASS;
+ Set<WBInjectionPoint<?, ?>> resourceInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
+ for (WBField<?, ?> field : type.getAnnotatedWBFields(resourceAnnotationType))
+ {
+ resourceInjectionPoints.add(FieldInjectionPoint.of(declaringBean, field));
+ }
+ return resourceInjectionPoints;
+ }
+ else
+ {
+ return Collections.emptySet();
+ }
+ }
+
public static Set<MethodInjectionPoint<?, ?>> getInitializerMethods(Bean<?> declaringBean, WBClass<?> type)
{
Set<MethodInjectionPoint<?, ?>> initializerMethods = new HashSet<MethodInjectionPoint<?, ?>>();
@@ -407,4 +489,73 @@
}
}
+ /**
+ * Injects EJBs and common fields
+ */
+ public static <T> void injectEEFields(T beanInstance, BeanManagerImpl manager, Iterable<WBInjectionPoint<?, ?>> ejbInjectionPoints, Iterable<WBInjectionPoint<?, ?>> persistenceContextInjectionPoints, Iterable<WBInjectionPoint<?, ?>> persistenceUnitInjectionPoints, Iterable<WBInjectionPoint<?, ?>> resourceInjectionPoints)
+ {
+ EjbInjectionServices ejbServices = manager.getServices().get(EjbInjectionServices.class);
+ JpaInjectionServices jpaServices = manager.getServices().get(JpaInjectionServices.class);
+ ResourceInjectionServices resourceServices = manager.getServices().get(ResourceInjectionServices.class);
+
+ if (ejbServices != null)
+ {
+ for (WBInjectionPoint<?, ?> injectionPoint : ejbInjectionPoints)
+ {
+ Object ejbInstance = ejbServices.resolveEjb(injectionPoint);
+ injectionPoint.inject(beanInstance, ejbInstance);
+ }
+ }
+
+ if (jpaServices != null)
+ {
+ for (WBInjectionPoint<?, ?> injectionPoint : persistenceContextInjectionPoints)
+ {
+ Object pcInstance = jpaServices.resolvePersistenceContext(injectionPoint);
+ injectionPoint.inject(beanInstance, pcInstance);
+ }
+ for (WBInjectionPoint<?, ?> injectionPoint : persistenceUnitInjectionPoints)
+ {
+ Object puInstance = jpaServices.resolvePersistenceUnit(injectionPoint);
+ injectionPoint.inject(beanInstance, puInstance);
+ }
+ }
+
+ if (resourceServices != null)
+ {
+ for (WBInjectionPoint<?, ?> injectionPoint : resourceInjectionPoints)
+ {
+ Object resourceInstance = resourceServices.resolveResource(injectionPoint);
+ injectionPoint.inject(beanInstance, resourceInstance);
+ }
+ }
+ }
+
+
+ /**
+ * Injects bound fields
+ *
+ * @param instance The instance to inject into
+ */
+ public static <T> void injectBoundFields(T instance, CreationalContext<T> creationalContext, BeanManagerImpl manager, Iterable<FieldInjectionPoint<?, ?>> injectableFields)
+ {
+ for (FieldInjectionPoint<?, ?> injectableField : injectableFields)
+ {
+ injectableField.inject(instance, manager, creationalContext);
+ }
+ }
+
+ /**
+ * Calls all initializers of the bean
+ *
+ * @param instance The bean instance
+ */
+ public static <T> void callInitializers(T instance, CreationalContext<T> creationalContext, BeanManagerImpl manager, Iterable<? extends MethodInjectionPoint<?, ?>> initializerMethods)
+ {
+ for (MethodInjectionPoint<?, ?> initializer : initializerMethods)
+ {
+ initializer.invoke(instance, manager, creationalContext, CreationException.class);
+ }
+ }
+
}
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -20,10 +20,11 @@
import java.util.Set;
import org.jboss.webbeans.ejb.spi.EjbServices;
-import org.jboss.webbeans.jsf.spi.JSFServices;
-import org.jboss.webbeans.persistence.spi.JpaServices;
+import org.jboss.webbeans.injection.spi.EjbInjectionServices;
+import org.jboss.webbeans.injection.spi.InjectionServices;
+import org.jboss.webbeans.injection.spi.JpaInjectionServices;
+import org.jboss.webbeans.injection.spi.ResourceInjectionServices;
import org.jboss.webbeans.resources.spi.ResourceLoader;
-import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.security.spi.SecurityServices;
import org.jboss.webbeans.servlet.api.ServletServices;
import org.jboss.webbeans.transaction.spi.TransactionServices;
@@ -40,19 +41,44 @@
/**
* Java EE5 or Java EE6
+ *
+ * In this environment, Web Beans requires that {@link JpaInjectionServices},
+ * {@link ResourceInjectionServices} and {@link EjbInjectionServices} are
+ * present, and so will perform EE-style field injection on managed beans
+ * itself
*/
+ EE_INJECT(new EnvironmentBuilder()
+ .addRequiredDeploymentService(TransactionServices.class)
+ .addRequiredDeploymentService(ResourceLoader.class)
+ .addRequiredDeploymentService(SecurityServices.class)
+ .addRequiredDeploymentService(ValidationServices.class)
+ .addRequiredDeploymentService(ServletServices.class)
+ .addRequiredDeploymentService(EjbServices.class)
+ .addRequiredBeanDeploymentArchiveService(JpaInjectionServices.class)
+ .addRequiredBeanDeploymentArchiveService(ResourceInjectionServices.class)
+ .addRequiredBeanDeploymentArchiveService(EjbInjectionServices.class)
+ ),
+
+ /**
+ * Java EE5 or Java EE6
+ *
+ * In this environment, Web Beans requires that {@link InjectionServices} are
+ * present, and expects the container to use this callback to perform EE-style
+ * injection
+ *
+ */
EE(new EnvironmentBuilder()
.addRequiredDeploymentService(TransactionServices.class)
.addRequiredDeploymentService(ResourceLoader.class)
.addRequiredDeploymentService(SecurityServices.class)
.addRequiredDeploymentService(ValidationServices.class)
.addRequiredDeploymentService(ServletServices.class)
- .addRequiredDeploymentService(JSFServices.class)
- .addRequiredBeanDeploymentArchiveService(JpaServices.class)
- .addRequiredBeanDeploymentArchiveService(ResourceServices.class)
- .addRequiredBeanDeploymentArchiveService(EjbServices.class)
+ .addRequiredDeploymentService(EjbServices.class)
+ .addRequiredBeanDeploymentArchiveService(InjectionServices.class)
),
+
+
/**
* Servlet container such as Tomcat
*/
@@ -94,29 +120,29 @@
private final Set<Class<? extends Service>> requiredBeanDeploymentArchiveServices;
- public EnvironmentBuilder()
+ private EnvironmentBuilder()
{
this.requiredBeanDeploymentArchiveServices = new HashSet<Class<? extends Service>>();
this.requiredDeploymentServices = new HashSet<Class<? extends Service>>();
}
- public Set<Class<? extends Service>> getRequiredBeanDeploymentArchiveServices()
+ private Set<Class<? extends Service>> getRequiredBeanDeploymentArchiveServices()
{
return requiredBeanDeploymentArchiveServices;
}
- public Set<Class<? extends Service>> getRequiredDeploymentServices()
+ private Set<Class<? extends Service>> getRequiredDeploymentServices()
{
return requiredDeploymentServices;
}
- public EnvironmentBuilder addRequiredDeploymentService(Class<? extends Service> service)
+ private EnvironmentBuilder addRequiredDeploymentService(Class<? extends Service> service)
{
this.requiredDeploymentServices.add(service);
return this;
}
- public EnvironmentBuilder addRequiredBeanDeploymentArchiveService(Class<? extends Service> service)
+ private EnvironmentBuilder addRequiredBeanDeploymentArchiveService(Class<? extends Service> service)
{
this.requiredBeanDeploymentArchiveServices.add(service);
return this;
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -17,8 +17,6 @@
package org.jboss.webbeans.ejb.spi;
-import javax.enterprise.inject.spi.InjectionPoint;
-
import org.jboss.webbeans.bootstrap.api.Service;
import org.jboss.webbeans.ejb.api.SessionObjectReference;
@@ -33,20 +31,6 @@
{
/**
- * Resolve the value for the given @EJB injection point
- *
- * @param injectionPoint
- * the injection point metadata
- * @return an instance of the EJB
- * @throws IllegalArgumentException
- * if the injection point is not annotated with @EJB, or, if the
- * injection point is a method that doesn't follow JavaBean
- * conventions
-
- */
- public Object resolveEjb(InjectionPoint injectionPoint);
-
- /**
* Request a reference to an EJB session object from the container. If the
* EJB being resolved is a stateful session bean, the container should ensure
* the session bean is created before this method returns.
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -16,8 +16,6 @@
*/
package org.jboss.webbeans.ejb.spi.helpers;
-import javax.enterprise.inject.spi.InjectionPoint;
-
import org.jboss.webbeans.ejb.api.SessionObjectReference;
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
import org.jboss.webbeans.ejb.spi.EjbServices;
@@ -37,11 +35,6 @@
public abstract EjbServices delegate();
- public Object resolveEjb(InjectionPoint injectionPoint)
- {
- return delegate().resolveEjb(injectionPoint);
- }
-
public SessionObjectReference resolveEjb(EjbDescriptor<?> ejbDescriptor)
{
return delegate().resolveEjb(ejbDescriptor);
Added: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/EjbInjectionServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/EjbInjectionServices.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/EjbInjectionServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,48 @@
+/*
+ * 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.spi;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.webbeans.bootstrap.api.Service;
+
+/**
+ * A container should implement this interface to allow Web Beans to
+ * resolve EJB
+ *
+ * @author Pete Muir
+ *
+ */
+public interface EjbInjectionServices extends Service
+{
+
+ /**
+ * Resolve the value for the given @EJB injection point
+ *
+ * @param injectionPoint
+ * the injection point metadata
+ * @return an instance of the EJB
+ * @throws IllegalArgumentException
+ * if the injection point is not annotated with @EJB, or, if the
+ * injection point is a method that doesn't follow JavaBean
+ * conventions
+
+ */
+ public Object resolveEjb(InjectionPoint injectionPoint);
+
+}
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/EjbInjectionServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionContext.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionContext.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionContext.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,34 @@
+/*
+ * 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.spi;
+
+import javax.enterprise.inject.spi.InjectionTarget;
+
+/**
+ * @author pmuir
+ *
+ */
+public interface InjectionContext<T>
+{
+
+ public void proceed();
+
+ public T getTarget();
+
+ public InjectionTarget<T> getInjectionTarget();
+
+}
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionServices.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,43 @@
+/*
+ * 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.spi;
+
+import org.jboss.webbeans.bootstrap.api.Service;
+
+/**
+ * Provides callbacks to the container when Web Beans performs injection on an
+ * InjectionTarget, managed bean or session bean
+ *
+ * This service may be used to provide EE-style injection.
+ *
+ * @author pmuir
+ *
+ */
+public interface InjectionServices extends Service
+{
+
+ /**
+ * Callback for injection.
+ *
+ * Call {@link InjectionContext#proceed()} to cause CDI-style injection to
+ * occur.
+ *
+ * @param injectionContext
+ */
+ public <T> void aroundInject(InjectionContext<T> injectionContext);
+
+}
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/JpaInjectionServices.java (from rev 3593, ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/JpaServices.java)
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/JpaInjectionServices.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/JpaInjectionServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,65 @@
+/*
+ * 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.spi;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.jboss.webbeans.bootstrap.api.Service;
+
+/**
+ * A container should implement this interface to allow the Web Beans RI to
+ * resolve JPA persistence units and discover entities
+ *
+ * @author Pete Muir
+ *
+ */
+public interface JpaInjectionServices extends Service
+{
+
+ /**
+ * Resolve the value for the given @PersistenceContext injection point
+ *
+ * @param injectionPoint
+ * the injection point metadata
+ * @return an instance of the entity manager
+ * @throws IllegalArgumentException
+ * if the injection point is not annotated with
+ * @PersistenceContext, or, if the injection point is a method
+ * that doesn't follow JavaBean conventions
+ * @throws IllegalStateException
+ * if no suitable persistence units can be resolved for injection
+ */
+ public EntityManager resolvePersistenceContext(InjectionPoint injectionPoint);
+
+ /**
+ * Resolve the value for the given @PersistenceUnit injection point
+ *
+ * @param injectionPoint
+ * the injection point metadata
+ * @return an instance of the entity manager
+ * @throws IllegalArgumentException
+ * if the injection point is not annotated with
+ * @PersistenceUnit, or, if the injection point is a method
+ * that doesn't follow JavaBean conventions
+ * @throws IllegalStateException
+ * if no suitable persistence units can be resolved for injection
+ */
+ public EntityManagerFactory resolvePersistenceUnit(InjectionPoint injectionPoint);
+
+}
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/JpaInjectionServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/ResourceInjectionServices.java (from rev 3593, ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceServices.java)
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/ResourceInjectionServices.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/ResourceInjectionServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,61 @@
+/*
+ * 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.spi;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.webbeans.bootstrap.api.Service;
+
+/**
+ * A container should implement this interface to allow the Web Beans RI to
+ * resolve Resources
+ *
+ * @author Pete Muir
+ *
+ */
+public interface ResourceInjectionServices extends Service
+{
+
+ /**
+ * Resolve the value for the given @Resource injection point
+ *
+ * @param injectionPoint
+ * the injection point metadata
+ * @return an instance of the resource
+ * @throws IllegalArgumentException
+ * if the injection point is not annotated with @Resource, or, if
+ * the injection point is a method that doesn't follow JavaBean
+ * conventions
+ * @throws IllegalStateException
+ * if no resource can be resolved for injection
+ */
+ public Object resolveResource(InjectionPoint injectionPoint);
+
+ /**
+ * Resolve the value for the given JNDI name and mapped name
+ *
+ * @param injectionPoint
+ * the injection point metadata
+ * @return an instance of the resource
+ * @throws IllegalStateException
+ * if no resource can be resolved for injection
+ * @throws IllegalArgumentException
+ * if both jndiName and mappedName are null
+ */
+ public Object resolveResource(String jndiName, String mappedName);
+
+}
\ No newline at end of file
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/ResourceInjectionServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/AbstractResourceServices.java (from rev 3567, ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractResourceServices.java)
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/AbstractResourceServices.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/AbstractResourceServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,124 @@
+package org.jboss.webbeans.injection.spi.helpers;
+
+import java.beans.Introspector;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.annotation.Resource;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+public abstract class AbstractResourceServices
+{
+
+ private static final String RESOURCE_LOOKUP_PREFIX = "java:/comp/env";
+
+ /* (non-Javadoc)
+ * @see org.jboss.webbeans.resources.spi.helpers.ResourceServices#resolveResource(javax.inject.manager.InjectionPoint)
+ */
+ public Object resolveResource(InjectionPoint injectionPoint)
+ {
+ if (!injectionPoint.getAnnotated().isAnnotationPresent(Resource.class))
+ {
+ throw new IllegalArgumentException("No @Resource annotation found on injection point " + injectionPoint);
+ }
+ if (injectionPoint.getMember() instanceof Method && ((Method) injectionPoint.getMember()).getParameterTypes().length != 1)
+ {
+ throw new IllegalArgumentException("Injection point represents a method which doesn't follow JavaBean conventions (must have exactly one parameter) " + injectionPoint);
+ }
+ String name = getResourceName(injectionPoint);
+ try
+ {
+ return getContext().lookup(name);
+ }
+ catch (NamingException e)
+ {
+ throw new RuntimeException("Error looking up " + name + " in JNDI", e);
+ }
+ }
+
+ public Object resolveResource(String jndiName, String mappedName)
+ {
+ String name = getResourceName(jndiName, mappedName);
+ try
+ {
+ return getContext().lookup(name);
+ }
+ catch (NamingException e)
+ {
+ throw new RuntimeException("Error looking up " + name + " in JNDI", e);
+ }
+ }
+
+ protected String getResourceName(String jndiName, String mappedName)
+ {
+ if (mappedName != null)
+ {
+ return mappedName;
+ }
+ else if (jndiName != null)
+ {
+ return jndiName;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Both jndiName and mappedName are null");
+ }
+ }
+
+ protected abstract Context getContext();
+
+ protected String getResourceName(InjectionPoint injectionPoint)
+ {
+ Resource resource = injectionPoint.getAnnotated().getAnnotation(Resource.class);
+ String mappedName = resource.mappedName();
+ if (!mappedName.equals(""))
+ {
+ return mappedName;
+ }
+ String name = resource.name();
+ if (!name.equals(""))
+ {
+ return RESOURCE_LOOKUP_PREFIX + "/" + name;
+ }
+ String propertyName;
+ if (injectionPoint.getMember() instanceof Field)
+ {
+ propertyName = injectionPoint.getMember().getName();
+ }
+ else if (injectionPoint.getMember() instanceof Method)
+ {
+ propertyName = getPropertyName((Method) injectionPoint.getMember());
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException("Injection point represents a method which doesn't follow JavaBean conventions (unable to determine property name) " + injectionPoint);
+ }
+ }
+ else
+ {
+ throw new AssertionError("Unable to inject into " + injectionPoint);
+ }
+ String className = injectionPoint.getMember().getDeclaringClass().getName();
+ return RESOURCE_LOOKUP_PREFIX + "/" + className + "/" + propertyName;
+ }
+
+ public static String getPropertyName(Method method)
+ {
+ String methodName = method.getName();
+ if (methodName.matches("^(get).*") && method.getParameterTypes().length == 0)
+ {
+ return Introspector.decapitalize(methodName.substring(3));
+ }
+ else if (methodName.matches("^(is).*") && method.getParameterTypes().length == 0)
+ {
+ return Introspector.decapitalize(methodName.substring(2));
+ }
+ else
+ {
+ return null;
+ }
+
+ }
+
+}
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/AbstractResourceServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingJpaInjectionServices.java (from rev 3593, ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/helpers/ForwardingJpaServices.java)
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingJpaInjectionServices.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingJpaInjectionServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,68 @@
+/*
+ * 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.spi.helpers;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.jboss.webbeans.injection.spi.JpaInjectionServices;
+
+/**
+ * An implementation of {@link JpaInjectionServices} which forwards all its method calls
+ * to another {@link JpaInjectionServices}}. Subclasses should override one or more
+ * methods to modify the behavior of the backing {@link JpaInjectionServices} as desired
+ * per the <a
+ * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
+ *
+ * @author Pete Muir
+ *
+ */
+public abstract class ForwardingJpaInjectionServices implements JpaInjectionServices
+{
+
+ protected abstract JpaInjectionServices delegate();
+
+ public EntityManager resolvePersistenceContext(InjectionPoint injectionPoint)
+ {
+ return delegate().resolvePersistenceContext(injectionPoint);
+ }
+
+ public EntityManagerFactory resolvePersistenceUnit(InjectionPoint injectionPoint)
+ {
+ return delegate().resolvePersistenceUnit(injectionPoint);
+ }
+
+ @Override
+ public String toString()
+ {
+ return delegate().toString();
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return delegate().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ return delegate().equals(obj);
+ }
+
+}
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingJpaInjectionServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingResourceInjectionServices.java (from rev 3593, ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/ForwardingResourceServices.java)
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingResourceInjectionServices.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingResourceInjectionServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,22 @@
+package org.jboss.webbeans.injection.spi.helpers;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.webbeans.injection.spi.ResourceInjectionServices;
+
+public abstract class ForwardingResourceInjectionServices implements ResourceInjectionServices
+{
+
+ protected abstract ResourceInjectionServices delegate();
+
+ public Object resolveResource(InjectionPoint injectionPoint)
+ {
+ return delegate().resolveResource(injectionPoint);
+ }
+
+ public Object resolveResource(String jndiName, String mappedName)
+ {
+ return delegate().resolveResource(jndiName, mappedName);
+ }
+
+}
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingResourceInjectionServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -1,61 +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.resources.spi;
-
-import javax.enterprise.inject.spi.InjectionPoint;
-
-import org.jboss.webbeans.bootstrap.api.Service;
-
-/**
- * A container should implement this interface to allow the Web Beans RI to
- * resolve Resources
- *
- * @author Pete Muir
- *
- */
-public interface ResourceServices extends Service
-{
-
- /**
- * Resolve the value for the given @Resource injection point
- *
- * @param injectionPoint
- * the injection point metadata
- * @return an instance of the resource
- * @throws IllegalArgumentException
- * if the injection point is not annotated with @Resource, or, if
- * the injection point is a method that doesn't follow JavaBean
- * conventions
- * @throws IllegalStateException
- * if no resource can be resolved for injection
- */
- public Object resolveResource(InjectionPoint injectionPoint);
-
- /**
- * Resolve the value for the given JNDI name and mapped name
- *
- * @param injectionPoint
- * the injection point metadata
- * @return an instance of the resource
- * @throws IllegalStateException
- * if no resource can be resolved for injection
- * @throws IllegalArgumentException
- * if both jndiName and mappedName are null
- */
- public Object resolveResource(String jndiName, String mappedName);
-
-}
\ No newline at end of file
Deleted: ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractResourceServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractResourceServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractResourceServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -1,124 +0,0 @@
-package org.jboss.webbeans.resources.spi.helpers;
-
-import java.beans.Introspector;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import javax.annotation.Resource;
-import javax.enterprise.inject.spi.InjectionPoint;
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-public abstract class AbstractResourceServices
-{
-
- private static final String RESOURCE_LOOKUP_PREFIX = "java:/comp/env";
-
- /* (non-Javadoc)
- * @see org.jboss.webbeans.resources.spi.helpers.ResourceServices#resolveResource(javax.inject.manager.InjectionPoint)
- */
- public Object resolveResource(InjectionPoint injectionPoint)
- {
- if (!injectionPoint.getAnnotated().isAnnotationPresent(Resource.class))
- {
- throw new IllegalArgumentException("No @Resource annotation found on injection point " + injectionPoint);
- }
- if (injectionPoint.getMember() instanceof Method && ((Method) injectionPoint.getMember()).getParameterTypes().length != 1)
- {
- throw new IllegalArgumentException("Injection point represents a method which doesn't follow JavaBean conventions (must have exactly one parameter) " + injectionPoint);
- }
- String name = getResourceName(injectionPoint);
- try
- {
- return getContext().lookup(name);
- }
- catch (NamingException e)
- {
- throw new RuntimeException("Error looking up " + name + " in JNDI", e);
- }
- }
-
- public Object resolveResource(String jndiName, String mappedName)
- {
- String name = getResourceName(jndiName, mappedName);
- try
- {
- return getContext().lookup(name);
- }
- catch (NamingException e)
- {
- throw new RuntimeException("Error looking up " + name + " in JNDI", e);
- }
- }
-
- protected String getResourceName(String jndiName, String mappedName)
- {
- if (mappedName != null)
- {
- return mappedName;
- }
- else if (jndiName != null)
- {
- return jndiName;
- }
- else
- {
- throw new IllegalArgumentException("Both jndiName and mappedName are null");
- }
- }
-
- protected abstract Context getContext();
-
- protected String getResourceName(InjectionPoint injectionPoint)
- {
- Resource resource = injectionPoint.getAnnotated().getAnnotation(Resource.class);
- String mappedName = resource.mappedName();
- if (!mappedName.equals(""))
- {
- return mappedName;
- }
- String name = resource.name();
- if (!name.equals(""))
- {
- return RESOURCE_LOOKUP_PREFIX + "/" + name;
- }
- String propertyName;
- if (injectionPoint.getMember() instanceof Field)
- {
- propertyName = injectionPoint.getMember().getName();
- }
- else if (injectionPoint.getMember() instanceof Method)
- {
- propertyName = getPropertyName((Method) injectionPoint.getMember());
- if (propertyName == null)
- {
- throw new IllegalArgumentException("Injection point represents a method which doesn't follow JavaBean conventions (unable to determine property name) " + injectionPoint);
- }
- }
- else
- {
- throw new AssertionError("Unable to inject into " + injectionPoint);
- }
- String className = injectionPoint.getMember().getDeclaringClass().getName();
- return RESOURCE_LOOKUP_PREFIX + "/" + className + "/" + propertyName;
- }
-
- public static String getPropertyName(Method method)
- {
- String methodName = method.getName();
- if (methodName.matches("^(get).*") && method.getParameterTypes().length == 0)
- {
- return Introspector.decapitalize(methodName.substring(3));
- }
- else if (methodName.matches("^(is).*") && method.getParameterTypes().length == 0)
- {
- return Introspector.decapitalize(methodName.substring(2));
- }
- else
- {
- return null;
- }
-
- }
-
-}
Deleted: ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/ForwardingResourceServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/ForwardingResourceServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/ForwardingResourceServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -1,22 +0,0 @@
-package org.jboss.webbeans.resources.spi.helpers;
-
-import javax.enterprise.inject.spi.InjectionPoint;
-
-import org.jboss.webbeans.resources.spi.ResourceServices;
-
-public abstract class ForwardingResourceServices implements ResourceServices
-{
-
- protected abstract ResourceServices delegate();
-
- public Object resolveResource(InjectionPoint injectionPoint)
- {
- return delegate().resolveResource(injectionPoint);
- }
-
- public Object resolveResource(String jndiName, String mappedName)
- {
- return delegate().resolveResource(jndiName, mappedName);
- }
-
-}
Modified: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java
===================================================================
--- ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -7,10 +7,10 @@
import org.jboss.webbeans.bootstrap.api.test.MockDeployment.MockBeanDeploymentArchive;
import org.jboss.webbeans.bootstrap.spi.Deployment;
import org.jboss.webbeans.ejb.spi.EjbServices;
-import org.jboss.webbeans.jsf.spi.JSFServices;
-import org.jboss.webbeans.persistence.spi.JpaServices;
+import org.jboss.webbeans.injection.spi.EjbInjectionServices;
+import org.jboss.webbeans.injection.spi.JpaInjectionServices;
+import org.jboss.webbeans.injection.spi.ResourceInjectionServices;
import org.jboss.webbeans.resources.spi.ResourceLoader;
-import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.security.spi.SecurityServices;
import org.jboss.webbeans.servlet.api.ServletServices;
import org.jboss.webbeans.transaction.spi.TransactionServices;
@@ -31,138 +31,140 @@
deploymentServices.add(SecurityServices.class, new MockSecurityServices());
deploymentServices.add(ValidationServices.class, new MockValidationServices());
deploymentServices.add(ServletServices.class, new MockServletServices());
- deploymentServices.add(JSFServices.class, new MockJSFServices());
- bdaServices.add(JpaServices.class, new MockJpaServices());
- bdaServices.add(ResourceServices.class, new MockResourceServices());
+ bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
+ bdaServices.add(ResourceInjectionServices.class, new MockResourceServices());
+ bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
- bootstrap.startContainer(Environments.EE, deployment, null);
+ bootstrap.startContainer(Environments.EE_INJECT, deployment, null);
}
-
+
@Test(expectedExceptions = IllegalStateException.class)
- public void testMissingJpaServices()
+ public void testMissingEjbInjectionServices()
{
Bootstrap bootstrap = new MockBootstrap();
ServiceRegistry deploymentServices = new SimpleServiceRegistry();
+ ServiceRegistry bdaServices = new SimpleServiceRegistry();
deploymentServices.add(ResourceLoader.class, new MockResourceLoader());
deploymentServices.add(TransactionServices.class, new MockTransactionServices());
deploymentServices.add(SecurityServices.class, new MockSecurityServices());
deploymentServices.add(ValidationServices.class, new MockValidationServices());
deploymentServices.add(ServletServices.class, new MockServletServices());
- deploymentServices.add(JSFServices.class, new MockJSFServices());
- ServiceRegistry bdaServices = new SimpleServiceRegistry();
- bdaServices.add(EjbServices.class, new MockEjbServices());
- bdaServices.add(ResourceServices.class, new MockResourceServices());
+ bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
+ bdaServices.add(ResourceInjectionServices.class, new MockResourceServices());
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
- bootstrap.startContainer(Environments.EE, deployment, null);
+ bootstrap.startContainer(Environments.EE_INJECT, deployment, null);
}
@Test(expectedExceptions = IllegalStateException.class)
- public void testMissingSecurityServices()
+ public void testMissingJpaServices()
{
Bootstrap bootstrap = new MockBootstrap();
ServiceRegistry deploymentServices = new SimpleServiceRegistry();
deploymentServices.add(ResourceLoader.class, new MockResourceLoader());
deploymentServices.add(TransactionServices.class, new MockTransactionServices());
+ deploymentServices.add(SecurityServices.class, new MockSecurityServices());
deploymentServices.add(ValidationServices.class, new MockValidationServices());
deploymentServices.add(ServletServices.class, new MockServletServices());
- deploymentServices.add(JSFServices.class, new MockJSFServices());
+ deploymentServices.add(EjbServices.class, new MockEjbServices());
ServiceRegistry bdaServices = new SimpleServiceRegistry();
- bdaServices.add(EjbServices.class, new MockEjbServices());
- bdaServices.add(JpaServices.class, new MockJpaServices());
- bdaServices.add(ResourceServices.class, new MockResourceServices());
+ bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
+ bdaServices.add(ResourceInjectionServices.class, new MockResourceServices());
+ bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
+
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
- bootstrap.startContainer(Environments.EE, deployment, null);
+ bootstrap.startContainer(Environments.EE_INJECT, deployment, null);
}
@Test(expectedExceptions = IllegalStateException.class)
- public void testMissingValidationServices()
+ public void testMissingSecurityServices()
{
Bootstrap bootstrap = new MockBootstrap();
ServiceRegistry deploymentServices = new SimpleServiceRegistry();
deploymentServices.add(ResourceLoader.class, new MockResourceLoader());
deploymentServices.add(TransactionServices.class, new MockTransactionServices());
- deploymentServices.add(SecurityServices.class, new MockSecurityServices());
+ deploymentServices.add(ValidationServices.class, new MockValidationServices());
deploymentServices.add(ServletServices.class, new MockServletServices());
- deploymentServices.add(JSFServices.class, new MockJSFServices());
+ deploymentServices.add(EjbServices.class, new MockEjbServices());
ServiceRegistry bdaServices = new SimpleServiceRegistry();
- bdaServices.add(EjbServices.class, new MockEjbServices());
- bdaServices.add(JpaServices.class, new MockJpaServices());
- bdaServices.add(ResourceServices.class, new MockResourceServices());
+ bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
+ bdaServices.add(ResourceInjectionServices.class, new MockResourceServices());
+ bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
+
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
- bootstrap.startContainer(Environments.EE, deployment, null);
+ bootstrap.startContainer(Environments.EE_INJECT, deployment, null);
}
- @Test
- public void testEEEnv()
+ @Test(expectedExceptions = IllegalStateException.class)
+ public void testMissingValidationServices()
{
Bootstrap bootstrap = new MockBootstrap();
ServiceRegistry deploymentServices = new SimpleServiceRegistry();
deploymentServices.add(ResourceLoader.class, new MockResourceLoader());
deploymentServices.add(TransactionServices.class, new MockTransactionServices());
deploymentServices.add(SecurityServices.class, new MockSecurityServices());
- deploymentServices.add(ValidationServices.class, new MockValidationServices());
deploymentServices.add(ServletServices.class, new MockServletServices());
- deploymentServices.add(JSFServices.class, new MockJSFServices());
+ deploymentServices.add(EjbServices.class, new MockEjbServices());
ServiceRegistry bdaServices = new SimpleServiceRegistry();
- bdaServices.add(EjbServices.class, new MockEjbServices());
- bdaServices.add(JpaServices.class, new MockJpaServices());
- bdaServices.add(ResourceServices.class, new MockResourceServices());
+ bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
+ bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
+ bdaServices.add(ResourceInjectionServices.class, new MockResourceServices());
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
- bootstrap.startContainer(Environments.EE, deployment, null);
+ bootstrap.startContainer(Environments.EE_INJECT, deployment, null);
}
- @Test(expectedExceptions = IllegalStateException.class)
- public void testMissingTxServices()
+ @Test
+ public void testEEEnv()
{
Bootstrap bootstrap = new MockBootstrap();
ServiceRegistry deploymentServices = new SimpleServiceRegistry();
deploymentServices.add(ResourceLoader.class, new MockResourceLoader());
+ deploymentServices.add(TransactionServices.class, new MockTransactionServices());
deploymentServices.add(SecurityServices.class, new MockSecurityServices());
deploymentServices.add(ValidationServices.class, new MockValidationServices());
deploymentServices.add(ServletServices.class, new MockServletServices());
- deploymentServices.add(JSFServices.class, new MockJSFServices());
+ deploymentServices.add(EjbServices.class, new MockEjbServices());
ServiceRegistry bdaServices = new SimpleServiceRegistry();
- bdaServices.add(EjbServices.class, new MockEjbServices());
- bdaServices.add(JpaServices.class, new MockJpaServices());
- bdaServices.add(ResourceServices.class, new MockResourceServices());
+ bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
+ bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
+ bdaServices.add(ResourceInjectionServices.class, new MockResourceServices());
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
- bootstrap.startContainer(Environments.EE, deployment, null);
+ bootstrap.startContainer(Environments.EE_INJECT, deployment, null);
}
@Test(expectedExceptions = IllegalStateException.class)
- public void testMissingResourceServices()
+ public void testMissingTxServices()
{
Bootstrap bootstrap = new MockBootstrap();
ServiceRegistry deploymentServices = new SimpleServiceRegistry();
deploymentServices.add(ResourceLoader.class, new MockResourceLoader());
- deploymentServices.add(TransactionServices.class, new MockTransactionServices());
deploymentServices.add(SecurityServices.class, new MockSecurityServices());
deploymentServices.add(ValidationServices.class, new MockValidationServices());
deploymentServices.add(ServletServices.class, new MockServletServices());
- deploymentServices.add(JSFServices.class, new MockJSFServices());
+ deploymentServices.add(EjbServices.class, new MockEjbServices());
ServiceRegistry bdaServices = new SimpleServiceRegistry();
- bdaServices.add(EjbServices.class, new MockEjbServices());
- bdaServices.add(JpaServices.class, new MockJpaServices());
+ bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
+ bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
+ bdaServices.add(ResourceInjectionServices.class, new MockResourceServices());
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
- bootstrap.startContainer(Environments.EE, deployment, null);
+ bootstrap.startContainer(Environments.EE_INJECT, deployment, null);
}
@Test(expectedExceptions = IllegalStateException.class)
- public void testMissingJSFServices()
+ public void testMissingResourceServices()
{
Bootstrap bootstrap = new MockBootstrap();
ServiceRegistry deploymentServices = new SimpleServiceRegistry();
@@ -171,14 +173,14 @@
deploymentServices.add(SecurityServices.class, new MockSecurityServices());
deploymentServices.add(ValidationServices.class, new MockValidationServices());
deploymentServices.add(ServletServices.class, new MockServletServices());
+ deploymentServices.add(EjbServices.class, new MockEjbServices());
ServiceRegistry bdaServices = new SimpleServiceRegistry();
- bdaServices.add(EjbServices.class, new MockEjbServices());
- bdaServices.add(JpaServices.class, new MockJpaServices());
- bdaServices.add(ResourceServices.class, new MockResourceServices());
+ bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
+ bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
- bootstrap.startContainer(Environments.EE, deployment, null);
+ bootstrap.startContainer(Environments.EE_INJECT, deployment, null);
}
@Test(expectedExceptions = IllegalStateException.class)
@@ -190,15 +192,15 @@
deploymentServices.add(TransactionServices.class, new MockTransactionServices());
deploymentServices.add(SecurityServices.class, new MockSecurityServices());
deploymentServices.add(ValidationServices.class, new MockValidationServices());
- deploymentServices.add(JSFServices.class, new MockJSFServices());
+ deploymentServices.add(EjbServices.class, new MockEjbServices());
ServiceRegistry bdaServices = new SimpleServiceRegistry();
- bdaServices.add(EjbServices.class, new MockEjbServices());
- bdaServices.add(JpaServices.class, new MockJpaServices());
- bdaServices.add(ResourceServices.class, new MockResourceServices());
+ bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
+ bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
+ bdaServices.add(ResourceInjectionServices.class, new MockResourceServices());
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
- bootstrap.startContainer(Environments.EE, deployment, null);
+ bootstrap.startContainer(Environments.EE_INJECT, deployment, null);
}
@Test
Added: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbInjectionServices.java
===================================================================
--- ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbInjectionServices.java (rev 0)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbInjectionServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,35 @@
+/*
+ * 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.bootstrap.api.test;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.webbeans.injection.spi.EjbInjectionServices;
+
+/**
+ * @author pmuir
+ *
+ */
+public class MockEjbInjectionServices implements EjbInjectionServices
+{
+
+ public Object resolveEjb(InjectionPoint injectionPoint)
+ {
+ return null;
+ }
+
+}
Property changes on: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbInjectionServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJSFServices.java
===================================================================
--- ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJSFServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJSFServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -1,36 +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.bootstrap.api.test;
-
-import javax.faces.application.Application;
-
-import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.webbeans.jsf.spi.JSFServices;
-
-/**
- * @author pmuir
- *
- */
-public class MockJSFServices implements JSFServices
-{
-
- public BeanDeploymentArchive getBeanDeploymentArchive(Application application)
- {
- return null;
- }
-
-}
Modified: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java
===================================================================
--- ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -6,9 +6,9 @@
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
-import org.jboss.webbeans.persistence.spi.JpaServices;
+import org.jboss.webbeans.injection.spi.JpaInjectionServices;
-public class MockJpaServices implements JpaServices
+public class MockJpaServices implements JpaInjectionServices
{
public Collection<Class<?>> discoverEntities()
Modified: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java
===================================================================
--- ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -2,9 +2,9 @@
import javax.enterprise.inject.spi.InjectionPoint;
-import org.jboss.webbeans.resources.spi.ResourceServices;
+import org.jboss.webbeans.injection.spi.ResourceInjectionServices;
-public class MockResourceServices implements ResourceServices
+public class MockResourceServices implements ResourceInjectionServices
{
public Object resolveResource(InjectionPoint injectionPoint)
Deleted: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockConversationManager.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockConversationManager.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockConversationManager.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -1,31 +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.mock;
-
-import org.jboss.webbeans.conversation.ServletConversationManager;
-
-/**
- * Mock of a conversation manager without servlet dependencies
- *
- * @author Nicklas Karlsson
- *
- */
-// TODO dummy
-public class MockConversationManager extends ServletConversationManager
-{
-
-}
Modified: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -19,9 +19,9 @@
import org.jboss.webbeans.bootstrap.api.Environment;
import org.jboss.webbeans.bootstrap.api.Environments;
import org.jboss.webbeans.ejb.spi.EjbServices;
-import org.jboss.webbeans.jsf.spi.JSFServices;
-import org.jboss.webbeans.persistence.spi.JpaServices;
-import org.jboss.webbeans.resources.spi.ResourceServices;
+import org.jboss.webbeans.injection.spi.EjbInjectionServices;
+import org.jboss.webbeans.injection.spi.JpaInjectionServices;
+import org.jboss.webbeans.injection.spi.ResourceInjectionServices;
import org.jboss.webbeans.security.spi.SecurityServices;
import org.jboss.webbeans.transaction.spi.TransactionServices;
import org.jboss.webbeans.validation.spi.ValidationServices;
@@ -37,15 +37,15 @@
getDeployment().getServices().add(TransactionServices.class, MOCK_TRANSACTION_SERVICES);
getDeployment().getServices().add(SecurityServices.class, new MockSecurityServices());
getDeployment().getServices().add(ValidationServices.class, new MockValidationServices());
- getDeployment().getServices().add(JSFServices.class, new MockJSFServices());
- getDeployment().getArchive().getServices().add(EjbServices.class, new MockEjBServices());
- getDeployment().getArchive().getServices().add(JpaServices.class, new MockJpaServices(getDeployment()));
- getDeployment().getArchive().getServices().add(ResourceServices.class, new MockResourceServices());
+ getDeployment().getServices().add(EjbServices.class, new MockEjBServices());
+ getDeployment().getArchive().getServices().add(EjbInjectionServices.class, new MockEjbInjectionServices());
+ getDeployment().getArchive().getServices().add(JpaInjectionServices.class, new MockJpaServices(getDeployment()));
+ getDeployment().getArchive().getServices().add(ResourceInjectionServices.class, new MockResourceServices());
}
public Environment getEnvironment()
{
- return Environments.EE;
+ return Environments.EE_INJECT;
}
}
Modified: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -3,8 +3,6 @@
*/
package org.jboss.webbeans.mock;
-import java.util.Collection;
-
import javax.enterprise.inject.spi.InjectionPoint;
import org.jboss.webbeans.ejb.api.SessionObjectReference;
@@ -14,20 +12,7 @@
public class MockEjBServices implements EjbServices
{
- public Object resolveEjb(InjectionPoint injectionPoint)
- {
- return null;
- }
- public void removeEjb(Collection<Object> instance)
- {
- // No-op
- }
-
- public Object resolveRemoteEjb(String jndiName, String mappedName, String ejbLink)
- {
- return null;
- }
public SessionObjectReference resolveEjb(EjbDescriptor<?> ejbDescriptor)
{
Added: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjbInjectionServices.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjbInjectionServices.java (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjbInjectionServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,35 @@
+/*
+ * 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.mock;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.webbeans.injection.spi.EjbInjectionServices;
+
+/**
+ * @author pmuir
+ *
+ */
+public class MockEjbInjectionServices implements EjbInjectionServices
+{
+
+ public Object resolveEjb(InjectionPoint injectionPoint)
+ {
+ return null;
+ }
+
+}
Property changes on: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjbInjectionServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJSFServices.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJSFServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJSFServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -1,36 +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.mock;
-
-import javax.faces.application.Application;
-
-import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.webbeans.jsf.spi.JSFServices;
-
-/**
- * @author pmuir
- *
- */
-public class MockJSFServices implements JSFServices
-{
-
- public BeanDeploymentArchive getBeanDeploymentArchive(Application application)
- {
- return null;
- }
-
-}
Modified: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -14,9 +14,9 @@
import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.webbeans.bootstrap.spi.Deployment;
-import org.jboss.webbeans.persistence.spi.JpaServices;
+import org.jboss.webbeans.injection.spi.JpaInjectionServices;
-public class MockJpaServices implements JpaServices
+public class MockJpaServices implements JpaInjectionServices
{
private final Deployment deployment;
Modified: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -18,13 +18,13 @@
import javax.enterprise.inject.spi.InjectionPoint;
-import org.jboss.webbeans.resources.spi.ResourceServices;
+import org.jboss.webbeans.injection.spi.ResourceInjectionServices;
/**
* @author Pete Muir
*
*/
-public class MockResourceServices implements ResourceServices
+public class MockResourceServices implements ResourceInjectionServices
{
public Object resolveResource(InjectionPoint injectionPoint)
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/CheckableInjectionServices.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/CheckableInjectionServices.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/CheckableInjectionServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,82 @@
+/*
+ * 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.test.unit.bootstrap;
+
+import org.jboss.webbeans.injection.spi.InjectionContext;
+import org.jboss.webbeans.injection.spi.InjectionServices;
+
+/**
+ * @author pmuir
+ *
+ */
+public class CheckableInjectionServices implements InjectionServices
+{
+
+ private boolean before = false;
+ private boolean after = false;
+ private boolean injectedAfter = false;
+ private boolean injectionTargetCorrect = false;
+
+ public <T> void aroundInject(InjectionContext<T> injectionContext)
+ {
+ before = true;
+ if (injectionContext.getTarget() instanceof Foo)
+ {
+ ((Foo) injectionContext.getTarget()).message = "hi!";
+ if (injectionContext.getInjectionTarget().getInjectionPoints().size() == 1)
+ {
+ injectionTargetCorrect = injectionContext.getInjectionTarget().getInjectionPoints().iterator().next().getType().equals(Bar.class);
+ }
+ }
+ injectionContext.proceed();
+ after = true;
+ if (injectionContext.getTarget() instanceof Foo)
+ {
+ Foo foo = (Foo) injectionContext.getTarget();
+ injectedAfter = foo.getBar() instanceof Bar && foo.getMessage().equals("hi!");
+ }
+ }
+
+ public void reset()
+ {
+ before = false;
+ after = false;
+ injectedAfter = false;
+ injectionTargetCorrect = false;
+ }
+
+ public boolean isBefore()
+ {
+ return before;
+ }
+
+ public boolean isAfter()
+ {
+ return after;
+ }
+
+ public boolean isInjectedAfter()
+ {
+ return injectedAfter;
+ }
+
+ public boolean isInjectionTargetCorrect()
+ {
+ return injectionTargetCorrect;
+ }
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/CheckableInjectionServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/InjectionServicesTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/InjectionServicesTest.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/InjectionServicesTest.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,47 @@
+package org.jboss.webbeans.test.unit.bootstrap;
+
+import java.util.Arrays;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.jboss.webbeans.injection.spi.InjectionServices;
+import org.jboss.webbeans.mock.MockEELifecycle;
+import org.testng.annotations.Test;
+
+public class InjectionServicesTest
+{
+
+ @Test
+ public void testDiscoverFails()
+ {
+ MockEELifecycle lifecycle = new MockEELifecycle();
+ lifecycle.getDeployment().getArchive().setBeanClasses(Arrays.asList(Foo.class, Bar.class));
+ CheckableInjectionServices ijs = new CheckableInjectionServices();
+ lifecycle.getDeployment().getArchive().getServices().add(InjectionServices.class, ijs);
+ lifecycle.initialize();
+ lifecycle.beginApplication();
+ lifecycle.beginSession();
+ lifecycle.beginRequest();
+
+ BeanManager manager = lifecycle.getBootstrap().getManager(lifecycle.getDeployment().getArchive());
+
+ Bean<? extends Object> bean = manager.resolve(manager.getBeans(Foo.class));
+ ijs.reset();
+ Foo foo = (Foo) manager.getReference(bean, Foo.class, manager.createCreationalContext(bean));
+
+ assert ijs.isBefore();
+ assert ijs.isAfter();
+ assert ijs.isInjectedAfter();
+ assert ijs.isInjectionTargetCorrect();
+
+ assert foo.getBar() != null;
+ assert foo.getMessage().equals("hi!");
+
+
+ lifecycle.endRequest();
+ lifecycle.endSession();
+ lifecycle.endApplication();
+ }
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/InjectionServicesTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 3 months
[webbeans-commits] Webbeans SVN: r3605 - ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap.
by webbeans-commits@lists.jboss.org
Author: kabir.khan(a)jboss.com
Date: 2009-08-27 08:43:59 -0400 (Thu, 27 Aug 2009)
New Revision: 3605
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/WBStartupTest.java
Log:
Check Foo.bar
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/WBStartupTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/WBStartupTest.java 2009-08-27 12:40:39 UTC (rev 3604)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/WBStartupTest.java 2009-08-27 12:43:59 UTC (rev 3605)
@@ -47,6 +47,7 @@
Foo foo = (Foo) manager.getReference(bean, Foo.class, manager.createCreationalContext(bean));
assert foo != null;
+ assert foo.getBar() != null;
lifecycle.endRequest();
15 years, 3 months
[webbeans-commits] Webbeans SVN: r3604 - ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-08-27 08:40:39 -0400 (Thu, 27 Aug 2009)
New Revision: 3604
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/Bar.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/Foo.java
Log:
Simple example of booting container
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/Bar.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/Bar.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/Bar.java 2009-08-27 12:40:39 UTC (rev 3604)
@@ -0,0 +1,26 @@
+/*
+ * 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.test.unit.bootstrap;
+
+/**
+ * @author pmuir
+ *
+ */
+public class Bar
+{
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/Bar.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/Foo.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/Foo.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/Foo.java 2009-08-27 12:40:39 UTC (rev 3604)
@@ -0,0 +1,49 @@
+/*
+ * 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.test.unit.bootstrap;
+
+import javax.enterprise.inject.Current;
+
+/**
+ * @author pmuir
+ *
+ */
+public class Foo
+{
+
+ @Current
+ private Bar bar;
+
+ public String message;
+
+ /**
+ * @return the bar
+ */
+ public Bar getBar()
+ {
+ return bar;
+ }
+
+ /**
+ * @return the message
+ */
+ public String getMessage()
+ {
+ return message;
+ }
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/Foo.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 3 months
[webbeans-commits] Webbeans SVN: r3603 - ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-08-27 08:10:19 -0400 (Thu, 27 Aug 2009)
New Revision: 3603
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/WBStartupTest.java
Log:
Simple example of booting container
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/WBStartupTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/WBStartupTest.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/WBStartupTest.java 2009-08-27 12:10:19 UTC (rev 3603)
@@ -0,0 +1,57 @@
+/*
+ * 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.test.unit.bootstrap;
+
+import java.util.Arrays;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.jboss.webbeans.mock.MockEELifecycle;
+import org.testng.annotations.Test;
+
+/**
+ * @author pmuir
+ *
+ */
+public class WBStartupTest
+{
+
+ @Test
+ public void test()
+ {
+ MockEELifecycle lifecycle = new MockEELifecycle();
+ lifecycle.getDeployment().getArchive().setBeanClasses(Arrays.asList(Foo.class, Bar.class));
+ lifecycle.initialize();
+ lifecycle.beginApplication();
+ lifecycle.beginSession();
+ lifecycle.beginRequest();
+
+ BeanManager manager = lifecycle.getBootstrap().getManager(lifecycle.getDeployment().getArchive());
+
+ Bean<? extends Object> bean = manager.resolve(manager.getBeans(Foo.class));
+ Foo foo = (Foo) manager.getReference(bean, Foo.class, manager.createCreationalContext(bean));
+
+ assert foo != null;
+
+
+ lifecycle.endRequest();
+ lifecycle.endSession();
+ lifecycle.endApplication();
+ }
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/WBStartupTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 3 months