1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package javax
.microedition
.swm
;
12 import cc
.squirreljme
.runtime
.cldc
.annotation
.Api
;
15 * This class provides static methods for obtaining the application suite and
21 public class ManagerFactory
23 /** Lock for initialization. */
24 private static final Object _LOCK
=
27 /** The suite manager. */
28 private static volatile SuiteManager _SUITE_MANAGER
;
30 /** The task manager. */
31 private static volatile TaskManager _TASK_MANAGER
;
34 * Returns an instance of the suite manager that the application may use
35 * to manage suites on the system.
37 * @return The manager which is used to manage suites installed on the
39 * @throws SecurityException If the {@code {@link SWMPermission}("client",
40 * "manageSuite")} or {@code {@link SWMPermission}("crossClient",
41 * "manageSuite")} permission is not permitted.
45 public static SuiteManager
getSuiteManager()
46 throws SecurityException
49 synchronized (ManagerFactory
._LOCK
)
51 SuiteManager rv
= ManagerFactory
._SUITE_MANAGER
;
53 ManagerFactory
._SUITE_MANAGER
=
54 (rv
= new __SystemSuiteManager__());
60 * This returns an instance of the task manager which is used to start,
61 * stop, and enumerate currently running tasks.
63 * @return The manager which is used to manage tasks which are currently
65 * @throws SecurityException If the {@code {@link SWMPermission}("client",
66 * "manageTask")} or {@code {@link SWMPermission}("crossClient",
67 * "manageTask")} permission is not permitted.
71 public static TaskManager
getTaskManager()
72 throws SecurityException
74 // Lazily initialize so that the class is easier to bring up rather
75 // than at class initialization time
76 synchronized (ManagerFactory
._LOCK
)
78 TaskManager rv
= ManagerFactory
._TASK_MANAGER
;
80 ManagerFactory
._TASK_MANAGER
=
81 (rv
= new __SystemTaskManager__());