Skip to content

Commit

Permalink
Tidy up
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@2794 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Jun 8, 2009
1 parent c19b400 commit 10aa1e1
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 24 deletions.
Expand Up @@ -117,7 +117,7 @@ public interface BeanManager
* The Bean representation of the bean.
* @return the mest specialized enabled bean
*/
public <X> Bean<X> getMostSpecializedBean(Bean<X> bean);
public <X> Bean<? extends X> getMostSpecializedBean(Bean<X> bean);

/**
* Returns the PassivationCapableBean with the given identifier.
Expand Down
22 changes: 2 additions & 20 deletions impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
Expand Up @@ -700,25 +700,7 @@ public Context getContext(Class<? extends Annotation> scopeType)
throw new IllegalStateException("More than one context active for scope type " + scopeType.getName());
}
return activeContexts.iterator().next();
}

@Deprecated
public <T> T getInstance(Bean<T> bean)
{
return getInstance(bean, true);
}

@Deprecated
public <T> T getInstance(Bean<T> bean, boolean create)
{
if (create)
{
return (T) getInjectableReference(bean, CreationalContextImpl.of(bean));
}
else
{
return (T) getInjectableReference(bean, null);
}
}

public Object getInjectableReference(Bean<?> bean, CreationalContext<?> creationalContext)
Expand Down Expand Up @@ -836,7 +818,7 @@ public <T> T getInstanceByType(TypeLiteral<T> type, Annotation... bindings)
@Deprecated
public <T> T getInstanceByType(AnnotatedItem<T, ?> element, Annotation... bindings)
{
return getInstance(getBean(element, bindings));
return (T) getReference(getBean(element, bindings), element.getType());
}

public <T> Bean<T> getBean(AnnotatedItem<T, ?> element, Annotation... bindings)
Expand Down Expand Up @@ -1112,7 +1094,7 @@ public <T> ManagedBean<T> createManagedBean(AnnotatedType<T> type)



public <X> Bean<X> getMostSpecializedBean(Bean<X> bean)
public <X> Bean<? extends X> getMostSpecializedBean(Bean<X> bean)
{
Bean<?> key = bean;
while (specializedBeans.containsKey(key))
Expand Down
Expand Up @@ -325,7 +325,7 @@ protected Object getReceiver(CreationalContext<?> creationalContext)
return creationalContextImpl.getIncompleteInstance(getDeclaringBean());
}
}
return manager.getInstance(getDeclaringBean());
return manager.getReference(getDeclaringBean(), getDeclaringBean().getType());
}
}

Expand Down
Expand Up @@ -182,7 +182,8 @@ public T create(CreationalContext<T> creationalContext)

public void invokeDisposeMethod(Object instance, CreationalContext<?> creationalContext)
{
Object beanInstance = disposalMethodInjectionPoint.isStatic() ? declaringBean : getManager().getInstance(declaringBean);
// TODO WTF - why isn't this using getReceiver!? Why is it assigning the beanInstance as the beanObject!?!
Object beanInstance = disposalMethodInjectionPoint.isStatic() ? declaringBean : getManager().getReference(declaringBean, declaringBean.getType());
disposalMethodInjectionPoint.invokeWithSpecialValue(beanInstance, Disposes.class, instance, manager, creationalContext, IllegalArgumentException.class);
}

Expand Down
Expand Up @@ -83,7 +83,7 @@ public <T> T getEnterpriseBean(Class<? extends T> beanType, Class<T> localInterf

public <T> T createBeanInstance(Bean<T> bean)
{
return CurrentManager.rootManager().getCurrent().getInstance(bean, true);
return (T) CurrentManager.rootManager().getCurrent().getReference(bean, Object.class);
}

public <T> void destroyAndRemoveBeanInstance(Bean<T> bean, T instance)
Expand Down

0 comments on commit 10aa1e1

Please sign in to comment.