blob: 5faf508aaf54e0d87e990fa457596af9fb43ba0e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.osgi.test.counterservice;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
/**
* A service which must be imported by another bundle to be used
*
* @author bratseth
*/
public class CounterServiceImpl implements CounterService, BundleActivator {
private int counter=0;
private ServiceRegistration counterServiceRegistration;
public void start(BundleContext context) {
counterServiceRegistration=context.registerService(CounterService.class.getName(), this, null);
}
public void stop(BundleContext context) {
counterServiceRegistration.unregister();
}
public int getCounter() {
return counter;
}
public void incrementCounter() {
counter++;
}
}
|