Hi Larry,

This is an interesting suggestion. I've entered a RFE for it:
http://restlet.tigris.org/issues/show_bug.cgi?id=1170

Best regards,
Jerome
--
Restlet ~ Founder and Technical Lead ~ http://www.restlet.o​rg
Noelios Technologies ~ http://www.noelios.com



-----Message d'origine-----
De : Larry Meadors [mailto:[email protected]] 
Envoyé : jeudi 17 juin 2010 14:39
À : [email protected]
Objet : Replacing doInit() and doRelease() with @Before and @After annotations

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

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

Reply via email to