Java 8 PrivilegedExceptionAction - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 PrivilegedExceptionAction class.

This code example shows how to use the following methods:run
		@Override 
		public <T> T wrap( 
				PrivilegedExceptionAction<T> privilegedExceptionAction)
			throws Exception {
 
			return privilegedExceptionAction.run();
		} 
 
		@Override 
		public <T> T wrap(T t) {
			return t;
		} 
 
		@Override 
		public <T> T wrapWhenActive(T t) {
			return t;
		} 
 
	} 
 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:run
   */ 
  public static <T> T runPrivileged(UserGroupInformation login,
                                    PrivilegedExceptionAction<T> action) {
    try { 
      if (login == null) {
        return action.run();
      } else { 
        return login.doAs(action);
      } 
    } catch (IOException ex) {
      throw new DatasetIOException("Privileged action failed", ex);
    } catch (InterruptedException ex) {
      Thread.interrupted();
      throw new DatasetException(ex);
    } catch (Exception ex) {
      throw Throwables.propagate(ex);
    } 
  } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:run
	private <T> T run(PrivilegedAction<T> action) {
		return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run();
	} 
 
	private <T> T run(PrivilegedExceptionAction<T> action) throws Exception {
		return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run();
	} 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:run
		return (System.getSecurityManager() != null) ? AccessController.doPrivileged(action) : action.run();
	} 
 
	public static <T> T run(PrivilegedExceptionAction<T> action) throws Exception
	{ 
		return (System.getSecurityManager() != null) ? AccessController.doPrivileged(action) : action.run();
	} 
 
	public static <T, E extends Exception> T run(PrivilegedExceptionAction<T> action, Class<E> exceptionClass) throws E
	{ 
		try 
		{ 
			return (System.getSecurityManager() != null) ? AccessController.doPrivileged(action) : action.run();
		} 
		catch (Exception e)
		{ 
			throw exceptionClass.cast(e);
		} 
	} 
 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:run
    public static <T> T doPrivileged(PrivilegedExceptionAction<T> action)
            throws PrivilegedActionException {
        SecurityManager sm = System.getSecurityManager();
        if (sm == null) {
            try { 
                return action.run();
            } catch (java.lang.RuntimeException e) {
                throw e;
            } catch (Exception e) {
                throw new PrivilegedActionException(e);
            } 
        } else { 
            return java.security.AccessController.doPrivileged(action);
        } 
    } 
 
 
    /** 
     * Performs the specified <code>PrivilegedExceptionAction</code> with 
     * privileges enabled and restricted by the specified 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:run
        try { 
          if (ugi != null) {
            callStatic("setCurrentUGI", new Class[]{UserGroupInformation.class},
                new Object[]{ugi}); 
          } 
          result = action.run();
        } finally { 
          callStatic("setCurrentUGI", new Class[]{UserGroupInformation.class},
              new Object[]{previous}); 
        } 
      } catch (Exception e) {
        if (e instanceof IOException) {
          throw (IOException)e;
        } else if (e instanceof InterruptedException) {
          throw (InterruptedException)e;
        } else if (e instanceof RuntimeException) {
          throw (RuntimeException)e;
        } else { 
          throw new UndeclaredThrowableException(e, "Unknown exception in runAs()");
        } 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:run
                                      VmAccessControlContext context) throws PrivilegedActionException {
        final VmThread thread = VmThread.currentThread();
        final VmAccessControlContext prevContext = thread.getContext();
        thread.setContext(context);
        try { 
            return action.run();
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new PrivilegedActionException(e);
        } finally { 
            thread.setContext(prevContext);
        } 
    } 
} 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:run
   */ 
  public static <T> T runPrivileged(UserGroupInformation login,
                                    PrivilegedExceptionAction<T> action) {
    try { 
      if (login == null) {
        return action.run();
      } else { 
        return login.doAs(action);
      } 
    } catch (IOException ex) {
      throw new DatasetIOException("Privileged action failed", ex);
    } catch (InterruptedException ex) {
      Thread.interrupted();
      throw new DatasetException(ex);
    } catch (Exception ex) {
      throw Throwables.propagate(ex);
    } 
  } 
} 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:run
        try { 
          if (ugi != null) {
            callStatic("setCurrentUGI", new Class[]{UserGroupInformation.class},
                new Object[]{ugi});
          } 
          result = action.run();
        } finally { 
          callStatic("setCurrentUGI", new Class[]{UserGroupInformation.class},
              new Object[]{previous});
        } 
      } catch (Exception e) {
        if (e instanceof IOException) {
          throw (IOException)e;
        } else if (e instanceof InterruptedException) {
          throw (InterruptedException)e;
        } else if (e instanceof RuntimeException) {
          throw (RuntimeException)e;
        } else { 
          throw new UndeclaredThrowableException(e, "Unknown exception in runAs()");
        } 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 PrivilegedExceptionAction Methods: