1 17 package org.alfresco.tools; 18 19 import java.io.IOException ; 20 21 27 public class Repository extends Tool 28 { 29 @Override  30 String getToolName() 31 { 32 return "Repository"; 33 } 34 35 @Override  36 ToolContext processArgs(String [] args) throws ToolException 37 { 38 ToolContext context = new ToolContext(); 39 context.setLogin(true); 40 41 int i = 0; 42 while (i < args.length) 43 { 44 if (args[i].equals("-h") || args[i].equals("-help")) 45 { 46 context.setHelp(true); 47 break; 48 } 49 else if (args[i].equals("-user")) 50 { 51 i++; 52 if (i == args.length || args[i].length() == 0) 53 { 54 throw new ToolException("The value <user> for the option -user must be specified"); 55 } 56 context.setUsername(args[i]); 57 } 58 else if (args[i].equals("-pwd")) 59 { 60 i++; 61 if (i == args.length || args[i].length() == 0) 62 { 63 throw new ToolException("The value <password> for the option -pwd must be specified"); 64 } 65 context.setPassword(args[i]); 66 } 67 else 68 { 69 throw new ToolException("Unknown option " + args[i] + ". Use -help for options."); 70 } 71 72 i++; 74 } 75 76 return context; 77 } 78 79 @Override  80 void displayHelp() 81 { 82 System.out.println( 83 "usage: repository [OPTIONS] \n" + 84 "\n" + 85 "Initialize the Alfresco application context, initiating any \n" + 86 "configured server beans (e.g. CIFS server, FTP server, etc). \n" + 87 "\n" + 88 "Options: \n" + 89 " -h -help Display this help \n" + 90 " -user USER Login as USER \n" + 91 " -pwd PASSWORD Use PASSWORD to login"); 92 } 93 94 @Override  95 synchronized void execute() throws ToolException 96 { 97 try 98 { 99 System.out.println("\nRepository initialized.\nPress ENTER to exit..."); 100 System.in.read(); 101 System.out.println("\nShutting down the repository."); 102 new ShutdownNotifierThread().start(); 104 try { wait(3000L); } catch (InterruptedException e) {} 105 } 106 catch (IOException e) 107 { 108 } 110 } 111 112 117 public static void main(String [] args) 118 { 119 new Repository().start(args); 120 } 121 122 private static class ShutdownNotifierThread extends Thread  123 { 124 private ShutdownNotifierThread() 125 { 126 this.setDaemon(true); 127 } 128 @Override  129 public synchronized void run() 130 { 131 while (true) 132 { 133 System.out.print('.'); 134 try 135 { 136 wait(500L); 137 } 138 catch (InterruptedException e) 139 { 140 } 141 } 142 } 143 } 144 } 145
| Popular Tags
|