Get the list of deployed Axis services from another Axis service
I have a question about how to obtain a list of deployed Axis services within another Axis service. here is the scenario. I am using Tomcat 7.0.14 and Axis 2-1.5.5 as the deployment environment. Suppose there are currently 5 Axis services deployed on Tomcat, namely A, B, C, D, E. And I want to write some code in service E so that it can obtain a service list containing all the deployed services, that is, A, B, C, D, E.
I have tried to use the ConfigurationContextFactory.createConfigurationContextFromFileSystem() method. But the method seemed to create a new Axis 2 isntance each time it is invoked. And since I used it in the constructor of a web service, it caused an infinite loop. (create Axis instance -> create service instance -> create Axis instance -> create service instance -> ...) So I would like to know is there a way to programmatically get a list of deployed services from another deployed service? (Just like the http://localhost:8080/axis2/services/listServices does). Any help is gre开发者_如何转开发atly appreciated.
Thank you.
You need to get the environment's AxisConfiguration
object. It provides among other things a function called getServices()
which returns a map of installed services.
If your service implements ServiceLifecycle, the ServiceLifecycle.startup()
function is passed the AxisConfiguration object during service startup. Alternately, if your service class implements Lifecycle
, then the Lifecycle.init()
function is passed a ServiceContext
object. You should be able to call ServiceContext.getConfigurationContext().getAxisConfiguration()
to get the AxisConfiguration from there.
精彩评论