I am trying to create behaviors to react to association changes, but it is not working and I cannot figure out why. I'm sure it must be something simple like a typo. Can anyone help me out?
I know the init method is being called because I put a break in the debugger and it hit and executed just fine. The problem is that the onCreateAssociation and onDeleteAssociation methods are never called.
Here is the relevant portions of the content model and java code:
One thing I always recommend: Make use of constants instead of creating QName instances by hand.
E.g. the interfaces for OnCreateAssociationPolicy and its deleted counterpart all define a QNAME constant with the name to use during registration. With regards to your own model, it is always recommended to create a custom interface / class to define your own QName constants. I have seen a lot of issues caused just by the smallest typo or misuse of a namespace URI in such manual QName instantiation code, which always was very hard to spot.
In this case I myself can't spot any typos.
One thing to keep in mind: The OnCreateAssociationPolicy is only triggered IF the source node already has the relevant aspect applied at the time the association is added. If the node does not have the aspect applied yet, the policy will be triggered only for the type and other aspects at the time, before the "missing" aspect is added. That means there is a "notification gap" in the Alfresco behaviour code, which can cause you to miss on events - and maybe your tests fall into that notification gap.