I was able to solve this issue . I have added a custom element with its own
namespace to the service reference . So My service reference definition
looks like this
*<reference id="ValidationService"
interface="com.csc.fs.BreezWay.intf.AppEntryValidation"
availability="optional" filter="(org.name=*)">
<BW:BWExtElement>
<BW:ProcessFilter>true</BW:ProcessFilter>
</BW:BWExtElement>
</reference>*
I also registered a namespacehandle for this custom namespace. This
namespacehandler bean is like any other service which could be initialized
using the properties . The service definition for the namespace handler
looks like this .
*<service auto-export="interfaces" ref="BWNSHandler">
<service-properties>
<entry key="service.exported.interfaces" value="*"></entry>
<entry key="osgi.service.blueprint.namespace"
value="http://com.csc.fs.bw.services/BWExt"></entry></service-properties></service>*
When the Aries parser detects this custom element in the reference , it
executes decorate method on corresponding namespace handler passing the
reference metadata that it has created before . In this decorate method then
I process the filter as I want to using the property values set on the
namespacehandler bean .
public ComponentMetadata decorate(Node arg0, ComponentMetadata arg1,
ParserContext arg2) {
ReferenceMetadataImpl r = (ReferenceMetadataImpl) arg1;
String f = r.getFilter();
int i= f.indexOf('*');
if(i>0 && f.contains("org.name") && f.contains("*")){
f= f.replace("*", orgName);
}
r.setFilter(f);
return arg1;
}
One issue I ran into was the aries parser was not able to locate my custom
schema which I have included in the / resources folder of the bundle . So I
had to turn off the validation by setting bundle symbolic name of the
bundle to AppEntryValidationRoute;blueprint.aries.xml-validation:=false .
Hope this helps
--
View this message in context:
http://servicemix.396122.n5.nabble.com/Property-in-OSGi-service-reference-filter-attribute-tp5713964p5715300.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.