Skip to content

Commit

Permalink
[osgifeature] create a working bundle
Browse files Browse the repository at this point in the history
- use osgi.service.feature snapshot
- use bnd and export OSGi API
- add BundleActivator, register FeatureService

Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
  • Loading branch information
stbischof committed Jun 15, 2021
1 parent 47a3c77 commit 1f8d55c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 6 deletions.
29 changes: 24 additions & 5 deletions osgi-featuremodel/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@
<sling.java.version>11</sling.java.version>
</properties>

<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<build>
<plugins>
<plugin>
Expand All @@ -42,11 +54,10 @@
</archive>
</configuration>
</plugin>
<!--
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<version>4.3.1</version>
<version>5.3.0</version>
<executions>
<execution>
<goals>
Expand All @@ -56,12 +67,14 @@
</executions>
<configuration>
<bnd><![CDATA[
Bundle-Activator: org.apache.sling.feature.osgi.impl.Activator
Export-Package: org.osgi.service.feature
-exportcontents: ${packages;VERSIONED}
-removeheaders: Private-Package,Include-Resource
]]></bnd>
</configuration>
</plugin>
-->

<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
Expand All @@ -83,8 +96,14 @@
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.core</artifactId>
<version>8.0.0</version>
<artifactId>org.osgi.framework</artifactId>
<version>1.8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.feature</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.apache.sling.feature.osgi.impl;

import java.util.Dictionary;
import java.util.Hashtable;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.feature.FeatureService;

public class Activator implements BundleActivator {

private ServiceRegistration<FeatureService> reg = null;

@Override
public void start(BundleContext context) throws Exception {

Dictionary<String, Object> dict = new Hashtable<>();
dict.put(Constants.SERVICE_VENDOR, "sling");

reg = context.registerService(FeatureService.class, new FeatureServiceImpl(), dict);
}

@Override
public void stop(BundleContext context) throws Exception {
reg.unregister();

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@
import org.osgi.service.feature.FeatureConfigurationBuilder;
import org.osgi.service.feature.FeatureExtension;
import org.osgi.service.feature.FeatureExtensionBuilder;
import org.osgi.service.feature.FeatureService;
import org.osgi.service.feature.ID;

public class FeatureServiceImpl {
public class FeatureServiceImpl implements FeatureService {
private final BuilderFactoryImpl builderFactory = new BuilderFactoryImpl();

public BuilderFactory getBuilderFactory() {
Expand Down

0 comments on commit 1f8d55c

Please sign in to comment.