Annotation Interface OnTime
Marks an annotated method as a method invoked by
execute(String, Object...),
timeout(String, long, Obejct...),
interval(String, long) or
interval(String, long long, Object...).
The method must be a thread safe.
@Controller
class MyController extends AbstractController{
@OnCreate
void init(){
timeout( "foo", 1000 );
}
@OnTime( "foo" )
void foo(){
// Called from the init method
}
@OnTime( "foo" )
void bar(){
// Called from the init method
}
}
When the value() is omitted, method names are used to identify which @OnTime methods should be invoked.
@Controller
class MyController extends AbstractController{
@OnCreate
void init(){
timeout( "foo", 1000 );
}
@OnTime
void foo(){
// Called from the init method
}
@OnTime
void bar(){
// Not called from the init method
}
If the value() contains "*", annotated methods are invoked regardless of a name.
@Controller
class MyController extends AbstractController{
@OnCreate
void init(){
timeout( "foo", 1000 );
}
@OnTime( "*" )
void bar(){
// Called from the init method
}
When a method is called, a controller owing the method is not locked.
Accessing fields of the controller owing the method, thus, is not thread safe.
@Controller
class MyController {
@Autowired
SString name;
int score;
@OnTime
void foo(){
// Not thread safe
score = 12;
// Thread safe
lock();
try{
score = 12;
} finally {
unlock();
}
// Thread safe because set(Object) locks the `MyController` internally.
name.set( "Cardinal" );
}
}
-
任意要素の概要
任意要素
-
要素の詳細
-
value
String[] value- デフォルト:
- {}
-