This is an automated email from the ASF dual-hosted git repository. davidb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-javax-activation.git
commit 76fa657f92c3f2035490c63b13dc072faadd3e16 Author: Konrad Windszus <[email protected]> AuthorDate: Mon Jul 27 17:11:22 2020 +0200 SLING-9603 update to newest parent (#3) use bnd-m-plugin instead of m-bundle-plugin SLING-8040 inline activation.jar --- pom.xml | 98 ++++++++++++++-------- .../sling/javax/activation/internal/Activator.java | 30 +++---- 2 files changed, 72 insertions(+), 56 deletions(-) diff --git a/pom.xml b/pom.xml index c12050a..af42cab 100755 --- a/pom.xml +++ b/pom.xml @@ -22,19 +22,19 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.sling</groupId> - <artifactId>sling</artifactId> - <version>34</version> + <artifactId>sling-bundle-parent</artifactId> + <version>39</version> <relativePath/> </parent> - + <artifactId>org.apache.sling.javax.activation</artifactId> - <packaging>bundle</packaging> <version>0.1.1-SNAPSHOT</version> <name>Apache Sling javax.activation bundle</name> <description>The Apache Sling javax.activation bundle contributes an OSGi-compatible activation bundle.</description> <properties> + <project.build.outputTimestamp>2019-10-02T08:04:00Z</project.build.outputTimestamp> <javax.activation.version>1.2.2</javax.activation.version> <site.javadoc.exclude>**.impl.**</site.javadoc.exclude> </properties> @@ -48,35 +48,63 @@ <build> <plugins> <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> + <groupId>biz.aQute.bnd</groupId> + <artifactId>bnd-maven-plugin</artifactId> <executions> <execution> - <id>bundle</id> - <goals><goal>bundle</goal></goals> + <id>bnd-process-nodeps</id> + <goals> + <goal>bnd-process</goal> + </goals> + <configuration> + <bnd><![CDATA[ +Bundle-Name: ${project.name} (No embedded dependencies) +Bundle-SymbolicName: ${project.artifactId}.nodeps +]]> + </bnd> + <manifestPath>${project.build.directory}/nodeps-classes/META-INF/MANIFEST.MF</manifestPath> + <outputDir>${project.build.directory}/nodeps-classes</outputDir> + </configuration> + </execution> + <execution> + <id>bnd-process</id> <configuration> - <instructions> - <Bundle-Activator>org.apache.sling.javax.activation.internal.Activator</Bundle-Activator> - <Export-Package>javax.activation;version=${javax.activation.version}</Export-Package> - <Embed-Dependency>*;scope=compile</Embed-Dependency> - </instructions> + <bnd><![CDATA[ +-includeresource:@jakarta.activation-[0-9.]*(-SNAPSHOT)?.jar +# version automatically determined from the MANIFEST.MF of the jakarta.activation.jar +Export-Package: javax.activation,com.sun.activation.registries,com.sun.activation.viewers +]]> + </bnd> + <manifestPath>${project.build.directory}/deps-classes/META-INF/MANIFEST.MF</manifestPath> + <outputDir>${project.build.directory}/deps-classes</outputDir> </configuration> </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <executions> <execution> - <id>nodepsbundle</id> - <goals><goal>bundle</goal></goals> + <id>default-jar</id> + <configuration> + <classesDirectory>${project.build.directory}/deps-classes</classesDirectory> + <archive> + <manifestFile>${project.build.directory}/deps-classes/META-INF/MANIFEST.MF</manifestFile> + </archive> + </configuration> + </execution> + <execution> + <id>jar-nodeps</id> + <goals> + <goal>jar</goal> + </goals> <configuration> <classifier>nodeps</classifier> - <instructions> - <Bundle-Name> - ${project.name} (No embedded dependencies) - </Bundle-Name> - <Bundle-SymbolicName> - ${project.artifactId}.nodeps - </Bundle-SymbolicName> - <Bundle-Activator>org.apache.sling.javax.activation.internal.Activator</Bundle-Activator> - </instructions> + <classesDirectory>${project.build.directory}/nodeps-classes</classesDirectory> + <archive> + <manifestFile>${project.build.directory}/nodeps-classes/META-INF/MANIFEST.MF</manifestFile> + </archive> </configuration> </execution> </executions> @@ -90,30 +118,26 @@ <artifactId>jakarta.activation</artifactId> <version>${javax.activation.version}</version> </dependency> - <!-- Compendium 4.2.0 is needed to access BundleTracker --> <dependency> <groupId>org.osgi</groupId> - <artifactId>org.osgi.compendium</artifactId> - <version>4.2.0</version> + <artifactId>org.osgi.annotation.bundle</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.osgi</groupId> - <artifactId>org.osgi.core</artifactId> - <version>4.2.0</version> + <artifactId>org.osgi.framework</artifactId> <scope>provided</scope> </dependency> <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.util.tracker</artifactId> + <version>1.5.1</version> <scope>provided</scope> </dependency> - - <!-- Test dependencies --> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>provided</scope> </dependency> </dependencies> </project> diff --git a/src/main/java/org/apache/sling/javax/activation/internal/Activator.java b/src/main/java/org/apache/sling/javax/activation/internal/Activator.java index 626613a..751abeb 100755 --- a/src/main/java/org/apache/sling/javax/activation/internal/Activator.java +++ b/src/main/java/org/apache/sling/javax/activation/internal/Activator.java @@ -25,10 +25,12 @@ import java.net.URL; import javax.activation.CommandMap; import javax.activation.MailcapCommandMap; +import org.osgi.annotation.bundle.Header; import org.osgi.framework.Bundle; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleEvent; +import org.osgi.framework.Constants; import org.osgi.util.tracker.BundleTracker; import org.osgi.util.tracker.BundleTrackerCustomizer; import org.slf4j.Logger; @@ -47,12 +49,13 @@ import org.slf4j.LoggerFactory; * </p> * */ +@Header(name = Constants.BUNDLE_ACTIVATOR, value = "${@class}") public class Activator implements BundleActivator { private static final String MAILCAP_FILE_NAME = "/META-INF/mailcap"; private static final Logger log = LoggerFactory.getLogger(Activator.class); - private BundleTracker bundleTracker; + private BundleTracker<Void> bundleTracker; private OsgiMailcapCommandMap commandMap; public void start(BundleContext context) throws Exception { @@ -64,21 +67,21 @@ public class Activator implements BundleActivator { CommandMap.setDefaultCommandMap(commandMap); - bundleTracker = new BundleTracker(context, Bundle.ACTIVE | Bundle.UNINSTALLED | Bundle.STOP_TRANSIENT, - new BundleTrackerCustomizer() { + bundleTracker = new BundleTracker<>(context, Bundle.ACTIVE | Bundle.UNINSTALLED | Bundle.STOP_TRANSIENT, + new BundleTrackerCustomizer<Void>() { - public void removedBundle(Bundle bundle, BundleEvent event, Object object) { + public void removedBundle(Bundle bundle, BundleEvent event, Void object) { unregisterBundleMailcapEntries(bundle); } - public void modifiedBundle(Bundle bundle, BundleEvent event, Object object) { + public void modifiedBundle(Bundle bundle, BundleEvent event, Void object) { unregisterBundleMailcapEntries(bundle); registerBundleMailcapEntries(bundle); } - public Object addingBundle(Bundle bundle, BundleEvent event) { + public Void addingBundle(Bundle bundle, BundleEvent event) { registerBundleMailcapEntries(bundle); - return bundle; + return null; } }); @@ -94,21 +97,10 @@ public class Activator implements BundleActivator { if (mailcapEntry == null) return; - InputStream input = null; - - try { - input = mailcapEntry.openStream(); - + try (InputStream input = mailcapEntry.openStream()) { commandMap.addMailcapEntries(input, bundle); - } catch (IOException e) { log.warn("Failed loading " + MAILCAP_FILE_NAME + " from bundle " + bundle, e); - } finally { - try { - input.close(); - } catch (IOException e) { - // don't care - } } }
