1 14 package org.compiere; 15 16 import java.awt.*; 17 import java.net.*; 18 import java.io.*; 19 import java.util.jar.*; 20 import javax.swing.*; 21 import javax.naming.*; 22 23 import org.compiere.util.*; 24 import org.compiere.plaf.*; 25 import org.compiere.db.*; 26 27 33 public final class Compiere 34 { 35 36 static public final String TIMESTAMP = "$Date: 2003/11/01 07:08:18 $"; 37 38 static public final String MAIN_VERSION = "Version 2.5.0d"; 39 40 static public final String DATE_VERSION = "2003-11-01"; 41 42 static public final String DB_VERSION = "2003-11-01"; 43 44 45 static public final String NAME = "Compiere\u2122"; 46 47 static public final String URL = "www.compiere.org"; 48 49 static private final String s_File16x16 = "images/C16.gif"; 50 51 static private final String s_file32x32 = "images/C32.gif"; 52 53 static private final String s_file100x30 = "images/C10030.gif"; 54 55 static private final String s_file48x15 = "images/Compiere.gif"; 56 57 static private String s_supportEmail = "info@company.com"; 58 59 60 static public final String SUB_TITLE = " Smart ERP & CRM "; 61 62 static public final String POWERED_BY = " Powered by Compiere\u2122 "; 63 64 static public final String COPYRIGHT = "Copyright \u00A9 1999-2003 Jorg Janke"; 65 66 static private String s_ImplementationVersion = null; 67 static private String s_ImplementationVendor = null; 68 69 static private Image s_image16; 70 static private Image s_image48x15; 71 static private Image s_imageLogo; 72 static private ImageIcon s_imageIcon32; 73 static private ImageIcon s_imageIconLogo; 74 75 76 private static Logger s_log = null; 77 78 82 public static String getName() 83 { 84 return NAME; 85 } 87 88 92 public static String getSum() 93 { 94 StringBuffer sb = new StringBuffer (); 95 sb.append(NAME).append(" ").append(MAIN_VERSION).append(SUB_TITLE); 96 return sb.toString(); 97 } 99 103 public static String getSummary() 104 { 105 StringBuffer sb = new StringBuffer (); 106 sb.append(NAME).append(" ") 107 .append(MAIN_VERSION).append("/").append(DATE_VERSION) 108 .append(" -").append(SUB_TITLE) 109 .append("- ").append(COPYRIGHT) 110 .append("; Implementation: ").append(getImplementationVersion()) 111 .append(" - ").append(getImplementationVendor()); 112 return sb.toString(); 113 } 115 118 private static void setJarInfo() 119 { 120 if (s_ImplementationVendor != null) 121 return; 122 s_ImplementationVendor = "?"; 123 s_ImplementationVersion = "?"; 124 125 try 126 { 127 JarFile jar = ZipUtil.getJar("CClient.jar"); 129 if (jar == null) 130 jar = ZipUtil.getJar("CTools.jar"); 131 if (jar == null) 132 return; 133 134 Manifest mf = jar.getManifest(); 138 if (mf != null) 139 { 140 Attributes atts = mf.getMainAttributes(); 141 s_ImplementationVendor = atts.getValue("Implementation-Vendor"); 142 s_ImplementationVersion = atts.getValue("Implementation-Version"); 143 } 144 } 145 catch (IOException ex) 146 { 147 System.err.println(ex); 148 } 149 } 151 155 public static String getImplementationVersion() 156 { 157 if (s_ImplementationVersion == null) 158 setJarInfo(); 159 return s_ImplementationVersion; 160 } 162 166 public static String getImplementationVendor() 167 { 168 if (s_ImplementationVendor == null) 169 setJarInfo(); 170 return s_ImplementationVendor; 171 } 173 177 public static int getCheckSum() 178 { 179 return getSum().hashCode(); 180 } 182 186 public static String getSummaryAscii() 187 { 188 String retValue = getSummary(); 189 retValue = Util.replace(retValue, "\u00AE", "(r)"); 191 retValue = Util.replace(retValue, "\u2122", "(tm)"); 193 retValue = Util.replace(retValue, "\u00A9", "(c)"); 195 retValue = Util.replace(retValue, Env.NL, " "); 197 retValue = Util.replace(retValue, "\n", " "); 198 return retValue; 199 } 201 205 public static String getJavaInfo() 206 { 207 return System.getProperty("java.vm.name") + " " + System.getProperty("java.vm.version"); 208 } 210 214 public static String getOSInfo() 215 { 216 return System.getProperty("os.name") + " " + System.getProperty("os.version") + " " + System.getProperty("sun.os.patch.level"); 217 } 219 223 public static String getURL() 224 { 225 return "http://" + URL; 226 } 228 232 public static String getPowered() 233 { 234 return POWERED_BY; 235 } 237 241 public static String getSubtitle() 242 { 243 return SUB_TITLE; 244 } 246 250 public static Image getImage16() 251 { 252 if (s_image16 == null) 253 { 254 Toolkit tk = Toolkit.getDefaultToolkit(); 255 URL url = org.compiere.Compiere.class.getResource(s_File16x16); 256 if (url == null) 258 return null; 259 s_image16 = tk.getImage(url); 260 } 261 return s_image16; 262 } 264 268 public static Image getImageLogoSmall() 269 { 270 if (s_image48x15 == null) 271 { 272 Toolkit tk = Toolkit.getDefaultToolkit(); 273 URL url = org.compiere.Compiere.class.getResource(s_file48x15); 274 if (url == null) 276 return null; 277 s_image48x15 = tk.getImage(url); 278 } 279 return s_image48x15; 280 } 282 286 public static Image getImageLogo() 287 { 288 if (s_imageLogo == null) 289 { 290 Toolkit tk = Toolkit.getDefaultToolkit(); 291 URL url = org.compiere.Compiere.class.getResource(s_file100x30); 292 if (url == null) 294 return null; 295 s_imageLogo = tk.getImage(url); 296 } 297 return s_imageLogo; 298 } 300 304 public static ImageIcon getImageIcon32() 305 { 306 if (s_imageIcon32 == null) 307 { 308 URL url = org.compiere.Compiere.class.getResource(s_file32x32); 309 if (url == null) 311 return null; 312 s_imageIcon32 = new ImageIcon(url); 313 } 314 return s_imageIcon32; 315 } 317 321 public static ImageIcon getImageIconLogo() 322 { 323 if (s_imageIconLogo == null) 324 { 325 URL url = org.compiere.Compiere.class.getResource(s_file100x30); 326 if (url == null) 328 return null; 329 s_imageIconLogo = new ImageIcon(url); 330 } 331 return s_imageIconLogo; 332 } 334 338 public static String getCompiereHome() 339 { 340 String retValue = Ini.getCompiereHome(); 342 if (retValue == null && System.getProperty("user.dir").indexOf("Compiere2") != -1) 344 { 345 retValue = System.getProperty("user.dir"); 346 int pos = retValue.indexOf("Compiere2"); 347 retValue = retValue.substring(pos+9); 348 } 349 if (retValue == null) 350 retValue = File.separator + "Compiere2"; 351 return retValue; 352 } 354 358 public static String getSupportEMail() 359 { 360 return s_supportEmail; 361 } 363 367 public static void setSupportEMail(String email) 368 { 369 s_supportEmail = email; 370 } 372 373 374 383 public static boolean startupClient () 384 { 385 if (s_log != null) 387 return true; 388 389 initClientLog(); 390 s_log.info(getSummaryAscii()); 392 s_log.info(getCompiereHome() + " - " + getJavaInfo() + " - " + getOSInfo()); 393 394 Ini.setClient (true); 396 if (!Env.isJavaOK()) 398 System.exit(1); 399 400 403 System.setProperty("javax.xml.parsers.DocumentBuilderFactory", 405 "org.apache.crimson.jaxp.DocumentBuilderFactoryImpl"); System.setProperty("javax.xml.parsers.SAXParserFactory", 408 "org.apache.crimson.jaxp.SAXParserFactoryImpl"); 411 Ini.loadProperties (false); 413 Log.initLog(); 415 416 CompiereTheme.load(); 418 CompierePLAF.setPLAF (null); 419 420 DB.setDBTarget(CConnection.get()); 422 return true; 423 } 425 434 public static boolean startupServer (Context context) 435 { 436 if (s_log != null && Ini.isLoaded()) 438 return true; 439 440 s_log = Logger.getCLogger(Compiere.class); 442 s_log.info(getSummaryAscii()); 444 s_log.info(getCompiereHome() + " - " + getJavaInfo() + " - " + getOSInfo()); 445 446 Ini.setClient (false); 448 Env.isJavaOK(); 450 453 System.setProperty("javax.xml.parsers.DocumentBuilderFactory", 455 "org.apache.crimson.jaxp.DocumentBuilderFactoryImpl"); System.setProperty("javax.xml.parsers.SAXParserFactory", 458 "org.apache.crimson.jaxp.SAXParserFactoryImpl"); 461 Ini.loadProperties (false); 463 Log.initLog(); 465 466 CConnection cc = CConnection.get(); 468 DB.setDBTarget(cc); 469 if (context != null) 471 cc.setDataSource (context, Ini.getProperty(Ini.P_CONTEXT)); 472 if (!cc.isDataSource()) 473 { 474 s_log.warn("startupServer - no DataSource"); 475 return false; 476 } 477 return true; 479 } 481 486 public static void initClientLog() 487 { 488 s_log = Logger.getCLogger(Compiere.class); 490 org.apache.log4j.LogManager.resetConfiguration(); 491 org.apache.log4j.Logger root = Logger.getRootLogger(); 492 root.addAppender(new org.apache.log4j.ConsoleAppender(new LogLayout())); 494 root.setLevel(org.apache.log4j.Level.ALL); 495 root.addAppender(LogBuffer.get()); 497 } 499 500 505 public static void main (String [] args) 506 { 507 Splash.getSplash(); 508 startupClient (); 510 String className = "org.compiere.apps.AMenu"; 512 for (int i = 0; i < args.length; i++) 513 { 514 if (!args[i].equals("-debug")) { 516 className = args[i]; 517 break; 518 } 519 } 520 try 522 { 523 Class startClass = Class.forName(className); 524 startClass.newInstance(); 525 } 526 catch (Exception e) 527 { 528 System.err.println("Cannot start: " + className + " - " + e.toString()); 529 e.printStackTrace(); 530 } 531 } } | Popular Tags |