FYI: This is a really nice framework - I'm enjoying it a lot. :)

I have a ResourceBase class that I use to start and commit my database
transactions, and I was using doInit and doRelease to handle that, but
I didn't want to risk other developers accidentally replacing them.

I stole an idea from the Stripes framework and implemented it in my
project like this:

I override doInit() like this:

@Override
protected void doInit() throws ResourceException {
    for (Method m : getClass().getMethods()) {
        if (null != m.getAnnotation(Before.class)) {
            try {
                m.invoke(this);
            } catch (Exception e) {
                throw new ResourceException(e);
            }
        }
    }
}

My doRelease is almost identical, except for it looks for an @After annotation.

I am telling my developers to use @Before instead of doInit() and
@After instead of doRelease().

Is there a reason that those aren't annotations in the framework?

Larry

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2623078

Reply via email to