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> FJavaOptions;
  44     std::list<TString> FArgs;
  45 
  46     TString FPackageRootDirectory;
  47     TString FPackageAppDirectory;
  48     TString FPackageLauncherDirectory;
  49     TString FAppDataDirectory;
  50     TString FPackageAppDataDirectory;
  51     TString FClassPath;
  52     TString FModulePath;
  53     TString FMainJar;
  54     TString FMainModule;
  55     TString FMainClassName;
  56     TString FJavaRuntimeDirectory;
  57     TString FJavaLibraryFileName;
  58     TString FSplashScreenFileName;
  59     bool FUseJavaPreferences;
  60     TString FCommandName;
  61 
  62     TString FAppCDSCacheFileName;
  63 
  64     TPlatformNumber FMemorySize;
  65     MemoryState FMemoryState;
  66 };
  67 
  68 
  69 class Package {
  70 private:
  71     Package(Package const&); // Don't Implement.
  72     void operator=(Package const&); // Don't implement
  73 
  74 private:
  75     bool FInitialized;
  76     PackageBootFields* FBootFields;
  77     TString FAppCDSCacheDirectory;
  78 
  79     DebugState FDebugging;
  80 
  81     Package(void);
  82 
  83     TString GetMainJar();
  84     void ReadJavaOptions(ISectionalPropertyContainer* Config);
  85     void PromoteAppCDSState(ISectionalPropertyContainer* Config);
  86 
  87 public:
  88     static Package& GetInstance();
  89     ~Package(void);
  90 
  91     void Initialize();
  92     void Clear();
  93     void FreeBootFields();
  94 
  95     void SetCommandLineArguments(int argc, TCHAR* argv[]);
  96 
  97     OrderedMap<TString, TString> GetJavaOptions();
  98     TString GetMainModule();
  99 
 100     std::list<TString> GetArgs();
 101 
 102     TString GetPackageRootDirectory();
 103     TString GetPackageAppDirectory();
 104     TString GetPackageLauncherDirectory();
 105     TString GetAppDataDirectory();
 106 
 107     TString GetAppCDSCacheDirectory();
 108     TString GetAppCDSCacheFileName();
 109 
 110     TString GetPackageAppDataDirectory();
 111     TString GetClassPath();
 112     TString GetModulePath();
 113     TString GetMainClassName();
 114     TString GetJavaLibraryFileName();
 115     TString GetJavaRuntimeDirectory();
 116     TString GetSplashScreenFileName();
 117     bool HasSplashScreen();
 118     TString GetCommandName();
 119 
 120     TPlatformNumber GetMemorySize();
 121     PackageBootFields::MemoryState GetMemoryState();
 122 
 123     DebugState Debugging();
 124 };
 125 
 126 #endif // PACKAGE_H