Skip to content

Commit

Permalink
Added a couple more lifecycle tests for EJBs and added new operation …
Browse files Browse the repository at this point in the history
…to Beans in TCK API.

git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@1949 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
drallen committed Mar 12, 2009
1 parent a744af4 commit 96548f2
Showing 1 changed file with 22 additions and 0 deletions.
Expand Up @@ -2,6 +2,7 @@

import org.jboss.jsr299.tck.spi.Beans;
import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
import org.jboss.webbeans.util.Reflections;

Expand Down Expand Up @@ -71,4 +72,25 @@ public boolean isProxy(Object instance)
return Reflections.isProxy(instance);
}

public <T> T getEnterpriseBean(Class<? extends T> beanType, Class<T> localInterface)
{
T enterpriseBean = null;
if (CurrentManager.rootManager().getEjbDescriptorCache().containsKey(beanType))
{
EjbDescriptor<?> ejbDescriptor = CurrentManager.rootManager().getEjbDescriptorCache().get(beanType).iterator().next();
String jndiName = null;
for (BusinessInterfaceDescriptor<?> businessInterface : ejbDescriptor.getLocalBusinessInterfaces())
{
if (businessInterface.getInterface().equals(localInterface))
{
jndiName = businessInterface.getJndiName();
}
}
if (jndiName == null)
throw new NullPointerException("No JNDI name found for interface " + localInterface.getName() + " on bean " + beanType.getName());
enterpriseBean = CurrentManager.rootManager().getNaming().lookup(jndiName, localInterface);
}
return enterpriseBean;
}

}

0 comments on commit 96548f2

Please sign in to comment.