[webbeans-commits] Webbeans SVN: r3528 - ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap and 2 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Sun Aug 16 12:17:20 EDT 2009
Author: pete.muir at jboss.org
Date: 2009-08-16 12:17:19 -0400 (Sun, 16 Aug 2009)
New Revision: 3528
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/UserTransactionBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/BuiltInBeansTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/InjectedBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/InjectedBeanLocal.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/ExtensionBeanDeployer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
Log:
Add UT test and impl
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/UserTransactionBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/UserTransactionBean.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/UserTransactionBean.java 2009-08-16 16:17:19 UTC (rev 3528)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.builtin;
+
+import java.lang.reflect.Type;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.transaction.UserTransaction;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.transaction.spi.TransactionServices;
+import org.jboss.webbeans.util.collections.Arrays2;
+
+/**
+ * @author pmuir
+ *
+ */
+public class UserTransactionBean extends AbstractBuiltInBean<UserTransaction>
+{
+
+ private static final Set<Type> TYPES = Arrays2.<Type>asSet(Object.class, UserTransaction.class);
+
+ public UserTransactionBean(BeanManagerImpl manager)
+ {
+ super(manager);
+ }
+
+ @Override
+ public Class<UserTransaction> getType()
+ {
+ return UserTransaction.class;
+ }
+
+ public Set<Type> getTypes()
+ {
+ return TYPES;
+ }
+
+ public UserTransaction create(CreationalContext<UserTransaction> creationalContext)
+ {
+ return getManager().getServices().get(TransactionServices.class).getUserTransaction();
+ }
+
+ public void destroy(UserTransaction instance, CreationalContext<UserTransaction> creationalContext)
+ {
+ // No-op
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/UserTransactionBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/ExtensionBeanDeployer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/ExtensionBeanDeployer.java 2009-08-16 16:16:39 UTC (rev 3527)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/ExtensionBeanDeployer.java 2009-08-16 16:17:19 UTC (rev 3528)
@@ -50,7 +50,7 @@
@SuppressWarnings("unchecked")
WBClass<Extension> clazz = (WBClass<Extension>) classTransformer.loadClass(extension.getClass());
- ExtensionBean bean = ExtensionBean.of(getManager(), clazz, extension);
+ ExtensionBean bean = new ExtensionBean(getManager(), clazz, extension);
getEnvironment().addBean(bean);
createObserverMethods(bean, clazz);
}
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-16 16:16:39 UTC (rev 3527)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-08-16 16:17:19 UTC (rev 3528)
@@ -31,6 +31,7 @@
import org.jboss.webbeans.Validator;
import org.jboss.webbeans.bean.builtin.InjectionPointBean;
import org.jboss.webbeans.bean.builtin.ManagerBean;
+import org.jboss.webbeans.bean.builtin.UserTransactionBean;
import org.jboss.webbeans.bean.builtin.facade.EventBean;
import org.jboss.webbeans.bean.builtin.facade.InstanceBean;
import org.jboss.webbeans.bootstrap.api.Bootstrap;
@@ -171,7 +172,7 @@
verify();
if (!getServices().contains(TransactionServices.class))
{
- log.info("Transactional services not available. Transactional observers will be invoked synchronously.");
+ log.info("Transactional services not available. Injection of @Current UserTransaction not available. Transactional observers will be invoked synchronously.");
}
if (!getServices().contains(EjbServices.class))
{
@@ -263,10 +264,10 @@
synchronized (this)
{
beanDeployer.addClasses(deploymentVisitor.getBeanClasses());
- beanDeployer.getEnvironment().addBean(ManagerBean.of(manager));
- beanDeployer.getEnvironment().addBean(InjectionPointBean.of(manager));
- beanDeployer.getEnvironment().addBean(EventBean.of(manager));
- beanDeployer.getEnvironment().addBean(InstanceBean.of(manager));
+ beanDeployer.getEnvironment().addBean(new ManagerBean(manager));
+ beanDeployer.getEnvironment().addBean(new InjectionPointBean(manager));
+ beanDeployer.getEnvironment().addBean(new EventBean(manager));
+ beanDeployer.getEnvironment().addBean(new InstanceBean(manager));
if (!getEnvironment().equals(Environments.SE))
{
beanDeployer.addClass(ConversationImpl.class);
@@ -275,6 +276,10 @@
beanDeployer.addClass(NumericConversationIdGenerator.class);
beanDeployer.addClass(HttpSessionManager.class);
}
+ if (getServices().contains(TransactionServices.class))
+ {
+ beanDeployer.getEnvironment().addBean(new UserTransactionBean(manager));
+ }
beanDeployer.createBeans().deploy();
fireAfterBeanDiscoveryEvent();
log.debug("Web Beans initialized. Validating beans.");
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/BuiltInBeansTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/BuiltInBeansTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/BuiltInBeansTest.java 2009-08-16 16:17:19 UTC (rev 3528)
@@ -0,0 +1,41 @@
+package org.jboss.jsr299.tck.tests.implementation.builtin;
+
+import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
+
+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;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.testng.annotations.Test;
+
+/**
+ * Section 3.6
+ *
+ * @author Pete Muir
+ *
+ */
+ at Artifact
+ at Packaging(PackagingType.EAR)
+ at IntegrationTest
+ at SpecVersion("20090625")
+public class BuiltInBeansTest extends AbstractJSR299Test
+{
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section="3.6", id="a")
+ })
+ public void testUserTransactionBean() throws SystemException
+ {
+ UserTransaction userTransaction = getInstanceByType(InjectedBeanLocal.class).getUserTransaction();
+ assert userTransaction != null;
+ // Check that the UserTransaction is at least queryable
+ userTransaction.getStatus();
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/BuiltInBeansTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/InjectedBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/InjectedBean.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/InjectedBean.java 2009-08-16 16:17:19 UTC (rev 3528)
@@ -0,0 +1,38 @@
+/*
+ * 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.jsr299.tck.tests.implementation.builtin;
+
+import javax.ejb.Stateful;
+import javax.enterprise.inject.Current;
+import javax.transaction.UserTransaction;
+
+/**
+ * @author pmuir
+ *
+ */
+ at Stateful
+public class InjectedBean implements InjectedBeanLocal
+{
+
+ @Current transient UserTransaction userTransaction;
+
+ public UserTransaction getUserTransaction()
+ {
+ return userTransaction;
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/InjectedBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/InjectedBeanLocal.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/InjectedBeanLocal.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/InjectedBeanLocal.java 2009-08-16 16:17:19 UTC (rev 3528)
@@ -0,0 +1,30 @@
+/*
+ * 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.jsr299.tck.tests.implementation.builtin;
+
+import javax.transaction.UserTransaction;
+
+/**
+ * @author pmuir
+ *
+ */
+public interface InjectedBeanLocal
+{
+
+ public UserTransaction getUserTransaction();
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/InjectedBeanLocal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the weld-commits
mailing list