AspectJ and void methods

Consider the following snippet of code which outlines a join point that intercepts all Spring beans annotated with @PermitAll:


@Around("@annotation(javax.annotation.security.PermitAll)")
public Object securityAdvice(ProceedingJoinPoint jp)
throws Throwable {
Object[] args = jp.getArgs();
Signature signature = jp.getSignature();
String methodName = signature.getName();
// log method name, arguments and return value
// :
}
the idea being that this interceptor should log arguments, return value and the method name for the calls it intercepts. For this output to be usable we need to a way to distinguish between void methods and methods that simply return null (a void method also has a return value in reflection). A simple way to accomplish this is to use a regular expression which discovers void methods based on their signature:

String voidMatch = String.format(".* void .*(%s).*", methodName);
boolean voidMethod = signature.toLongString().matches(voidMatch);
this however seams a bit to much magic, a better way is to retrieve the java.lang.reflect.Method object and use its return type evaluator:

Type returnType = signature.getMethod().getGenericReturnType();
boolean voidMethod = returnType.equals(void.class);
The full interceptor, is shown below:
@Around("@annotation(javax.annotation.security.PermitAll)")
public Object securityAdvice(ProceedingJoinPoint jp) throws Throwable {
// before execution
Object[] args = jp.getArgs();
MethodSignature signature = (MethodSignature) jp.getSignature();
String methodName = signature.getName();
// determine if this is a void method
Type returnType = signature.getMethod().getGenericReturnType();
final boolean voidMethod = returnType.equals(void.class);
// continue execution
Object res = null;
try {
res = jp.proceed();
return res;
} finally {
// get return value
String returnValue = (res == null) ? "" : res.toString();
if (voidMethod)
returnValue = "";
// log method signature, arguments and return value
final String msg = String.format(
"around method: %s with args: '%s' which returned: %s",
methodName, args.toString(), returnValue);
logger.info(msg);
}
}
remember to register this advice with Spring (or even better use AspectJ auto discovering).

The Code Book


By: Simon Singh
Year: 2000
Genre: Factual

As always Simon Singh takes the reader on a fantastic trip through History. Filled with entertaining stories, puzzles and heroic events, the author skillfully covers the history of secret writing. If you liked his coverage of Fermat's Enigma then you will definitely enjoy this book.

The prose is capturing, deep enough to fascinate technical readers and light enough to just entertain the casual reader. I specialized in Quantum computers while studying Mathematics and I am astonished that the author manages to explain such non-trivial subjects as quantum computers and cryptography to the degree where ordinary readers can actually understand how they work and their impact on ciphers such as RSA/DSA. In short another great read from one of the best and most entertaining technical writers who ever lived.

From: The Code Book (quote of: Charles Babbage):
Propose to an Englishman any principle or any instrument, however admirable, and you will observe that the whole effort of the English mind is directed to find a difficulty, a defect, or an impossibility in it. If you speak to him of a machine for peeling a potato, he will pronounce it impossible: if you peel a potato with it before his eyes, he will declare it useless, because it will not slice a pineapple

Howto reset your Mozilla Weave Passphrase

There is no way to retrieve a lost passphrase as Mozilla does not keep clear text passwords. Further as your stored settings cannot be decrypted without it, the only solution is to delete all your data on Mozilla's servers, then upload and encrypt it again.

Note if you are running Ubuntu then you might first want to read this FAQ about getting Weave working on the latest Ubuntu release.

WARNING: this procedure will delete all your settings stored on Mozilla servers - make sure you have backups before you proceed.

  1. Stop all Firefox instances.
  2. Weave uses WEBDAV, if your user is john@doe.com then your account will be available at:
    https://services.mozilla.com/user/john@doe.com/
    On Linux you can mount and clear this by:
    mount -t davfs https://services.mozilla.com/user/john@doe.com/ /mnt/dav
    rm -r /mnt/dav/* -f
    umount /mnt/dav
    You will be asked for your username and password in order to login. On Debian/Ubuntu, davfs support can be enabled by installing the davfs2 package (apt-get install davfs2).
  3. Start Firefox and log on to Weave, using a new value in the passphrase field.
  4. Load your bookmarks from backup and resynchronize your data.
Thats about it, not a pretty solution and the good folks at Mozilla should seriously consider making an online option for doing this. Of cause it results in loosing all your data, but it still beats the current solution where people are just creating new accounts whenever they forget (or in my case mistype) their passphrase.

10 Days to Faster Reading


By: Abby Marks-Beale
Year: 2001
Genre: Productivity

This actually work. Initially I was very pessimistic about speed reading as most of the techniques located on the web will tell you to automatically skip lines or other obviously erroneous techniques. There is no substitute for actually reading everything, but there are ways to do it faster and more efficiently. These includes:

  1. Training your eye span and movement.
  2. View larger word clusters instead of single words.
  3. Use a pacer that works for you (this is highly individual and this book wisely contain many choices).
  4. Limit sub-vocalization (internal whispering)
  5. Read with a purpose.
  6. Vary you reading style in accordance to the material
Besides all this the book contains a multitude of tests, pointers on screen (computer) reading and lots of other useful stuff.

The book is not without its limitations, the biggest problem being that it is simply to ambitious; it's material on note taking and technical reading is so short and over simplified that it ends up doing more harm than good, for people interested in this important subject I suggests you look to the book What Smart Students Know. Another and perhaps more important area that lacks attention is the speed techniques themselves, although many are presented only few are backed with exercises which is crucial to their development and understanding.

For all it's problems the book still recommended, simply because it will install confidence in you that this actually works. I went from 220 WPM to 330-350 WPM within a week, with my comprehension rate rising from 50 to 70%. However if you want to go up to 400-600WPM, extend your mental abilities to concentrate (read) for longer intervals and get your comprehension rate up to 80-90%, you will have to look to more compressive (and time consuming) programs such as the one brilliantly outlined in Breakthrough Rapid Reading. For newcomers and people who just need quick improvement or motivation I will strongly recommend this great little book.

Using Subversion with Eclipse

Recently Eclipse gained official Subversion support through its Subversive project. However, due to licenses restrictions, the installation procedure is not as trivial as one might have hoped for. So here is a walk through (tested on Eclipse 3.4 (Ganymede)):

  1. Open Help -> Software Updates and pick the Available Software tab
  2. Add the following update sites:
  3. Pick these targets:
    • JDT Ignore Extensions
    • SVN Team Provider
    • Subvesive SVN Connectors
    • SVNKit 1.1.X Implementation
    the outline should look like this:


  4. Click Install..., this should give you the following view:


  5. Click next, accept the license and restart Eclipse
Now you are ready to connect to a Subversion site:
  1. Click Window -> Open Perspective -> Other... and chose the SVN Repository Exploring perspective.
  2. Select File -> New -> Repository Location and fill out the form. The outline below shows a connection to Google's Guice public repository:


Have fun.

Ratner's Star

By: Don Delillo
Year: 1976
Genre: Science Fiction

Ratner's star is a spectacular novel about a genius kid, Billy, who enjoys phenomenal gifts in Mathematics and a suspicious relationship to elderly persons whom he continuously accuse of all sorts grossness. At brilliant manifestation of Don Dellilo's literary skills applied to the bizar world of mathematical geniuses and a fictional demonstration of why mathematics is only as correct as logic allows it to be.

The story revolves around Billy's participation in a top secret research project where he encounters a fascinating array of persons; including the brilliant mathematician Endor, who have chosen to live in a hole after his attempt on cracking a extraterrestial code and the enigmatic Mohole, with his flimsy theory on Moholean relativity and garage sale of "vintage art films" such as "Aunt Polly's Banana Surprise" and "What the Butler Did".

As a mathematician myself I find it a laudable achievement to write a book full of wit and slapstick that centers around the development of a logical system of discourse for use in celestial communication (Logicon). The book is however not without its flaws as it contains to many wasted side stories that does nothing for the plot.

Ultimately a story about ignorance at the frontiers of knowledge, this book will properly bore the casual reader and if you are looking for a introduction to Don Delillo I suggest you look elsewhere (like Libra or White Noise).

The avid Delillo fan will however find this book to be a fascinating and enormously ambitious achievement. A splendid read for math lovers and layman alike. Packed with brilliant prose and a insane character gallery it's sure to keep you turning the pages.

From: Ratner's Star:
Old people's bare feet had always caused him some concern. It was not in the order of things for old men and woman to go around barefoot and it made him want to throw lighted matched at their feet to teach them a lesson.

From Ratner's Star:
I remember telling him once how interesting I thought it was that the first use of zero as a number probably took place a great deal earlier than the usual estimates would have it and in Indochina no less, where we can imagine a sort of common abstract boundary between the Taoist concept of emptiness and the Hindu notation of void.

From: Ratner's Star:
"Girls have three armpits." Ralphie Buber said. "The extra one's between their legs"

From: Ratner's Star:
"First we confirm your identidad. First name first. Nilly. This is correct ?"
"Billy, not Nilly."
"Meaningless slip - do forgive. Nada de nadiensis. Full begging of pardon."
"I hope that was an accident."
"Try to excuse my wordage. Half of it is my fault. But most of it is the fault of him over there. I find him distraxis at times. But enough funyaka and gameski. We're here to make an offer."

From: Ratner's Star:
Sometimes it was hard to say things. Things were so complicated. People might resent what you said. They might use your remarks against you. They might be indifferent to your remarks. They might take you seriously and act upon your words, actually do something, They might not even hear you, which perhaps was the only thing worth hoping for. But it was more complicated than that. The sheer effort of speaking. Easier to stay apart, leave things as they are, avoid responsibility for reflecting the world and all its grave weight. Things that should be simple are always hard. But hard things are never Easy.

From: Ratner's Star:
"Pants on Fire"
"My pants are on fire" Hoy said. "Fire burn burning."
"Who else should I tell?"
"Foot leg fire flame"
"Try rolling, " Billy said. "Roll over on the floor. Smother. That's the word I want.
Roll on the floor and smother the flames."
He followed Hoy around the desk as the chubby man hopped on one foot
and tried to remove his pants in transit. Smoke gathered in the small office.

From: Ratner's Star:
He recalled that Lester Bolin had once told him how boring it was to tech game theory to sophomores. That was a long time ago. That was Lester on the brink. Now he was inescapably within the confines. Prenex normal forms. Recursive undecidability. The pure monadic predicate calculus. A firm foundation for analysis is all that got it going. EXERCISE: Prove that every consistent decidable first-order theory has a consistent decidable complete extension.
Uga boo
Uga boo boo uga

New RubyGems

RubyGem's version 1.2 is out in the wild and seams to solve most of my problems with the earlier releases. If you installed it from source (which you always should do) then you can simply use RubyGem's to update itself:

gem install rubygems-update -s http://gems.rubyforge.vm.bytemark.co.uk
update_rubygems
check the version number with:
gem -v
> 1.2.0
finally, assert that updates works:
gem update --system
> Updating RubyGems
> Nothing to update
although it's only been out for a short time, my initial experience is very positive - keep up the good work.



Recommended Money Makers