Return-Path: X-Original-To: apmail-felix-dev-archive@www.apache.org Delivered-To: apmail-felix-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5AB0817E0F for ; Sun, 1 Mar 2015 14:20:05 +0000 (UTC) Received: (qmail 10252 invoked by uid 500); 1 Mar 2015 14:20:05 -0000 Delivered-To: apmail-felix-dev-archive@felix.apache.org Received: (qmail 10180 invoked by uid 500); 1 Mar 2015 14:20:05 -0000 Mailing-List: contact dev-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list dev@felix.apache.org Received: (qmail 10168 invoked by uid 99); 1 Mar 2015 14:20:05 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Mar 2015 14:20:05 +0000 Date: Sun, 1 Mar 2015 14:20:05 +0000 (UTC) From: "Pierre De Rop (JIRA)" To: dev@felix.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (FELIX-4709) Incorrect Named Dependencies are binded to the Service Instance MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FELIX-4709?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:all-tabpanel ] Pierre De Rop updated FELIX-4709: --------------------------------- Component/s: (was: Dependency Manager) Dependency Manager Runtime > Incorrect Named Dependencies are binded to the Service Instance > --------------------------------------------------------------- > > Key: FELIX-4709 > URL: https://issues.apache.org/jira/browse/FELIX-4709 > Project: Felix > Issue Type: Bug > Components: Dependency Manager Runtime > Affects Versions: dependencymanager.runtime-3.2.0 > Environment: Windows 7 Enterprise, Eclipse 3.8 > Reporter: Anuj > Assignee: Pierre De Rop > Fix For: org.apache.felix.dependencymanager-r1 > > Attachments: FELIX-4709.patch > > > There is an issue when we use @FactoryConfigurationAdapterService with dy= namic filtering using init() method.=20 > Use Case: We want to have multiple instances of a service. For each servi= ce instance, we want to dynamically specify service dependency filter base= d on the configuration received for the service instance. > Issue: Whenever init() method of new created service instance is invoked= , ALL Named dependencies(with filters) defined in init method of previously= created service instances are also added as named dependencies for this se= rvice instance. This is not logical as init must ONLY add filters defined = in the init of this particular service instance. When we run DM command, t= his is visible. We created two service instances with value of property: co= m.ericsson.rm.config.tag as main and v30. In the output of Dm command, we = can see that second instance of the factory i.e. 137 also has named depende= ncies with filters of the first service instance i.e. 136 . Second instance= must not have named dependencies with filter com.ericsson.rm.config.tag= =3Dmain which was specified in configuration of first instance (136) . 137 = must only have named dependencies with filter com.ericsson.rm.config.tag=3D= v30. > Output of DM command: > [110] com.ericsson.bss.voucher.traffic.persistence.cassandra > [34] Adapter for factory pid com.ericsson.rm.voucher.traffic.persistence= .cassandra registered > com.ericsson.bss.ctrl.service.jmx.MBeanServerAdmin service required a= vailable > javax.transaction.TransactionManager service required available > [136] com.ericsson.rm.service.voucher.traffic.persistence.VoucherPersist= enceService(service.pid=3Dcom.ericsson.rm.voucher.traffic.persistence.cassa= ndra-1416741861126-0,com.ericsson.rm.config.tag=3Dmain,service.factoryPid= =3Dcom.ericsson.rm.voucher.traffic.persistence.cassandra) registered > javax.transaction.TransactionManager service required available com= .ericsson.rm.service.domain.types.cryption.DomainTypesCryption (com.ericsso= n.rm.config.tag=3Dmain-db) service required available com.ericsson.rm.servi= ce.encryption.hash.EncryptionTokenService (com.ericsson.rm.config.tag=3Dmai= n) service required available > [137] com.ericsson.rm.service.voucher.traffic.persistence.VoucherPersist= enceService(service.pid=3Dcom.ericsson.rm.voucher.traffic.persistence.cassa= ndra-1416742092818-74,com.ericsson.rm.config.tag=3Dv30, ,service.factoryPid= =3Dcom.ericsson.rm.voucher.traffic.persistence.cassandra) registered > javax.transaction.TransactionManager service required available com.eric= sson.rm.service.domain.types.cryption.DomainTypesCryption (com.ericsson.rm.= config.tag=3Dmain-db) service required availablc > com.ericsson.rm.service.encryption.hash.EncryptionTokenService (com.erics= son.rm.config.tag=3Dmain) service required available > com.ericsson.rm.service.domain.types.cryption.DomainTypesCryption (com.e= ricsson.rm.config.tag=3Dv30-db) service required available > com.ericsson.rm.service.encryption.hash.EncryptionTokenService (com.e= ricsson.rm.config.tag=3Dv30) service required available > We are intermittently facing issues where named dependencies (with filter= s specified in other service instances) are getting bound to a service inst= ance and we suspect that the above mentioned issue is the reason. Please co= nfirm our assumption. If you see any other problem in the code , please let= us know. Please also suggest workaround to make sure binding is correct. > Felix Code Analysis: > Looking into the code of ServiceLifeCycleHandler,we observed: Instead of = creating new list of named dependencies with their filter for EACH service = instance created, ServiceLifecycleHandler maintains a common list of all n= amed dependencies with their filters for all service instances. Thus when = init method of a service instance is called, named dependencies with filter= s are added to existing list of dependencies from previous service instance= s=20 > We used dependency manager as follows: > @FactoryConfigurationAdapterService(provides =3D VoucherPersistenceServic= e.class, factoryPid =3D "com.ericsson.rm.voucher.traffic.persistence.cassan= dra", > propagate =3D true, updated =3D "configure") > public class CassandraPersistence implements VoucherPersistenceService > { > =E2=80=A6=E2=80=A6 > //Named Dependencies. > @ServiceDependency(name =3D "Cryption", added =3D "bindDomainTypesCryptio= n", removed =3D "unbindDomainTypesCryption", required =3D true) > public void bindDomainTypesCryption(final DomainTypesCryption parDoma= inTypesCryption) > { //some code } > @ServiceDependency(name =3D "EncryptionTokenService", added =3D "bindEncr= yptionTokenService", removed =3D "unbindEncryptionTokenService", required = =3D true) > public void bindEncryptionTokenService(final EncryptionTokenService p= arEncryptionTokenService) > { //some code } > =20 > //Unnamed Dependencies > @ServiceDependency(added =3D "bindTransactionManager", removed =3D "u= nbindTransactionManager", required =3D true) > public void bindTransactionManager(final TransactionManager parTransa= ctionManager) > {//some code} > protected void configure(Dictionary parParameters) > { > myMvnoId =3D (String) parParameters.get(Constants.MVNO_CONFIG_TAG= ); > =20 > } > @Init > Map init() > { > Map m =3D new HashMap(); > String filter =3D "(com.ericsson.rm.config.tag=3D" + myMvnoId + "= )"; > m.put("Cryption.filter", Constants.MVNO_FILTER_PREFIX + myMvnoId + Const= ants.MVNO_SEPARATOR + "db)"); > m.put("EncryptionTokenService.filter", filter); > return m; > }=09 > Thanks -- This message was sent by Atlassian JIRA (v6.3.4#6332)