Skip to content

Commit

Permalink
Add UT test and impl
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@3528 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Aug 16, 2009
1 parent f1ad7c0 commit 0491587
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 6 deletions.
@@ -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
}

}
Expand Up @@ -50,7 +50,7 @@ public AbstractBeanDeployer createBeans()
@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);
}
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -171,7 +172,7 @@ public Bootstrap startContainer()
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))
{
Expand Down Expand Up @@ -263,10 +264,10 @@ public Bootstrap deployBeans()
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);
Expand All @@ -275,6 +276,10 @@ public Bootstrap deployBeans()
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.");
Expand Down

0 comments on commit 0491587

Please sign in to comment.