Pre-Requisite: Object Scopes and Caching

Method Resolution

When you make a method call on any Container (Child or Derived class's) object, the Container object has to decide, which method of which Composed (Parent or Base class's) object should it delegate the call to? the decision will be made, based on the method resolution strategy used by the MIMethodResolver (JavaDoc | Source Code) , configured through MIFactory (JavaDoc | Source Code) .

Project MI+ comes with a default out-of-the-box implementation of MIMethodResolver (JavaDoc | Source Code) called MIMethodResolverImpl (JavaDoc | Source Code) , which resolves method based on the MISupport (JavaDoc | Source Code) annotation's attribute parentClasses "order" and method resolution strategy defined in getMatchingAccessibleMethod(Class, String, Class[]) method of class org.apache.commons.beanutils.MethodUtils of Apache Commons BeanUtils API. The strategy works as follows:

  • Iterate over composed objects
  • For each composed object, check if there's a matching 'accessible' method based on the algorithm defined by getMatchingAccessibleMethod(Class, String, Class[]) method of class org.apache.commons.beanutils.MethodUtils of Apache Commons BeanUtils API i.e.
    • "it finds an accessible method that matches the given name and has compatible parameters. Compatible parameters mean that every method parameter is assignable from the given parameters. In other words, it finds a method with the given name that will take the parameters given."
  • If a match is found, break the iteration and exit from the loop
  • Return the corresponding composed object and the matched method

No additional configuration is required, if you are using this default out-of-the-box implementation.

You can also create your own custom MIMethodResolver (JavaDoc | Source Code) implementation and plug in either your or any third party implementation of MIMethodResolver (JavaDoc | Source Code) . An example of how to define and plug in a custom method resolver is available in Examples.

What's Next?

Examples


© Syed Muhammad Humayun - smhumayun@gmail.com - www.smhumayun.com - www.linkedin.com/in/smhumayun