You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by "Griffin, Charles (NIH/NCI) [C]" <gr...@mail.nih.gov> on 2006/09/07 17:31:19 UTC

Getting Paths to config files within a Service Unit Jar

Is it possible to access files packaged in the Service Unit jar?  I
placed a file in the root of my Service Unit jar and tried to get the
path to them from within the init method of my POJO (deployed to the
lightweight container and extends PojoSupport) using the code below but
was unsuccessful.  I had to eventually revert to placing the config
files in an external directory that I knew the path to but would like to
be able to package the config files with the Service Unit jar.  If
anybody has done this or has an alternative strategy please let me know.


 

 

  Properties props = System.getProperties();
  url =
this.getClass().getClassLoader().getSystemResource("ApplicationSecurityC
onfig.xml");
  path = url.getPath();

 

 

Thanks,

Charles 


Re: Getting Paths to config files within a Service Unit Jar

Posted by Guillaume Nodet <gn...@gmail.com>.
If you use the classpath location, you should be able to load them using
  this.getClass().getClassLoader().getResource("
ApplicationSecurityConfig.xml");

getSystemResource is a static method that use the system class loader
and the the one you want.

On 9/7/06, Griffin, Charles (NIH/NCI) [C] <gr...@mail.nih.gov> wrote:
>
> I've packaged a class extending PojoSupport that is deployed to the
> lightweight container in a jar.  This Service Unit jar was then packaged
> into a service assembly jar which I placed in the hotdeploy directory.
>
> I've pasted the Servicemix.xml for the service unit below.
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns:sm="http://servicemix.apache.org/config/1.0"
> xmlns:authorization="http://gov.nih.nci.caxchange/services/authorization
> ">
>         <classpath>
>                 <location>.</location>
>         <location>lib/caXchangeCommon.jar</location>
>         <location>lib/csmapi.jar</location>
>         <location>lib/clm.jar</location>
>         </classpath>
>
>         <sm:serviceunit id="jbi">
>                 <sm:activationSpecs>
>                         <sm:activationSpec
> componentName="AuthorizationComponent"
>
> endpoint="authorization:AuthorizationComponent"
>
> service="authorization:AuthorizationService">
>                                 <sm:component>
>                                         <bean
> class="gov.nih.nci.caxchange.services.authorization.AuthorizationService
> "></bean>
>                                 </sm:component>
>                         </sm:activationSpec>
>                 </sm:activationSpecs>
>         </sm:serviceunit>
> </beans>
>
>
> The jbi.xml for the service assembly is below:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <jbi xmlns="http://java.sun.com/xml/ns/jbi" version="1.0">
>
>    <service-assembly>
>      <identification>
>        <name>security</name>
>        <description>Security Service Assembly</description>
>      </identification>
>      <service-unit>
>        <identification>
>          <name>authenticationservice</name>
>          <description>Authentication Service Unit</description>
>        </identification>
>        <target>
>          <artifacts-zip>AuthenticationService-su.jar</artifacts-zip>
>          <component-name>servicemix-lwcontainer</component-name>
>        </target>
>      </service-unit>
>      <service-unit>
>        <identification>
>          <name>authorizationservice</name>
>          <description>Authorization Service Unit</description>
>        </identification>
>        <target>
>          <artifacts-zip>AuthorizationService-su.jar</artifacts-zip>
>          <component-name>servicemix-lwcontainer</component-name>
>        </target>
>      </service-unit>
>     </service-assembly>
>
> </jbi>
>
> Thanks in advance for any help you can provide.
> Charles
>
>
> -----Original Message-----
> From: Guillaume Nodet [mailto:gnodet@gmail.com]
> Sent: Thursday, September 07, 2006 11:55 AM
> To: servicemix-users@geronimo.apache.org
> Subject: Re: Getting Paths to config files within a Service Unit Jar
>
> For which component and using which packaging ?
>
> On 9/7/06, Griffin, Charles (NIH/NCI) [C] <gr...@mail.nih.gov>
> wrote:
> >
> > Is it possible to access files packaged in the Service Unit jar?  I
> > placed a file in the root of my Service Unit jar and tried to get the
> > path to them from within the init method of my POJO (deployed to the
> > lightweight container and extends PojoSupport) using the code below
> but
> > was unsuccessful.  I had to eventually revert to placing the config
> > files in an external directory that I knew the path to but would like
> to
> > be able to package the config files with the Service Unit jar.  If
> > anybody has done this or has an alternative strategy please let me
> know.
> >
> >
> >
> >
> >
> >
> >   Properties props = System.getProperties();
> >   url =
> >
> this.getClass().getClassLoader().getSystemResource("ApplicationSecurityC
> > onfig.xml");
> >   path = url.getPath();
> >
> >
> >
> >
> >
> > Thanks,
> >
> > Charles
> >
> >
> >
>
>
> --
> Cheers,
> Guillaume Nodet
>



-- 
Cheers,
Guillaume Nodet

RE: Getting Paths to config files within a Service Unit Jar

Posted by "Griffin, Charles (NIH/NCI) [C]" <gr...@mail.nih.gov>.
I've packaged a class extending PojoSupport that is deployed to the
lightweight container in a jar.  This Service Unit jar was then packaged
into a service assembly jar which I placed in the hotdeploy directory.  

I've pasted the Servicemix.xml for the service unit below.  


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
xmlns:authorization="http://gov.nih.nci.caxchange/services/authorization
">
	<classpath>
		<location>.</location>
        <location>lib/caXchangeCommon.jar</location>
        <location>lib/csmapi.jar</location>
        <location>lib/clm.jar</location>
	</classpath>
	
	<sm:serviceunit id="jbi">
		<sm:activationSpecs>
			<sm:activationSpec
componentName="AuthorizationComponent"
	
endpoint="authorization:AuthorizationComponent"
	
service="authorization:AuthorizationService">
				<sm:component>
					<bean
class="gov.nih.nci.caxchange.services.authorization.AuthorizationService
"></bean>
				</sm:component>
			</sm:activationSpec>
		</sm:activationSpecs>
	</sm:serviceunit>
</beans>


The jbi.xml for the service assembly is below:


<?xml version="1.0" encoding="UTF-8"?>
<jbi xmlns="http://java.sun.com/xml/ns/jbi" version="1.0">

   <service-assembly>
     <identification>
       <name>security</name>
       <description>Security Service Assembly</description>
     </identification>
     <service-unit>
       <identification>
         <name>authenticationservice</name>
         <description>Authentication Service Unit</description>
       </identification>
       <target>
         <artifacts-zip>AuthenticationService-su.jar</artifacts-zip>
         <component-name>servicemix-lwcontainer</component-name>
       </target>
     </service-unit>
     <service-unit>
       <identification>
         <name>authorizationservice</name>
         <description>Authorization Service Unit</description>
       </identification>
       <target>
         <artifacts-zip>AuthorizationService-su.jar</artifacts-zip>
         <component-name>servicemix-lwcontainer</component-name>
       </target>
     </service-unit>
    </service-assembly>

</jbi>

Thanks in advance for any help you can provide.
Charles


-----Original Message-----
From: Guillaume Nodet [mailto:gnodet@gmail.com] 
Sent: Thursday, September 07, 2006 11:55 AM
To: servicemix-users@geronimo.apache.org
Subject: Re: Getting Paths to config files within a Service Unit Jar

For which component and using which packaging ?

On 9/7/06, Griffin, Charles (NIH/NCI) [C] <gr...@mail.nih.gov>
wrote:
>
> Is it possible to access files packaged in the Service Unit jar?  I
> placed a file in the root of my Service Unit jar and tried to get the
> path to them from within the init method of my POJO (deployed to the
> lightweight container and extends PojoSupport) using the code below
but
> was unsuccessful.  I had to eventually revert to placing the config
> files in an external directory that I knew the path to but would like
to
> be able to package the config files with the Service Unit jar.  If
> anybody has done this or has an alternative strategy please let me
know.
>
>
>
>
>
>
>   Properties props = System.getProperties();
>   url =
>
this.getClass().getClassLoader().getSystemResource("ApplicationSecurityC
> onfig.xml");
>   path = url.getPath();
>
>
>
>
>
> Thanks,
>
> Charles
>
>
>


-- 
Cheers,
Guillaume Nodet

Re: Getting Paths to config files within a Service Unit Jar

Posted by Guillaume Nodet <gn...@gmail.com>.
For which component and using which packaging ?

On 9/7/06, Griffin, Charles (NIH/NCI) [C] <gr...@mail.nih.gov> wrote:
>
> Is it possible to access files packaged in the Service Unit jar?  I
> placed a file in the root of my Service Unit jar and tried to get the
> path to them from within the init method of my POJO (deployed to the
> lightweight container and extends PojoSupport) using the code below but
> was unsuccessful.  I had to eventually revert to placing the config
> files in an external directory that I knew the path to but would like to
> be able to package the config files with the Service Unit jar.  If
> anybody has done this or has an alternative strategy please let me know.
>
>
>
>
>
>
>   Properties props = System.getProperties();
>   url =
> this.getClass().getClassLoader().getSystemResource("ApplicationSecurityC
> onfig.xml");
>   path = url.getPath();
>
>
>
>
>
> Thanks,
>
> Charles
>
>
>


-- 
Cheers,
Guillaume Nodet