This content has been marked as final.
Show 23 replies
-
15. Re: setting managed property of type List
adrian.brock Dec 12, 2007 7:29 AM (in response to aloubyansky)"alesj" wrote:
OK, this is deeper problem, than I anticipated earlier.
There is a problem of interfaces/abstract classes.
You should just define default implementations for the collection interfaces
like JAXB or JMX does.
http://java.sun.com/javase/6/docs/api/javax/management/MXBean.html
A List<E> is reconstructed as a java.util.ArrayList<E>; a Set<E> as a java.util.HashSet<E>; a SortedSet<E> as a java.util.TreeSet<E>.
Generically, we could allow some kind of plugin mechanism to allow
somebody to configure:
interface -> implementation class or factory -
16. Re: setting managed property of type List
alesj Dec 12, 2007 7:36 AM (in response to aloubyansky)"adrian@jboss.org" wrote:
Generically, we could allow some kind of plugin mechanism to allow
somebody to configure:
interface -> implementation class or factory
Even for non collection classes?
The composite ones.
Doesn't that defeat the whole purpose of OO? :-) -
17. Re: setting managed property of type List
adrian.brock Dec 12, 2007 7:48 AM (in response to aloubyansky)"alesj" wrote:
"adrian@jboss.org" wrote:
Generically, we could allow some kind of plugin mechanism to allow
somebody to configure:
interface -> implementation class or factory
Even for non collection classes?
The composite ones.
Doesn't that defeat the whole purpose of OO? :-)
I don't get the reference to OO? This is reflection/serialization where we've
taken apart the object to split its state into "primitives".
The issue is how do we reconstruct it.
e.g.@ManagementProperty public void setSomething(Interface i) {} public interface Interface { void setInteger(int i); void setString(String s); }
This is a composite with two primitive properties, but we don't know
what the implementation is.
There are two options
1) Create a proxy
http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/trunk/mbeans/src/main/org/jboss/mx/mxbean/CompositeDataInvocationHandler.java?revision=57108&view=markup
2) Allow somebody to define what the implementation class is (or a factory to create one)
The proxy approach doesn't work for collections since they aren't javabeans. -
18. Re: setting managed property of type List
adrian.brock Dec 12, 2007 7:49 AM (in response to aloubyansky)"adrian@jboss.org" wrote:
1) Create a proxy
http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/trunk/mbeans/src/main/org/jboss/mx/mxbean/CompositeDataInvocationHandler.java?revision=57108&view=markup
The proxy approach doesn't work for collections since they aren't javabeans.
It's also immutable. :-) -
19. Re: setting managed property of type List
alesj Dec 12, 2007 8:03 AM (in response to aloubyansky)"adrian@jboss.org" wrote:
I don't get the reference to OO?
OK, this is a mechanism for taking apart non serializable objects.
If we only remember its interface and then have a map 'interface --> default impl', then we forget about polymorphism.
e.g. I would still like to have MyInterface1 and MyInterface2, both implementing Interface, taken apart, but when I want to re-construct them, I very much care about the impl details. -
20. Re: setting managed property of type List
alesj Dec 12, 2007 8:10 AM (in response to aloubyansky)"alesj" wrote:
If we only remember its interface and then have a map 'interface --> default impl', then we forget about polymorphism.
e.g. I would still like to have MyInterface1 and MyInterface2, both implementing Interface, taken apart, but when I want to re-construct them, I very much care about the impl details.
Aha, I see.
The proxy approach would work here. ;-) -
21. Re: setting managed property of type List
alesj Dec 12, 2007 9:34 AM (in response to aloubyansky)OK, I'll use the proxy approach if the TypeInfo passed in for Composite is interface, otherwise I'll use the info to reconstruct the instance.
But this means some details could get lost:public class Pojo ... public class SubPojo extends Pojo ... MetaValue mv = MVF.create(new SubPojo(), Pojo.class); SubPojo sp = MVF.unwrap(mv); // failed!!
I guess I could expand proxy usage to what I did with lazy stuff, to be able to handle classes as well for proxying:
- http://anonsvn.jboss.org/repos/jbossas/projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/lazy/LazyProxyFactory.java
But for Collections, you're saying there is nothing better than a default impl? -
22. Re: setting managed property of type List
alesj Dec 17, 2007 8:15 PM (in response to aloubyansky)Alexey had some more problems:
I think I figured it out... AbstractManagedObjectFactory: public ManagedObject buildManagedObject(Class<? extends Serializable> clazz) { if (managed) { TypeInfo typeInfo = propertyInfo.getType(); if( typeInfo.isArray() || typeInfo.isCollection() ) metaType = new ArrayMetaType(1, MANAGED_OBJECT_META_TYPE); else metaType = MANAGED_OBJECT_META_TYPE; } else { metaType = metaTypeFactory.resolve(propertyInfo.getType()); } should create CollectionMetaType for collections.
Once I've fixed this, I had to update MockProfileService as well.
So this means that the real ProfileServiceImpl must be updated as well.
This can be my TODO, or see how this was done in the mock. -
23. Re: setting managed property of type List
starksm64 Dec 17, 2007 8:49 PM (in response to aloubyansky)I'll update it.