1 5 6 package joseki; 7 8 import jena.cmdline.* ; 9 10 import org.joseki.server.* ; 11 import org.joseki.Joseki ; 12 13 18 19 20 public class rdfserver 21 { 22 public static String defaultConfigFile = RDFServer.defaultConfigFile ; 23 24 public static boolean VERBOSE = false ; 25 public static boolean DEBUG = false ; 26 27 public static final int defaultPort = 2020 ; 28 public static int port = defaultPort ; 29 30 public static final String PortArg = "port" ; 31 32 public static void main (String args[]) 33 { 34 38 if ( System.getProperty("log4j.configuration") == null ) 39 System.setProperty("log4j.configuration", "file:etc/log4j.properties") ; 40 41 port = Integer.parseInt(System.getProperty("jena.rdfserver.port", defaultPort+"")) ; 42 43 String usageMessage = rdfserver.class.getName()+ 44 " [--verbose] [--port N] "+ 45 "dataSourceConfigFile" ; 46 47 48 CommandLine cmd = new CommandLine() ; 49 cmd.setUsage(usageMessage) ; 50 51 ArgDecl verboseDecl = new ArgDecl(false, "-v", "--verbose") ; 52 cmd.add(verboseDecl) ; 53 cmd.add("--debug", false) ; 54 cmd.add("--help", false) ; 55 cmd.add(PortArg, true) ; 56 57 cmd.process(args) ; 59 60 if ( cmd.contains("help") ) 61 { 62 System.out.println(usageMessage) ; 63 System.exit(0) ; 64 } 65 66 if ( cmd.contains(PortArg) ) 67 port = Integer.parseInt(cmd.getArg(PortArg).getValue()) ; 68 69 if ( cmd.contains("--debug") ) 70 { 71 DEBUG = true ; 72 Joseki.serverDebug = true ; 73 Joseki.serverContentType = "application/n3" ; 74 } 75 76 if ( cmd.contains(verboseDecl) ) 77 VERBOSE = true ; 78 79 if ( cmd.items().size() > 1 ) 80 { 81 System.err.println("Must specify exactly one configuration file (or use default : "+defaultConfigFile+")") ; 82 System.err.println(usageMessage) ; 83 System.exit(1) ; 84 } 85 86 String configFile = null ; 87 88 if ( cmd.items().size() > 0 ) 89 configFile = (String )cmd.items().get(0) ; 90 else 91 configFile = defaultConfigFile ; 92 93 try { 94 RDFServer server = new RDFServer(configFile, port) ; 95 server.start() ; 96 } catch (ConfigurationErrorException confEx) 97 { 98 System.out.flush() ; 100 System.err.println(); 101 System.err.println("Failed to load the configuration file - see log") ; 102 System.err.println(); 107 System.exit(99) ; 108 } 109 } 111 } 112 113 139 | Popular Tags |