adding cxf-rs cepage and jaxrs sample
diff --git a/winegrower-cepages/pom.xml b/winegrower-cepages/pom.xml
index 467ccf9..5065806 100644
--- a/winegrower-cepages/pom.xml
+++ b/winegrower-cepages/pom.xml
@@ -30,6 +30,7 @@
<relativePath>../pom.xml</relativePath>
</parent>
+ <groupId>org.apache.winegrower.cepages</groupId>
<artifactId>winegrower-cepages</artifactId>
<name>Apache Winegrower :: Cepages</name>
<packaging>pom</packaging>
@@ -40,6 +41,19 @@
<modules>
<module>winegrower-cepage-shell</module>
+ <module>winegrower-cepage-cxf-rs</module>
</modules>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.1.0</version>
+ <configuration>
+ <skipIfEmpty>true</skipIfEmpty>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
diff --git a/winegrower-cepages/winegrower-cepage-cxf-rs/pom.xml b/winegrower-cepages/winegrower-cepage-cxf-rs/pom.xml
new file mode 100644
index 0000000..1d4ea46
--- /dev/null
+++ b/winegrower-cepages/winegrower-cepage-cxf-rs/pom.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.apache.winegrower.cepages</groupId>
+ <artifactId>winegrower-cepages</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>cxf-rs</artifactId>
+ <name>Apache Winegrower :: Cepages :: CXF JAX-RS</name>
+
+ <properties>
+ <cxf.version>3.2.6</cxf.version>
+ <pax-web.version>7.2.3</pax-web.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-client</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.cmpn</artifactId>
+ <version>${osgi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.cm</artifactId>
+ <version>1.3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.webosgi</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.proxy</groupId>
+ <artifactId>org.apache.aries.proxy</artifactId>
+ <version>1.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
+ </dependency>
+ <dependency> <!-- todo: use tomcat ? -->
+ <groupId>org.ops4j.pax.web</groupId>
+ <artifactId>pax-web-jetty</artifactId>
+ <version>${pax-web.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty.aggregate</groupId>
+ <artifactId>jetty-all</artifactId>
+ <classifier>uber</classifier>
+ <version>9.4.11.v20180605</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm-commons</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.web</groupId>
+ <artifactId>pax-web-runtime</artifactId>
+ <version>${pax-web.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.web</groupId>
+ <artifactId>pax-web-extender-whiteboard</artifactId>
+ <version>${pax-web.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.web</groupId>
+ <artifactId>pax-web-api</artifactId>
+ <version>${pax-web.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.web</groupId>
+ <artifactId>pax-web-spi</artifactId>
+ <version>${pax-web.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.web</groupId>
+ <artifactId>org.apache.karaf.web.core</artifactId>
+ <version>${karaf.version}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/winegrower-cepages/winegrower-cepage-shell/pom.xml b/winegrower-cepages/winegrower-cepage-shell/pom.xml
index e14162b..00f8729 100644
--- a/winegrower-cepages/winegrower-cepage-shell/pom.xml
+++ b/winegrower-cepages/winegrower-cepage-shell/pom.xml
@@ -24,13 +24,12 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.apache.winegrower</groupId>
+ <groupId>org.apache.winegrower.cepages</groupId>
<artifactId>winegrower-cepages</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <groupId>org.apache.winegrower.cepages</groupId>
<artifactId>shell</artifactId>
<name>Apache Winegrower :: Cepages :: Shell</name>
diff --git a/winegrower-core/pom.xml b/winegrower-core/pom.xml
index b05224f..05d0383 100644
--- a/winegrower-core/pom.xml
+++ b/winegrower-core/pom.xml
@@ -43,6 +43,11 @@
<artifactId>org.osgi.core</artifactId>
</dependency>
<dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.cmpn</artifactId>
+ <version>${osgi.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-finder-shaded</artifactId>
</dependency>
diff --git a/winegrower-core/src/main/java/org/apache/winegrower/Ripener.java b/winegrower-core/src/main/java/org/apache/winegrower/Ripener.java
index 2d241bc..4eff244 100644
--- a/winegrower-core/src/main/java/org/apache/winegrower/Ripener.java
+++ b/winegrower-core/src/main/java/org/apache/winegrower/Ripener.java
@@ -14,7 +14,6 @@
package org.apache.winegrower;
import static java.util.Arrays.asList;
-import static java.util.Comparator.comparing;
import static java.util.stream.Collectors.toList;
import java.io.File;
@@ -28,7 +27,7 @@
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Collection;
-import java.util.Comparator;
+import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.UUID;
@@ -41,6 +40,7 @@
import org.apache.winegrower.deployer.OSGiBundleLifecycle;
import org.apache.winegrower.scanner.StandaloneScanner;
import org.apache.winegrower.scanner.manifest.ActivatorManifestContributor;
+import org.apache.winegrower.scanner.manifest.BlueprintManifestContributor;
import org.apache.winegrower.scanner.manifest.KarafCommandManifestContributor;
import org.apache.winegrower.scanner.manifest.ManifestContributor;
import org.apache.winegrower.service.BundleRegistry;
@@ -77,9 +77,25 @@
private Collection<String> scanningIncludes;
private Collection<String> scanningExcludes;
private Collection<ManifestContributor> manifestContributors = Stream.concat(
- Stream.of(new KarafCommandManifestContributor(), new ActivatorManifestContributor()), // built-in
- StreamSupport.stream(ServiceLoader.load(ManifestContributor.class).spliterator(), false) // extensions
+ // built-in
+ Stream.of(new KarafCommandManifestContributor(), new ActivatorManifestContributor(), new BlueprintManifestContributor()),
+ // extensions
+ StreamSupport.stream(ServiceLoader.load(ManifestContributor.class).spliterator(), false)
).collect(toList());
+ // known bundles
+ private List<String> prioritizedBundles = asList(
+ "org.apache.aries.blueprint.core",
+ "org.apache.aries.blueprint.cm",
+ "pax-web-extender-whiteboard",
+ "pax-web-runtime");
+
+ public List<String> getPrioritizedBundles() {
+ return prioritizedBundles;
+ }
+
+ public void setPrioritizedBundles(final List<String> prioritizedBundles) {
+ this.prioritizedBundles = prioritizedBundles;
+ }
public Collection<ManifestContributor> getManifestContributors() {
return manifestContributors;
@@ -156,7 +172,7 @@
final StandaloneScanner scanner = new StandaloneScanner(configuration, registry.getFramework());
final AtomicLong bundleIdGenerator = new AtomicLong(1);
Stream.concat(scanner.findOSGiBundles().stream(), scanner.findPotentialOSGiBundles().stream())
- .sorted(comparing(b -> b.getJar().getName()))
+ .sorted(this::compareBundles)
.map(it -> new OSGiBundleLifecycle(it.getManifest(), it.getJar(), services, registry, configuration, bundleIdGenerator.getAndIncrement()))
.peek(OSGiBundleLifecycle::start)
.peek(it -> registry.getBundles().put(it.getBundle().getBundleId(), it))
@@ -207,6 +223,29 @@
public void close() {
stop();
}
+
+ private int compareBundles(final StandaloneScanner.BundleDefinition bundle1, final StandaloneScanner.BundleDefinition bundle2) {
+ final int index1 = matchPriorities(bundle1.getJar().getName());
+ final int index2 = matchPriorities(bundle2.getJar().getName());
+ if (index1 == index2) {
+ return bundle1.getJar().getName().compareTo(bundle2.getJar().getName());
+ }
+ if (index1 == -1) {
+ return 1;
+ }
+ if (index2 == -1) {
+ return -1;
+ }
+ return index1 - index2;
+ }
+
+ private int matchPriorities(final String name) {
+ return configuration.getPrioritizedBundles().stream()
+ .filter(name::startsWith)
+ .findFirst()
+ .map(it -> configuration.getPrioritizedBundles().indexOf(it))
+ .orElse(-1);
+ }
}
static void main(final String[] args) {
diff --git a/winegrower-core/src/main/java/org/apache/winegrower/deployer/BundleContextImpl.java b/winegrower-core/src/main/java/org/apache/winegrower/deployer/BundleContextImpl.java
index 1112c8a..e0ebd9d 100644
--- a/winegrower-core/src/main/java/org/apache/winegrower/deployer/BundleContextImpl.java
+++ b/winegrower-core/src/main/java/org/apache/winegrower/deployer/BundleContextImpl.java
@@ -23,8 +23,10 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Dictionary;
+import java.util.Objects;
import java.util.function.Supplier;
import java.util.jar.Manifest;
+import java.util.stream.Stream;
import org.apache.winegrower.service.BundleRegistry;
import org.apache.winegrower.service.OSGiServices;
@@ -168,8 +170,24 @@
@Override
public ServiceReference<?>[] getServiceReferences(final String clazz, final String filter) {
final Filter predicate = filter == null ? null : createFilter(filter);
+ final Bundle bundle = getBundle();
+ final Class<?> expected;
+ try {
+ expected = clazz == null ? Object.class : bundle.loadClass(clazz);
+ } catch (final ClassNotFoundException e) {
+ return new ServiceReference<?>[0];
+ }
return services.getServices().stream()
- .filter(it -> asList(ServiceRegistrationImpl.class.cast(it).getClasses()).contains(clazz))
+ .filter(it -> Stream.of(ServiceRegistrationImpl.class.cast(it).getClasses())
+ .map(name -> {
+ try {
+ return bundle.loadClass(name);
+ } catch (final NoClassDefFoundError | ClassNotFoundException e) {
+ return null;
+ }
+ })
+ .filter(Objects::nonNull)
+ .anyMatch(expected::isAssignableFrom))
.filter(it -> predicate == null || predicate.match(it.getReference()))
.map(it -> ServiceRegistrationImpl.class.cast(it).getReference())
.toArray(ServiceReference[]::new);
diff --git a/winegrower-core/src/main/java/org/apache/winegrower/deployer/BundleImpl.java b/winegrower-core/src/main/java/org/apache/winegrower/deployer/BundleImpl.java
index 033e1ec..d523b69 100644
--- a/winegrower-core/src/main/java/org/apache/winegrower/deployer/BundleImpl.java
+++ b/winegrower-core/src/main/java/org/apache/winegrower/deployer/BundleImpl.java
@@ -51,6 +51,7 @@
import org.osgi.framework.Constants;
import org.osgi.framework.Filter;
import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.Version;
import org.osgi.framework.wiring.BundleWiring;
@@ -167,6 +168,7 @@
public ServiceReference<?>[] getRegisteredServices() {
return context.getServices().getServices().stream()
.filter(it -> it.getReference().getBundle() == this)
+ .map(ServiceRegistration::getReference)
.toArray(ServiceReference[]::new);
}
diff --git a/winegrower-core/src/main/java/org/apache/winegrower/deployer/OSGiBundleLifecycle.java b/winegrower-core/src/main/java/org/apache/winegrower/deployer/OSGiBundleLifecycle.java
index 2b243a2..78ff557 100644
--- a/winegrower-core/src/main/java/org/apache/winegrower/deployer/OSGiBundleLifecycle.java
+++ b/winegrower-core/src/main/java/org/apache/winegrower/deployer/OSGiBundleLifecycle.java
@@ -82,4 +82,9 @@
}
bundle.onStop();
}
+
+ @Override
+ public String toString() {
+ return "OSGiBundleLifecycle{bundle=" + bundle + '}';
+ }
}
diff --git a/winegrower-core/src/main/java/org/apache/winegrower/scanner/manifest/BlueprintManifestContributor.java b/winegrower-core/src/main/java/org/apache/winegrower/scanner/manifest/BlueprintManifestContributor.java
new file mode 100644
index 0000000..ec782e6
--- /dev/null
+++ b/winegrower-core/src/main/java/org/apache/winegrower/scanner/manifest/BlueprintManifestContributor.java
@@ -0,0 +1,52 @@
+package org.apache.winegrower.scanner.manifest;
+
+import static java.util.Collections.list;
+import static java.util.Optional.ofNullable;
+import static java.util.stream.Collectors.joining;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.function.Supplier;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.stream.Stream;
+import java.util.zip.ZipEntry;
+
+import org.apache.xbean.finder.AnnotationFinder;
+import org.apache.xbean.finder.archive.Archive;
+import org.apache.xbean.finder.archive.FileArchive;
+import org.apache.xbean.finder.archive.JarArchive;
+import org.apache.xbean.finder.util.Files;
+
+public class BlueprintManifestContributor implements ManifestContributor {
+ @Override
+ public void contribute(final AnnotationFinder finder, final Supplier<Manifest> manifest) {
+ final Archive archive = finder.getArchive();
+ if (JarArchive.class.isInstance(archive)) {
+ try (final JarFile jar = new JarFile(Files.toFile(JarArchive.class.cast(archive).getUrl()))) {
+ addBlueprintEntries(manifest, list(jar.entries()).stream()
+ .filter(it -> it.getName().startsWith("OSGI-INF/blueprint/") && it.getName().endsWith(".xml"))
+ .map(ZipEntry::getName)
+ .collect(joining(",")));
+ } catch (final IOException e) {
+ // no-op
+ }
+ } else if (FileArchive.class.isInstance(archive)) {
+ final File base = FileArchive.class.cast(archive).getDir();
+ final File blueprint = new File(base, "OSGI-INF/blueprint/");
+ if (blueprint.isDirectory()) {
+ addBlueprintEntries(manifest, Stream.of(ofNullable(blueprint.list()).orElseGet(() -> new String[0]))
+ .filter(it -> it.endsWith(".xml"))
+ .map(it -> "OSGI-INF/blueprint/" + it)
+ .collect(joining(",")));
+ }
+ }
+ }
+
+ private void addBlueprintEntries(final Supplier<Manifest> manifest, final String list) {
+ if (list.isEmpty()) {
+ return;
+ }
+ manifest.get().getMainAttributes().putValue("Bundle-Blueprint", list);
+ }
+}
diff --git a/winegrower-core/src/main/java/org/apache/winegrower/service/OSGiServices.java b/winegrower-core/src/main/java/org/apache/winegrower/service/OSGiServices.java
index 62e0520..64351c0 100644
--- a/winegrower-core/src/main/java/org/apache/winegrower/service/OSGiServices.java
+++ b/winegrower-core/src/main/java/org/apache/winegrower/service/OSGiServices.java
@@ -14,12 +14,13 @@
package org.apache.winegrower.service;
import static java.util.Arrays.asList;
+import static java.util.Collections.list;
+import static java.util.stream.Collectors.toList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Dictionary;
import java.util.Hashtable;
-import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Stream;
@@ -34,6 +35,8 @@
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
// holder of all services
public class OSGiServices {
@@ -110,7 +113,7 @@
final Bundle from) {
final Hashtable<String, Object> serviceProperties = new Hashtable<>();
if (properties != null) {
- serviceProperties.putAll(Map.class.cast(properties));
+ list(properties.keys()).forEach(key -> serviceProperties.put(key, properties.get(key)));
}
serviceProperties.put(Constants.OBJECTCLASS, classes);
serviceProperties.put(Constants.SERVICE_ID, idGenerator.getAndIncrement());
@@ -132,13 +135,21 @@
});
services.add(registration);
final ServiceEvent event = new ServiceEvent(ServiceEvent.REGISTERED, registration.getReference());
+ if (ManagedService.class.isInstance(service)) {
+ try {
+ ManagedService.class.cast(service).updated(properties);
+ } catch (final ConfigurationException e) {
+ throw new IllegalStateException(e);
+ }
+ }
getListeners(registration).forEach(listener -> listener.listener.serviceChanged(event));
return registration;
}
- private Stream<ServiceListenerDefinition> getListeners(final ServiceRegistration<?> reg) {
+ private Collection<ServiceListenerDefinition> getListeners(final ServiceRegistration<?> reg) {
return serviceListeners.stream()
- .filter(it -> it.filter == null || it.filter.match(reg.getReference()));
+ .filter(it -> it.filter == null || it.filter.match(reg.getReference()))
+ .collect(toList());
}
public synchronized Collection<ServiceRegistration<?>> getServices() {
diff --git a/winegrower-core/src/test/java/org/apache/winegrower/RipenerTest.java b/winegrower-core/src/test/java/org/apache/winegrower/RipenerTest.java
index 096ab4c..dd927bd 100644
--- a/winegrower-core/src/test/java/org/apache/winegrower/RipenerTest.java
+++ b/winegrower-core/src/test/java/org/apache/winegrower/RipenerTest.java
@@ -71,13 +71,13 @@
@Test
@WithRipener
void ensureFrameworkBundle(@Service final Ripener ripener) {
- assertEquals(1, ripener.getRegistry().getBundles().size());
+ assertEquals(2, ripener.getRegistry().getBundles().size());
}
@Test
@WithRipener(includeResources = @Entry(path = "org.apache.winegrower.test.simpleactivator"))
void simpleActivator(@Service final Ripener ripener) {
- assertEquals(2, ripener.getRegistry().getBundles().size());
+ assertEquals(3, ripener.getRegistry().getBundles().size());
final BundleActivatorHandler activatorHandler = ripener.getRegistry().getBundles().values().stream()
.filter(it -> it.getActivator() != null)
diff --git a/winegrower-examples/jaxrs/pom.xml b/winegrower-examples/jaxrs/pom.xml
new file mode 100644
index 0000000..b2a2b1d
--- /dev/null
+++ b/winegrower-examples/jaxrs/pom.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>winegrower-examples</artifactId>
+ <groupId>org.apache.winegrower</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>jaxrs</artifactId>
+ <name>Apache Winegrower :: Examples :: JAX-RS</name>
+ <description>
+ Run "mvn package winegrower:pour" then hit http://localhost:8080/cxf/api/harvest.
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.winegrower</groupId>
+ <artifactId>winegrower-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.winegrower.cepages</groupId>
+ <artifactId>cxf-rs</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.winegrower</groupId>
+ <artifactId>winegrower-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/winegrower-examples/jaxrs/src/main/java/org/apache/winegrower/example/jaxrs/Harvest.java b/winegrower-examples/jaxrs/src/main/java/org/apache/winegrower/example/jaxrs/Harvest.java
new file mode 100644
index 0000000..4bc8801
--- /dev/null
+++ b/winegrower-examples/jaxrs/src/main/java/org/apache/winegrower/example/jaxrs/Harvest.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.winegrower.example.jaxrs;
+
+import java.time.LocalDate;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+@Path("harvest")
+public class Harvest {
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public String get() {
+ return "{\"year\":\"" + LocalDate.now().getYear() + "\"}";
+ }
+}
diff --git a/winegrower-examples/jaxrs/src/main/resources/OSGI-INF/blueprint/server.xml b/winegrower-examples/jaxrs/src/main/resources/OSGI-INF/blueprint/server.xml
new file mode 100644
index 0000000..bc0b828
--- /dev/null
+++ b/winegrower-examples/jaxrs/src/main/resources/OSGI-INF/blueprint/server.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs"
+ xmlns:cxf="http://cxf.apache.org/blueprint/core"
+ xsi:schemaLocation="
+ http://www.osgi.org/xmlns/blueprint/v1.0.0
+ http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
+ http://cxf.apache.org/blueprint/jaxrs
+ http://cxf.apache.org/schemas/blueprint/jaxrs.xsd
+ http://cxf.apache.org/blueprint/core
+ http://cxf.apache.org/schemas/blueprint/core.xsd">
+ <cxf:bus>
+ <cxf:features>
+ <cxf:logging/>
+ </cxf:features>
+ </cxf:bus>
+
+ <jaxrs:server id="harvestServer" address="/api">
+ <jaxrs:serviceBeans>
+ <bean class="org.apache.winegrower.example.jaxrs.Harvest"/>
+ </jaxrs:serviceBeans>
+ </jaxrs:server>
+</blueprint>
diff --git a/winegrower-examples/pom.xml b/winegrower-examples/pom.xml
index 9aa8f9d..525f2ab 100644
--- a/winegrower-examples/pom.xml
+++ b/winegrower-examples/pom.xml
@@ -40,6 +40,7 @@
<!-- <module>services</module> -->
<!-- <module>scr</module> -->
<module>shell</module>
+ <module>jaxrs</module>
<!-- <module>monitoring</module> -->
<!-- <module>cdi</module> -->
<!-- <module>spring</module> -->
diff --git a/winegrower-extension/winegrower-build/winegrower-maven-plugin/src/main/java/org/apache/winegrower/extension/build/maven/PourMojo.java b/winegrower-extension/winegrower-build/winegrower-maven-plugin/src/main/java/org/apache/winegrower/extension/build/maven/PourMojo.java
index 72eda8b..10e69d8 100644
--- a/winegrower-extension/winegrower-build/winegrower-maven-plugin/src/main/java/org/apache/winegrower/extension/build/maven/PourMojo.java
+++ b/winegrower-extension/winegrower-build/winegrower-maven-plugin/src/main/java/org/apache/winegrower/extension/build/maven/PourMojo.java
@@ -13,6 +13,7 @@
*/
package org.apache.winegrower.extension.build.maven;
+import static java.util.Collections.singletonList;
import static java.util.Optional.ofNullable;
import static java.util.stream.Collectors.toList;
import static org.apache.maven.plugins.annotations.ResolutionScope.RUNTIME_PLUS_SYSTEM;
@@ -60,6 +61,9 @@
@Parameter(property = "winegrower.dependencyScopes", defaultValue = "provided,compile,system,runtime")
private Collection<String> dependencyScopes;
+ @Parameter(property = "winegrower.prioritizedBundles", defaultValue = "org.apache.aries.blueprint.core")
+ private Collection<String> prioritizedBundles;
+
@Parameter(property = "winegrower.systemVariables")
private Map<String, String> systemVariables;
@@ -129,6 +133,7 @@
private Ripener.Configuration createConfiguration() {
final Ripener.Configuration configuration = new Ripener.Configuration();
ofNullable(workDir).ifPresent(configuration::setWorkDir);
+ ofNullable(prioritizedBundles).filter(it -> !it.isEmpty()).ifPresent(configuration::setPrioritizedBundles);
ofNullable(scanningIncludes).filter(it -> !it.isEmpty()).ifPresent(configuration::setScanningIncludes);
ofNullable(scanningExcludes).filter(it -> !it.isEmpty()).ifPresent(configuration::setScanningIncludes);
ofNullable(manifestContributors).filter(it -> !it.isEmpty()).ifPresent(contributors -> {
diff --git a/winegrower-extension/winegrower-testing/winegrower-testing-junit5/src/main/java/org/apache/winegrower/extension/testing/junit5/Winegrower.java b/winegrower-extension/winegrower-testing/winegrower-testing-junit5/src/main/java/org/apache/winegrower/extension/testing/junit5/Winegrower.java
index b933e24..7cad83b 100644
--- a/winegrower-extension/winegrower-testing/winegrower-testing-junit5/src/main/java/org/apache/winegrower/extension/testing/junit5/Winegrower.java
+++ b/winegrower-extension/winegrower-testing/winegrower-testing-junit5/src/main/java/org/apache/winegrower/extension/testing/junit5/Winegrower.java
@@ -32,6 +32,7 @@
@ExtendWith(WinegrowerExtension.class)
public @interface Winegrower {
String workDir() default "";
+ String[] prioritizedBundles() default {};
Class<? extends ManifestContributor>[] manifestContributor() default {};
Class<? extends JarFilter> jarFilter() default JarFilter.class;
String[] scanningExcludes() default {};
diff --git a/winegrower-extension/winegrower-testing/winegrower-testing-junit5/src/main/java/org/apache/winegrower/extension/testing/junit5/internal/WinegrowerExtension.java b/winegrower-extension/winegrower-testing/winegrower-testing-junit5/src/main/java/org/apache/winegrower/extension/testing/junit5/internal/WinegrowerExtension.java
index 91fdf15..efb4191 100644
--- a/winegrower-extension/winegrower-testing/winegrower-testing-junit5/src/main/java/org/apache/winegrower/extension/testing/junit5/internal/WinegrowerExtension.java
+++ b/winegrower-extension/winegrower-testing/winegrower-testing-junit5/src/main/java/org/apache/winegrower/extension/testing/junit5/internal/WinegrowerExtension.java
@@ -51,6 +51,9 @@
of(winegrower.workDir())
.filter(it -> !it.isEmpty())
.ifPresent(wd -> configuration.setWorkDir(new File(wd)));
+ of(winegrower.prioritizedBundles())
+ .filter(it -> it.length > 0)
+ .ifPresent(prioritizedBundles -> configuration.setScanningIncludes(asList(prioritizedBundles)));
of(winegrower.scanningIncludes())
.filter(it -> it.length > 0)
.ifPresent(includes -> configuration.setScanningIncludes(asList(includes)));