axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kimberly Nicholls <knicho...@liveworld.com>
Subject Re: Module engaged where it should not
Date Thu, 03 Feb 2011 18:16:42 GMT
I ran into this too.  I found that if you reference a module in a 
service, it gets added to the phase for *all* services.  I found this 
explanation:

https://issues.apache.org/jira/browse/AXIS2C-575
This is a "feature" in Axis2 architecture. If you engage the module in a 
service to a globle phase, then that module gets engaged globally. 
Modules can use axis2_svc_is_module_engaged method to check if the 
service being used has engaged a given module and act accordingly.

I don't think that makes any sense.  What's the point of configuring it 
at the service level then?  Why should every module have to check 
whether it's supposed to be invoked or not -- isn't that why you define 
it (or not) in the service.xml file?

In kernel/src/org/apache/axis2/engine/Phase.java, here's where it 
invokes all of the modules:

    311            while (currentIndex < handlersSize) {
    312                Handler handler = (Handler) 
handlers.get(currentIndex);
    313
    314                if (isDebugEnabled) {
    315                    log.debug(msgctx.getLogIDString() + " 
Invoking Handler '" + handler.getName() +
    316                            "' in Phase '" + phaseName + "'");
    317                }
    318                pi = handler.invoke(msgctx);

If I add this before line 318:

             boolean engagedService = 
msgctx.getAxisService().isEngaged(handler.getName());
             HashMap modules = 
msgctx.getConfigurationContext().getAxisConfiguration().getModules();
             boolean engagedGlobal = false;
             if (modules != null)
                 engagedGlobal = modules.containsKey(handler.getName());

msgctx.getConfigurationContext().getAxisConfiguration().getModules() 
returns the modules engaged for all services, but not the modules 
engaged in the global config file.  I don't know how to get those.

If a module is engaged globally (in axis2.xml, such as 
RequestURIBasedDispatcher), both engagedService and engagedGlobal are 
false.

If a module is engaged for the current service, engagedService is true 
and engagedGlobal is false.

If the module is not engaged for the current service, engagedService is 
false and engagedGlobal is false.

I am going to update my local copy of Phase.java to invoke modules as 
they were configured.  If anyone is interested in the changes, let me 
know.  According to the JIRA, it appears that this won't get fixed in 
Axis2 anytime soon.

Kimberly Nicholls

>  When I call Axis2Service my module is invoked and works perfectly.
>  But when I call Axis2ServiceNoSec the module is invoked too !
>  So when a module is defined for a service, it is invoked for all other
>  services !!!! It's not what we expect....



Mime
View raw message