You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Etienne Dube <et...@gmail.com> on 2007/11/12 20:59:35 UTC
Getting the local path where a service is deployed
Hello,
I'm looking for a way to retrieve the local path where an Axis2 service
is deployed. In my case, it is located in
C:\java\Tomcat6\webapps\axis2\WEB-INF\services\MyService . I deployed it
as a directory instead of an .aar archive for performance reasons (I use
lots of external JARs and class loading is too slow when deploying as an
.aar). In the code of my service class, I need to open a file located in
the root of the service directory structure. For the moment I'm using a
hard-coded path, but I'd like to handle this in a more graceful manner.
Is there a way to do what I want? I'm using Axis2 version 1.3.
Thank you in advance,
Etienne
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Getting the local path where a service is deployed
Posted by Etienne Dube <et...@gmail.com>.
Hi Upul,
Yes, I guess this would work, but I'd like to avoid adding a dependency
to servlet-api.jar (needed for ServletContext). It looks like it's a
common problem with J2EE apps, as seen in the thread "libraries and
configuration files"... I think I'll just add a property in my
services.xml as a workaround, to specify the absolute path where the
file can be found.
Thank you very much for your response,
Etienne
Upul Godage wrote :
> Hi Etienne,
>
> You can do something like this.
> In your service class you can have init(ServiceContext) method which
> is called by Axis2. You can use serviceContext like this.
>
> public class ServiceClass {
>
> public void init(ServiceContext serviceContext) {
> ServletContext servletContext = (ServletContext)
> serviceContext.getProperty("transport.http.servletContext");
> servletContext.getResourceAsStream("/WEB-INF/path/file");
> }
>
> ...
> }
>
> Hope this helps.
>
>
> Upul
>
>
> On Nov 13, 2007 1:29 AM, Etienne Dube <et...@gmail.com> wrote:
>
>> Hello,
>>
>> I'm looking for a way to retrieve the local path where an Axis2 service
>> is deployed. In my case, it is located in
>> C:\java\Tomcat6\webapps\axis2\WEB-INF\services\MyService . I deployed it
>> as a directory instead of an .aar archive for performance reasons (I use
>> lots of external JARs and class loading is too slow when deploying as an
>> .aar). In the code of my service class, I need to open a file located in
>> the root of the service directory structure. For the moment I'm using a
>> hard-coded path, but I'd like to handle this in a more graceful manner.
>> Is there a way to do what I want? I'm using Axis2 version 1.3.
>>
>> Thank you in advance,
>>
>> Etienne
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Getting the local path where a service is deployed
Posted by Upul Godage <up...@gmail.com>.
Hi Etienne,
You can do something like this.
In your service class you can have init(ServiceContext) method which
is called by Axis2. You can use serviceContext like this.
public class ServiceClass {
public void init(ServiceContext serviceContext) {
ServletContext servletContext = (ServletContext)
serviceContext.getProperty("transport.http.servletContext");
servletContext.getResourceAsStream("/WEB-INF/path/file");
}
...
}
Hope this helps.
Upul
On Nov 13, 2007 1:29 AM, Etienne Dube <et...@gmail.com> wrote:
> Hello,
>
> I'm looking for a way to retrieve the local path where an Axis2 service
> is deployed. In my case, it is located in
> C:\java\Tomcat6\webapps\axis2\WEB-INF\services\MyService . I deployed it
> as a directory instead of an .aar archive for performance reasons (I use
> lots of external JARs and class loading is too slow when deploying as an
> .aar). In the code of my service class, I need to open a file located in
> the root of the service directory structure. For the moment I'm using a
> hard-coded path, but I'd like to handle this in a more graceful manner.
> Is there a way to do what I want? I'm using Axis2 version 1.3.
>
> Thank you in advance,
>
> Etienne
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org