337 |
|
* @return a callable object |
338 |
|
* @throws NullPointerException if action null |
339 |
|
*/ |
340 |
< |
public static Callable<Object> callable(PrivilegedAction<?> action) { |
340 |
> |
public static Callable<Object> callable(final PrivilegedAction<?> action) { |
341 |
|
if (action == null) |
342 |
|
throw new NullPointerException(); |
343 |
< |
return new PrivilegedActionAdapter<Object>(action); |
343 |
> |
return new Callable<Object>() { |
344 |
> |
public Object call() { return action.run(); }}; |
345 |
|
} |
346 |
|
|
347 |
|
/** |
352 |
|
* @return a callable object |
353 |
|
* @throws NullPointerException if action null |
354 |
|
*/ |
355 |
< |
public static Callable<Object> callable(PrivilegedExceptionAction<?> action) { |
355 |
> |
public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) { |
356 |
|
if (action == null) |
357 |
|
throw new NullPointerException(); |
358 |
< |
return new PrivilegedExceptionActionAdapter<Object>(action); |
358 |
> |
return new Callable<Object>() { |
359 |
> |
public Object call() throws Exception { return action.run(); }}; |
360 |
|
} |
361 |
|
|
362 |
|
/** |
422 |
|
} |
423 |
|
|
424 |
|
/** |
423 |
– |
* A callable that runs given privileged action and returns its result |
424 |
– |
*/ |
425 |
– |
static final class PrivilegedActionAdapter<T> implements Callable<Object> { |
426 |
– |
PrivilegedActionAdapter(PrivilegedAction action) { |
427 |
– |
this.action = action; |
428 |
– |
} |
429 |
– |
public Object call () { |
430 |
– |
return action.run(); |
431 |
– |
} |
432 |
– |
private final PrivilegedAction action; |
433 |
– |
} |
434 |
– |
|
435 |
– |
/** |
436 |
– |
* A callable that runs given privileged exception action and returns its result |
437 |
– |
*/ |
438 |
– |
static final class PrivilegedExceptionActionAdapter<T> implements Callable<Object> { |
439 |
– |
PrivilegedExceptionActionAdapter(PrivilegedExceptionAction action) { |
440 |
– |
this.action = action; |
441 |
– |
} |
442 |
– |
public Object call () throws Exception { |
443 |
– |
return action.run(); |
444 |
– |
} |
445 |
– |
private final PrivilegedExceptionAction action; |
446 |
– |
} |
447 |
– |
|
448 |
– |
|
449 |
– |
/** |
425 |
|
* A callable that runs under established access control settings |
426 |
|
*/ |
427 |
|
static final class PrivilegedCallable<T> implements Callable<T> { |