javaruntimes/jvmargmodifier/file/src/jvmargsmodifier.cpp
branchRCL_3
changeset 19 04becd199f91
child 64 0ea12c182930
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  A default empty implementation for JvmArgs modifier.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <algorithm>
       
    19 
       
    20 #include "jvmargsmodifier.h"
       
    21 #include "logger.h"
       
    22 
       
    23 #include "jvmargsfilereader.h"
       
    24 #include "argsmodifier.h"
       
    25 
       
    26 #ifdef __SYMBIAN32__
       
    27 #include <AknGlobalNote.h>
       
    28 _LIT(KArgsTxt, "Note! Modified VM arguments used!");
       
    29 #endif
       
    30 
       
    31 void logArguments(std::wstring aArg)
       
    32 {
       
    33     WLOG1(EJavaRuntime, " '%S'", aArg.c_str());
       
    34 }
       
    35 
       
    36 #ifdef __SYMBIAN32__
       
    37 void showWarningDialogL()
       
    38 {
       
    39     ::CAknGlobalNote* globalNote = CAknGlobalNote::NewL();
       
    40     CleanupStack::PushL(globalNote);
       
    41     globalNote->ShowNoteL(EAknGlobalInformationNote, KArgsTxt);
       
    42     CleanupStack::PopAndDestroy(globalNote);
       
    43 }
       
    44 #endif
       
    45 
       
    46 
       
    47 OS_EXPORT
       
    48 void java::runtime::modifyJvmArguments(const std::wstring& aIdentifier,
       
    49                                        std::list<std::wstring>& aJvmArgs,
       
    50                                        std::list<std::wstring>& aApplicationAndArgs)
       
    51 {
       
    52     JELOG2(EJavaRuntime);
       
    53 
       
    54 #ifdef __SYMBIAN32__
       
    55     // Open the extension directory of the J9 VM.
       
    56     aJvmArgs.push_back(L"-Dcom.ibm.j9.ext.dirs=c:\\resource\\java\\jvm\\lib\\common;z:\\resource\\java\\jvm\\lib\\common");
       
    57 #endif
       
    58 
       
    59     JvmArgsFileReader reader(aIdentifier);
       
    60     JvmArgsModifier modifier;
       
    61     std::list<std::wstring> newJvmArgs = reader.getJvmArguments();
       
    62     std::list<std::wstring> newAppArgs = reader.getApplicationArguments();
       
    63 
       
    64     modifier.combineArguments(aJvmArgs, newJvmArgs);
       
    65     modifier.combineArguments(aApplicationAndArgs, newAppArgs);
       
    66 
       
    67     if (newJvmArgs.size() != 0 || newAppArgs.size() != 0)
       
    68     {
       
    69         WLOG(EJavaRuntime, "new JVM arguments");
       
    70         std::for_each(aJvmArgs.begin(), aJvmArgs.end(), logArguments);
       
    71         WLOG(EJavaRuntime, "new App arguments");
       
    72         std::for_each(aApplicationAndArgs.begin(), aApplicationAndArgs.end(), logArguments);
       
    73 #ifdef __SYMBIAN32__
       
    74         TRAP_IGNORE(showWarningDialogL());
       
    75 #endif
       
    76     }
       
    77 }
       
    78