Skip to content

Commit

Permalink
Provider Interface Support SPI & Optimize ProviderManager SPI (#4218
Browse files Browse the repository at this point in the history
)

* Provider & ProviderManager support spi

* add default implementation for method `com.ctrip.framework.foundation.spi.ProviderManager.getOrder`

* rollback

* rollback

* update CHANGES.md

* Update CHANGES.md

Co-authored-by: Jason Song <[email protected]>
  • Loading branch information
darcydai and nobodyiam authored Jan 29, 2022
1 parent ced8ad9 commit e3448dd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Apollo 2.0.0
* [Make password check not hardcoded](https://github.com/apolloconfig/apollo/pull/4207)
* [Fix update user's password failure](https://github.com/apolloconfig/apollo/pull/4212)
* [Fix bug: associated namespace display incorrect in text view](https://github.com/apolloconfig/apollo/pull/4219)
* [Add Ordered interface to ProviderManager SPI](https://github.com/apolloconfig/apollo/pull/4218)

------------------
All issues and pull requests are [here](https://github.com/ctripcorp/apollo/milestone/8?closed=1)
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
import org.slf4j.LoggerFactory;

public abstract class Foundation {

private static final Logger logger = LoggerFactory.getLogger(Foundation.class);
private static Object lock = new Object();
private static final Object LOCK = new Object();

private static volatile ProviderManager s_manager;

Expand All @@ -40,9 +41,9 @@ private static ProviderManager getManager() {
try {
if (s_manager == null) {
// Double locking to make sure only one thread initializes ProviderManager.
synchronized (lock) {
synchronized (LOCK) {
if (s_manager == null) {
s_manager = ServiceBootstrap.loadFirst(ProviderManager.class);
s_manager = ServiceBootstrap.loadPrimary(ProviderManager.class);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private void initAppLabel() {
return;
}

m_appLabel=null;
m_appLabel = null;
logger.warn("app.label is not available from System Property and {}. It is set to null",
APP_PROPERTIES_CLASSPATH);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@
*/
package com.ctrip.framework.foundation.spi;

import com.ctrip.framework.apollo.core.spi.Ordered;
import com.ctrip.framework.foundation.spi.provider.Provider;

public interface ProviderManager {
public interface ProviderManager extends Ordered {

String getProperty(String name, String defaultValue);

<T extends Provider> T provider(Class<T> clazz);

@Override
default int getOrder() {
return Ordered.LOWEST_PRECEDENCE;
}
}

0 comments on commit e3448dd

Please sign in to comment.