1 /* |
1 /* |
2 * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
168 // wrapperMap maintains a table of LogWrapper instances used by |
168 // wrapperMap maintains a table of LogWrapper instances used by |
169 // different classes to log exceptions. The key is a StringPair |
169 // different classes to log exceptions. The key is a StringPair |
170 // representing LogDomain and ExceptionGroup. |
170 // representing LogDomain and ExceptionGroup. |
171 private Map wrapperMap ; |
171 private Map wrapperMap ; |
172 |
172 |
|
173 static class Holder { |
|
174 static final PresentationManager defaultPresentationManager = |
|
175 setupPresentationManager(); |
|
176 } |
|
177 private static final Object pmLock = new Object(); |
|
178 |
173 private static Map staticWrapperMap = new ConcurrentHashMap(); |
179 private static Map staticWrapperMap = new ConcurrentHashMap(); |
174 |
180 |
175 protected MonitoringManager monitoringManager; |
181 protected MonitoringManager monitoringManager; |
176 |
182 |
177 private static PresentationManager setupPresentationManager() { |
183 private static PresentationManager setupPresentationManager() { |
233 * Returns the Presentation Manager for the current thread group, using the ThreadGroup-specific |
239 * Returns the Presentation Manager for the current thread group, using the ThreadGroup-specific |
234 * AppContext to hold it. Creates and records one if needed. |
240 * AppContext to hold it. Creates and records one if needed. |
235 */ |
241 */ |
236 public static PresentationManager getPresentationManager() |
242 public static PresentationManager getPresentationManager() |
237 { |
243 { |
238 AppContext ac = AppContext.getAppContext(); |
244 SecurityManager sm = System.getSecurityManager(); |
239 PresentationManager pm = (PresentationManager) ac.get(PresentationManager.class); |
245 if (sm != null && AppContext.getAppContexts().size() > 0) { |
240 if (pm == null) { |
246 AppContext ac = AppContext.getAppContext(); |
241 pm = setupPresentationManager(); |
247 if (ac != null) { |
242 ac.put(PresentationManager.class, pm); |
248 synchronized (pmLock) { |
243 } |
249 PresentationManager pm = |
244 return pm; |
250 (PresentationManager) ac.get(PresentationManager.class); |
|
251 if (pm == null) { |
|
252 pm = setupPresentationManager(); |
|
253 ac.put(PresentationManager.class, pm); |
|
254 } |
|
255 return pm; |
|
256 } |
|
257 } |
|
258 } |
|
259 |
|
260 // No security manager or AppContext |
|
261 return Holder.defaultPresentationManager; |
245 } |
262 } |
246 |
263 |
247 /** Get the appropriate StubFactoryFactory. This |
264 /** Get the appropriate StubFactoryFactory. This |
248 * will be dynamic or static depending on whether |
265 * will be dynamic or static depending on whether |
249 * com.sun.CORBA.ORBUseDynamicStub is true or false. |
266 * com.sun.CORBA.ORBUseDynamicStub is true or false. |