Skip to content

Commit

Permalink
[osgi] Solutions for eclipse/microprofile#33
Browse files Browse the repository at this point in the history
Signed-off-by: Raymond Auge <[email protected]>
  • Loading branch information
rotty3000 committed Aug 30, 2018
1 parent 05c282f commit 1beb751
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
16 changes: 15 additions & 1 deletion api/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,23 @@
org.eclipse.microprofile.*

Import-Package: \
javax.enterprise.util;version="[1.1,3)", \
javax.enterprise.*;-remove-attribute:=version, \
javax.inject;-remove-attribute:=version,\
*

Require-Capability: \
osgi.contract;\
osgi.contract=JavaCDI;\
filter:="(&(osgi.contract=JavaCDI)(version=${cdi.api.version}))",\
osgi.contract;\
osgi.contract=JavaInject;\
filter:="(&(osgi.contract=JavaInject)(version=${inject.api.version}))",\
osgi.serviceloader;\
filter:="(osgi.serviceloader=org.eclipse.microprofile.config.spi.ConfigProviderResolver)";\
cardinality:=multiple,\
osgi.extender;\
filter:="(osgi.extender=osgi.serviceloader.processor)"

Bundle-SymbolicName: org.eclipse.microprofile.config
Bundle-Name: MicroProfile Config Bundle
Bundle-License: Apache License, Version 2.0
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<version>3.4.0</version>
<version>3.5.0</version>

<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,27 @@ public ClassLoader run() {
ConfigProviderResolver instance = loadSpi(parentcl);

if (instance == null) {
ServiceLoader<ConfigProviderResolver> sl = ServiceLoader.load(
ConfigProviderResolver.class, cl);
for (ConfigProviderResolver spi : sl) {
if (instance != null) {
throw new IllegalStateException(
"Multiple ConfigResolverProvider implementations found: "
+ spi.getClass().getName() + " and "
+ instance.getClass().getName());
}
else {
instance = spi;
Thread thread = Thread.currentThread();
ClassLoader original = thread.getContextClassLoader();

try {
thread.setContextClassLoader(cl);

for (ConfigProviderResolver spi : ServiceLoader.load(ConfigProviderResolver.class)) {
if (instance != null) {
throw new IllegalStateException(
"Multiple ConfigResolverProvider implementations found: "
+ spi.getClass().getName() + " and "
+ instance.getClass().getName());
}
else {
instance = spi;
}
}
}
finally {
thread.setContextClassLoader(original);
}
}
return instance;
}
Expand Down
4 changes: 3 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

<checkstyle.version>2.17</checkstyle.version>
<checkstyle.methodNameFormat>^_?[a-z][a-zA-Z0-9]*$</checkstyle.methodNameFormat>
<cdi.api.version>1.1</cdi.api.version>
<inject.api.version>1.0</inject.api.version>
</properties>

<licenses>
Expand Down Expand Up @@ -105,7 +107,7 @@
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.2</version>
<version>${cdi.api.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian</groupId>
Expand Down

0 comments on commit 1beb751

Please sign in to comment.