01: /*
02: *
03: *
04: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: */
26:
27: package com.sun.midp.lcdui;
28:
29: import com.sun.j2me.security.AccessController;
30:
31: import com.sun.midp.security.Permissions;
32: import com.sun.midp.security.SecurityToken;
33: import javax.microedition.lcdui.Display;
34:
35: /** System non-MIDlet classes use this class to get Display. */
36: public class DisplayFactory {
37: private static DisplayStaticAccess displayTunnel;
38:
39: /**
40: * Sets up the reference to the DisplayStaticAccess implementation.
41: * This must be called exactly once during system initialization.
42: *
43: * @param token security token for authorizing the caller
44: * @param tunnel the DisplayStaticAccess implementation
45: */
46: public static void setStaticDisplayAccess(SecurityToken token,
47: DisplayStaticAccess tunnel) {
48: token.checkIfPermissionAllowed(Permissions.MIDP);
49: displayTunnel = tunnel;
50: }
51:
52: /**
53: * Gets the <code>Display</code> object by owner name.
54: *
55: * @param token security token for authorizing the caller for the
56: * com.sun.midp permission.
57: * @param owner name of the owner of the display, the owner can be
58: *
59: * @return the display object that application can use for its user
60: * interface
61: *
62: * @throws NullPointerException if <code>owner</code> is <code>null</code>
63: */
64: public static Display getDisplay(SecurityToken token, String owner) {
65: token.checkIfPermissionAllowed(Permissions.MIDP);
66: return displayTunnel.getDisplay(owner);
67: }
68:
69: /**
70: * Gets the <code>Display</code> object by owner name.
71: * The caller must be granted the com.sun.midp permission.
72: *
73: * @param owner name of the owner of the display, the owner can be
74: *
75: * @return the display object that application can use for its user
76: * interface
77: *
78: * @throws NullPointerException if <code>owner</code> is <code>null</code>
79: */
80: public static Display getDisplay(String owner) {
81: AccessController
82: .checkPermission(Permissions.MIDP_PERMISSION_NAME);
83:
84: return displayTunnel.getDisplay(owner);
85: }
86: }
|