You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Tim Jones <ti...@mccarthy.co.nz> on 2014/08/20 06:51:58 UTC

Weaving hook called multiple times, is this the expected behavior?

                            
--------------------------------------------------------    
-----------------------------------
                            | Bundle A                                        
|    | Bundle D                   |
                            |                                                      
|    |                                  |
                            |      AbstractBaseClassToBeWoven   |    |  
MyWeavingHook      |
                            |                         ^  (woven once)      
|    | (weaves into classes  |
                            |                         |                            
|    |  in Bundle A )             |
                            |                         |                            
|    -----------------------------------    
                            |       AbstractClassToBeWoven         |        
                            |                 ^           ^ (woven twice)  |
                           
-------------------|-----------|------------------------
                                             /              \
                                           /                   \      
                                        /                         \
                                     /                               \
                                  /                                     \
                               /                                           \
   --------------------------|-------------------        
------------------|--------------------------------                    
   | Bundle B           |                   |        |                 |                
Bundle C |
   |                         |                   |        |                
|                                |
   | FirstSubClassOfWovenClass |        | SecondSubClassOfWovenClass |
   |                                             |        |                                                 
|
   ----------------------------------------------        
---------------------------------------------------

Hi, I am trying to implement a weaving hook. I am able to successfully weave
into the class AbstractBaseClassToBeWoven but when I try to weave into the
sub class AbstractClassToBeWoven the overidden method weave(WovenClass
wovenClass) in MyWeavingHook is usually* invoked twice by two different
Blueprint Extender threads causing issues e.g. when trying to add a new
method it complains about the method already being present.

If however I weave into the super class AbstractBaseClassToBeWoven, the
overidden method weave(WovenClass wovenClass) in MyWeavingHook is only
invoked once.

Is this the expected behaviour? If so, what is the best way of weaving into
the AbstractClassToBeWoven class ie. weaving into a class where multiple
classes in different bundles extend that same class?


Note -

1) if I do not install Bundle C then method weave(WovenClass wovenClass) is
only invoked once
2) *occassionally when weaving into AbstractClassToBeWoven the method
weave(WovenClass wovenClass) is only invoked once

I have set up a two Felix/Karaf Pax Exam test cases, one blueprint, and one
Spring DM and both have the same behaviour.

(also posted to Felix User forum a couple of weeks ago but no replies
http://apache-felix.18485.x6.nabble.com/Weaving-hook-called-multiple-times-is-this-the-expected-behavior-td5009331.html)


Thanks,

Tim 



--
View this message in context: http://karaf.922171.n3.nabble.com/Weaving-hook-called-multiple-times-is-this-the-expected-behavior-tp4034834.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Weaving hook called multiple times, is this the expected behavior?

Posted by David Jencks <da...@yahoo.com>.
I can't help with your problem but I would take a look at the aries project that does weaving, I think it's proxy but may not have it right.  I believe this works successfully so it might be a model and also something to experiment with to see if the same thing happens when you weave your classes with that weaver.

good luck :-)
david jencks

On Aug 19, 2014, at 9:51 PM, Tim Jones <ti...@mccarthy.co.nz> wrote:

> 
> --------------------------------------------------------    
> -----------------------------------
>                            | Bundle A                                        
> |    | Bundle D                   |
>                            |                                                      
> |    |                                  |
>                            |      AbstractBaseClassToBeWoven   |    |  
> MyWeavingHook      |
>                            |                         ^  (woven once)      
> |    | (weaves into classes  |
>                            |                         |                            
> |    |  in Bundle A )             |
>                            |                         |                            
> |    -----------------------------------    
>                            |       AbstractClassToBeWoven         |        
>                            |                 ^           ^ (woven twice)  |
> 
> -------------------|-----------|------------------------
>                                             /              \
>                                           /                   \      
>                                        /                         \
>                                     /                               \
>                                  /                                     \
>                               /                                           \
>   --------------------------|-------------------        
> ------------------|--------------------------------                    
>   | Bundle B           |                   |        |                 |                
> Bundle C |
>   |                         |                   |        |                
> |                                |
>   | FirstSubClassOfWovenClass |        | SecondSubClassOfWovenClass |
>   |                                             |        |                                                 
> |
>   ----------------------------------------------        
> ---------------------------------------------------
> 
> Hi, I am trying to implement a weaving hook. I am able to successfully weave
> into the class AbstractBaseClassToBeWoven but when I try to weave into the
> sub class AbstractClassToBeWoven the overidden method weave(WovenClass
> wovenClass) in MyWeavingHook is usually* invoked twice by two different
> Blueprint Extender threads causing issues e.g. when trying to add a new
> method it complains about the method already being present.
> 
> If however I weave into the super class AbstractBaseClassToBeWoven, the
> overidden method weave(WovenClass wovenClass) in MyWeavingHook is only
> invoked once.
> 
> Is this the expected behaviour? If so, what is the best way of weaving into
> the AbstractClassToBeWoven class ie. weaving into a class where multiple
> classes in different bundles extend that same class?
> 
> 
> Note -
> 
> 1) if I do not install Bundle C then method weave(WovenClass wovenClass) is
> only invoked once
> 2) *occassionally when weaving into AbstractClassToBeWoven the method
> weave(WovenClass wovenClass) is only invoked once
> 
> I have set up a two Felix/Karaf Pax Exam test cases, one blueprint, and one
> Spring DM and both have the same behaviour.
> 
> (also posted to Felix User forum a couple of weeks ago but no replies
> http://apache-felix.18485.x6.nabble.com/Weaving-hook-called-multiple-times-is-this-the-expected-behavior-td5009331.html)
> 
> 
> Thanks,
> 
> Tim 
> 
> 
> 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Weaving-hook-called-multiple-times-is-this-the-expected-behavior-tp4034834.html
> Sent from the Karaf - User mailing list archive at Nabble.com.