You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by pradet <pd...@gmail.com> on 2012/08/29 08:43:51 UTC

Is it possible to read property key without hardcoding in Blueprint - using OSGi config Admin

Hi,

Currently i am reading the property file using OSGi config Admin services
approach. which is working fine.

<cm:property-placeholder persistent-id="sampleFile"
update-strategy="reload">
 	<cm:default-properties>
 		<cm:property name="host" value=""/>
 		<cm:property name="host1" value=""/>
 	</cm:default-properties>
</cm:property-placeholder>

Where, 'sampleFile.cfg' is my config file, which I have placed in the ETC
folder of ServiceMix.

I want to read the key name also from property file. i.e. instead of
hardcoding the keyname in the blueprint XML file. I want to pass the
property Key name which I am getting from an HTTP parameter.

Can I configure something like this ?

 	<cm:default-properties>
 		<cm:property name=&quot;${in.header.&lt;paramname>}" value=""/>
 	</cm:default-properties>

Can someone let me know, if this can be done ?

Thanks in Advance,

Pradeep




--
View this message in context: http://servicemix.396122.n5.nabble.com/Is-it-possible-to-read-property-key-without-hardcoding-in-Blueprint-using-OSGi-config-Admin-tp5714288.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Is it possible to read property key without hardcoding in Blueprint - using OSGi config Admin

Posted by pradet <pd...@gmail.com>.
James,

Yes I can very well get the "host" on first place. But, this is just an
approach i mentioned.

The actual scenario is, I am getting an HTTP request along with a query
parameter.

Ex: http://serviceMixUrl:9898?param1=SOAP_WS

And, supposedly this query parameter should be the key name for my property
file

And, the property file contains, 

SOAP_WS=https://esp.go:6656/service/orderInfo

This substitute should happen at runtime. I am looking for some info on this
aspect.

Cheers,

Pradeep




--
View this message in context: http://servicemix.396122.n5.nabble.com/Is-it-possible-to-read-property-key-without-hardcoding-in-Blueprint-using-OSGi-config-Admin-tp5714288p5714296.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Is it possible to read property key without hardcoding in Blueprint - using OSGi config Admin

Posted by James Carman <ja...@carmanconsulting.com>.
If you have to set a property to tell to tell it to use "host" vs.
"host1", then why not just use that property to specify the host in
the first place?

On Wed, Aug 29, 2012 at 2:43 AM, pradet <pd...@gmail.com> wrote:
> Hi,
>
> Currently i am reading the property file using OSGi config Admin services
> approach. which is working fine.
>
> <cm:property-placeholder persistent-id="sampleFile"
> update-strategy="reload">
>         <cm:default-properties>
>                 <cm:property name="host" value=""/>
>                 <cm:property name="host1" value=""/>
>         </cm:default-properties>
> </cm:property-placeholder>
>
> Where, 'sampleFile.cfg' is my config file, which I have placed in the ETC
> folder of ServiceMix.
>
> I want to read the key name also from property file. i.e. instead of
> hardcoding the keyname in the blueprint XML file. I want to pass the
> property Key name which I am getting from an HTTP parameter.
>
> Can I configure something like this ?
>
>         <cm:default-properties>
>                 <cm:property name=&quot;${in.header.&lt;paramname>}" value=""/>
>         </cm:default-properties>
>
> Can someone let me know, if this can be done ?
>
> Thanks in Advance,
>
> Pradeep
>
>
>
>
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Is-it-possible-to-read-property-key-without-hardcoding-in-Blueprint-using-OSGi-config-Admin-tp5714288.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Is it possible to read property key without hardcoding in Blueprint - using OSGi config Admin

Posted by pradet <pd...@gmail.com>.
Hi Fillippo

Thanks for the information. In my project, the customer is not ready to
allow any java code or java code reference in the Blueprint XML file . 

Anyways, will give a try for this programmatic appraoch. 

Cheers,

Pradeep




--
View this message in context: http://servicemix.396122.n5.nabble.com/Is-it-possible-to-read-property-key-without-hardcoding-in-Blueprint-using-OSGi-config-Admin-tp5714288p5714295.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Is it possible to read property key without hardcoding in Blueprint - using OSGi config Admin

Posted by Filippo Balicchia <fb...@gmail.com>.
Hi Pradeep,

In IHMO, your possible solution contains a security flaw, the client
can Inject everything.

I think that in declarative mode is not possible to do you solution,
but in programmatic  in your bundle you can do

some like this.

ServiceReference ref =
bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
		if (ref != null) {
			ConfigurationAdmin cm = (ConfigurationAdmin) bundleContext.getService(ref);
			if (cm != null) {
				try {
					Dictionary dict = cm.getConfiguration(persistentId).getProperties();
					ecc.ecc
				}





Regards

--Filippo

2012/8/29 pradet <pd...@gmail.com>:
> Hi,
>
> Currently i am reading the property file using OSGi config Admin services
> approach. which is working fine.
>
> <cm:property-placeholder persistent-id="sampleFile"
> update-strategy="reload">
>         <cm:default-properties>
>                 <cm:property name="host" value=""/>
>                 <cm:property name="host1" value=""/>
>         </cm:default-properties>
> </cm:property-placeholder>
>
> Where, 'sampleFile.cfg' is my config file, which I have placed in the ETC
> folder of ServiceMix.
>
> I want to read the key name also from property file. i.e. instead of
> hardcoding the keyname in the blueprint XML file. I want to pass the
> property Key name which I am getting from an HTTP parameter.
>
> Can I configure something like this ?
>
>         <cm:default-properties>
>                 <cm:property name=&quot;${in.header.&lt;paramname>}" value=""/>
>         </cm:default-properties>
>
> Can someone let me know, if this can be done ?
>
> Thanks in Advance,
>
> Pradeep
>
>
>
>
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Is-it-possible-to-read-property-key-without-hardcoding-in-Blueprint-using-OSGi-config-Admin-tp5714288.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.