1 /*******************************************************************************
2 * Copyright (c) 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.procore.server.environment;
16 * @author Tuukka Lehtonen
18 public final class ExecutionEnvironment {
20 public final OSType os;
21 public final ARCHType arch;
23 private ExecutionEnvironment(OSType os, ARCHType arch) {
28 public static ExecutionEnvironment calculate() {
29 return new ExecutionEnvironment(calculateOS(), calculateArch());
32 public static ARCHType calculateArch() {
33 String osArch = System.getProperty("os.arch", "");
34 osArch = osArch.toLowerCase();
35 if (osArch.equals("i386") || osArch.equals("i586") || osArch.equals("i686") || osArch.equals("x86"))
37 if (osArch.startsWith("amd64") || osArch.startsWith("x86_64"))
38 return ARCHType.X86_64;
39 if (osArch.equals("ppc"))
41 if (osArch.startsWith("ppc"))
42 return ARCHType.PPC_64;
43 if (osArch.startsWith("sparc"))
44 return ARCHType.SPARC;
45 return ARCHType.UNKNOWN;
48 public static OSType calculateOS() {
49 String osName = System.getProperty("os.name", "");
50 osName = osName.toLowerCase();
51 if (osName.startsWith("mac os x"))
53 if (osName.startsWith("windows"))
54 return OSType.WINDOWS;
55 if (osName.startsWith("linux"))
57 if (osName.startsWith("sun"))
59 return OSType.UNKNOWN;