Re: [Resin-interest] InjectManager not binding generified class?

2009-05-06 Thread Scott Ferguson

On May 6, 2009, at 2:21 AM, Scott Hernandez wrote:

> The inject manager isn't adding this class to the registered beans. I
> have seen a few issues with Generic classes with matching classes but
> this ones seems pretty straight forward.
>
> Does anything anyone know why this isn't picked up and registered in
> the inject manager?

I'm not sure that @New is supposed to be allowed on the class itself,  
but that part of the spec has been changing a bit.

But the main issue is that generic classes are not "simple beans",  
because the generic type is part of the Java Injection matching  
algorithm.  In other words, you can register a Foo (using a  
producer method), but not a Foo, because that's not a complete type.

In other words, if you want to register a parameterized class, you  
currently need to have a @Produces factory for the class.

-- Scott

>
>
> @New
> public class InjectBeanHelper {
>
>   @Current Manager mgr;
>   
>   public InjectBeanHelper(){}
>   
>   @SuppressWarnings("unchecked")
>   public T getInstance(String clazz){
>   T o = null;
>   Class tc = null;
>   try {
>   tc = (Class) Class.forName(clazz);
>   o = (T)mgr.getInstanceByType(tc);
>   }catch(ClassNotFoundException e){}
>   
>   if(o==null) o = (T)mgr.getInstanceByName(clazz);
>   
>   return o;   
>   }
>   public T getInstance(Class clazz){
>   return this.mgr.getInstanceByType(clazz);
>   }
> }
>
> I'm still working against trunk :)
>
>
> ___
> resin-interest mailing list
> resin-interest@caucho.com
> http://maillist.caucho.com/mailman/listinfo/resin-interest



___
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest


[Resin-interest] InjectManager not binding generified class?

2009-05-06 Thread Scott Hernandez
The inject manager isn't adding this class to the registered beans. I
have seen a few issues with Generic classes with matching classes but
this ones seems pretty straight forward.

Does anything anyone know why this isn't picked up and registered in
the inject manager?

@New
public class InjectBeanHelper {

@Current Manager mgr;

public InjectBeanHelper(){}

@SuppressWarnings("unchecked")
public T getInstance(String clazz){
T o = null;
Class tc = null;
try {
tc = (Class) Class.forName(clazz);
o = (T)mgr.getInstanceByType(tc);
}catch(ClassNotFoundException e){}

if(o==null) o = (T)mgr.getInstanceByName(clazz);

return o;   
}
public T getInstance(Class clazz){
return this.mgr.getInstanceByType(clazz);
}
}

I'm still working against trunk :)


___
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest