1 /** 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.geronimo.kernel.util; 18 19 import java.util.ArrayList; 20 import java.util.Iterator; 21 import java.util.List; 22 import java.util.Set; 23 24 import org.apache.geronimo.gbean.AbstractName; 25 import org.apache.geronimo.gbean.AbstractNameQuery; 26 import org.apache.geronimo.kernel.config.ConfigurationManager; 27 import org.apache.geronimo.kernel.config.ConfigurationUtil; 28 import org.apache.geronimo.kernel.config.PersistentConfigurationList; 29 import org.apache.geronimo.kernel.repository.Artifact; 30 31 /** 32 * 33 * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $ 34 */ 35 public class MainBootstrapper extends MainConfigurationBootstrapper { 36 37 public static void main(String[] args) { 38 int status = main(new MainBootstrapper(), args); 39 System.exit(status); 40 } 41 42 public void loadPersistentConfigurations() throws Exception { 43 List<Artifact> configs = new ArrayList<Artifact>(); 44 45 AbstractNameQuery query = new AbstractNameQuery(PersistentConfigurationList.class.getName()); 46 Set configLists = kernel.listGBeans(query); 47 for (Iterator i = configLists.iterator(); i.hasNext();) { 48 AbstractName configListName = (AbstractName) i.next(); 49 configs.addAll((List<Artifact>) kernel.invoke(configListName, "restore")); 50 } 51 52 ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel); 53 try { 54 for (Artifact config : configs) { 55 configurationManager.loadConfiguration(config); 56 configurationManager.startConfiguration(config); 57 } 58 } finally { 59 ConfigurationUtil.releaseConfigurationManager(kernel, configurationManager); 60 } 61 } 62 63 }