This is awesome!!! Thanks for sharing!
Hendy On Dec 19, 2012 12:54 AM, "spandit2 [via ServiceMix]" < [email protected]> wrote: > 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 > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://servicemix.396122.n5.nabble.com/Property-in-OSGi-service-reference-filter-attribute-tp5713964p5715300.html > To unsubscribe from Property in OSGi service reference filter attribute, > click > here<http://servicemix.396122.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5713964&code=aGVuZHlAc29sdXZhcy5jb218NTcxMzk2NHwxNTI0Njc4NzUy> > . > NAML<http://servicemix.396122.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- View this message in context: http://servicemix.396122.n5.nabble.com/Property-in-OSGi-service-reference-filter-attribute-tp5713964p5715301.html Sent from the ServiceMix - User mailing list archive at Nabble.com.
