Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provider Interface Support SPI & Optimize ProviderManager SPI #4218

Merged
merged 7 commits into from
Jan 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
darcydai marked this conversation as resolved.
Show resolved Hide resolved

String getProperty(String name, String defaultValue);

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

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