1 |
|
---|
2 | package org.greenstone.server;
|
---|
3 |
|
---|
4 | import java.awt.Dimension;
|
---|
5 | import java.awt.Toolkit;
|
---|
6 | import java.io.File;
|
---|
7 | import java.io.InputStream;
|
---|
8 | import java.util.Properties;
|
---|
9 |
|
---|
10 | import org.greenstone.gsdl3.util.Dictionary;
|
---|
11 |
|
---|
12 | //import org.greenstone.gsdl3.util.GlobalProperties;
|
---|
13 |
|
---|
14 | public class Server
|
---|
15 | {
|
---|
16 | public static Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize();
|
---|
17 | public static File build_properties_file;
|
---|
18 | public static String images_path; // should be in classpath??
|
---|
19 | public static Properties build_properties;
|
---|
20 | public static Dictionary dictionary;
|
---|
21 |
|
---|
22 | public Server(String gsdl3_src_home)
|
---|
23 | {
|
---|
24 | //this.gsdl3_home = gsdl3_home;
|
---|
25 | //this.gsdl3_src_home = gsdl3_src_home;
|
---|
26 |
|
---|
27 | //this.global_properties=gsdl3_home+File.separatorChar+"WEB-INF"+File.separatorChar+"classes"+File.separatorChar+"global.properties";
|
---|
28 | String build_properties_path=gsdl3_src_home+File.separatorChar+"build.properties";
|
---|
29 | this.build_properties_file = new File(build_properties_path);
|
---|
30 | if (!this.build_properties_file.exists()) {
|
---|
31 | System.err.println("Can't find build.properties file "+build_properties_path);
|
---|
32 | System.exit(1);
|
---|
33 | }
|
---|
34 | build_properties = new Properties();
|
---|
35 | reloadBuildProperties();
|
---|
36 | this.images_path = gsdl3_src_home+File.separatorChar+"resources"+File.separatorChar+"images"+File.separatorChar;
|
---|
37 |
|
---|
38 | // make it dynamic language
|
---|
39 | this.dictionary = new Dictionary("server", "en", this.getClass().getClassLoader());
|
---|
40 | ServerControl serverControl = new ServerControl();
|
---|
41 | }
|
---|
42 |
|
---|
43 | public static void reloadBuildProperties() {
|
---|
44 | try {
|
---|
45 | InputStream in = Class.forName("org.greenstone.server.Server").getClassLoader().getResourceAsStream("build.properties");
|
---|
46 | if (in != null) {
|
---|
47 | System.err.println("loading build properties");
|
---|
48 | build_properties.load(in);
|
---|
49 | in.close();
|
---|
50 | } else {
|
---|
51 | System.err.println("couldn't load build properties!");
|
---|
52 | }
|
---|
53 | } catch (Exception e) {
|
---|
54 | System.err.println("Exception trying to reload build.properties: "+e);
|
---|
55 | }
|
---|
56 |
|
---|
57 |
|
---|
58 | }
|
---|
59 | public static void main (String[] args){
|
---|
60 | System.out.println(args[0]);
|
---|
61 | if (args.length != 1) {
|
---|
62 | System.err.println("Usage: java org.greenstone.server.ServerMain <gsdl3 src home> ");
|
---|
63 | System.exit(1);
|
---|
64 | }
|
---|
65 |
|
---|
66 | File gsdl3_src_dir = new File(args[0]);
|
---|
67 | if (!gsdl3_src_dir.isDirectory()) {
|
---|
68 | System.err.println("Usage: java org.greenstone.server.ServerMain <gsdl3 src home> ");
|
---|
69 | System.err.println("src directory does not exist!");
|
---|
70 | System.exit(1);
|
---|
71 | }
|
---|
72 | Server server = new Server(args[0]);
|
---|
73 | }
|
---|
74 | }
|
---|