Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@302 1c488680-804c-0410-94cd-c6b725194a0e
- Loading branch information
Showing
38 changed files
with
304 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.jboss.webbeans.bootstrap; | ||
|
||
import static org.jboss.webbeans.util.BeanFactory.createEnterpriseBean; | ||
import static org.jboss.webbeans.util.BeanFactory.createProducerMethodBean; | ||
import static org.jboss.webbeans.util.BeanFactory.createSimpleBean; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import org.jboss.webbeans.ManagerImpl; | ||
import org.jboss.webbeans.bean.AbstractBean; | ||
import org.jboss.webbeans.bean.AbstractClassBean; | ||
import org.jboss.webbeans.introspector.AnnotatedMethod; | ||
|
||
public class Bootstrap | ||
{ | ||
|
||
private ManagerImpl manager; | ||
|
||
public Bootstrap() | ||
{ | ||
this(new ManagerImpl()); | ||
} | ||
|
||
protected Bootstrap(ManagerImpl manager) | ||
{ | ||
this.manager = manager; | ||
} | ||
|
||
public Set<AbstractBean<?, ?>> discoverBeans(Class<?>... classes) | ||
{ | ||
Set<AbstractBean<?, ?>> beans = new HashSet<AbstractBean<?, ?>>(); | ||
for (Class<?> clazz : classes) | ||
{ | ||
AbstractClassBean<?> bean; | ||
if (manager.getModelManager().getEjbMetaData(clazz).isEjb()) | ||
{ | ||
bean = createEnterpriseBean(clazz, manager); | ||
} | ||
else | ||
{ | ||
bean = createSimpleBean(clazz, manager); | ||
} | ||
beans.add(bean); | ||
for (AnnotatedMethod<Object> producerMethod : bean.getProducerMethods()) | ||
{ | ||
beans.add(createProducerMethodBean(producerMethod.getType(), producerMethod, manager, bean)); | ||
} | ||
|
||
} | ||
return beans; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
webbeans-ri/src/test/java/org/jboss/webbeans/test/BindingTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
webbeans-ri/src/test/java/org/jboss/webbeans/test/BoostrapTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package org.jboss.webbeans.test; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import org.jboss.webbeans.bean.AbstractBean; | ||
import org.jboss.webbeans.test.beans.Elephant; | ||
import org.jboss.webbeans.test.beans.Panther; | ||
import org.jboss.webbeans.test.beans.Salmon; | ||
import org.jboss.webbeans.test.beans.SeaBass; | ||
import org.jboss.webbeans.test.beans.Sole; | ||
import org.jboss.webbeans.test.beans.Tarantula; | ||
import org.jboss.webbeans.test.beans.TarantulaProducer; | ||
import org.jboss.webbeans.test.beans.Tiger; | ||
import org.jboss.webbeans.test.beans.Tuna; | ||
import org.jboss.webbeans.test.ejb.model.valid.Hound; | ||
import org.testng.annotations.Test; | ||
|
||
public class BoostrapTest extends AbstractTest | ||
{ | ||
@Test(groups="bootstrap") | ||
public void testSingleSimpleBean() | ||
{ | ||
Set<AbstractBean<?, ?>> beans = bootstrap.discoverBeans(Tuna.class); | ||
assert beans.size() == 1; | ||
assert beans.iterator().next().getType().equals(Tuna.class); | ||
} | ||
|
||
@Test(groups="bootstrap") | ||
public void testSingleEnterpriseBean() | ||
{ | ||
Set<AbstractBean<?, ?>> beans = bootstrap.discoverBeans(Hound.class); | ||
assert beans.size() == 1; | ||
assert beans.iterator().next().getType().equals(Hound.class); | ||
} | ||
|
||
@Test(groups="bootstrap") | ||
public void testMultipleSimpleBean() | ||
{ | ||
Set<AbstractBean<?, ?>> beans = bootstrap.discoverBeans(Tuna.class, Salmon.class, SeaBass.class, Sole.class); | ||
assert beans.size() == 4; | ||
Set<Class<?>> classes = new HashSet<Class<?>>(); | ||
for (AbstractBean<?, ?> bean : beans) | ||
{ | ||
classes.add(bean.getType()); | ||
} | ||
assert classes.contains(Tuna.class); | ||
assert classes.contains(Salmon.class); | ||
assert classes.contains(SeaBass.class); | ||
assert classes.contains(Sole.class); | ||
} | ||
|
||
@Test(groups="bootstrap") | ||
public void testProducerMethodBean() | ||
{ | ||
Set<AbstractBean<?, ?>> beans = bootstrap.discoverBeans(TarantulaProducer.class); | ||
assert beans.size() == 2; | ||
Set<Class<?>> classes = new HashSet<Class<?>>(); | ||
for (AbstractBean<?, ?> bean : beans) | ||
{ | ||
classes.add(bean.getType()); | ||
} | ||
assert classes.contains(TarantulaProducer.class); | ||
assert classes.contains(Tarantula.class); | ||
} | ||
|
||
@Test(groups="bootstrap") | ||
public void testMultipleEnterpriseBean() | ||
{ | ||
Set<AbstractBean<?, ?>> beans = bootstrap.discoverBeans(Hound.class, Elephant.class, Panther.class, Tiger.class); | ||
assert beans.size() == 4; | ||
Set<Class<?>> classes = new HashSet<Class<?>>(); | ||
for (AbstractBean<?, ?> bean : beans) | ||
{ | ||
classes.add(bean.getType()); | ||
} | ||
assert classes.contains(Hound.class); | ||
assert classes.contains(Elephant.class); | ||
assert classes.contains(Panther.class); | ||
assert classes.contains(Tiger.class); | ||
} | ||
|
||
@Test(groups="bootstrap") | ||
public void testMultipleEnterpriseAndSimpleBean() | ||
{ | ||
Set<AbstractBean<?, ?>> beans = bootstrap.discoverBeans(Hound.class, Elephant.class, Panther.class, Tiger.class, Tuna.class, Salmon.class, SeaBass.class, Sole.class); | ||
assert beans.size() == 8; | ||
Set<Class<?>> classes = new HashSet<Class<?>>(); | ||
for (AbstractBean<?, ?> bean : beans) | ||
{ | ||
classes.add(bean.getType()); | ||
} | ||
assert classes.contains(Hound.class); | ||
assert classes.contains(Elephant.class); | ||
assert classes.contains(Panther.class); | ||
assert classes.contains(Tiger.class); | ||
assert classes.contains(Tuna.class); | ||
assert classes.contains(Salmon.class); | ||
assert classes.contains(SeaBass.class); | ||
assert classes.contains(Sole.class); | ||
} | ||
} |
Oops, something went wrong.