src/jdk.jpackager/share/native/library/common/Package.cpp
author herrick
Mon, 05 Nov 2018 17:32:00 -0500
branchJDK-8200758-branch
changeset 57017 1b08af362a30
parent 56995 src/jdk.packager/share/native/library/common/Package.cpp@3d5b13207b70
permissions -rw-r--r--
8213156:rename packages for jpackager Reviewed-by: almatvee, kcr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     1
/*
56854
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
     2
 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     4
 *
56854
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    10
 *
56854
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    15
 * accompanied this code).
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    16
 *
56854
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    20
 *
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    23
 * questions.
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    24
 */
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    25
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    26
#include "Package.h"
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    27
#include "Lock.h"
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    28
#include "Helpers.h"
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    29
#include "Macros.h"
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    30
#include "IniFile.h"
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    31
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    32
#include <assert.h>
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    33
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    34
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    35
Package::Package(void) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    36
    FInitialized = false;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    37
    Initialize();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    38
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    39
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    40
TPlatformNumber StringToPercentageOfNumber(TString Value,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    41
        TPlatformNumber Number) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    42
    TPlatformNumber result = 0;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    43
    size_t percentage = atoi(PlatformString(Value.c_str()));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    44
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    45
    if (percentage > 0 && Number > 0) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    46
        result = Number * percentage / 100;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    47
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    48
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    49
    return result;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    50
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    51
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    52
bool Package::CheckForSingleInstance() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    53
    Platform& platform = Platform::GetInstance();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    54
#ifdef MAC
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    55
    if (platform.IsMainThread()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    56
        return false;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    57
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    58
#endif
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    59
    if (FInitialized == true) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    60
        // everything must be initialised at this point
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    61
        return false;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    62
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    63
    TString appName;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    64
    TString appVersion;
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    65
    AutoFreePtr<ISectionalPropertyContainer> config =
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    66
            platform.GetConfigFile(platform.GetConfigFileName());
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    67
    std::map<TString, TString> keys = platform.GetKeys();
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    68
    config->GetValue(keys[CONFIG_SECTION_APPLICATION],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    69
            keys[APP_NAME_KEY], appName);
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    70
    config->GetValue(keys[CONFIG_SECTION_APPLICATION],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    71
            keys[CONFIG_VERSION], appVersion);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    72
    TString singleInstance;
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    73
    config->GetValue(keys[CONFIG_SECTION_APPLICATION],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    74
            keys[CONFIG_APPLICATION_INSTANCE], singleInstance);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    75
    if (singleInstance == _T("single")) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    76
        TString uniqueID = appName + FBootFields->FAppID + appVersion;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    77
        // if another instance is running, later we can try to reactivate it
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    78
        return platform.CheckForSingleInstance(uniqueID);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    79
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    80
    return false;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    81
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    82
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    83
void Package::Initialize() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    84
    if (FInitialized == true) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    85
        return;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    86
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    87
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    88
    Platform& platform = Platform::GetInstance();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    89
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    90
    FBootFields = new PackageBootFields();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    91
    FDebugging = dsNone;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    92
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    93
    FBootFields->FPackageRootDirectory = platform.GetPackageRootDirectory();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    94
    FBootFields->FPackageAppDirectory = platform.GetPackageAppDirectory();
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    95
    FBootFields->FPackageLauncherDirectory =
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    96
            platform.GetPackageLauncherDirectory();
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    97
    FBootFields->FAppDataDirectory = platform.GetAppDataDirectory();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    98
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    99
    std::map<TString, TString> keys = platform.GetKeys();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   100
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   101
    // Read from configure.cfg/Info.plist
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   102
    AutoFreePtr<ISectionalPropertyContainer> config =
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   103
            platform.GetConfigFile(platform.GetConfigFileName());
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   104
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   105
    config->GetValue(keys[CONFIG_SECTION_APPLICATION],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   106
            keys[CONFIG_APP_ID_KEY], FBootFields->FAppID);
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   107
    config->GetValue(keys[CONFIG_SECTION_APPLICATION],
57017
1b08af362a30 8213156:rename packages for jpackager
herrick
parents: 56995
diff changeset
   108
            keys[JPACKAGER_APP_DATA_DIR], FBootFields->FPackageAppDataDirectory);
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   109
    FBootFields->FPackageAppDataDirectory =
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   110
            FilePath::FixPathForPlatform(FBootFields->FPackageAppDataDirectory);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   111
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   112
    // Main JAR.
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   113
    config->GetValue(keys[CONFIG_SECTION_APPLICATION],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   114
            keys[CONFIG_MAINJAR_KEY], FBootFields->FMainJar);
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   115
    FBootFields->FMainJar =
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   116
            FilePath::IncludeTrailingSeparator(GetPackageAppDirectory())
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   117
            + FilePath::FixPathForPlatform(FBootFields->FMainJar);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   118
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   119
    // Main Module.
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   120
    config->GetValue(keys[CONFIG_SECTION_APPLICATION],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   121
            keys[CONFIG_MAINMODULE_KEY], FBootFields->FMainModule);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   122
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   123
    // Classpath.
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   124
    // 1. If the provided class path contains main jar then only use
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   125
    //    provided class path.
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   126
    // 2. If class path provided by config file is empty then add main jar.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   127
    // 3. If main jar is not in provided class path then add it.
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   128
    config->GetValue(keys[CONFIG_SECTION_APPLICATION],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   129
            keys[CONFIG_CLASSPATH_KEY], FBootFields->FClassPath);
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   130
    FBootFields->FClassPath =
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   131
            FilePath::FixPathSeparatorForPlatform(FBootFields->FClassPath);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   132
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   133
    if (FBootFields->FClassPath.empty() == true) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   134
        FBootFields->FClassPath = GetMainJar();
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   135
    } else if (FBootFields->FClassPath.find(GetMainJar()) == TString::npos) {
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   136
        FBootFields->FClassPath = GetMainJar()
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   137
                + FilePath::PathSeparator() + FBootFields->FClassPath;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   138
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   139
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   140
    // Modulepath.
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   141
    config->GetValue(keys[CONFIG_SECTION_APPLICATION],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   142
            keys[CONFIG_MODULEPATH_KEY], FBootFields->FModulePath);
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   143
    FBootFields->FModulePath =
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   144
            FilePath::FixPathSeparatorForPlatform(FBootFields->FModulePath);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   145
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   146
    // Main Class.
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   147
    config->GetValue(keys[CONFIG_SECTION_APPLICATION],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   148
            keys[CONFIG_MAINCLASSNAME_KEY], FBootFields->FMainClassName);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   149
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   150
    // Splash Screen.
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   151
    if (config->GetValue(keys[CONFIG_SECTION_APPLICATION],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   152
            keys[CONFIG_SPLASH_KEY],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   153
            FBootFields->FSplashScreenFileName) == true) {
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   154
        FBootFields->FSplashScreenFileName =
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   155
            FilePath::IncludeTrailingSeparator(GetPackageAppDirectory())
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   156
            + FilePath::FixPathForPlatform(FBootFields->FSplashScreenFileName);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   157
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   158
        if (FilePath::FileExists(FBootFields->FSplashScreenFileName) == false) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   159
            FBootFields->FSplashScreenFileName = _T("");
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   160
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   161
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   162
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   163
    // Runtime.
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   164
    config->GetValue(keys[CONFIG_SECTION_APPLICATION],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   165
            keys[JVM_RUNTIME_KEY], FBootFields->FJVMRuntimeDirectory);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   166
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   167
    // Read jvmargs.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   168
    PromoteAppCDSState(config);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   169
    ReadJVMArgs(config);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   170
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   171
    // Read args if none were passed in.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   172
    if (FBootFields->FArgs.size() == 0) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   173
        OrderedMap<TString, TString> args;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   174
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   175
        if (config->GetSection(keys[CONFIG_SECTION_ARGOPTIONS], args) == true) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   176
            FBootFields->FArgs = Helpers::MapToNameValueList(args);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   177
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   178
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   179
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   180
    // Auto Memory.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   181
    TString autoMemory;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   182
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   183
    if (config->GetValue(keys[CONFIG_SECTION_APPLICATION],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   184
            keys[CONFIG_APP_MEMORY], autoMemory) == true) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   185
        if (autoMemory == _T("auto") || autoMemory == _T("100%")) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   186
            FBootFields->FMemoryState = PackageBootFields::msAuto;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   187
            FBootFields->FMemorySize = platform.GetMemorySize();
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   188
        } else if (autoMemory.length() == 2 && isdigit(autoMemory[0]) &&
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   189
                autoMemory[1] == '%') {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   190
            FBootFields->FMemoryState = PackageBootFields::msAuto;
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   191
            FBootFields->FMemorySize =
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   192
                    StringToPercentageOfNumber(autoMemory.substr(0, 1),
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   193
                    platform.GetMemorySize());
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   194
        } else if (autoMemory.length() == 3 && isdigit(autoMemory[0]) &&
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   195
                isdigit(autoMemory[1]) && autoMemory[2] == '%') {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   196
            FBootFields->FMemoryState = PackageBootFields::msAuto;
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   197
            FBootFields->FMemorySize =
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   198
                    StringToPercentageOfNumber(autoMemory.substr(0, 2),
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   199
                    platform.GetMemorySize());
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   200
        } else {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   201
            FBootFields->FMemoryState = PackageBootFields::msManual;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   202
            FBootFields->FMemorySize = 0;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   203
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   204
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   205
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   206
    // Debug
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   207
    TString debug;
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   208
    if (config->GetValue(keys[CONFIG_SECTION_APPLICATION],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   209
            keys[CONFIG_APP_DEBUG], debug) == true) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   210
        FBootFields->FArgs.push_back(debug);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   211
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   212
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   213
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   214
void Package::Clear() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   215
    FreeBootFields();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   216
    FInitialized = false;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   217
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   218
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   219
// This is the only location that the AppCDS state should be modified except
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   220
// by command line arguments provided by the user.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   221
//
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   222
// The state of AppCDS is as follows:
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   223
//
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   224
// -> cdsUninitialized
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   225
//    -> cdsGenCache If -Xappcds:generatecache
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   226
//    -> cdsDisabled If -Xappcds:off
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   227
//    -> cdsEnabled If "AppCDSJVMOptions" section is present
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   228
//    -> cdsAuto If "AppCDSJVMOptions" section is present and
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   229
//               app.appcds.cache=auto
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   230
//    -> cdsDisabled Default
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   231
//
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   232
void Package::PromoteAppCDSState(ISectionalPropertyContainer* Config) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   233
    Platform& platform = Platform::GetInstance();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   234
    std::map<TString, TString> keys = platform.GetKeys();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   235
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   236
    // The AppCDS state can change at this point.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   237
    switch (platform.GetAppCDSState()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   238
        case cdsEnabled:
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   239
        case cdsAuto:
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   240
        case cdsDisabled:
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   241
        case cdsGenCache: {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   242
            // Do nothing.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   243
            break;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   244
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   245
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   246
        case cdsUninitialized: {
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   247
            if (Config->ContainsSection(
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   248
                    keys[CONFIG_SECTION_APPCDSJVMOPTIONS]) == true) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   249
                // If the AppCDS section is present then enable AppCDS.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   250
                TString appCDSCacheValue;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   251
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   252
                // If running with AppCDS enabled, and the configuration has
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   253
                // been setup so "auto" is enabled, then
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   254
                // the launcher will attempt to generate the cache file
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   255
                // automatically and run the application.
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   256
                if (Config->GetValue(keys[CONFIG_SECTION_APPLICATION],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   257
                        _T("app.appcds.cache"), appCDSCacheValue) == true &&
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   258
                    appCDSCacheValue == _T("auto")) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   259
                    platform.SetAppCDSState(cdsAuto);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   260
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   261
                else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   262
                    platform.SetAppCDSState(cdsEnabled);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   263
                }
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   264
            } else {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   265
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   266
                platform.SetAppCDSState(cdsDisabled);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   267
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   268
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   269
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   270
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   271
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   272
void Package::ReadJVMArgs(ISectionalPropertyContainer* Config) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   273
    Platform& platform = Platform::GetInstance();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   274
    std::map<TString, TString> keys = platform.GetKeys();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   275
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   276
    // Evaluate based on the current AppCDS state.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   277
    switch (platform.GetAppCDSState()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   278
        case cdsUninitialized: {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   279
            throw Exception(_T("Internal Error"));
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   280
        }
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   281
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   282
        case cdsDisabled: {
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   283
            Config->GetSection(keys[CONFIG_SECTION_JVMOPTIONS],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   284
                    FBootFields->FJVMArgs);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   285
            break;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   286
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   287
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   288
        case cdsGenCache: {
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   289
            Config->GetSection(keys[
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   290
                    CONFIG_SECTION_APPCDSGENERATECACHEJVMOPTIONS],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   291
                    FBootFields->FJVMArgs);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   292
            break;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   293
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   294
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   295
        case cdsAuto:
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   296
        case cdsEnabled: {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   297
            if (Config->GetValue(keys[CONFIG_SECTION_APPCDSJVMOPTIONS],
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   298
                    _T( "-XX:SharedArchiveFile"),
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   299
                    FBootFields->FAppCDSCacheFileName) == true) {
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   300
                // File names may contain the incorrect path separators.
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   301
                // The cache file name must be corrected at this point.
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   302
                if (FBootFields->FAppCDSCacheFileName.empty() == false) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   303
                    IniFile* iniConfig = dynamic_cast<IniFile*>(Config);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   304
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   305
                    if (iniConfig != NULL) {
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   306
                        FBootFields->FAppCDSCacheFileName =
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   307
                                FilePath::FixPathForPlatform(
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   308
                                FBootFields->FAppCDSCacheFileName);
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   309
                        iniConfig->SetValue(keys[
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   310
                                CONFIG_SECTION_APPCDSJVMOPTIONS],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   311
                                _T( "-XX:SharedArchiveFile"),
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   312
                                FBootFields->FAppCDSCacheFileName);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   313
                    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   314
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   315
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   316
                Config->GetSection(keys[CONFIG_SECTION_APPCDSJVMOPTIONS],
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   317
                        FBootFields->FJVMArgs);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   318
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   319
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   320
            break;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   321
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   322
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   323
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   324
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   325
void Package::SetCommandLineArguments(int argc, TCHAR* argv[]) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   326
    if (argc > 0) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   327
        std::list<TString> args;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   328
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   329
        // Prepare app arguments. Skip value at index 0 -
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   330
        // this is path to executable.
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   331
        FBootFields->FCommandName = argv[0];
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   332
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   333
        // Path to executable is at 0 index so start at index 1.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   334
        for (int index = 1; index < argc; index++) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   335
            TString arg = argv[index];
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   336
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   337
#ifdef DEBUG
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   338
            if (arg == _T("-debug")) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   339
                FDebugging = dsNative;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   340
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   341
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   342
            if (arg == _T("-javadebug")) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   343
                FDebugging = dsJava;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   344
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   345
#endif //DEBUG
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   346
#ifdef MAC
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   347
            if (arg.find(_T("-psn_"), 0) != TString::npos) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   348
                Platform& platform = Platform::GetInstance();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   349
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   350
                if (platform.IsMainThread() == true) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   351
#ifdef DEBUG
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   352
                    printf("%s\n", arg.c_str());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   353
#endif //DEBUG
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   354
                    continue;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   355
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   356
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   357
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   358
            if (arg == _T("-NSDocumentRevisionsDebugMode")) {
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   359
                // Ignore -NSDocumentRevisionsDebugMode and
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   360
                // the following YES/NO
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   361
                index++;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   362
                continue;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   363
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   364
#endif //MAC
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   365
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   366
            args.push_back(arg);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   367
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   368
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   369
        if (args.size() > 0) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   370
            FBootFields->FArgs = args;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   371
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   372
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   373
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   374
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   375
Package& Package::GetInstance() {
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   376
    static Package instance;
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   377
    // Guaranteed to be destroyed. Instantiated on first use.
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   378
    return instance;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   379
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   380
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   381
Package::~Package(void) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   382
    FreeBootFields();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   383
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   384
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   385
void Package::FreeBootFields() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   386
    if (FBootFields != NULL) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   387
        delete FBootFields;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   388
        FBootFields = NULL;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   389
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   390
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   391
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   392
OrderedMap<TString, TString> Package::GetJVMArgs() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   393
    return FBootFields->FJVMArgs;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   394
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   395
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   396
std::vector<TString> GetKeysThatAreNotDuplicates(OrderedMap<TString,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   397
        TString> &Defaults, OrderedMap<TString, TString> &Overrides) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   398
    std::vector<TString> result;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   399
    std::vector<TString> overrideKeys = Overrides.GetKeys();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   400
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   401
    for (size_t index = 0; index < overrideKeys.size(); index++) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   402
        TString overridesKey = overrideKeys[index];
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   403
        TString overridesValue;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   404
        TString defaultValue;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   405
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   406
        if ((Defaults.ContainsKey(overridesKey) == false) ||
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   407
           (Defaults.GetValue(overridesKey, defaultValue) == true &&
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   408
            Overrides.GetValue(overridesKey, overridesValue) == true &&
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   409
            defaultValue != overridesValue)) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   410
            result.push_back(overridesKey);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   411
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   412
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   413
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   414
    return result;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   415
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   416
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   417
OrderedMap<TString, TString> CreateOrderedMapFromKeyList(OrderedMap<TString,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   418
        TString> &Map, std::vector<TString> &Keys) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   419
    OrderedMap<TString, TString> result;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   420
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   421
    for (size_t index = 0; index < Keys.size(); index++) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   422
        TString key = Keys[index];
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   423
        TString value;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   424
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   425
        if (Map.GetValue(key, value) == true) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   426
            result.Append(key, value);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   427
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   428
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   429
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   430
    return result;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   431
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   432
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   433
std::vector<TString> GetKeysThatAreNotOverridesOfDefaultValues(
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   434
        OrderedMap<TString, TString> &Defaults, OrderedMap<TString,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   435
        TString> &Overrides) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   436
    std::vector<TString> result;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   437
    std::vector<TString> keys = Overrides.GetKeys();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   438
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   439
    for (unsigned int index = 0; index< keys.size(); index++) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   440
        TString key = keys[index];
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   441
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   442
        if (Defaults.ContainsKey(key) == true) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   443
            try {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   444
                TString value = Overrides[key];
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   445
                Defaults[key] = value;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   446
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   447
            catch (std::out_of_range) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   448
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   449
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   450
        else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   451
            result.push_back(key);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   452
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   453
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   454
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   455
    return result;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   456
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   457
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   458
std::list<TString> Package::GetArgs() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   459
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   460
    return FBootFields->FArgs;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   461
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   462
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   463
TString Package::GetPackageRootDirectory() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   464
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   465
    return FBootFields->FPackageRootDirectory;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   466
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   467
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   468
TString Package::GetPackageAppDirectory() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   469
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   470
    return FBootFields->FPackageAppDirectory;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   471
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   472
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   473
TString Package::GetPackageLauncherDirectory() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   474
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   475
    return FBootFields->FPackageLauncherDirectory;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   476
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   477
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   478
TString Package::GetAppDataDirectory() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   479
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   480
    return FBootFields->FAppDataDirectory;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   481
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   482
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   483
TString Package::GetAppCDSCacheDirectory() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   484
    if (FAppCDSCacheDirectory.empty()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   485
        Platform& platform = Platform::GetInstance();
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   486
        FAppCDSCacheDirectory = FilePath::IncludeTrailingSeparator(
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   487
                platform.GetAppDataDirectory())
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   488
                + FilePath::IncludeTrailingSeparator(
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   489
                GetPackageAppDataDirectory()) + _T("cache");
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   490
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   491
        Macros& macros = Macros::GetInstance();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   492
        FAppCDSCacheDirectory = macros.ExpandMacros(FAppCDSCacheDirectory);
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   493
        FAppCDSCacheDirectory =
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   494
                FilePath::FixPathForPlatform(FAppCDSCacheDirectory);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   495
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   496
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   497
    return FAppCDSCacheDirectory;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   498
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   499
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   500
TString Package::GetAppCDSCacheFileName() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   501
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   502
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   503
    if (FBootFields->FAppCDSCacheFileName.empty() == false) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   504
        Macros& macros = Macros::GetInstance();
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   505
        FBootFields->FAppCDSCacheFileName =
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   506
                macros.ExpandMacros(FBootFields->FAppCDSCacheFileName);
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   507
        FBootFields->FAppCDSCacheFileName =
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   508
                FilePath::FixPathForPlatform(FBootFields->FAppCDSCacheFileName);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   509
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   510
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   511
    return FBootFields->FAppCDSCacheFileName;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   512
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   513
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   514
TString Package::GetAppID() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   515
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   516
    return FBootFields->FAppID;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   517
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   518
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   519
TString Package::GetPackageAppDataDirectory() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   520
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   521
    return FBootFields->FPackageAppDataDirectory;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   522
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   523
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   524
TString Package::GetClassPath() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   525
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   526
    return FBootFields->FClassPath;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   527
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   528
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   529
TString Package::GetModulePath() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   530
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   531
    return FBootFields->FModulePath;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   532
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   533
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   534
TString Package::GetMainJar() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   535
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   536
    return FBootFields->FMainJar;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   537
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   538
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   539
TString Package::GetMainModule() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   540
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   541
    return FBootFields->FMainModule;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   542
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   543
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   544
TString Package::GetMainClassName() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   545
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   546
    return FBootFields->FMainClassName;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   547
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   548
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   549
TString Package::GetJVMLibraryFileName() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   550
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   551
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   552
    if (FBootFields->FJVMLibraryFileName.empty() == true) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   553
        Platform& platform = Platform::GetInstance();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   554
        Macros& macros = Macros::GetInstance();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   555
        TString jvmRuntimePath = macros.ExpandMacros(GetJVMRuntimeDirectory());
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   556
        FBootFields->FJVMLibraryFileName =
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   557
                platform.GetBundledJVMLibraryFileName(jvmRuntimePath);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   558
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   559
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   560
    return FBootFields->FJVMLibraryFileName;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   561
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   562
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   563
TString Package::GetJVMRuntimeDirectory() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   564
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   565
    return FBootFields->FJVMRuntimeDirectory;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   566
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   567
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   568
TString Package::GetSplashScreenFileName() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   569
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   570
    return FBootFields->FSplashScreenFileName;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   571
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   572
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   573
bool Package::HasSplashScreen() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   574
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   575
    return FilePath::FileExists(FBootFields->FSplashScreenFileName);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   576
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   577
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   578
TString Package::GetCommandName() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   579
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   580
    return FBootFields->FCommandName;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   581
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   582
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   583
TPlatformNumber Package::GetMemorySize() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   584
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   585
    return FBootFields->FMemorySize;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   586
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   587
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   588
PackageBootFields::MemoryState Package::GetMemoryState() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   589
    assert(FBootFields != NULL);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   590
    return FBootFields->FMemoryState;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   591
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   592
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   593
DebugState Package::Debugging() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   594
    return FDebugging;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   595
}