Skip to content

Commit

Permalink
Auto register stereotypes
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@400 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Dec 4, 2008
1 parent 50dcdf5 commit 433e626
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 32 deletions.
17 changes: 6 additions & 11 deletions webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java
Expand Up @@ -38,23 +38,18 @@ public class MetaDataCache

private ConcurrentCache<Class<?>, EjbMetaData<?>> ejbMetaDataMap = new ConcurrentCache<Class<?>, EjbMetaData<?>>();

public <T extends Annotation> void addStereotype(final Class<T> stereotype)
public <T extends Annotation> StereotypeModel<T> getStereotype(final Class<T> stereotype)
{
stereotypes.putIfAbsent(stereotype, new Callable<StereotypeModel<?>>()
return stereotypes.putIfAbsent(stereotype, new Callable<StereotypeModel<T>>()
{

public StereotypeModel<?> call() throws Exception
public StereotypeModel<T> call() throws Exception
{
return new StereotypeModel<T>(stereotype);
}
});
}

public StereotypeModel<?> getStereotype(Class<? extends Annotation> annotationType)
{
return stereotypes.getValue(annotationType);
}

public <T extends Annotation> ScopeModel<T> getScopeModel(final Class<T> scopeType)
{
return scopes.putIfAbsent(scopeType, new Callable<ScopeModel<T>>()
Expand All @@ -64,7 +59,7 @@ public ScopeModel<T> call() throws Exception
{
return new ScopeModel<T>(scopeType);
}

});
}

Expand All @@ -77,7 +72,7 @@ public BindingTypeModel<T> call() throws Exception
{
return new BindingTypeModel<T>(bindingType);
}

});
}

Expand All @@ -90,7 +85,7 @@ public EjbMetaData<T> call() throws Exception
{
return new EjbMetaData<T>(clazz);
}

});
}

Expand Down
@@ -1,19 +1,11 @@
package org.jboss.webbeans.test;

import javax.webbeans.Decorator;
import javax.webbeans.Interceptor;
import javax.webbeans.Production;
import javax.webbeans.Standard;

import org.jboss.webbeans.bootstrap.Bootstrap;
import org.jboss.webbeans.test.annotations.AnimalStereotype;
import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
import org.jboss.webbeans.test.annotations.FishStereotype;
import org.jboss.webbeans.test.annotations.HornedAnimalDeploymentType;
import org.jboss.webbeans.test.annotations.HornedMammalStereotype;
import org.jboss.webbeans.test.annotations.MammalStereotype;
import org.jboss.webbeans.test.annotations.RequestScopedAnimalStereotype;
import org.jboss.webbeans.test.annotations.RiverFishStereotype;
import org.jboss.webbeans.test.mock.MockBootstrap;
import org.jboss.webbeans.test.mock.MockManagerImpl;
import org.testng.annotations.BeforeMethod;
Expand All @@ -35,25 +27,12 @@ public final void before()

protected void init()
{
addStereotypes();
addEnabledDeploymentTypes();
}

protected void addEnabledDeploymentTypes()
{
manager.setEnabledDeploymentTypes(Standard.class, Production.class, AnotherDeploymentType.class, HornedAnimalDeploymentType.class);
}

protected void addStereotypes()
{
manager.getMetaDataCache().addStereotype(Decorator.class);
manager.getMetaDataCache().addStereotype(Interceptor.class);
manager.getMetaDataCache().addStereotype(AnimalStereotype.class);
manager.getMetaDataCache().addStereotype(HornedMammalStereotype.class);
manager.getMetaDataCache().addStereotype(MammalStereotype.class);
manager.getMetaDataCache().addStereotype(FishStereotype.class);
manager.getMetaDataCache().addStereotype(RiverFishStereotype.class);
manager.getMetaDataCache().addStereotype(RequestScopedAnimalStereotype.class);
}

}

0 comments on commit 433e626

Please sign in to comment.