In the service layer I have a classes that look something like:
class MyService {
public doSomething() {
TelnetSession session = new TelnetSession();
session.open("username", "password");
session.execute("blah");
session.close();
}
}
In many classes I have to declare and open session and then at the end close it. I'd rather do something with annotations but I've got no idea where to start. How do other people do something like this:
class MyService {
@TelnetTransaction
public doSomething() {
session.execute("blah");
}
}
where a method annotated with @TelnetTransaction
instantiates, opens and passes in the TelnetSession
object.
Thanks,
James