Skip to content
Merged

Variants #42853

Show file tree
Hide file tree
Changes from 16 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import javax.naming.NamingException;

import org.apache.commons.logging.Log;
import org.springframework.beans.BeanUtils;
import org.springframework.boot.BootstrapRegistry.InstanceSupplier;
import org.springframework.boot.context.config.ConfigDataLocation;
import org.springframework.boot.context.config.ConfigDataLocationNotFoundException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,28 @@
// Licensed under the MIT License.
package com.azure.spring.cloud.feature.management;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.NonNull;

import com.azure.spring.cloud.feature.management.implementation.FeatureManagementConfigProperties;
import com.azure.spring.cloud.feature.management.implementation.FeatureManagementProperties;
import com.azure.spring.cloud.feature.management.targeting.TargetingContextAccessor;
import com.azure.spring.cloud.feature.management.targeting.TargetingEvaluationOptions;

/**
* Configuration for setting up FeatureManager
*/
@Configuration
@EnableConfigurationProperties({ FeatureManagementConfigProperties.class, FeatureManagementProperties.class })
class FeatureManagementConfiguration {
class FeatureManagementConfiguration implements ApplicationContextAware {

private ApplicationContext appContext;

/**
* Creates Feature Manager
Expand All @@ -26,8 +34,21 @@ class FeatureManagementConfiguration {
* @return FeatureManager
*/
@Bean
FeatureManager featureManager(ApplicationContext context,
FeatureManagementProperties featureManagementConfigurations, FeatureManagementConfigProperties properties) {
return new FeatureManager(context, featureManagementConfigurations, properties);
FeatureManager featureManager(FeatureManagementProperties featureManagementConfigurations,
FeatureManagementConfigProperties properties,
ObjectProvider<TargetingContextAccessor> contextAccessorProvider,
ObjectProvider<TargetingEvaluationOptions> evaluationOptionsProvider) {

TargetingContextAccessor contextAccessor = contextAccessorProvider.getIfAvailable();
TargetingEvaluationOptions evaluationOptions = evaluationOptionsProvider
.getIfAvailable(() -> new TargetingEvaluationOptions());

return new FeatureManager(appContext, featureManagementConfigurations, properties, contextAccessor,
evaluationOptions);
}

@Override
public void setApplicationContext(@NonNull ApplicationContext applicationContext) throws BeansException {
this.appContext = applicationContext;
}
}
Loading