-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Emily Jiang <[email protected]>
- Loading branch information
1 parent
66e2762
commit e12b038
Showing
6 changed files
with
37 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,10 +27,10 @@ | |
|
||
/** | ||
* This class is not intended to be used by end-users but for | ||
* portable container integration purpose only! | ||
* portable container integration purpose only. | ||
* | ||
* Service provider for ConfigProviderResolver. The implementation registers | ||
* itself via {@link java.util.ServiceLoader} mechanism. | ||
* itself via the {@link java.util.ServiceLoader} mechanism. | ||
* | ||
* @author <a href="mailto:[email protected]">Mark Struberg</a> | ||
* @author <a href="mailto:[email protected]">Romain Manni-Bucau</a> | ||
|
@@ -77,12 +77,12 @@ public static ConfigProviderResolver instance() { | |
if (instance != null) { | ||
return instance; | ||
} | ||
|
||
ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { | ||
@Override | ||
public ClassLoader run() { | ||
public ClassLoader run() { | ||
return Thread.currentThread().getContextClassLoader(); | ||
} | ||
} | ||
}); | ||
if (cl == null) { | ||
cl = ConfigProviderResolver.class.getClassLoader(); | ||
|
@@ -91,7 +91,8 @@ public ClassLoader run() { | |
ConfigProviderResolver newInstance = loadSpi(cl); | ||
|
||
if (newInstance == null) { | ||
throw new IllegalStateException("No ConfigProviderResolver implementation found!"); | ||
throw new IllegalStateException( | ||
"No ConfigProviderResolver implementation found!"); | ||
} | ||
|
||
instance = newInstance; | ||
|
@@ -110,21 +111,22 @@ private static ConfigProviderResolver loadSpi(ClassLoader cl) { | |
ConfigProviderResolver instance = loadSpi(cl.getParent()); | ||
|
||
if (instance == null) { | ||
ServiceLoader<ConfigProviderResolver> sl = ServiceLoader.load(ConfigProviderResolver.class, cl); | ||
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 { | ||
throw new IllegalStateException( | ||
"Multiple ConfigResolverProvider implementations found: " | ||
+ spi.getClass().getName() + " and " | ||
+ instance.getClass().getName()); | ||
} else { | ||
instance = spi; | ||
} | ||
} | ||
} | ||
return instance; | ||
} | ||
|
||
|
||
/** | ||
* Set the instance. It is used by OSGi environment while service loader | ||
* pattern is not supported. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,18 +20,18 @@ | |
import java.util.Map; | ||
|
||
/** | ||
* <p> Represent a config source, which provides properties. The config source includes: properties, xml, json files or datastore. <p> | ||
* <p> Represent a config source, which provides properties. The config source can encapsulate: properties, xml, json files or datastore data. <p> | ||
* The default config sources: | ||
* <ol> | ||
* <li>System properties (ordinal=400)</li> | ||
* <li>Environment properties (ordinal=300)</li> | ||
* <li>/META-INF/microprofile-config.properties (ordinal=100)</li> | ||
* </ol> | ||
* | ||
* <p>A ConfigSource will get picked up via the | ||
* {@link java.util.ServiceLoader} mechanism and must get registered via | ||
* <p>ConfigSource will get picked up via the | ||
* {@link java.util.ServiceLoader} mechanism and and can be registered via | ||
* META-INF/services/javax.config.spi.ConfigSource</p> | ||
* The other custom config source can be added programmatically via {@link org.eclipse.microprofile.config.ConfigProvider}. | ||
* Other custom config source can be added programmatically via {@link org.eclipse.microprofile.config.ConfigProvider}. | ||
* @author <a href="mailto:[email protected]">Mark Struberg</a> | ||
* @author <a href="mailto:[email protected]">Gerhard Petracek</a> | ||
* @author <a href="mailto:[email protected]">Emily Jiang</a> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,17 +18,16 @@ | |
|
||
package org.eclipse.microprofile.config.spi; | ||
|
||
|
||
/** | ||
* <p>Implement this interfaces to provide multiple ConfigSources. | ||
* This is e.g. needed if there are multiple property files of a given name.</p> | ||
* This is needed if there are multiple property files of a given name.</p> | ||
* | ||
* <p>If a ConfigSource like JNDI only exists once, then there is no need | ||
* to implement it via the ConfigSourceProvider but should directly | ||
* expose a {@link ConfigSource}.</p> | ||
* <p>If a single ConfigSource exists, then there is no need | ||
* to register it using a custom implementation of ConfigSourceProvider, it can be | ||
* registered directly as a {@link ConfigSource}.</p> | ||
* | ||
* <p>A ConfigSourceProvider will get picked up via the | ||
* {@link java.util.ServiceLoader} mechanism and must get registered via | ||
* {@link java.util.ServiceLoader} mechanism and can be registered via | ||
* META-INF/services/javax.config.spi.ConfigSourceProvider</p> | ||
* | ||
* @author <a href="mailto:[email protected]">Mark Struberg</a> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters