org.wso2.carbon.localentry.util.ConfigHolder Maven / Gradle / Ivy
/**
* Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* 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 org.wso2.carbon.localentry.util;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.config.SynapseConfiguration;
import org.wso2.carbon.localentry.LocalEntryAdminException;
import org.wso2.carbon.mediation.initializer.services.SynapseEnvironmentService;
import org.wso2.carbon.registry.core.session.UserRegistry;
import org.wso2.carbon.mediation.dependency.mgt.services.DependencyManagementService;
import java.util.HashMap;
import java.util.Map;
/**
*
*/
public class ConfigHolder {
private static ConfigHolder instance;
private static final Log log = LogFactory.getLog(ConfigHolder.class);
private SynapseConfiguration synapseConfiguration;
private AxisConfiguration axisConfiguration;
private UserRegistry registry;
private DependencyManagementService dependencyManager;
private Map synapseEnvironmentServices =
new HashMap();
private ConfigHolder() {
}
public static ConfigHolder getInstance() {
if(instance == null) {
instance = new ConfigHolder();
}
return instance;
}
public SynapseConfiguration getSynapseConfiguration() throws LocalEntryAdminException {
assertNull("SynapseConfiguration", synapseConfiguration);
return synapseConfiguration;
}
public void setSynapseConfiguration(SynapseConfiguration synapseConfiguration) {
this.synapseConfiguration = synapseConfiguration;
}
public AxisConfiguration getAxisConfiguration() throws LocalEntryAdminException {
assertNull("AxisConfiguration", axisConfiguration);
return axisConfiguration;
}
public void setAxisConfiguration(AxisConfiguration axisConfiguration) {
this.axisConfiguration = axisConfiguration;
}
public UserRegistry getRegistry() throws LocalEntryAdminException {
assertNull("Registry", registry);
return registry;
}
public DependencyManagementService getDependencyManager() {
return dependencyManager;
}
public void setDependencyManager(DependencyManagementService dependencyManager) {
this.dependencyManager = dependencyManager;
}
public void setRegistry(UserRegistry registry) {
this.registry = registry;
}
private void assertNull(String name, Object object) throws LocalEntryAdminException {
if (object == null) {
String message = name + " reference in the proxy admin config holder is null";
log.error(message);
throw new LocalEntryAdminException(message);
}
}
public SynapseEnvironmentService getSynapseEnvironmentService(int id) {
return synapseEnvironmentServices.get(id);
}
public void addSynapseEnvironmentService(int id,
SynapseEnvironmentService synapseEnvironmentService) {
synapseEnvironmentServices.put(id, synapseEnvironmentService);
}
public void removeSynapseEnvironmentService(int id) {
synapseEnvironmentServices.remove(id);
}
public Map getSynapseEnvironmentServices() {
return synapseEnvironmentServices;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy