comparison src/java/de/intevation/mxd/ArcGISInitializer.java @ 180:f4eb506499f5

Done some code styling and removed TODOs.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 11 Jul 2011 12:11:08 +0200
parents 104af51a4717
children df4e0946ef02
comparison
equal deleted inserted replaced
179:f3a91cd7440b 180:f4eb506499f5
38 public boolean initArcGIS () 38 public boolean initArcGIS ()
39 throws IOException { 39 throws IOException {
40 logger.debug("initArcGIS()"); 40 logger.debug("initArcGIS()");
41 41
42 String engineInstallDir = System.getenv("AGSENGINEJAVA"); 42 String engineInstallDir = System.getenv("AGSENGINEJAVA");
43 if(engineInstallDir == null) { 43 if(engineInstallDir == null) {
44 engineInstallDir = System.getenv("AGSDESKTOPJAVA"); 44 engineInstallDir = System.getenv("AGSDESKTOPJAVA");
45 if(engineInstallDir == null) { 45 if(engineInstallDir == null) {
46 logger.error("Could not find ArcGIS Environment. \n" + 46 logger.error("Could not find ArcGIS Environment. \n" +
47 "AGSENGINEJAVA or AGSDESKTOPJAVA not set."); 47 "AGSENGINEJAVA or AGSDESKTOPJAVA not set.");
48 return false; 48 return false;
49 } 49 }
50 } 50 }
51 51
52 //Obtain the relative path to the arcobjects.jar file 52 //Obtain the relative path to the arcobjects.jar file
53 String jarPath = engineInstallDir + "java" + File.separator + "lib" + 53 String jarPath = engineInstallDir + "java" + File.separator + "lib" +
54 File.separator + "arcobjects.jar"; 54 File.separator + "arcobjects.jar";
55 55
56 //Create a new file 56 //Create a new file
57 File jarFile = new File(jarPath); 57 File jarFile = new File(jarPath);
58 58
59 //Test for file existence 59 //Test for file existence
60 if(!jarFile.exists()){ 60 if(!jarFile.exists()){
61 logger.error("The arcobjects.jar was not found in the following location: " + 61 logger.error("The arcobjects.jar was not found in the" +
62 jarFile.getParent()); 62 " following location: " + jarFile.getParent());
63 logger.error("Verify that arcobjects.jar can be located in the specified folder."); 63 logger.error("Verify that arcobjects.jar can" +
64 logger.error("If not present, try uninstalling your ArcGIS software and reinstalling it."); 64 " be located in the specified folder.");
65 logger.error("If not present, try uninstalling your" +
66 " ArcGIS software and reinstalling it.");
65 System.exit(0); 67 System.exit(0);
66 } 68 }
67 69
68 //Helps load classes and resources from a search path of URLs 70 //Helps load classes and resources from a search path of URLs
69 URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader(); 71 URLClassLoader sysloader =
72 (URLClassLoader) ClassLoader.getSystemClassLoader();
70 Class<URLClassLoader> sysclass = URLClassLoader.class; 73 Class<URLClassLoader> sysclass = URLClassLoader.class;
71 74
72 try { 75 try {
73 Method method = sysclass.getDeclaredMethod("addURL", new Class[]{URL.class}); 76 Method method = sysclass.getDeclaredMethod("addURL",
77 new Class[]{URL.class});
74 method.setAccessible(true); 78 method.setAccessible(true);
75 method.invoke(sysloader, new Object[]{jarFile.toURI().toURL()}); 79 method.invoke(sysloader, new Object[]{jarFile.toURI().toURL()});
76 } 80 }
77 catch (Throwable throwable) { 81 catch (Throwable throwable) {
78 throwable.printStackTrace(); 82 throwable.printStackTrace();
79 logger.error("Could not add arcobjects.jar to system classloader"); 83 logger.error("Could not add arcobjects.jar to system classloader");
80 System.exit(0); 84 System.exit(0);
81 } 85 }
82 86
83 EngineInitializer.initializeEngine(); 87 EngineInitializer.initializeEngine();
84 88
85 aoInit = new AoInitialize(); 89 aoInit = new AoInitialize();
86 return true; 90 return true;
87 } 91 }
88 92
89 /** 93 /**
90 * Init ArcGIS License. 94 * Init ArcGIS License.
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)