This content has been marked as final. 
    
Show                 41 replies
    
- 
        30. Re: Bean instantiate order with contextual injectionalesj Aug 16, 2006 4:53 AM (in response to alesj)I've added TypeProvider interface - to help me with determinig the class type of injectee in describeVisit method. public interface TypeProvider { Class getType(MetaDataVisitor visitor); }
 There are certain classes (ParameterMD, MapMD, ...) that have String value of the injectee class - if this value is set that's what we are looking for, else we go down the stack.
 But how to get the actual class - where to get ClassLoader?
- 
        31. Re: Bean instantiate order with contextual injectionalesj Aug 16, 2006 7:15 AM (in response to alesj)Found it. :-) KernelControllerContext context = visitor.getControllerContext(); ClassLoader cl = Configurator.getClassLoader(context.getBeanMetaData()); 
- 
        32. Re: Bean instantiate order with contextual injectionalesj Aug 16, 2006 10:15 AM (in response to alesj)Ok, this is legit: <property name="foos"><list><inject/><list/></property> 
 Is there a way to get list's element class type - if defined by generics?
- 
        33. Re: Bean instantiate order with contextual injectionadrian.brock Aug 16, 2006 11:00 AM (in response to alesj)There is, but it is a seperate task to genercize the BeanInfo/ClassInfo: 
 example:package test; import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.List; public class Test { public List<String> getSomething() { return null; } public static void main(String[] args) throws Exception { Class<?> test = Test.class; Method getSomething = test.getMethod("getSomething", new Class[0]); ParameterizedType type = (ParameterizedType) getSomething.getGenericReturnType(); for (Type t : type.getActualTypeArguments()) System.out.println(((Class) t).getName()); } }
- 
        34. Re: Bean instantiate order with contextual injectionadrian.brock Aug 16, 2006 11:02 AM (in response to alesj)There is also another feature request on collections 
 where it uses any preconstructed collection
 rather than creating a new one.
 http://jira.jboss.com/jira/browse/JBMICROCONT-35public class MyClass { private List<String> list; public List<String> getList(); } <property name="list"><list><value>...</value><list></property>
 i.e. this will do
 getList() and if it is not null, it will add to the list
 rather than overwriting it.
- 
        35. Re: Bean instantiate order with contextual injectionadrian.brock Aug 16, 2006 11:04 AM (in response to alesj)"alesj" wrote: 
 But how to get the actual class - where to get ClassLoader?
 Why do you need the classloader? You should be using the
 BeanInfo/TypeInfo.
- 
        36. Re: Bean instantiate order with contextual injectionalesj Aug 16, 2006 4:14 PM (in response to alesj)"adrian@jboss.org" wrote: "alesj" wrote: 
 But how to get the actual class - where to get ClassLoader?
 Why do you need the classloader? You should be using the
 BeanInfo/TypeInfo.
 What's the use of BeanInfo/TypeInfo when I need an actual class from parameters type definition / collections element class type definition / map's value type definition?
 Isn'tKernelControllerContext context = visitor.getControllerContext(); ClassLoader cl = Configurator.getClassLoader(context.getBeanMetaData()); KernelConfiguration configuration KernelConfigurator.getClassInfo(String className, ClassLoader cl) throws Throwable; 
 what results in what I want, if className exists?
 What's the deal with ClassContextKernelRegistryPlugin?
 Where to register/define it, so it doesn't 'polute' AbstractKernelController?
- 
        37. Re: Bean instantiate order with contextual injectionalesj Aug 17, 2006 8:56 AM (in response to alesj)Another issue: <bean name="testObject5" class="org.jboss.test.kernel.inject.support.PropertyInjectTestObject"> <property name="map"> <map> <entry > <key>test</key> <value class="org.jboss.test.kernel.inject.support.TesterInterface"><inject/></value> </entry> </map> </property> </bean> public Class getType(MetaDataVisitor visitor, MetaDataVisitorNode previous) throws Throwable { // where did I come from ... key or value for(MetaDataVisitorNode key : keySet()) { if (previous.equals(key) && keyType != null) { return getClass(visitor, keyType); } } for(MetaDataVisitorNode v : values()) { if (previous.equals(v) && valueType != null) { return getClass(visitor, valueType); } } return super.getType(visitor, this); }
 But the thing is that MD values seem to get cloned ... so we never actually get equality.
 In that Constructor factory + inject problem we should probably set dependency item's whenRequired to earlier state ... will that do it?
 Ok, off to the sea. :-)
- 
        38. Re: Bean instantiate order with contextual injectionalesj Aug 27, 2006 3:41 PM (in response to alesj)"alesj" wrote: 
 But the thing is that MD values seem to get cloned ... so we never actually get equality.
 Uf, my wrong (key != keyClass) - it works now - don't know what I was looking :-(.
- 
        39. Re: Bean instantiate order with contextual injectionadrian.brock Aug 28, 2006 9:10 AM (in response to alesj)One thing you are missing is an "uninstall" part of the describe process 
 that removes the class references from the dependencies.
 Otherwise you're going to cause a memory leak:
 controllerContext -> dependencyInfo -> dependency -> class -> undeployed classloader -> memory leak
- 
        40. Re: Bean instantiate order with contextual injectionalesj Aug 28, 2006 10:07 AM (in response to alesj)"adrian@jboss.org" wrote: 
 One thing you are missing is an "uninstall" part of the describe process
 that removes the class references from the dependencies.
 Otherwise you're going to cause a memory leak:
 controllerContext -> dependencyInfo -> dependency -> class -> undeployed classloader -> memory leak
 Where to do this 'uninstall'?
 Ok, when class dependency gets resolved, iDependOn (demandClass) is set with context name.
 Probably simple adding ofpublic void unresolved(Controller controller) { setIDependOn(null); super.unresolved(controller); }
 won't do the trick entirely.
 Should I iterate through DependencyInfo.getIDependOn(ClassContextDependencyItem.class) when context.beanInfo is set to null in DescribeAction.uninstallAction?
- 
        41. Re: Bean instantiate order with contextual injectionadrian.brock Aug 28, 2006 10:12 AM (in response to alesj)Correct. 
 
    