1
- /**
2
- *
3
- * Copyright 2016-2017, Optimizely and contributors
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
1
+ /****************************************************************************
2
+ * Copyright 2016-2017, Optimizely, Inc. and contributors *
3
+ * *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); *
5
+ * you may not use this file except in compliance with the License. *
6
+ * You may obtain a copy of the License at *
7
+ * *
8
+ * http://www.apache.org/licenses/LICENSE-2.0 *
9
+ * *
10
+ * Unless required by applicable law or agreed to in writing, software *
11
+ * distributed under the License is distributed on an "AS IS" BASIS, *
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13
+ * See the License for the specific language governing permissions and *
14
+ * limitations under the License. *
15
+ ***************************************************************************/
17
16
package com .optimizely .ab ;
18
17
19
18
import com .optimizely .ab .annotations .VisibleForTesting ;
20
19
import com .optimizely .ab .bucketing .Bucketer ;
21
20
import com .optimizely .ab .bucketing .DecisionService ;
22
- import com .optimizely .ab .bucketing .UserProfile ;
21
+ import com .optimizely .ab .bucketing .UserProfileService ;
23
22
import com .optimizely .ab .config .Attribute ;
24
23
import com .optimizely .ab .config .EventType ;
25
24
import com .optimizely .ab .config .Experiment ;
40
39
import com .optimizely .ab .event .internal .payload .Event .ClientEngine ;
41
40
import com .optimizely .ab .internal .EventTagUtils ;
42
41
import com .optimizely .ab .internal .ReservedEventKey ;
43
- import com .optimizely .ab .internal .UserProfileUtils ;
44
42
import com .optimizely .ab .notification .NotificationBroadcaster ;
45
43
import com .optimizely .ab .notification .NotificationListener ;
46
44
import org .slf4j .Logger ;
@@ -92,26 +90,26 @@ public class Optimizely {
92
90
@ VisibleForTesting final EventHandler eventHandler ;
93
91
@ VisibleForTesting final ErrorHandler errorHandler ;
94
92
@ VisibleForTesting final NotificationBroadcaster notificationBroadcaster = new NotificationBroadcaster ();
95
- @ Nullable private final UserProfile userProfile ;
93
+ @ Nullable private final UserProfileService userProfileService ;
96
94
97
95
private Optimizely (@ Nonnull ProjectConfig projectConfig ,
98
96
@ Nonnull DecisionService decisionService ,
99
97
@ Nonnull EventHandler eventHandler ,
100
98
@ Nonnull EventBuilder eventBuilder ,
101
99
@ Nonnull ErrorHandler errorHandler ,
102
- @ Nullable UserProfile userProfile ) {
100
+ @ Nullable UserProfileService userProfileService ) {
103
101
this .projectConfig = projectConfig ;
104
102
this .decisionService = decisionService ;
105
103
this .eventHandler = eventHandler ;
106
104
this .eventBuilder = eventBuilder ;
107
105
this .errorHandler = errorHandler ;
108
- this .userProfile = userProfile ;
106
+ this .userProfileService = userProfileService ;
109
107
}
110
108
111
109
// Do work here that should be done once per Optimizely lifecycle
112
110
@ VisibleForTesting
113
111
void initialize () {
114
- UserProfileUtils . cleanUserProfiles ( userProfile , projectConfig );
112
+
115
113
}
116
114
117
115
//======== activate calls ========//
@@ -506,11 +504,10 @@ private static ProjectConfig getProjectConfig(String datafile) throws ConfigPars
506
504
}
507
505
508
506
@ Nullable
509
- public UserProfile getUserProfile () {
510
- return userProfile ;
507
+ public UserProfileService getUserProfileService () {
508
+ return userProfileService ;
511
509
}
512
510
513
-
514
511
//======== Notification listeners ========//
515
512
516
513
/**
@@ -709,7 +706,7 @@ public static class Builder {
709
706
private ClientEngine clientEngine ;
710
707
private String clientVersion ;
711
708
private ProjectConfig projectConfig ;
712
- private UserProfile userProfile ;
709
+ private UserProfileService userProfileService ;
713
710
714
711
public Builder (@ Nonnull String datafile ,
715
712
@ Nonnull EventHandler eventHandler ) {
@@ -732,8 +729,8 @@ public Builder withErrorHandler(ErrorHandler errorHandler) {
732
729
return this ;
733
730
}
734
731
735
- public Builder withUserProfile ( UserProfile userProfile ) {
736
- this .userProfile = userProfile ;
732
+ public Builder withUserProfileService ( UserProfileService userProfileService ) {
733
+ this .userProfileService = userProfileService ;
737
734
return this ;
738
735
}
739
736
@@ -775,9 +772,6 @@ public Optimizely build() throws ConfigParseException {
775
772
clientVersion = BuildVersionInfo .VERSION ;
776
773
}
777
774
778
- if (decisionService == null ) {
779
- decisionService = new DecisionService (bucketer , projectConfig , userProfile );
780
- }
781
775
782
776
if (eventBuilder == null ) {
783
777
eventBuilder = new EventBuilderV2 (clientEngine , clientVersion );
@@ -787,7 +781,11 @@ public Optimizely build() throws ConfigParseException {
787
781
errorHandler = new NoOpErrorHandler ();
788
782
}
789
783
790
- Optimizely optimizely = new Optimizely (projectConfig , decisionService , eventHandler , eventBuilder , errorHandler , userProfile );
784
+ if (decisionService == null ) {
785
+ decisionService = new DecisionService (bucketer , errorHandler , projectConfig , userProfileService );
786
+ }
787
+
788
+ Optimizely optimizely = new Optimizely (projectConfig , decisionService , eventHandler , eventBuilder , errorHandler , userProfileService );
791
789
optimizely .initialize ();
792
790
return optimizely ;
793
791
}
0 commit comments