1 /* 2 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. 3 * All rights reserved. Use is subject to license terms. 4 * 5 * This file is available and licensed under the following license: 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * - Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * - Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the distribution. 16 * - Neither the name of Oracle Corporation nor the names of its 17 * contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 34 #ifndef PACKAGE_H 35 #define PACKAGE_H 36 37 38 #include "Platform.h" 39 #include "PlatformString.h" 40 #include "FilePath.h" 41 #include "PropertyFile.h" 42 43 #include <map> 44 #include <list> 45 46 class PackageBootFields { 47 public: 48 enum MemoryState {msManual, msAuto}; 49 50 public: 51 OrderedMap<TString, TString> FJVMArgs; 52 std::list<TString> FArgs; 53 54 TString FPackageRootDirectory; 55 TString FPackageAppDirectory; 56 TString FPackageLauncherDirectory; 57 TString FAppDataDirectory; 58 TString FAppID; 59 TString FPackageAppDataDirectory; 60 TString FClassPath; 61 TString FModulePath; 62 TString FMainJar; 63 TString FMainModule; 64 TString FMainClassName; 65 bool FIsRuntimeBundled; 66 TString FJVMRuntimeDirectory; 67 TString FJVMLibraryFileName; 68 TString FSplashScreenFileName; 69 bool FUseJavaPreferences; 70 TString FCommandName; 71 72 TString FAppCDSCacheFileName; 73 74 TPlatformNumber FMemorySize; 75 MemoryState FMemoryState; 76 }; 77 78 79 class Package { 80 private: 81 Package(Package const&); // Don't Implement. 82 void operator=(Package const&); // Don't implement 83 84 private: 85 bool FInitialized; 86 PackageBootFields* FBootFields; 87 TString FJVMUserArgsConfigFileName; 88 TString FAppCDSCacheDirectory; 89 90 DebugState FDebugging; 91 92 OrderedMap<TString, TString> FJVMUserArgsOverrides; 93 OrderedMap<TString, TString> FDefaultJVMUserArgs; // Contains JVM user defaults 94 OrderedMap<TString, TString> FJVMUserArgs; // Contains a merge of JVM defaults and user overrides 95 96 97 Package(void); 98 99 //void Initialize(); 100 void MergeJVMDefaultsWithOverrides(); 101 TString GetMainJar(); 102 void SaveJVMUserArgOverrides(OrderedMap<TString, TString> Data); 103 void ReadJVMArgs(ISectionalPropertyContainer* Config); 104 void PromoteAppCDSState(ISectionalPropertyContainer* Config); 105 106 public: 107 static Package& GetInstance(); 108 ~Package(void); 109 110 void Initialize(); 111 void Clear(); 112 void FreeBootFields(); 113 bool CheckForSingleInstance(); 114 115 void SetCommandLineArguments(int argc, TCHAR* argv[]); 116 117 OrderedMap<TString, TString> GetJVMArgs(); 118 OrderedMap<TString, TString> GetDefaultJVMUserArgs(); 119 OrderedMap<TString, TString> GetJVMUserArgOverrides(); 120 void SetJVMUserArgOverrides(OrderedMap<TString, TString> Value); 121 OrderedMap<TString, TString> GetJVMUserArgs(); 122 TString GetMainModule(); 123 124 std::list<TString> GetArgs(); 125 126 TString GetPackageRootDirectory(); 127 TString GetPackageAppDirectory(); 128 TString GetPackageLauncherDirectory(); 129 TString GetAppDataDirectory(); 130 131 TString GetJVMUserArgsConfigFileName(); 132 TString GetAppCDSCacheDirectory(); 133 TString GetAppCDSCacheFileName(); 134 135 TString GetAppID(); 136 TString GetPackageAppDataDirectory(); 137 TString GetClassPath(); 138 TString GetModulePath(); 139 TString GetMainClassName(); 140 bool IsRuntimeBundled(); 141 TString GetJVMLibraryFileName(); 142 TString GetJVMRuntimeDirectory(); 143 TString GetSplashScreenFileName(); 144 bool HasSplashScreen(); 145 TString GetCommandName(); 146 147 TPlatformNumber GetMemorySize(); 148 PackageBootFields::MemoryState GetMemoryState(); 149 150 DebugState Debugging(); 151 }; 152 153 #endif //PACKAGE_H