-
Notifications
You must be signed in to change notification settings - Fork 32
Fix: Added notificationRegistry to make sure that odpSettings updates #501
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
Changes from all commits
a006cf0
ed2bcbb
51357cf
f1c3d7a
5d791f2
01fd113
9c4f729
92004cf
01313a4
ecb12b5
38d735a
0deec47
e6bbc30
43da46a
0fe4fb3
dd6a823
680a5bf
65c150d
5bc8ffd
26d50ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/** | ||
* | ||
* Copyright 2019, Optimizely and contributors | ||
* Copyright 2019, 2023, Optimizely and contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -16,12 +16,33 @@ | |
*/ | ||
package com.optimizely.ab.config; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public interface ProjectConfigManager { | ||
/** | ||
* Implementations of this method should block until a datafile is available. | ||
* | ||
* @return ProjectConfig | ||
*/ | ||
ProjectConfig getConfig(); | ||
|
||
/** | ||
* Implementations of this method should not block until a datafile is available, instead return current cached project configuration. | ||
* return null if ProjectConfig is not ready at the moment. | ||
* | ||
mnoman09 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* NOTE: To use ODP segments, implementation of this function is required to return current project configuration. | ||
* @return ProjectConfig | ||
*/ | ||
@Nullable | ||
ProjectConfig getCachedConfig(); | ||
|
||
/** | ||
* Implementations of this method should return SDK key. If there is no SDKKey then it should return null. | ||
* | ||
* NOTE: To update ODP segments configuration via polling, it is required to return sdkKey. | ||
* @return String | ||
*/ | ||
@Nullable | ||
String getSDKKey(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we get sdkKey via There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see this comment. It will make sure that even when the config is not fetched, notificationCenter will contain the handler, which updates the ODPConfig. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mnoman09 Got it! Can we add a default implementation of this method (returning null), so no changes required for existing implementations. They'll all share the same internal notificationCenter for "null" sdkKey (until they fix it), which looks safe to me. |
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* | ||
* Copyright 2023, Optimizely | ||
* | ||
* 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 | ||
* | ||
* 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. | ||
*/ | ||
package com.optimizely.ab.internal; | ||
|
||
import com.optimizely.ab.notification.NotificationCenter; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
public class NotificationRegistry { | ||
private final static Map<String, NotificationCenter> _notificationCenters = new ConcurrentHashMap<>(); | ||
|
||
private NotificationRegistry() | ||
{ | ||
} | ||
|
||
public static NotificationCenter getInternalNotificationCenter(@Nonnull String sdkKey) | ||
{ | ||
NotificationCenter notificationCenter = null; | ||
if (sdkKey != null) { | ||
if (_notificationCenters.containsKey(sdkKey)) { | ||
notificationCenter = _notificationCenters.get(sdkKey); | ||
} else { | ||
notificationCenter = new NotificationCenter(); | ||
_notificationCenters.put(sdkKey, notificationCenter); | ||
} | ||
} | ||
return notificationCenter; | ||
} | ||
|
||
public static void clearNotificationCenterRegistry(@Nonnull String sdkKey) { | ||
if (sdkKey != null) { | ||
_notificationCenters.remove(sdkKey); | ||
} | ||
} | ||
|
||
} |
Uh oh!
There was an error while loading. Please reload this page.