I have some Axis2 web services which gets deployed exploded, meaning I don't create an .aar file to save in the services directory, but have a directory in which the files and folders of an Axis2 services are present. Something like the following:
[...]axis2\WEB-INF\services\someService\META-INF\service.xml
My ServiceClass is implementing ServiceLifeCycle to do something during startup of the service. To do what I need to do during startup I need a file in my service directory but I seem to be unable to get the path to my service directory during startup. Normally AxisService.getFileName() would provide the path to my service directory, but during startup there doesn't seem to be a path to the service yet, getFileName() delivers "null". It seems the path is only available for started services because in the shutDown method getFileName provides the proper path to my service.
Is there any way I can get may path during service startup? I already looked for Hooks or something to at least get notified directly after the startup of the service, but before it gets invoked the first time to get my path and do my "something", but there's doesn't seem to be one available.
What I don't want is to configure the path of my service in service.xml file, I would prefer something with that the service is able to retrieve it's path on it's own.
Thanks for any help!
Axis2 provides each service with a classloader that can access the files packaged with the service (in the AAR or in the exploded service directory). The normal way to access files packaged with the service is to use getResource()
or getResourceAsStream()
functions of that class loader.
To get the service classloader, you can call AxisService.getClassLoader()
. Calling this.getClass().getClassLoader()
from a class packaged in the service should also work.