Custom Exception Handling for AccessDeniedException

posted by Jake on

Our app throws all sorts of exceptions. Well, it doesn't usually. It shouldn't normally. Er... But, when it does we want to put in some handling so that the app doesn't blow up in some unsuspecting user's face. And even then, sometimes we want special handling for certain exceptions and make sure others are just caught. And that's what we'll do with AccessDeniedException.

Calling Webservices in Java

posted by Jake on

In Java Land, everything is tied up in multiple layers of multi-colored wrapping paper. The abstraction often provides niceties and protections and convenience, etc. But, sometimes it practically makes you forget where you are. For instance, why would anyone write a little howto on requesting something over the web from the context of the web. That should be easy, right? Well, yes, I think so. And it turns out it is in Java, as it is in many other languages. It's just that there you're super close to the HTTP protocol all the time, and in many Java ...

Backbone and JAX-RS

posted by Jake on

BackboneJS is setup to do some pretty sweet single-page app action. And of course, a single page app will probably be wanting to talk to web services on the server. And if your server code is doing the Java jive, then a great way to expose your REST services is via JAX-RS. It's as easy as Mikey singin' ABC-123!

Stored Procedures in Spring Jdbc

posted by Jake on

In addition to some sweet Inversion of Control injection action, Spring brings flowers and baby deer. And it brings some nice database connection help. Spring JdbcTemplate is a vanguard of strength and ease for connecting to your favorite RDBMS. And it so happens that the DBA I'm working with right now digs the stored procs. So, we'll meet in the middle with some more goodness born of Spring.

Generic Interfaces Arabian Magic

posted by Jake on

[flash bang!] Say words like generics, enums, or interfaces, and you've immediately transported to the realm of conjured whirlwind sandstorms and curved-sword-weilding assasins. Well, I guess we're going there, because I think this is pretty cool. Plus, undocumented, or at least un-reiterated to myself, and later I'll look at it and think it's just pretty complicated. Prepare for angle brackets in the amount of parens in lisp.

What's REALLY going on in that HashSet.contains() method

posted by Ted on

We all know that contains() is a handy way to check for the presence of an item in a HashSet. The java docs state: "Returns true if this collection contains the specified element. More formally, returns true if and only if this collection contains at least one element e such that (o==null ? e==null : o.equals(e))." So, you just need to override equals() the way you want, and everything's hunky-dory, right? Wrong!

Caching Ajax Requests in IE

posted by Jake on

Have you ever had a problem with ajax requests caching in Internet Explorer. I have, and recently I came across a nicer solution than I have traditionally used. In the past, I have used a unique parameter on the url to keep IE from caching previous requests to the same url, like so:

Django on Jython Intro

posted by Jake on

Here is a "new and shiney" presentation for running Django on Jython. It's based on my experiences with the DjangoJython tutorial.

As is discussed in the slide deck, and hence the subtitle of the presentation, much could be helped by more careful reading of documentation. Well, moments ago, I decided that I hadn't checked out django-jython 1.1. Well.... turns out many more problems could have been helped by using this later version. Sweet!

Parameterized States in Webflow

posted by Jake on

My first experience with Spring Webflow is on a project that uses Webflow 1.0.5. So far, I'm impressed. Apparently, Webflow 2 offers even more incredible awesomeness, but thusfar I would put my webflow experience over that of my previous couple years in Seam. (I was just waiting for a chance to abandon that library anyway.)

Change Maven JDK

posted by Jake on

Sometimes you want Maven to compile your code with a different JDK than is the one assigned to your JAVA_HOME. For instance, I have code in a project that I'm working on that only compiles on Java 1.5. My JAVA_HOME, however, is 1.6. So, how do we specify the JDK for Maven?

InstallCert for Java Security Certificate

posted by Jake on

Sometimes you need to install a security certificate for authentication to work for certain services -- services that are accessed by your java application that requirement a secure connection. For instance, needing to authenticate against an LDAP server from one of our apps, we had to run a little InstallCert.java on all JDKs used to run the app.

Environment-based Dependency Injection

posted by Jake on

In developing an email notification system recently, we became interested in code acting differently depending on what environment we were in. A potentially good solution for this is environment-based dependency injection. This means that different Spring beans, for instance, will be used depending on the environment, ie dev, test, etc. This is useful for something like emailing, because we may not want real emails hitting the mail server in dev or test environments, but we do in prod. With some Spring constructs, it's pretty easy.

Variable Declaration Performance

posted by Jake on

Often when coding, we use a single local variable multiple times, overwriting the value many times. It is considered good practice to move the variable out of the looping overwrite and into the smallest scope of code that is run once. But, this makes the code a little bit less concise. So, how useful is it, anyway? I wanted to run a few little tests and see if there's really a noticable difference in performance.

EasyMock Cause-Effect Exception Mapping

posted by Jake on

EasyMock is a great tool for separating external dependencies from unit tests. There is a learning curve to learning the mock method of testing, and unfortunately, EasyMock does not give very good prompts when you do something wrong. The exception messages are actually quite cryptic. This article is meant to be a crude mapping of exception output and the behavior that might have caused it. At least, this is a log of many of my experiences with EasyMock and how I usually get into the messes I do. It is quite possible that the same exception output could be had ...

Java Swing and Compiz

posted by Jake on

On Ubuntu 9.04, Jaunty, Compiz comes running out of the box on the mid-level preset for desktop effects. These effects and generally beautiful and pleasing, but a couple of the apps that I use are Java-based and have some compatibility issues with Compiz. At least for my apps, I've found a way around this issue.