How does Axis2 Engine know which assertions are relevant to a particular module ?
This is defined in the module.xml which is the descriptor file for a module using supported-policy-namespaces element. This tells Axis2 engine what policy assertions this module can handle.
<module name="my-module" class="org.apache.axis2.modules.MyModule">
<Description>
My simple module
</Description>
<supported-policy-namespaces namespaces="http://wso2.org/policy/v1 http://wso2.org/policy/v2"/>
</module>
Module interface (org.apache.axis2.modules.Module) in Axis2 has 3 important method relevant to policy. These are used by the module classes to express whether they can handle a specific assertion instance and also get notified when they are engaged to some AxisDescription. AxisMessage, AxisOperration, AxisService ... are some examples of elements in Axis2 description hierarchy.
/**
* When engaging this module to some service or operation , module will be notify by calling this
* method there module author can validate , add policy and do any thing that he want , and he can
* refuse the engage as well
*
* @param axisDescription
* @throws AxisFault
*/
void engageNotify(AxisDescription axisDescription) throws AxisFault;
/**
* Evaluate whether it can support the specified assertion and returns true if the assertion can
* be supported.
*
* @param assertion the assertion that the module must decide whether it can support or not.
* @return true if the specified assertion can be supported by the module
*/
public boolean canSupportAssertion(Assertion assertion);
/**
* Evaluates specified policy for the specified AxisDescription. It computes the configuration that
* is appropriate to support the policy and stores it the appropriate description.
*
* @param policy the policy that is applicable for the specified AxisDescription
* @throws AxisFault if anything goes wrong.
*/
public void applyPolicy(Policy policy, AxisDescription axisDescription) throws AxisFault;
When we apply a policy to an element in Axis2 description heirachy, it does five things.
1) Engage whatever modules necessary to execute new the effective policy of this AxisDescription instance.
2) Disengage whatever modules that are not necessary to execute the new effective policy of this AxisDescription instance.
3) Check whether each module can execute the new effective policy of this AxisDescription instance.
4) If not throw an AxisFault to notify the user.
5) Else notify each module about the new effective policy.
This is one good example of easy extensibility features in Apache Axis2 Design.










1 comments:
VERY NICE BLOG
ITS VERY USEFUL
THANK YOU..........
Post a Comment