List of usage examples for java.security AccessController doPrivileged
@CallerSensitive public static <T> T doPrivileged(PrivilegedExceptionAction<T> action) throws PrivilegedActionException
From source file:javazoom.jlgui.player.amp.PlayerApplet.java
/** * Simulates "Previous" selection.//from w w w . j av a2 s. co m */ public void pressPrevious() { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { acPrevious.fireEvent(); return null; } }); }
From source file:javazoom.jlgui.player.amp.PlayerApplet.java
/** * Simulates "Eject" selection./*from w ww.j a va 2 s .c o m*/ */ public void pressEject() { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { acEject.fireEvent(); return null; } }); }
From source file:javazoom.jlgui.player.amp.PlayerApplet.java
/** * Load skin.//w w w . j a v a 2s.c om */ public void loadMySkin(final String skn) { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { loadSkin(skn); return null; } }); }
From source file:javazoom.jlgui.player.amp.PlayerApplet.java
/** * Reset Playlist.//from ww w .j av a 2 s .co m */ public void resetMyPlaylist() { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { resetPlaylist(); return null; } }); }
From source file:javazoom.jlgui.player.amp.PlayerApplet.java
/** * Load a playlist./*from w ww. ja v a 2 s . co m*/ * @param playlistName */ public void loadMyPlaylist(final String playlistName) { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { loadPlaylist(playlistName); return null; } }); }
From source file:javazoom.jlgui.player.amp.PlayerApplet.java
/** * Simulates "Shuffle" selection.//from w w w. j av a 2 s . com */ public void pressShuffle() { final MouseEvent smevt = new MouseEvent(this, MouseEvent.MOUSE_RELEASED, 0, 1, 0, 0, 1, false); AccessController.doPrivileged(new PrivilegedAction() { public Object run() { acShuffle.processEvent(smevt); return null; } }); }
From source file:javazoom.jlgui.player.amp.PlayerApplet.java
/** * Simulates "Repeat" selection.//from ww w . java 2 s . c o m */ public void pressRepeat() { final MouseEvent rmevt = new MouseEvent(this, MouseEvent.MOUSE_RELEASED, 0, 1, 0, 0, 1, false); AccessController.doPrivileged(new PrivilegedAction() { public Object run() { acRepeat.processEvent(rmevt); return null; } }); }
From source file:org.apache.openjpa.enhance.PCEnhancer.java
/** * Return the method of the given owner type matching the given criteria. * * @param type the type of state being passed * @param prefix the prefix of the method to call; all methods * end in '[state type]Field'; only the prefix varies * @param get true if receiving information from the * owner, false if passing it to the owner * @param haspc true if the pc is passed as an extra argument * @param curValue true if the current state value is passed to * the owner as an extra argument/*from w w w . j a va 2s. co m*/ */ private Method getMethod(Class owner, Class type, String prefix, boolean get, boolean haspc, boolean curValue) throws NoSuchMethodException { // all methods end in [field type]Field, where the field type // can be any of the primitve types (but capitalized), 'String', // or 'Object'; figure out what type to use String typeName = type.getName(); if (type.isPrimitive()) typeName = typeName.substring(0, 1).toUpperCase(Locale.ENGLISH) + typeName.substring(1); else if (type.equals(String.class)) typeName = "String"; else { typeName = "Object"; type = Object.class; } // the field index is always passed as an arg; the pc instance and // the current value may be passed; if setting the new value is // also passed List plist = new ArrayList(4); if (haspc) plist.add(PCTYPE); plist.add(int.class); if (!get || curValue) plist.add(type); if (!get && curValue) { plist.add(type); plist.add(int.class); } // use reflection to return the right method String name = prefix + typeName + "Field"; Class[] params = (Class[]) plist.toArray(new Class[plist.size()]); try { return AccessController.doPrivileged(J2DoPrivHelper.getDeclaredMethodAction(owner, name, params)); } catch (PrivilegedActionException pae) { throw (NoSuchMethodException) pae.getException(); } }
From source file:edu.ku.brc.af.ui.forms.ViewFactory.java
/** * Returns the singleton for the ViewSetMgr. * @return the singleton for the ViewSetMgr */// w w w . j a v a2 s .com public static ViewFactory getInstance() { if (instance != null) { return instance; } // else String factoryNameStr = AccessController.doPrivileged(new PrivilegedAction<String>() { public String run() { return System.getProperty(factoryName); } }); if (factoryNameStr != null) { try { instance = (ViewFactory) Class.forName(factoryNameStr).newInstance(); return instance; } catch (Exception e) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(AppContextMgr.class, e); InternalError error = new InternalError("Can't instantiate ViewFactory factory " + factoryNameStr); //$NON-NLS-1$ error.initCause(e); throw error; } } return instance = new ViewFactory(); }
From source file:org.apache.openjpa.enhance.PCEnhancer.java
/** * Adds a custom writeObject method that delegates to the * {@link ObjectOutputStream#defaultWriteObject} method, * but only after calling the internal <code>pcSerializing</code> method. *//* w ww .ja v a2 s. c om*/ private void modifyWriteObjectMethod(BCMethod method, boolean full) { Code code = method.getCode(true); code.beforeFirst(); // bool clear = pcSerializing (); loadManagedInstance(code, false); code.invokevirtual().setMethod(PRE + "Serializing", boolean.class, null); int clear = code.getNextLocalsIndex(); code.istore().setLocal(clear); if (full) { // out.defaultWriteObject (); code.aload().setParam(0); code.invokevirtual().setMethod(ObjectOutputStream.class, "defaultWriteObject", void.class, null); code.vreturn(); } Instruction tmplate = (AccessController.doPrivileged(J2DoPrivHelper.newCodeAction())).vreturn(); JumpInstruction toret; Instruction ret; code.beforeFirst(); while (code.searchForward(tmplate)) { ret = code.previous(); // if (clear) pcSetDetachedState (null); code.iload().setLocal(clear); toret = code.ifeq(); loadManagedInstance(code, false); code.constant().setNull(); code.invokevirtual().setMethod(PRE + "SetDetachedState", void.class, new Class[] { Object.class }); toret.setTarget(ret); code.next(); // jump over return } code.calculateMaxStack(); code.calculateMaxLocals(); }