本文整理汇总了Java中org.togglz.core.Feature类的典型用法代码示例。如果您正苦于以下问题:Java Feature类的具体用法?Java Feature怎么用?Java Feature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Feature类属于org.togglz.core包,在下文中一共展示了Feature类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: from
import org.togglz.core.Feature; //导入依赖的package包/类
public static RemoteFeatureState from(FeatureState featureState) {
RemoteFeatureState remoteFeatureState = new RemoteFeatureState();
RemoteFeature feature = new RemoteFeature();
Feature featureFromGivenState = featureState.getFeature();
feature.setName(featureFromGivenState.name());
if(featureFromGivenState instanceof FeatureMetaData) {
FeatureMetaData metaData = (FeatureMetaData) featureFromGivenState;
feature.setLabel(metaData.getLabel());
feature.setEnabledByDefault(metaData.isEnabledByDefault());
}
remoteFeatureState.setFeature(feature);
remoteFeatureState.setEnabled(featureState.isEnabled());
remoteFeatureState.setStrategyId(featureState.getStrategyId());
remoteFeatureState.setParameters(new HashMap<>(2));
featureState.getParameterMap().forEach((k,v) -> remoteFeatureState.getParameters().put(k, v));
return remoteFeatureState;
}
示例2: createInMemoryStateRepository
import org.togglz.core.Feature; //导入依赖的package包/类
private StateRepository createInMemoryStateRepository() {
return new StateRepository() {
Logger LOG = getLogger(TogglzConfiguration.class);
private Map<String, FeatureState> featureStore = new ConcurrentHashMap<>();
@Autowired
UserProvider userProvider;
@Override
public FeatureState getFeatureState(final Feature feature) {
if (featureStore.containsKey(feature.name())) {
return featureStore.get(feature.name());
}
return new FeatureState(feature, false);
}
@Override
public void setFeatureState(final FeatureState featureState) {
featureStore.put(featureState.getFeature().name(), featureState);
LOG.info((!StringUtils.isEmpty(userProvider.getCurrentUser().getName()) ? "User '" + userProvider.getCurrentUser().getName() + "'" : "Unknown user")
+ (featureState.isEnabled() ? " enabled " : " disabled ") + "feature " + featureState.getFeature().name());
}
};
}
开发者ID:otto-de,项目名称:edison-microservice,代码行数:27,代码来源:InMemoryFeatureStateRepositoryConfiguration.java
示例3: getFeatureUsers
import org.togglz.core.Feature; //导入依赖的package包/类
protected List<String> getFeatureUsers(Feature feature) {
List<String> users = new ArrayList<String>();
try {
InitialContext jndiContext = getInitialContext();
String value = (String)jndiContext.lookup(feature.name()+".users");
if(value != null) {
value = value.trim();
if( !value.equals("")) {
users = Arrays.asList(value.split("( )*,( )*"));
}
}
} catch (NamingException e) {
logger.debug("unable to fetch user lists for feature "+feature.name());
}
return users;
}
示例4: DummyTogglzConfigForTest
import org.togglz.core.Feature; //导入依赖的package包/类
/**
* Create a simple dummy Togglz config for test
* @param featureClass
* @return
*/
private TogglzConfig DummyTogglzConfigForTest(final Class<? extends Feature> featureClass) {
return new TogglzConfig() {
@Override
public UserProvider getUserProvider() {
return new NoOpUserProvider();
}
@Override
public StateRepository getStateRepository() {
return new InMemoryStateRepository();
}
@Override
public Class<? extends Feature> getFeatureClass() {
return featureClass;
}
};
}
示例5: getMetaData
import org.togglz.core.Feature; //导入依赖的package包/类
@Override
public FeatureMetaData getMetaData(Feature feature) {
if (feature instanceof RemoteFeature) {
return (RemoteFeature)feature;
}
return null;
}
示例6: buildTogglzState
import org.togglz.core.Feature; //导入依赖的package包/类
private Map<String, FeatureToggleRepresentation> buildTogglzState(final Class<? extends Feature> featureClass) {
final Feature[] features = featureClass.getEnumConstants();
return stream(features)
.collect(
toMap(Feature::name, this::toFeatureToggleRepresentation)
);
}
示例7: toFeatureToggleRepresentation
import org.togglz.core.Feature; //导入依赖的package包/类
private FeatureToggleRepresentation toFeatureToggleRepresentation(final Feature feature) {
final Label label = getLabelAnnotation(feature);
return new FeatureToggleRepresentation(
label != null ? label.value() : feature.name(),
getFeatureManager().getFeatureState(feature).isEnabled(),
null);
}
示例8: allDisabledFeatureConfig
import org.togglz.core.Feature; //导入依赖的package包/类
public static void allDisabledFeatureConfig(final Class<? extends Feature> featureClass) {
TestFeatureManager featureManager = new TestFeatureManager(featureClass);
for (Feature feature : featureClass.getEnumConstants()) {
featureManager.disable(feature);
}
TestFeatureManagerProvider.setFeatureManager(featureManager);
clearCache();
}
示例9: enableAllFeaturesThatAreOkToEnableByDefaultInAllTests
import org.togglz.core.Feature; //导入依赖的package包/类
private static void enableAllFeaturesThatAreOkToEnableByDefaultInAllTests(final Class<? extends Feature> featureClass, final TestFeatureManager featureManager) {
for (Feature feature : featureClass.getEnumConstants()) {
if (shouldRunInTests(feature)) {
featureManager.enable(feature);
}
}
}
示例10: getFeatureState
import org.togglz.core.Feature; //导入依赖的package包/类
public FeatureState getFeatureState(Feature feature) {
DataFindRequest request = new DataFindRequest(entityName, version);
request.where(withValue("application", eq, application));
request.select(
Projection.array("features",
withValue("feature", eq, feature.name()),
true,
Projection.includeFieldRecursively("*"),
null
)
);
try {
LBTogglz[] result = lbClient.data(request, LBTogglz[].class);
if (result != null && result.length==1&&result[0].getFeatures()!=null && result[0].getFeatures().size()==1) {
LBTogglz.Toggle toggle = result[0].getFeatures().iterator().next();
FeatureState state = new FeatureState(feature);
state.setEnabled(toggle.isEnabled());
String strategyValue = toggle.getStrategy();
if (strategyValue!=null) {
state.setStrategyId(strategyValue.trim());
}
List<LBTogglz.Toggle.Parameter> parameters = toggle.getParameters();
if (parameters!=null) {
for (LBTogglz.Toggle.Parameter parameter : parameters) {
state.setParameter(parameter.getKey(), parameter.getValue().trim());
}
}
return state;
}
} catch (LightblueException e) {
e.printStackTrace();
}
return null;
}
示例11: getFeatures
import org.togglz.core.Feature; //导入依赖的package包/类
@Override
public Set<Feature> getFeatures() {
Set<Feature> features = new HashSet<>();
featureStateRepository.findAll().forEach(s -> features.add(s.getFeature()));
return features;
}
示例12: isActive
import org.togglz.core.Feature; //导入依赖的package包/类
@Override
public boolean isActive(Feature feature) {
return featureStateRepository.findByFeatureName(feature.name()).getEnabled();
}
示例13: getFeatureState
import org.togglz.core.Feature; //导入依赖的package包/类
@Override
public FeatureState getFeatureState(Feature feature) {
return RemoteFeatureState.toFeatureState(featureStateRepository.findByFeatureName(feature.name()));
}
示例14: getFeatureClass
import org.togglz.core.Feature; //导入依赖的package包/类
@Override
public Class<? extends Feature> getFeatureClass() {
return Features.class;
}
示例15: getFeatureClass
import org.togglz.core.Feature; //导入依赖的package包/类
@Override
public Class<? extends Feature> getFeatureClass() {
return featureClassProvider.getFeatureClass();
}