001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018 package org.apache.geronimo.kernel.config; 019 020 import java.io.File; 021 import java.io.IOException; 022 import java.io.OutputStream; 023 import java.net.MalformedURLException; 024 import java.net.URL; 025 import java.util.List; 026 import java.util.Set; 027 028 import org.apache.geronimo.kernel.repository.Artifact; 029 import org.apache.geronimo.gbean.AbstractName; 030 031 /** 032 * Interface to a store for Configurations. 033 * 034 * @version $Rev: 706640 $ $Date: 2008-10-21 14:44:05 +0000 (Tue, 21 Oct 2008) $ 035 */ 036 public interface ConfigurationStore { 037 038 /** 039 * Determines if the identified configuration is an in-place one. This 040 * means that the configuration store only stores some meta-data and the 041 * actual content of the configuration is rooted somewhere else. 042 * 043 * @param configId the unique ID of the configuration, which must be fully 044 * resolved (isResolved() == true) 045 * 046 * @return true if the identified configuration is an in-place one. 047 * 048 * @throws NoSuchConfigException if the configuration is not contained in 049 * the store 050 * @throws IOException If the store cannot be read. 051 */ 052 boolean isInPlaceConfiguration(Artifact configId) throws NoSuchConfigException, IOException; 053 054 /** 055 * Move the unpacked configuration directory into this store 056 * 057 * @param configurationData the configuration data 058 * @throws IOException if the direcotyr could not be moved into the store 059 * @throws InvalidConfigException if there is a configuration problem within the source direcotry 060 */ 061 void install(ConfigurationData configurationData) throws IOException, InvalidConfigException; 062 063 /** 064 * Removes a configuration from the store 065 * 066 * @param configId the id of the configuration to remove, which must be 067 * fully resolved (isResolved() == true) 068 * 069 * @throws NoSuchConfigException if the configuration is not contained in the store 070 * @throws IOException if a problem occurs during the removal 071 */ 072 void uninstall(Artifact configId) throws NoSuchConfigException, IOException; 073 074 /** 075 * Loads the specified configuration into the kernel 076 * 077 * @param configId the id of the configuration to load, which must be fully 078 * resolved (isResolved() == true) 079 * 080 * @return the the configuration object 081 * 082 * @throws NoSuchConfigException if the configuration is not contained in the kernel 083 * @throws IOException if a problem occurs loading the configuration from the store 084 * @throws InvalidConfigException if the configuration is corrupt 085 */ 086 ConfigurationData loadConfiguration(Artifact configId) throws NoSuchConfigException, IOException, InvalidConfigException; 087 088 /** 089 * Determines if the store contains a configuration with the specified ID. 090 * The configuration need not be loaded or running, this just checks 091 * whether the configuration store has the data for it. 092 * 093 * @param configId the unique ID of the configuration, which must be fully 094 * resolved (isResolved() == true) 095 * 096 * @return true if the store contains the configuration 097 */ 098 boolean containsConfiguration(Artifact configId); 099 100 /** 101 * Return the object name for the store. 102 * 103 * @return the object name for the store 104 */ 105 String getObjectName(); 106 107 /** 108 * Return the object name for the store. 109 * 110 * @return the object name for the store 111 */ 112 AbstractName getAbstractName(); 113 114 /** 115 * Return the configurations in the store 116 * 117 * @return a List (with entries of type ConfigurationInfo) of all the 118 * configurations contained in this configuration store 119 */ 120 List<ConfigurationInfo> listConfigurations(); 121 122 /** 123 * Creates an empty directory for a new configuration with the specified configId 124 * 125 * @param configId the unique ID of the configuration, which must be fully 126 * resolved (isResolved() == true) 127 * 128 * @return the location of the new directory 129 * 130 * @throws ConfigurationAlreadyExistsException if the configuration already exists in this store 131 */ 132 File createNewConfigurationDir(Artifact configId) throws ConfigurationAlreadyExistsException; 133 134 /** 135 * Locate the physical locations which match the supplied path in the given 136 * artifact/module. The path may be an Ant-style pattern. 137 * 138 * @param configId the artifact to search, which must be fully resolved 139 * (isResolved() == true) 140 * @param moduleName the module name or null to search in the top-level 141 * artifact location 142 * @param path the pattern to search for within the artifact/module, 143 * which may also be null to identify the artifact or 144 * module base path 145 * 146 * @return a Set (with entries of type URL) of the matching locations 147 */ 148 Set<URL> resolve(Artifact configId, String moduleName, String path) throws NoSuchConfigException, MalformedURLException; 149 150 /** 151 * Exports a configuration as a ZIP file. 152 * 153 * @param configId The unique ID of the configuration to export, which 154 * must be fully resolved (isResolved() == true) 155 * @param output The stream to write the ZIP content to 156 */ 157 void exportConfiguration(Artifact configId, OutputStream output) throws IOException, NoSuchConfigException; 158 }