felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MarcoF90 <marco.fierimo...@gmail.com>
Subject Re: Re[2]: Declarative Services problems in Apache Karaf
Date Fri, 17 Nov 2017 10:20:06 GMT
Hi Thomas,

thank you for the example. I will certainly go into the specifications in
more detail. 
What I need is a component that collects all the services that will then be
used in the bundle. 
When all services are available, the bundle starts all bootstrap operations
and starts processing logic. 
If a service (of another bundle) updates itself, 
I would like this service collector to update its reference without
reactivating. 
If I have understood well the combination of properties that allows me to
obtain 
this is: policy = DYNAMIC, policyOption = GREEDY, cardinality = MULTIPLE and
@Component (immediate = true).

EXAMPLE:

@Component 
public class AImpl implements A {} 

@Component 
public class BImpl implements B {} 

@Component(immediate = true)
public class ServicesCollector { 

    private A a; 	 
	private B b; 
	private Bootstrap boostrap; 
	 
	@Activate
	public void activate(BundleContext bundleContext) {
		boostrap.start();
	}

	@Deactivate
	public void deactivate() {
		boostrap.stop();
	}
	 
	 @Reference(cardinality = ReferenceCardinality.MULTIPLE, 
                           policy = ReferencePolicy.DYNAMIC,         
                           policyOption = ReferencePolicyOption.GREEDY)
	 public void setA(A a) {this.a = a}
	 
	 public void unsetA(A a) {}
	 
	 @Reference(cardinality = ReferenceCardinality.MULTIPLE,
                           policy = ReferencePolicy.DYNAMIC, 
                           policyOption = ReferencePolicyOption.GREEDY)
	 public void setB(B b) {this.b = b}
	 
	 public void unsetB(B a) {}
	 
} 

Are there no other options right? thanks for your helps.

Kind regards, 
Marco




--
Sent from: http://apache-felix.18485.x6.nabble.com/Apache-Felix-Users-f4833200.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Mime
View raw message