1 /* 2 * Copyright (C) 2007 u6k.yu1@gmail.com, All Rights Reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its 16 * contributors may be used to endorse or promote products derived 17 * from this software without prior written permission. For written 18 * permission, please contact clarkware@clarkware.com. 19 * 20 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 21 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 22 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 23 * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 26 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 29 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 package jp.gr.java_conf.u6k.filelock; 33 34 import java.io.IOException; 35 import java.util.Map; 36 import java.util.TreeMap; 37 38 /** 39 * <p> 40 * アプリケーションのエントリーポイントです。 41 * </p> 42 * 43 * @version $Id: ConsoleMain.java 27 2008-03-05 14:44:06Z u6k $ 44 */ 45 final class ConsoleMain { 46 47 private ConsoleMain() { 48 throw new UnsupportedOperationException(); 49 } 50 51 /** 52 * <p> 53 * アプリケーションのエントリーポイントです。 54 * </p> 55 * 56 * @param args 57 * アプリケーション引数。 58 * @throws IOException 59 * ファイルのロックに失敗した場合。 60 */ 61 public static void main(String[] args) throws IOException { 62 FileLockUtil flu = new FileLockUtil(args); 63 64 Map<String, Boolean> lockStateMap = new TreeMap<String, Boolean>(); 65 for (String path : flu.lockFiles()) { 66 lockStateMap.put(path, true); 67 } 68 for (String path : flu.lockFailFiles()) { 69 lockStateMap.put(path, false); 70 } 71 72 for (Map.Entry<String, Boolean> entry : lockStateMap.entrySet()) { 73 if (entry.getValue()) { 74 System.out.println(ResourceUtil.get("message.lock") + " " + entry.getKey()); 75 } else { 76 System.out.println(ResourceUtil.get("message.fail") + " " + entry.getKey()); 77 } 78 } 79 80 System.in.read(); 81 } 82 83 }