Skip navigation links

Package com.thoughtworks.proxy.toys.privilege

A toy to run method calls as privileged actions.

See: Description

Package com.thoughtworks.proxy.toys.privilege Description

A toy to run method calls as privileged actions.

The package provides a proxy factory creating proxies, that wrap each method call into a security.PrivilegedExceptionAction and pass this action to a user provided ActionExecutor. The toy is delivered with three predefined action executors:

The following using the AccessController to perform privileged read actions on the file:

File file = Privileging.proxy(new File("src/main/java/" + PoolToyExample.class.getName().replace('.', '/') + ".java"))
        .executedBy(new AccessControllerExecutor())
        .build(new CglibProxyFactory());
LineNumberReader reader = new LineNumberReader(new FileReader(file), 16 * 1024);
while (reader.readLine() != null);
System.out.println("Lines of code: " + reader.getLineNumber());
reader.close();
Skip navigation links

Copyright © 2005–2021 Codehaus. All rights reserved.