Bump date.
[SquirrelJME.git] / modules / meep-swm / src / main / java / javax / microedition / swm / ManagerFactory.java
blobd975ea07d277e316440cd3f295f4a63cf35d1039
1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
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;
14 /**
15 * This class provides static methods for obtaining the application suite and
16 * task manager.
18 * @since 2016/06/24
20 @Api
21 public class ManagerFactory
23 /** Lock for initialization. */
24 private static final Object _LOCK =
25 new Object();
27 /** The suite manager. */
28 private static volatile SuiteManager _SUITE_MANAGER;
30 /** The task manager. */
31 private static volatile TaskManager _TASK_MANAGER;
33 /**
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
38 * system.
39 * @throws SecurityException If the {@code {@link SWMPermission}("client",
40 * "manageSuite")} or {@code {@link SWMPermission}("crossClient",
41 * "manageSuite")} permission is not permitted.
42 * @since 2016/06/24
44 @Api
45 public static SuiteManager getSuiteManager()
46 throws SecurityException
48 // Lazily initialize
49 synchronized (ManagerFactory._LOCK)
51 SuiteManager rv = ManagerFactory._SUITE_MANAGER;
52 if (rv == null)
53 ManagerFactory._SUITE_MANAGER =
54 (rv = new __SystemSuiteManager__());
55 return rv;
59 /**
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
64 * running.
65 * @throws SecurityException If the {@code {@link SWMPermission}("client",
66 * "manageTask")} or {@code {@link SWMPermission}("crossClient",
67 * "manageTask")} permission is not permitted.
68 * @since 2016/06/24
70 @Api
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;
79 if (rv == null)
80 ManagerFactory._TASK_MANAGER =
81 (rv = new __SystemTaskManager__());
82 return rv;