From 31509cf6dabe936fe6e0e8a8ffe0365310c76628 Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Mon, 5 Aug 2013 17:31:31 -0700 Subject: [PATCH] Added new files --- framework/config/pom.xml | 38 +++++++++++ .../framework/config/ConfigDepotAdmin.java | 29 ++++++++ .../framework/config/ConfigDepotImpl.java | 67 +++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 framework/config/pom.xml create mode 100644 framework/config/src/org/apache/cloudstack/framework/config/ConfigDepotAdmin.java create mode 100644 framework/config/src/org/apache/cloudstack/framework/config/ConfigDepotImpl.java diff --git a/framework/config/pom.xml b/framework/config/pom.xml new file mode 100644 index 00000000000..d0e8367a3fb --- /dev/null +++ b/framework/config/pom.xml @@ -0,0 +1,38 @@ + + + 4.0.0 + cloud-framework-config + Apache CloudStack Framework - Configuration + + org.apache.cloudstack + cloudstack-framework + 4.3.0-SNAPSHOT + ../pom.xml + + + + org.apache.cloudstack + cloud-utils + ${project.version} + + + org.apache.cloudstack + cloud-framework-db + ${project.version} + + + org.apache.cloudstack + cloud-api + ${project.version} + + + diff --git a/framework/config/src/org/apache/cloudstack/framework/config/ConfigDepotAdmin.java b/framework/config/src/org/apache/cloudstack/framework/config/ConfigDepotAdmin.java new file mode 100644 index 00000000000..8dac77fd0a6 --- /dev/null +++ b/framework/config/src/org/apache/cloudstack/framework/config/ConfigDepotAdmin.java @@ -0,0 +1,29 @@ +// 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.cloudstack.framework.config; + +import java.util.List; + +/** + * Administrative interface to ConfigDepot + * + */ +public interface ConfigDepotAdmin { + void populateConfigurations(); + + List getComponentsInDepot(); +} diff --git a/framework/config/src/org/apache/cloudstack/framework/config/ConfigDepotImpl.java b/framework/config/src/org/apache/cloudstack/framework/config/ConfigDepotImpl.java new file mode 100644 index 00000000000..ce5ee8e4d99 --- /dev/null +++ b/framework/config/src/org/apache/cloudstack/framework/config/ConfigDepotImpl.java @@ -0,0 +1,67 @@ +// 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.cloudstack.framework.config; + +import java.util.ArrayList; +import java.util.List; + +import javax.inject.Inject; + +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; + +import com.cloud.utils.db.EntityManager; + +/** + * DepotImpl implements the ConfigDepot interface + * + */ +class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin { + @Inject + EntityManager _entityMgr; + + @Inject + ConfigurationDao _configDao; + + @Inject + List _configurables; + + public ConfigDepotImpl() { + } + + @Override + public ConfigValue get(ConfigKey config) { + return new ConfigValue(_entityMgr, config); + } + + @Override + public void populateConfigurations() { + for (Configurable configurable : _configurables) { + for (ConfigKey key : configurable.getConfigKeys()) { + ConfigurationVO vo = _configDao.findById(key.key()); + if (vo == null) { + vo = new ConfigurationVO(configurable.getConfigComponentName(), key); + _configDao.persist(vo); + } + } + } + } + + @Override + public List getComponentsInDepot() { + return new ArrayList(); + } +}