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 package org.apache.geronimo.kernel.util; 018 019 import java.util.ArrayList; 020 import java.util.Iterator; 021 import java.util.List; 022 import java.util.Set; 023 024 import org.apache.geronimo.gbean.AbstractName; 025 import org.apache.geronimo.gbean.AbstractNameQuery; 026 import org.apache.geronimo.kernel.config.ConfigurationManager; 027 import org.apache.geronimo.kernel.config.ConfigurationUtil; 028 import org.apache.geronimo.kernel.config.PersistentConfigurationList; 029 import org.apache.geronimo.kernel.repository.Artifact; 030 031 /** 032 * 033 * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $ 034 */ 035 public class MainBootstrapper extends MainConfigurationBootstrapper { 036 037 public static void main(String[] args) { 038 int status = main(new MainBootstrapper(), args); 039 System.exit(status); 040 } 041 042 public void loadPersistentConfigurations() throws Exception { 043 List<Artifact> configs = new ArrayList<Artifact>(); 044 045 AbstractNameQuery query = new AbstractNameQuery(PersistentConfigurationList.class.getName()); 046 Set configLists = kernel.listGBeans(query); 047 for (Iterator i = configLists.iterator(); i.hasNext();) { 048 AbstractName configListName = (AbstractName) i.next(); 049 configs.addAll((List<Artifact>) kernel.invoke(configListName, "restore")); 050 } 051 052 ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel); 053 try { 054 for (Artifact config : configs) { 055 configurationManager.loadConfiguration(config); 056 configurationManager.startConfiguration(config); 057 } 058 } finally { 059 ConfigurationUtil.releaseConfigurationManager(kernel, configurationManager); 060 } 061 } 062 063 }