Hi!

Not sure if this is worth doing, but could be nice from a usability pov.

Usually projects have a lot of blocks which need doPrivileged copied over from 
one class to the other.
Using @Privileged makes this a lot easier. But you still need to add private 
methods to all your classes...


Now imagine you have a public class SecurityUtil with methods having the 
annotation as in the example: 
public static @PrivilizerBlueprint ClassLoader getClassLoader() {..}

and on your other class where you like to use it you annotate the whole class 
with 

@UsingPrivilizerBlueprint(my.SecurityUtil.class)
public class MyOtherClass {
 public void doSomething() {
    ClassLoader cl = SecurityUtil.getClassLoader();
    ...
}


It would already be easy with the weaver to find all the classes which have a 
@UsingPrilizerBlueprint annotation. And it is also pretty easy to scan the 
bytecode and create private 'inlined' methods for all the @PrivilizerBlueprint 
methods (effectively copy over the bytecode for the whole method from the util 
class to the using class plus do the doPrivileged around it) and change the 
invocation from SecurityUtil.getClassLoader to this.privilized_getClassLoader()

In the afterWeave all the SecurityUtil methods which are just 
@PrivilizerBlueprint methods will get changed to Modifier private.


That would effectively reduce the need to manually add private methods to all 
your classes but instead maintain all those helper functions in a single well 
maintainable place.

If the weaver is disabled you would just use the SecurityUtil. Of course, from 
a debugging pov this is not that perfect, but from a writer/user pov it's a big 
benefit imo.



wdyt? worth trying?


LieGrue,
strub


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to