Skip to content

Commit 1f8d55c

Browse files
committed
[osgifeature] create a working bundle
- use osgi.service.feature snapshot - use bnd and export OSGi API - add BundleActivator, register FeatureService Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
1 parent 47a3c77 commit 1f8d55c

3 files changed

Lines changed: 57 additions & 6 deletions

File tree

osgi-featuremodel/pom.xml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@
3131
<sling.java.version>11</sling.java.version>
3232
</properties>
3333

34+
<repositories>
35+
<repository>
36+
<id>snapshots-repo</id>
37+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
38+
<releases>
39+
<enabled>false</enabled>
40+
</releases>
41+
<snapshots>
42+
<enabled>true</enabled>
43+
</snapshots>
44+
</repository>
45+
</repositories>
3446
<build>
3547
<plugins>
3648
<plugin>
@@ -42,11 +54,10 @@
4254
</archive>
4355
</configuration>
4456
</plugin>
45-
<!--
4657
<plugin>
4758
<groupId>biz.aQute.bnd</groupId>
4859
<artifactId>bnd-maven-plugin</artifactId>
49-
<version>4.3.1</version>
60+
<version>5.3.0</version>
5061
<executions>
5162
<execution>
5263
<goals>
@@ -56,12 +67,14 @@
5667
</executions>
5768
<configuration>
5869
<bnd><![CDATA[
70+
Bundle-Activator: org.apache.sling.feature.osgi.impl.Activator
71+
Export-Package: org.osgi.service.feature
5972
-exportcontents: ${packages;VERSIONED}
6073
-removeheaders: Private-Package,Include-Resource
6174
]]></bnd>
6275
</configuration>
6376
</plugin>
64-
-->
77+
6578
<plugin>
6679
<groupId>org.apache.rat</groupId>
6780
<artifactId>apache-rat-plugin</artifactId>
@@ -83,8 +96,14 @@
8396
</dependency>
8497
<dependency>
8598
<groupId>org.osgi</groupId>
86-
<artifactId>osgi.core</artifactId>
87-
<version>8.0.0</version>
99+
<artifactId>org.osgi.framework</artifactId>
100+
<version>1.8.0</version>
101+
<scope>provided</scope>
102+
</dependency>
103+
<dependency>
104+
<groupId>org.osgi</groupId>
105+
<artifactId>org.osgi.service.feature</artifactId>
106+
<version>1.0.0-SNAPSHOT</version>
88107
<scope>provided</scope>
89108
</dependency>
90109
<dependency>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.apache.sling.feature.osgi.impl;
2+
3+
import java.util.Dictionary;
4+
import java.util.Hashtable;
5+
6+
import org.osgi.framework.BundleActivator;
7+
import org.osgi.framework.BundleContext;
8+
import org.osgi.framework.Constants;
9+
import org.osgi.framework.ServiceRegistration;
10+
import org.osgi.service.feature.FeatureService;
11+
12+
public class Activator implements BundleActivator {
13+
14+
private ServiceRegistration<FeatureService> reg = null;
15+
16+
@Override
17+
public void start(BundleContext context) throws Exception {
18+
19+
Dictionary<String, Object> dict = new Hashtable<>();
20+
dict.put(Constants.SERVICE_VENDOR, "sling");
21+
22+
reg = context.registerService(FeatureService.class, new FeatureServiceImpl(), dict);
23+
}
24+
25+
@Override
26+
public void stop(BundleContext context) throws Exception {
27+
reg.unregister();
28+
29+
}
30+
31+
}

osgi-featuremodel/src/main/java/org/apache/sling/feature/osgi/impl/FeatureServiceImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@
3939
import org.osgi.service.feature.FeatureConfigurationBuilder;
4040
import org.osgi.service.feature.FeatureExtension;
4141
import org.osgi.service.feature.FeatureExtensionBuilder;
42+
import org.osgi.service.feature.FeatureService;
4243
import org.osgi.service.feature.ID;
4344

44-
public class FeatureServiceImpl {
45+
public class FeatureServiceImpl implements FeatureService {
4546
private final BuilderFactoryImpl builderFactory = new BuilderFactoryImpl();
4647

4748
public BuilderFactory getBuilderFactory() {

0 commit comments

Comments
 (0)