|
1 /* |
|
2 * Copyright (c) 2008-2010 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 package com.nokia.mj.impl.installer.ui; |
|
20 |
|
21 import com.nokia.mj.impl.utils.Logger; |
|
22 |
|
23 /** |
|
24 * Factory for JavaInstaller user interfaces. |
|
25 */ |
|
26 public class InstallerUiFactory |
|
27 { |
|
28 /** |
|
29 * Get instance of installer UI. |
|
30 * |
|
31 * @param aMode InstallerUi.MODE_INSTALL or InstallerUi.MODE_UNINSTALL |
|
32 * @param aListener installer UI listener |
|
33 * @return installer UI |
|
34 */ |
|
35 public static InstallerUi getInstallerUi |
|
36 (int aMode, InstallerUiListener aListener) |
|
37 { |
|
38 String className = "com.nokia.mj.impl.installer.ui.InstallerUi"; |
|
39 String uiProperty = |
|
40 System.getProperty("com.nokia.mj.impl.installer.ui"); |
|
41 if (uiProperty != null) |
|
42 { |
|
43 className = uiProperty; |
|
44 } |
|
45 |
|
46 InstallerUi installerUi = null; |
|
47 try |
|
48 { |
|
49 Class clazz = Class.forName(className); |
|
50 installerUi = (InstallerUi)clazz.newInstance(); |
|
51 installerUi.init(aMode, aListener); |
|
52 } |
|
53 catch (Exception ex) |
|
54 { |
|
55 logError("Instantiating " + className + " failed", ex); |
|
56 } |
|
57 return installerUi; |
|
58 } |
|
59 |
|
60 /** |
|
61 * Writes an info log entry to JavaInstaller log. |
|
62 * |
|
63 * @param aMsg message to be logged |
|
64 */ |
|
65 private static void log(String aMsg) |
|
66 { |
|
67 Logger.ILOG(Logger.EJavaInstaller, aMsg); |
|
68 } |
|
69 |
|
70 /** |
|
71 * Writes an error log entry to JavaInstaller log. |
|
72 * |
|
73 * @param aMsg message to be logged |
|
74 * @param aThrowable Throwable to be logged |
|
75 */ |
|
76 private static void logError(String aMsg, Throwable aThrowable) |
|
77 { |
|
78 Logger.ELOG(Logger.EJavaInstaller, aMsg, aThrowable); |
|
79 } |
|
80 } |