@Override
public List<? extends Statement> generateDecorator(InjectableInstance<Timed> ctx) {
try {
final MetaClass beanClass = ctx.getEnclosingType();
final Timed timed = ctx.getAnnotation();
final Statement methodInvokation
= InjectUtil.invokePublicOrPrivateMethod(ctx.getInjectionContext(), Refs.get("beanInstance"),
ctx.getMethod());
final org.jboss.errai.common.client.util.TimeUnit timeUnit = timed.timeUnit();
final int interval = timed.interval();
final Statement timerDecl
= Stmt.nestedCall(Stmt.newObject(Timer.class).extend()
.publicOverridesMethod("run")
.append(methodInvokation)
.finish().finish());
final String timerVarName = InjectUtil.getUniqueVarName();
final Statement timerVar = Stmt.declareFinalVariable(timerVarName, Timer.class, timerDecl);
final List<Statement> statements = new ArrayList<Statement>();
// statements.add(timerVar);
final Statement timerExec;
switch (timed.type()) {
case REPEATING:
timerExec = Stmt.loadVariable(timerVarName).invoke("scheduleRepeating", timeUnit.toMillis(interval));
break;
default:
case DELAYED: