jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Padraic I. Hannon" <...@wasabicowboy.com>
Subject Re: dynamic mixins and jcr mapping
Date Wed, 29 Aug 2007 18:57:56 GMT
I have been looking at the ObjectConverterImpl and I think I have a 
strategy for handling mixins that are defined in the mapper but not 
assigned to the nodetype in the mapping file.

For inserts one would get the interfaces on the object and loop through 
them. For each interface one would look for a class descriptor and add 
it to the objectNode one would also get the field, bean, and collection 
descriptors for that mixin's class descriptor and add them to the 
object's class descriptor.

// Scan Object Interfaces for mixins
Class[] interfaces = object.getClass().getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
    ClassDescriptor interfaceDescriptor = 
    for (Iterator it = 
interfaceDescriptor.getBeanDescriptors().iterator(); it.hasNext(); ) {
    for (Iterator it = 
interfaceDescriptor.getFieldDescriptors().iterator(); it.hasNext(); ) {
    for (Iterator it = 
interfaceDescriptor.getCollectionDescriptors().iterator(); it.hasNext(); ) {

I need to implement it, however, I think directionally this is the right 
way to go (??).

Updates would be very similar to inserts.

For loads we have a more interesting story and somewhere I need to spend 
more time. I think the steps are:

1) Retrieve object and load fields as described in the mapping file
2) Grab mixins from node
3) For mixins on node which are not in the class descriptor
    1) create mixin impl object based on mixin interface name from class 
descriptor + Impl (this way one could have more complex methods than 
just get/set beans)
    2) load fields into mixin impl object
    3) use cglib mixin to create a new object containing the base node + 
    4) repeat per mixin

Does this sound about right?


View raw message