Skip to content

Commit

Permalink
fix failing test, fix non contexual injector, fix simple bean to use …
Browse files Browse the repository at this point in the history
…individual services

git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@2332 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Apr 7, 2009
1 parent 4015eef commit f3ca3b7
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 14 deletions.
6 changes: 6 additions & 0 deletions impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
Expand Up @@ -308,7 +308,13 @@ public void initialize(BeanDeployerEnvironment environment)
if (getManager().getServices().contains(EjbServices.class))
{
initEjbInjectionPoints();
}
if (getManager().getServices().contains(JpaServices.class))
{
initPersistenceUnitInjectionPoints();
}
if (getManager().getServices().contains(ResourceServices.class))
{
initResourceInjectionPoints();
}
}
Expand Down
@@ -1,40 +1,120 @@
package org.jboss.webbeans.injection;

import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.Callable;

import javax.context.CreationalContext;
import javax.context.Dependent;
import javax.inject.Standard;
import javax.inject.manager.Bean;
import javax.inject.manager.InjectionPoint;

import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.context.ApplicationContext;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.collections.ConcurrentCache;

public class NonContextualInjector
{

private final Bean<?> nonContextualBean;

private final ConcurrentCache<Class<?>, Set<FieldInjectionPoint<?>>> instances;
private final ManagerImpl manager;

public NonContextualInjector(ManagerImpl manager)
{
this.instances = new ConcurrentCache<Class<?>, Set<FieldInjectionPoint<?>>>();
this.manager = manager;
nonContextualBean = new Bean<Object>(manager)
{

@Override
public Set<Annotation> getBindings()
{
return Collections.emptySet();
}

@Override
public Class<? extends Annotation> getDeploymentType()
{
return Standard.class;
}

@Override
public Set<? extends InjectionPoint> getInjectionPoints()
{
return Collections.emptySet();
}

@Override
public String getName()
{
return null;
}

@Override
public Class<? extends Annotation> getScopeType()
{
return Dependent.class;
}

@Override
public Set<? extends Type> getTypes()
{
return Collections.emptySet();
}

@Override
public boolean isNullable()
{
return false;
}

@Override
public boolean isSerializable()
{
return true;
}

public Object create(CreationalContext<Object> creationalContext)
{
return null;
}

public void destroy(Object instance)
{
}
};
}

public void inject(final Object instance)
{
Set<FieldInjectionPoint<?>> injectionPoints = instances.putIfAbsent(instance.getClass(), new Callable<Set<FieldInjectionPoint<?>>>()
if (DependentContext.INSTANCE != null && ApplicationContext.INSTANCE != null)
{

public Set<FieldInjectionPoint<?>> call() throws Exception
DependentContext.INSTANCE.setActive(true);
ApplicationContext.INSTANCE.setActive(true);
Set<FieldInjectionPoint<?>> injectionPoints = instances.putIfAbsent(instance.getClass(), new Callable<Set<FieldInjectionPoint<?>>>()
{
return Beans.getFieldInjectionPoints(manager.getServices().get(ClassTransformer.class).classForName(instance.getClass()), null);

public Set<FieldInjectionPoint<?>> call() throws Exception
{
return Beans.getFieldInjectionPoints(manager.getServices().get(ClassTransformer.class).classForName(instance.getClass()), nonContextualBean);
}

}

}
);
for (FieldInjectionPoint<?> injectionPoint : injectionPoints)
{
injectionPoint.inject(instance, manager, null);
);
for (FieldInjectionPoint<?> injectionPoint : injectionPoints)
{
injectionPoint.inject(instance, manager, null);
}
DependentContext.INSTANCE.setActive(false);
ApplicationContext.INSTANCE.setActive(false);
}
}

Expand Down
Expand Up @@ -12,8 +12,5 @@
</myapp:PaymentProcessor>
<myapp:User />
</myapp:Order>
<myapp:Login>
<ConversationScoped />
<BindingType />
</myapp:Login>

</Beans>
5 changes: 5 additions & 0 deletions version-matrix/pom.xml
Expand Up @@ -338,6 +338,11 @@
<type>pom</type>
</dependency>

<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>catalina</artifactId>
<version>6.0.18</version>
</dependency>

</dependencies>
</dependencyManagement>
Expand Down

0 comments on commit f3ca3b7

Please sign in to comment.