You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by gigeril <ma...@knapp.com> on 2008/08/18 10:02:12 UTC

Access files in src/main/resources trough a own written bc

Hello. I've written a provider binding component for my authorization system.
It works trough jaas this access hibernate wich connects to a database. The
problem is, that I want put the config files in the src/main/resources
folder of the specific SU that configures the Binding Component. But I have
no idea how i should access these Config files in the Binding Component??

My xbean.xml of the SU for the BindingComponent looks so:
<?xml version="1.0" encoding="UTF-8"?>

<beans  xmlns:jaas="java://org.knapp.servicemix.aam"
		xmlns:tcpjaas="http://knapp.com/tcpjaas">
  <jaas:JAASProviderEndpoint service="tcpjaas:jaasProvider"
                 endpoint="jaasProvider" 
				 jaasconfig="resources/AuthenticationAuthorization.config"
				 jaaspolicy="resources/AuthenticationAuthorization.policy"
				 hibernatecfg="resources/hibernate.cfg.xml"
     
  />
</beans>

The 3 files (AuthenticationAuthorization.config,
AuthenticationAuthorization.policy, hibernate.cfg.xml) are located under the
src/main/resources folder of the SU which is configuring my BC.

Now my BC Always tells me that he can'T find the files that I descriped in
the xbean.xml. What Path shout I specify in the xbean to get it work?.

Note:
If I specify a hardcoded path for this 3 properties (ex.
C:\\hibernate.cfg.xml,...) it works properly.


I think it's the same way as the drools bc access his *.drl file defined in
the xbean.xml of an su for the drools bc. I looked for this in the drools bc
source but I can't find it.



-- 
View this message in context: http://www.nabble.com/Access-files-in-src-main-resources-trough-a-own-written-bc-tp19027320p19027320.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Access files in src/main/resources trough a own written bc

Posted by gigeril <ma...@knapp.com>.
It works now!!
Thank you very much for the quick reply.




lhe77 wrote:
> 
> 1. define variables of type org.springframework.core.io.Resource for each
> file
> 2. define public setters and getters for these variables
> 3. in your SU's xbean.xml you define attributes for the variables and use 
> classpath in it
> 
> Example:
> <?xml version="1.0" encoding="UTF-8"?>
> <beans  xmlns:jaas="java://org.knapp.servicemix.aam"
>   	     xmlns:tcpjaas="http://knapp.com/tcpjaas">
>    <jaas:JAASProviderEndpoint service="tcpjaas:jaasProvider" 
> endpoint="jaasProvider"
> 		 jaasconfig="classpath:AuthenticationAuthorization.config"
> 		 jaaspolicy="classpath:AuthenticationAuthorization.policy"
> 		 hibernatecfg="classpath:hibernate.cfg.xml" />
> </beans>
> 
> Haven't tested it but it should do the trick.
> 
> Regards
> Lars
> 
> 
> 
> 
> Am Montag 18 August 2008 10:02:12 schrieb gigeril:
>> Hello. I've written a provider binding component for my authorization
>> system. It works trough jaas this access hibernate wich connects to a
>> database. The problem is, that I want put the config files in the
>> src/main/resources folder of the specific SU that configures the Binding
>> Component. But I have no idea how i should access these Config files in
>> the
>> Binding Component??
>>
>> My xbean.xml of the SU for the BindingComponent looks so:
>> <?xml version="1.0" encoding="UTF-8"?>
>>
>> <beans  xmlns:jaas="java://org.knapp.servicemix.aam"
>> 		xmlns:tcpjaas="http://knapp.com/tcpjaas">
>>   <jaas:JAASProviderEndpoint service="tcpjaas:jaasProvider"
>>                  endpoint="jaasProvider"
>> 				 jaasconfig="resources/AuthenticationAuthorization.config"
>> 				 jaaspolicy="resources/AuthenticationAuthorization.policy"
>> 				 hibernatecfg="resources/hibernate.cfg.xml"
>>
>>   />
>> </beans>
>>
>> The 3 files (AuthenticationAuthorization.config,
>> AuthenticationAuthorization.policy, hibernate.cfg.xml) are located under
>> the src/main/resources folder of the SU which is configuring my BC.
>>
>> Now my BC Always tells me that he can'T find the files that I descriped
>> in
>> the xbean.xml. What Path shout I specify in the xbean to get it work?.
>>
>> Note:
>> If I specify a hardcoded path for this 3 properties (ex.
>> C:\\hibernate.cfg.xml,...) it works properly.
>>
>>
>> I think it's the same way as the drools bc access his *.drl file defined
>> in
>> the xbean.xml of an su for the drools bc. I looked for this in the drools
>> bc source but I can't find it.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Access-files-in-src-main-resources-trough-a-own-written-bc-tp19027320p19029307.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Access files in src/main/resources trough a own written bc

Posted by Lars Heinemann <la...@compart.net>.
1. define variables of type org.springframework.core.io.Resource for each file
2. define public setters and getters for these variables
3. in your SU's xbean.xml you define attributes for the variables and use 
classpath in it

Example:
<?xml version="1.0" encoding="UTF-8"?>
<beans  xmlns:jaas="java://org.knapp.servicemix.aam"
  	     xmlns:tcpjaas="http://knapp.com/tcpjaas">
   <jaas:JAASProviderEndpoint service="tcpjaas:jaasProvider" 
endpoint="jaasProvider"
		 jaasconfig="classpath:AuthenticationAuthorization.config"
		 jaaspolicy="classpath:AuthenticationAuthorization.policy"
		 hibernatecfg="classpath:hibernate.cfg.xml" />
</beans>

Haven't tested it but it should do the trick.

Regards
Lars




Am Montag 18 August 2008 10:02:12 schrieb gigeril:
> Hello. I've written a provider binding component for my authorization
> system. It works trough jaas this access hibernate wich connects to a
> database. The problem is, that I want put the config files in the
> src/main/resources folder of the specific SU that configures the Binding
> Component. But I have no idea how i should access these Config files in the
> Binding Component??
>
> My xbean.xml of the SU for the BindingComponent looks so:
> <?xml version="1.0" encoding="UTF-8"?>
>
> <beans  xmlns:jaas="java://org.knapp.servicemix.aam"
> 		xmlns:tcpjaas="http://knapp.com/tcpjaas">
>   <jaas:JAASProviderEndpoint service="tcpjaas:jaasProvider"
>                  endpoint="jaasProvider"
> 				 jaasconfig="resources/AuthenticationAuthorization.config"
> 				 jaaspolicy="resources/AuthenticationAuthorization.policy"
> 				 hibernatecfg="resources/hibernate.cfg.xml"
>
>   />
> </beans>
>
> The 3 files (AuthenticationAuthorization.config,
> AuthenticationAuthorization.policy, hibernate.cfg.xml) are located under
> the src/main/resources folder of the SU which is configuring my BC.
>
> Now my BC Always tells me that he can'T find the files that I descriped in
> the xbean.xml. What Path shout I specify in the xbean to get it work?.
>
> Note:
> If I specify a hardcoded path for this 3 properties (ex.
> C:\\hibernate.cfg.xml,...) it works properly.
>
>
> I think it's the same way as the drools bc access his *.drl file defined in
> the xbean.xml of an su for the drools bc. I looked for this in the drools
> bc source but I can't find it.