001 /** 002 * 003 * Copyright 2003-2004 The Apache Software Foundation 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * 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.system.configuration.cli; 018 019 import java.io.*; 020 021 /** 022 * A tool for use by clients who really know what they're doing (such as the 023 * installer). You point this to a FileConfigurationList file, and give it 024 * a configuration name, and it adds the name to the file. This should only 025 * be run while the server is down, and will only work if you have previous 026 * knowledge of which PersistentConfigurationList implementation is going to 027 * be used and what file it persists to. This is NOT a general-purpose 028 * feature for users. 029 * 030 * @version $Rev: 355877 $ $Date: 2005-12-10 18:48:27 -0800 (Sat, 10 Dec 2005) $ 031 */ 032 public class AddStartupConfiguration { 033 public static void main(String[] args) { 034 try { 035 String file = args[0]; 036 String configuration = args[1].trim(); 037 BufferedReader in = new BufferedReader(new FileReader(file)); 038 String line; 039 while((line = in.readLine()) != null) { 040 if(line.trim().equals(configuration)) { 041 in.close(); 042 System.exit(0); 043 } 044 } 045 in.close(); 046 047 PrintWriter out = new PrintWriter(new FileWriter(file, true)); 048 out.println(configuration); 049 out.close(); 050 } catch (IOException e) { 051 e.printStackTrace(); 052 System.exit(1); 053 } 054 } 055 }