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 114 void SetCommandLineArguments(int argc, TCHAR* argv[]); 115 116 OrderedMap<TString, TString> GetJVMArgs(); 117 OrderedMap<TString, TString> GetDefaultJVMUserArgs(); 118 OrderedMap<TString, TString> GetJVMUserArgOverrides(); 119 void SetJVMUserArgOverrides(OrderedMap<TString, TString> Value); 120 OrderedMap<TString, TString> GetJVMUserArgs(); 121 TString GetMainModule(); 122 123 std::list<TString> GetArgs(); 124 125 TString GetPackageRootDirectory(); 126 TString GetPackageAppDirectory(); 127 TString GetPackageLauncherDirectory(); 128 TString GetAppDataDirectory(); 129 130 TString GetJVMUserArgsConfigFileName(); 131 TString GetAppCDSCacheDirectory(); 132 TString GetAppCDSCacheFileName(); 133 134 TString GetAppID(); 135 TString GetPackageAppDataDirectory(); 136 TString GetClassPath(); 137 TString GetModulePath(); 138 TString GetMainClassName(); 139 bool IsRuntimeBundled(); 140 TString GetJVMLibraryFileName(); 141 TString GetJVMRuntimeDirectory(); 142 TString GetSplashScreenFileName(); 143 bool HasSplashScreen(); 144 TString GetCommandName(); 145 146 TPlatformNumber GetMemorySize(); 147 PackageBootFields::MemoryState GetMemoryState(); 148 149 DebugState Debugging(); 150 }; 151 152 #endif //PACKAGE_H