comparison src/java/de/intevation/mxd/ArcGISInitializer.java @ 103:163d474165b0

Added check for ArcGISDesktop environment.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 10 Jun 2011 14:04:03 +0200
parents ef7ca23c4233
children 104af51a4717
comparison
equal deleted inserted replaced
102:3ca2ec55fb3b 103:163d474165b0
1 package de.intevation.mxd; 1 package de.intevation.mxd;
2 2
3 import java.io.IOException; 3 import java.io.IOException;
4 import java.io.File;
5
6 import org.apache.log4j.Logger;
4 7
5 import com.esri.arcgis.system.AoInitialize; 8 import com.esri.arcgis.system.AoInitialize;
6 import com.esri.arcgis.system.EngineInitializer; 9 import com.esri.arcgis.system.EngineInitializer;
7 import com.esri.arcgis.system.esriLicenseProductCode; 10 import com.esri.arcgis.system.esriLicenseProductCode;
8 import com.esri.arcgis.system.esriLicenseStatus; 11 import com.esri.arcgis.system.esriLicenseStatus;
13 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> 16 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
14 */ 17 */
15 public class ArcGISInitializer { 18 public class ArcGISInitializer {
16 19
17 /** 20 /**
21 * The Logger.
22 */
23 private static final Logger logger = Logger.getLogger(ArcGISInitializer.class);
24
25 /**
18 * Private member. 26 * Private member.
19 */ 27 */
20 private AoInitialize aoInit; 28 private AoInitialize aoInit;
21 private String engineInstallDir = ""; 29 private String engineInstallDir = "";
22 30
24 /** 32 /**
25 * Init ArcGIS Java Objects. 33 * Init ArcGIS Java Objects.
26 */ 34 */
27 public boolean initArcGIS () 35 public boolean initArcGIS ()
28 throws IOException { 36 throws IOException {
37 logger.debug("initArcGIS()");
29 EngineInitializer.initializeEngine(); 38 EngineInitializer.initializeEngine();
30 aoInit = new AoInitialize(); 39 aoInit = new AoInitialize();
31 engineInstallDir = System.getenv("AGSENGINEJAVA"); 40 engineInstallDir = System.getenv("AGSENGINEJAVA");
41 File installDir = new File(engineInstallDir);
42 if(!installDir.exists()) {
43 engineInstallDir = System.getenv("AGSDESKTOPJAVA");
44 installDir = new File(engineInstallDir);
45 if(!installDir.exists()) {
46 logger.error("Could not find ArcGIS Environment. \n" +
47 "AGSENGINEJAVA or AGSDESKTOPJAVA not set.");
48 return false;
49 }
50 }
51 else {
52 return true;
53 }
32 return true; 54 return true;
33 } 55 }
34 56
35 /** 57 /**
36 * Init ArcGIS License. 58 * Init ArcGIS License.
37 */ 59 */
38 public void initArcGISLicenses() 60 public boolean initArcGISLicenses()
39 throws IOException { 61 throws IOException {
62 logger.debug("initArcGISLicenses()");
40 if(aoInit.isProductCodeAvailable 63 if(aoInit.isProductCodeAvailable
41 (esriLicenseProductCode.esriLicenseProductCodeEngine) == 64 (esriLicenseProductCode.esriLicenseProductCodeEngine) ==
42 esriLicenseStatus.esriLicenseAvailable) { 65 esriLicenseStatus.esriLicenseAvailable) {
43 aoInit.initialize 66 aoInit.initialize
44 (esriLicenseProductCode.esriLicenseProductCodeEngine); 67 (esriLicenseProductCode.esriLicenseProductCodeEngine);
48 esriLicenseStatus.esriLicenseAvailable) { 71 esriLicenseStatus.esriLicenseAvailable) {
49 aoInit.initialize 72 aoInit.initialize
50 (esriLicenseProductCode.esriLicenseProductCodeArcView); 73 (esriLicenseProductCode.esriLicenseProductCodeArcView);
51 } 74 }
52 else { 75 else {
53 System.err.println("Engine Runtime or ArcView" + 76 logger.error("Engine Runtime or ArcView" +
54 " license not initialized."); 77 " license not initialized.\n" +
55 System.err.println("Exiting application."); 78 "Please install an ArcGIS product and set the" +
56 System.exit(-1); 79 " PATH-variable correctly.");
80 return false;
57 } 81 }
82 return true;
58 } 83 }
59 84
60 /** 85 /**
61 * Shutdown the ArcGIS Objects. 86 * Shutdown the ArcGIS Objects.
62 */ 87 */
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)