You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Stuart Roe <st...@ovic.co.uk> on 2009/06/25 11:26:58 UTC

Correct way to address resources

Hi everyone,
 
What is the best/correct way to build the access path to the resource files
within a deployed service unit? 
 
I have a file that is stored at the same location as xbean.xml within a
service unit. In SMX 3.3 I was using
getClass().getClassLoader().getResource("/") within the accessing class to
resolve to the appropriate folder:
 
apache-servicemix-3.3/data/smx/service-assemblies/application-sa/version_2/s
us/servicemix-bean/my-su/
 
After upgrading to SMX 3.3.1 the return value for the above getClass()
statement has changed. It is now returning the SMX installation root folder
apache-servicemix-3.3.1, not the deployment location.
 
What is the correct expression to locate the resource/unpacked location of
the service unit?
 
My environment:
SMX 3.3.1, JDK 1.5, WinXP.
 
Stuart.

Re: Correct way to address resources

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Stuart,

I have made some changes in the classloader policy in SMX 3.3.1. Now, 
using the <classpath/> tag, you can extend the classloader using the 
java archives (jar/war/ear) and optionally use of regexp to select 
archive entries. For example, in the xbean.xml, you can have something like:
<classpath>
   <location>jar:/path/to/my.jar!/lib/*.jar</location>
</classpath>

Nevertheless, the classloader hierarchy shouldn't have changed and is 
compliant with:
http://servicemix.apache.org/classloaders.html

I will take a look on the source code and check if something else hasn't 
changed.

On the other hand, you can use spring like resource management in the 
xbean.xml (as the xbean is a pure spring beans description).

Regards
JB

Stuart Roe wrote:
> Hi everyone,
>  
> What is the best/correct way to build the access path to the resource files
> within a deployed service unit? 
>  
> I have a file that is stored at the same location as xbean.xml within a
> service unit. In SMX 3.3 I was using
> getClass().getClassLoader().getResource("/") within the accessing class to
> resolve to the appropriate folder:
>  
> apache-servicemix-3.3/data/smx/service-assemblies/application-sa/version_2/s
> us/servicemix-bean/my-su/
>  
> After upgrading to SMX 3.3.1 the return value for the above getClass()
> statement has changed. It is now returning the SMX installation root folder
> apache-servicemix-3.3.1, not the deployment location.
>  
> What is the correct expression to locate the resource/unpacked location of
> the service unit?
>  
> My environment:
> SMX 3.3.1, JDK 1.5, WinXP.
>  
> Stuart.
>