![JAR search and dependency download from the Maven repository](/logo.png)
org.apache.dubbo.common.config.ModuleEnvironment Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dubbo Show documentation
Show all versions of dubbo Show documentation
The all in one project of dubbo
The newest version!
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.dubbo.common.config;
import org.apache.dubbo.common.config.configcenter.DynamicConfiguration;
import org.apache.dubbo.common.context.ModuleExt;
import org.apache.dubbo.common.extension.DisableInject;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.config.AbstractConfig;
import org.apache.dubbo.rpc.model.ModuleModel;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
public class ModuleEnvironment extends Environment implements ModuleExt {
// delegate
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ModuleEnvironment.class);
public static final String NAME = "moduleEnvironment";
private final AtomicBoolean initialized = new AtomicBoolean(false);
private final ModuleModel moduleModel;
private final Environment applicationDelegate;
private OrderedPropertiesConfiguration orderedPropertiesConfiguration;
private CompositeConfiguration dynamicGlobalConfiguration;
private DynamicConfiguration dynamicConfiguration;
public ModuleEnvironment(ModuleModel moduleModel) {
super(moduleModel);
this.moduleModel = moduleModel;
this.applicationDelegate = moduleModel.getApplicationModel().modelEnvironment();
}
@Override
public void initialize() throws IllegalStateException {
if (initialized.compareAndSet(false, true)) {
this.orderedPropertiesConfiguration = new OrderedPropertiesConfiguration(moduleModel);
}
}
@Override
public Configuration getPrefixedConfiguration(AbstractConfig config, String prefix) {
CompositeConfiguration compositeConfiguration = new CompositeConfiguration();
compositeConfiguration.addConfiguration(applicationDelegate.getPrefixedConfiguration(config, prefix));
compositeConfiguration.addConfiguration(orderedPropertiesConfiguration);
return new PrefixedConfiguration(compositeConfiguration, prefix);
}
@Override
public CompositeConfiguration getConfiguration() {
if (globalConfiguration == null) {
CompositeConfiguration configuration = new CompositeConfiguration();
configuration.addConfiguration(applicationDelegate.getConfiguration());
configuration.addConfiguration(orderedPropertiesConfiguration);
globalConfiguration = configuration;
}
return globalConfiguration;
}
@Override
public List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy