You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Hendy Irawan <he...@soluvas.com> on 2012/11/07 11:55:19 UTC

Re: Property in OSGi service reference filter attribute

Hi all,

I'm also in need of this functionality.

e.g. we have lots of references like this which we expect to work :

<reference id="ldapPool" interface="org.apache.commons.pool.ObjectPool"

filter="(&amp;(tenantId=${tenantId})(tenantEnv=${tenantEnv})(namespace=ldap))"/>

which actually doesn't work. :-(

So we need to duplicate a lot of Blueprint XML files and replace the values
using other means.

Is this feature planned? This would be very useful. I'm also glad we're not
the only one needing this feature.
Should we post a JIRA? (to Aries Blueprint project?)

Hendy



--
View this message in context: http://servicemix.396122.n5.nabble.com/Property-in-OSGi-service-reference-filter-attribute-tp5713964p5714857.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Property in OSGi service reference filter attribute

Posted by Hendy Irawan <he...@soluvas.com>.
Thank you Freeman,

I've posted it at :
http://aries.15396.n3.nabble.com/Property-in-OSGi-service-reference-filter-attribute-td4025643.html

Hendy



--
View this message in context: http://servicemix.396122.n5.nabble.com/Property-in-OSGi-service-reference-filter-attribute-tp5713964p5714877.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Property in OSGi service reference filter attribute

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

I'd say post this question on aries blueprint mailing list first there.

Freeman
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: http://weibo.com/u/1473905042

On 2012-11-7, at 下午6:55, Hendy Irawan wrote:

> Hi all,
> 
> I'm also in need of this functionality.
> 
> e.g. we have lots of references like this which we expect to work :
> 
> <reference id="ldapPool" interface="org.apache.commons.pool.ObjectPool"
> 
> filter="(&amp;(tenantId=${tenantId})(tenantEnv=${tenantEnv})(namespace=ldap))"/>
> 
> which actually doesn't work. :-(
> 
> So we need to duplicate a lot of Blueprint XML files and replace the values
> using other means.
> 
> Is this feature planned? This would be very useful. I'm also glad we're not
> the only one needing this feature.
> Should we post a JIRA? (to Aries Blueprint project?)
> 
> Hendy
> 
> 
> 
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Property-in-OSGi-service-reference-filter-attribute-tp5713964p5714857.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Property in OSGi service reference filter attribute

Posted by Hendy Irawan <he...@soluvas.com>.
No we didn't have a satisfying resolution.

Our "solution" (actually, a cumbersome workaround) is to:
1. Separate bundles with their "global" Blueprint XML vs. tenant-specific
Blueprint XML
2. Hardcode the property values in tenant-specific Blueprint XML and deploy
them individually. Each "module" will have its own blueprint file so these
modules can fail independently.
3. The tenant-specific Blueprint XMLs have hardcoded values for filters,
however most values like config come from CM. The filters are the only
blocker that makes us need to configure each tenant specifically.
Fortunately, the difference of XML due to this filter is quite minimal and
even obvious (i.e. for larger number of tenants, a simple
string-replacement script will do the job).

There is also another complication because cannot use even simple
expressions like string concatenation in property-set values, i.e.
"${tenantId}_${tenantEnv}" won't work, we have to either a) create a new
property with merged values, or b) provide 2 properties independently and
let the constructor do the concatenation.

Here's an example Blueprint that we use, containing 2 references with
hardcoded filters, everything else is provided by CM:

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
    xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.1.0"
    xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
    http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0
      http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.1.0
http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.1.0">

<cm:property-placeholder persistent-id="berbatik" update-strategy="none">
<cm:default-properties>
<cm:property name="neo4jPrefix" value="berbatik_dev" />
</cm:default-properties>
</cm:property-placeholder>

<reference id="graphDb" interface="org.neo4j.graphdb.GraphDatabaseService"
filter="(tenantId=berbatik)" />
<reference id="eventBus" interface="com.google.common.eventbus.EventBus"
filter="(tenantId=berbatik)" ext:proxy-method="classes" />

<!--
PersonLikeShop Repo only handles likes from Person to Shop
-->
<bean id="personLikeShopRepo"
class="id.co.bippo.like.Neo4jPersonLikeShopRepository">
<argument ref="graphDb" />
<argument value="${neo4jPrefix}" />
</bean>
<service ref="personLikeShopRepo" auto-export="interfaces">
<service-properties>
<entry key="clientId" value="${clientId}" />
<entry key="tenantEnv" value="${tenantEnv}" />
<entry key="tenantId" value="${tenantId}" />
<entry key="namespace" value="person-like-shop" />
</service-properties>
</service>

<!--
PersonLikeProduct Repo only handles likes from Person to Product
-->
<bean id="personLikeProductRepo"
class="id.co.bippo.like.Neo4jPersonLikeProductRepository">
<argument ref="graphDb" />
<argument value="${neo4jPrefix}" />
</bean>
<service ref="personLikeProductRepo" auto-export="interfaces">
<service-properties>
<entry key="clientId" value="${clientId}" />
<entry key="tenantEnv" value="${tenantEnv}" />
<entry key="tenantId" value="${tenantId}" />
<entry key="namespace" value="person-like-product" />
</service-properties>
</service>

<!-- LikeManager is Bippo specific, handles everything for Bippo's LIKE -->
<bean id="likeMgr" class="id.co.bippo.like.LikeManagerImpl"
depends-on="personLikeShopRepo personLikeProductRepo">
<argument ref="personLikeShopRepo" />
<argument ref="personLikeProductRepo" />
<argument ref="eventBus" />
</bean>
<service ref="likeMgr" auto-export="interfaces">
<service-properties>
<entry key="clientId" value="${clientId}" />
<entry key="tenantEnv" value="${tenantEnv}" />
<entry key="tenantId" value="${tenantId}" />
<entry key="namespace" value="" />
</service-properties>
</service>
</blueprint>


Hope this helps.

Hendy


On Wed, Dec 5, 2012 at 12:38 PM, Sunil Pandit <sp...@csc.com> wrote:

>
> Hi Hendy
>
> I saw your post at
>
>
> http://aries.15396.n3.nabble.com/Property-in-OSGi-service-reference-filter-attribute-td4025643.html
>
> regarding using property value for filter in service reference .
>
> Were you able to resolve this issue ? If so do you mind sharing your
> solution ?
>
> I am running into exact same situation.
>
> Thanks
> Sunil Pandit
> CSC
>
> 200 West Cesar Chavez., Austin, TX 78701
> Financial Services Sector  |  p: +1-512-2755792 | spandit2@csc.com  |
> www.csc.com
>
> This is a PRIVATE message. If you are not the intended recipient, please
> delete without copying and kindly advise us by e-mail of the mistake in
> delivery. NOTE: Regardless of content, this e-mail shall not operate to
> bind CSC to any order or other contract unless pursuant to explicit written
> agreement or government initiative expressly permitting the use of e-mail
> for such purpose.
>
>


-- 
Hendy Irawan - on Twitter <http://twitter.com/hendybippo> - on
LinkedIn<http://id.linkedin.com/in/hendyirawan>
Web Developer | Bippo Indonesia <http://www.bippo.co.id/> | Akselerator
Bisnis | Bandung




--
View this message in context: http://servicemix.396122.n5.nabble.com/Property-in-OSGi-service-reference-filter-attribute-tp5713964p5715151.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.