1 /*
   2  * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #ifndef PACKAGE_H
  27 #define PACKAGE_H
  28 
  29 
  30 #include "Platform.h"
  31 #include "PlatformString.h"
  32 #include "FilePath.h"
  33 #include "PropertyFile.h"
  34 
  35 #include <map>
  36 #include <list>
  37 
  38 class PackageBootFields {
  39 public:
  40     enum MemoryState {msManual, msAuto};
  41 
  42 public:
  43     OrderedMap<TString, TString> FJVMArgs;
  44     std::list<TString> FArgs;
  45 
  46     TString FPackageRootDirectory;
  47     TString FPackageAppDirectory;
  48     TString FPackageLauncherDirectory;
  49     TString FAppDataDirectory;
  50     TString FAppID;
  51     TString FPackageAppDataDirectory;
  52     TString FClassPath;
  53     TString FModulePath;
  54     TString FMainJar;
  55     TString FMainModule;
  56     TString FMainClassName;
  57     TString FJVMRuntimeDirectory;
  58     TString FJVMLibraryFileName;
  59     TString FSplashScreenFileName;
  60     bool FUseJavaPreferences;
  61     TString FCommandName;
  62 
  63     TString FAppCDSCacheFileName;
  64 
  65     TPlatformNumber FMemorySize;
  66     MemoryState FMemoryState;
  67 };
  68 
  69 
  70 class Package {
  71 private:
  72     Package(Package const&); // Don't Implement.
  73     void operator=(Package const&); // Don't implement
  74 
  75 private:
  76     bool FInitialized;
  77     PackageBootFields* FBootFields;
  78     TString FAppCDSCacheDirectory;
  79 
  80     DebugState FDebugging;
  81 
  82     Package(void);
  83 
  84     TString GetMainJar();
  85     void ReadJVMArgs(ISectionalPropertyContainer* Config);
  86     void PromoteAppCDSState(ISectionalPropertyContainer* Config);
  87 
  88 public:
  89     static Package& GetInstance();
  90     ~Package(void);
  91 
  92     void Initialize();
  93     void Clear();
  94     void FreeBootFields();
  95 
  96     void SetCommandLineArguments(int argc, TCHAR* argv[]);
  97 
  98     OrderedMap<TString, TString> GetJVMArgs();
  99     TString GetMainModule();
 100 
 101     std::list<TString> GetArgs();
 102 
 103     TString GetPackageRootDirectory();
 104     TString GetPackageAppDirectory();
 105     TString GetPackageLauncherDirectory();
 106     TString GetAppDataDirectory();
 107 
 108     TString GetAppCDSCacheDirectory();
 109     TString GetAppCDSCacheFileName();
 110 
 111     TString GetAppID();
 112     TString GetPackageAppDataDirectory();
 113     TString GetClassPath();
 114     TString GetModulePath();
 115     TString GetMainClassName();
 116     TString GetJVMLibraryFileName();
 117     TString GetJVMRuntimeDirectory();
 118     TString GetSplashScreenFileName();
 119     bool HasSplashScreen();
 120     TString GetCommandName();
 121 
 122     TPlatformNumber GetMemorySize();
 123     PackageBootFields::MemoryState GetMemoryState();
 124 
 125     DebugState Debugging();
 126 };
 127 
 128 #endif // PACKAGE_H