|
Lines 6-12
Link Here
|
| 6 |
import org.eclipse.tptp.logging.events.cbe.EventFactoryHome; |
6 |
import org.eclipse.tptp.logging.events.cbe.EventFactoryHome; |
| 7 |
|
7 |
|
| 8 |
/********************************************************************** |
8 |
/********************************************************************** |
| 9 |
* Copyright (c) 2005, 2006 IBM Corporation and others. |
9 |
* Copyright (c) 2005, 2007 IBM Corporation and others. |
| 10 |
* All rights reserved. This program and the accompanying materials |
10 |
* All rights reserved. This program and the accompanying materials |
| 11 |
* are made available under the terms of the Eclipse Public License v1.0 |
11 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 12 |
* which accompanies this distribution, and is available at |
12 |
* which accompanies this distribution, and is available at |
|
Lines 71-77
Link Here
|
| 71 |
* <p> |
71 |
* <p> |
| 72 |
* |
72 |
* |
| 73 |
* @author Paul E. Slauenwhite |
73 |
* @author Paul E. Slauenwhite |
| 74 |
* @version March 10, 2005 |
74 |
* @version October 27, 2007 |
| 75 |
* @since 1.0.1 |
75 |
* @since 1.0.1 |
| 76 |
* @see org.eclipse.tptp.logging.events.cbe.EventFactoryHome |
76 |
* @see org.eclipse.tptp.logging.events.cbe.EventFactoryHome |
| 77 |
*/ |
77 |
*/ |
|
Lines 204-308
Link Here
|
| 204 |
|
204 |
|
| 205 |
Class eventFactoryHomeClass = null; |
205 |
Class eventFactoryHomeClass = null; |
| 206 |
|
206 |
|
| 207 |
// Attempt to find the EventFactoryHome class using the parameter |
207 |
//Attempt to load the EventFactoryHome class using the parameter class loader: |
| 208 |
// (e.g. caller's) |
|
|
| 209 |
// class loader: |
| 210 |
if (classLoader != null) { |
208 |
if (classLoader != null) { |
| 211 |
|
209 |
|
| 212 |
try { |
210 |
try { |
| 213 |
|
211 |
|
| 214 |
// Consult the parameter (e.g. caller's) class loader to |
212 |
//Attempt to load the EventFactoryHome class using the parameter class loader and privileged security: |
| 215 |
// find the |
|
|
| 216 |
// EventFactoryHome class using privileged security: |
| 217 |
eventFactoryHomeClass = ((Class) (AccessController.doPrivileged(new PrivilegedExceptionAction() { |
213 |
eventFactoryHomeClass = ((Class) (AccessController.doPrivileged(new PrivilegedExceptionAction() { |
| 218 |
|
214 |
|
| 219 |
public Object run() throws Exception { |
215 |
public Object run() throws Exception { |
| 220 |
return (classLoader.loadClass(eventFactoryHomeType)); |
216 |
return (classLoader.loadClass(eventFactoryHomeType)); |
| 221 |
} |
217 |
} |
| 222 |
}))); |
218 |
}))); |
| 223 |
} catch (Throwable t) { |
219 |
} |
| 224 |
// Ignore since insufficient security privileges for |
220 |
catch (Throwable t) { |
| 225 |
// accessing the |
221 |
//Ignore since insufficient security privileges for loading the EventFactoryHome class using the parameter class loader and privileged security. |
| 226 |
// parameter (e.g. caller's) class loader and we will |
|
|
| 227 |
// attempt to use |
| 228 |
// the current class' class loader. |
| 229 |
} |
222 |
} |
| 230 |
} |
223 |
} |
| 231 |
|
224 |
|
| 232 |
// If the EventFactoryHome class could not be located using the |
225 |
//If the EventFactoryHome class could not be loaded using the parameter class loader, attempt the class load using the current class' (e.g. EventFactoryContext) class loader: |
| 233 |
// parameter (e.g. caller's) |
|
|
| 234 |
// class loader, the EventFactoryHome class is attempted to be |
| 235 |
// found using the following class loader hierarchy: |
| 236 |
// -The current class' (e.g. EventFactoryContext) class loader. |
| 237 |
// -The system's class loader. |
| 238 |
// -The current thread's context class loader. |
| 239 |
if (eventFactoryHomeClass == null) { |
226 |
if (eventFactoryHomeClass == null) { |
| 240 |
|
227 |
|
| 241 |
try { |
228 |
try { |
| 242 |
|
229 |
|
| 243 |
// Consult the current class' (e.g. EventFactoryContext) |
230 |
//Attempt to load the EventFactoryHome class using the current class' (e.g. EventFactoryContext) class loader and privileged security: |
| 244 |
// class |
|
|
| 245 |
// loader to find the EventFactoryHome class using |
| 246 |
// privileged |
| 247 |
// security: |
| 248 |
eventFactoryHomeClass = ((Class) (AccessController.doPrivileged(new PrivilegedExceptionAction() { |
231 |
eventFactoryHomeClass = ((Class) (AccessController.doPrivileged(new PrivilegedExceptionAction() { |
| 249 |
|
232 |
|
| 250 |
public Object run() throws Exception { |
233 |
public Object run() throws Exception { |
| 251 |
return (org.eclipse.tptp.logging.events.cbe.impl.EventFactoryContext.class.getClassLoader().loadClass(eventFactoryHomeType)); |
234 |
return (org.eclipse.tptp.logging.events.cbe.impl.EventFactoryContext.class.getClassLoader().loadClass(eventFactoryHomeType)); |
| 252 |
} |
235 |
} |
| 253 |
}))); |
236 |
}))); |
| 254 |
} catch (Throwable t) { |
237 |
} |
| 255 |
|
238 |
catch (Throwable t) { |
| 256 |
// Catch all exceptions since the current class' (e.g. |
239 |
//Ignore since insufficient security privileges for loading the EventFactoryHome class using the current class' (e.g. EventFactoryContext) class loader and privileged security. |
| 257 |
// EventFactoryContext) |
240 |
} |
| 258 |
// class loader may be null (e.g. current class was loaded |
241 |
|
| 259 |
// by the bootstrap |
242 |
//If the EventFactoryHome class could not be loaded using the current class' (e.g. EventFactoryContext) class loader, attempt the class load using the system's class loader: |
| 260 |
// class loader) or insufficient security privileges |
243 |
if(eventFactoryHomeClass == null){ |
| 261 |
// for accessing the current class' class loader and we |
244 |
|
| 262 |
// will attempt to use the system's class loader. |
245 |
try { |
| 263 |
try { |
|
|
| 264 |
|
246 |
|
| 265 |
// Consult the system's class loader to find the |
247 |
//Attempt to load the EventFactoryHome class using the system's class loader and privileged security: |
| 266 |
// EventFactoryHome class using privileged security: |
|
|
| 267 |
eventFactoryHomeClass = ((Class) (AccessController.doPrivileged(new PrivilegedExceptionAction() { |
248 |
eventFactoryHomeClass = ((Class) (AccessController.doPrivileged(new PrivilegedExceptionAction() { |
| 268 |
|
249 |
|
| 269 |
public Object run() throws Exception { |
250 |
public Object run() throws Exception { |
| 270 |
return (ClassLoader.getSystemClassLoader().loadClass(eventFactoryHomeType)); |
251 |
return (ClassLoader.getSystemClassLoader().loadClass(eventFactoryHomeType)); |
| 271 |
} |
252 |
} |
| 272 |
}))); |
253 |
}))); |
| 273 |
} catch (Throwable tt) { |
254 |
} |
|
|
255 |
catch (Throwable t) { |
| 256 |
//Ignore since insufficient security privileges for loading the EventFactoryHome class using the system's class loader and privileged security. |
| 257 |
} |
| 258 |
|
| 259 |
//If the EventFactoryHome class could not be loaded using the system's class loader, attempt the class load using the current thread's context class loader: |
| 260 |
if(eventFactoryHomeClass == null){ |
| 261 |
|
| 262 |
try { |
| 274 |
|
263 |
|
| 275 |
// Catch all exceptions since the system's class loader |
264 |
//Attempt to load the EventFactoryHome class using the system's class loader: |
| 276 |
// may be null or insufficient security privileges for |
|
|
| 277 |
// accessing the system's class loader and we |
| 278 |
// will attempt to use the current thread's context |
| 279 |
// class |
| 280 |
// loader. |
| 281 |
try { |
| 282 |
|
| 283 |
// Consult the current thread's context class loader |
| 284 |
// to find |
| 285 |
// the EventFactoryHome class using privileged |
| 286 |
// security: |
| 287 |
eventFactoryHomeClass = ((Class) (AccessController.doPrivileged(new PrivilegedExceptionAction() { |
265 |
eventFactoryHomeClass = ((Class) (AccessController.doPrivileged(new PrivilegedExceptionAction() { |
| 288 |
|
266 |
|
| 289 |
public Object run() throws Exception { |
267 |
public Object run() throws Exception { |
| 290 |
return (Thread.currentThread().getContextClassLoader().loadClass(eventFactoryHomeType)); |
268 |
return (Thread.currentThread().getContextClassLoader().loadClass(eventFactoryHomeType)); |
| 291 |
} |
269 |
} |
| 292 |
}))); |
270 |
}))); |
| 293 |
} catch (Throwable ttt) { |
271 |
} |
| 294 |
|
272 |
catch (Throwable t) { |
| 295 |
// Ignore since the current thread's context class |
273 |
//Ignore since insufficient security privileges for loading the EventFactoryHome class using the system's class loader. |
| 296 |
// loader |
|
|
| 297 |
// may be null or insufficient security privileges |
| 298 |
// for |
| 299 |
// accessing the current thread's context class |
| 300 |
// loader and |
| 301 |
// the API's post condition states a null return |
| 302 |
// value |
| 303 |
// if the EventFactoryHome cannot be resolved and/or |
| 304 |
// instantiated (e.g. insufficient security |
| 305 |
// privileges). |
| 306 |
} |
274 |
} |
| 307 |
} |
275 |
} |
| 308 |
} |
276 |
} |