|
1 /* |
|
2 * Copyright (c) 2002 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: This class setup MMA plugins. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 package com.nokia.microedition.media; |
|
20 |
|
21 import com.nokia.mj.impl.utils.Logger; |
|
22 |
|
23 /** |
|
24 * Class used to setup external components. |
|
25 */ |
|
26 public class Setup |
|
27 { |
|
28 // Class names used to invoke external components. |
|
29 private static final String[] MMA_PLUGINS = |
|
30 { |
|
31 //"com.nokia.amms.MMAInvokeListenerImpl" |
|
32 }; |
|
33 |
|
34 /** |
|
35 * Private constructor not to allow construction. |
|
36 */ |
|
37 private Setup() |
|
38 { |
|
39 } |
|
40 |
|
41 /** |
|
42 * Setup external components. |
|
43 * @param aEventSourceHandle Native handle MMA event source. |
|
44 */ |
|
45 public static void setup(int aEventSourceHandle) |
|
46 { |
|
47 // Go through all plugins |
|
48 for (int i = 0; i < MMA_PLUGINS.length; i++) |
|
49 { |
|
50 invokeComponent(aEventSourceHandle, MMA_PLUGINS[ i ]); |
|
51 } |
|
52 } |
|
53 |
|
54 /** |
|
55 * Invokes other component. This method returns without creating the |
|
56 * components if the class is not found. |
|
57 * |
|
58 * @param aEventSourceHandle Handle to native mma event source. |
|
59 * @param aClassName Full class name to create. Class must have public |
|
60 * default constructor and implement MMAInvokeListener interface. |
|
61 * @throws OutOfMemoryError if component cannot be created. |
|
62 */ |
|
63 private static void invokeComponent(int aEventSourceHandle, String aClassName) |
|
64 { |
|
65 try |
|
66 { |
|
67 Class invokerClass = |
|
68 Class.forName(aClassName); |
|
69 MMAInvokeListener invoker = |
|
70 (MMAInvokeListener)invokerClass.newInstance(); |
|
71 invoker.notifyInvoke(aEventSourceHandle); |
|
72 } |
|
73 catch (InstantiationException ie) |
|
74 { |
|
75 throw new OutOfMemoryError("Instantiation failed, " + ie.toString()); |
|
76 } |
|
77 catch (IllegalAccessException iae) |
|
78 { |
|
79 throw new OutOfMemoryError("Illegal access, " + iae.toString()); |
|
80 } |
|
81 catch (ClassNotFoundException cnfe) |
|
82 { |
|
83 // If invoker class cannot be found, plugin is not added to J2ME |
|
84 // build and MMA is used without it. |
|
85 Logger.ELOG(Logger.EJavaMMAPI, "MMA::Setup:: ", cnfe); |
|
86 } |
|
87 } |
|
88 } |
|
89 // End of File |
|
90 |