パッケージ org.wcardinal.controller
クラス AbstractController
java.lang.Object
org.wcardinal.controller.AbstractController
- すべての実装されたインタフェース:
ControllerContext
,Unlockable
- 直系の既知のサブクラス:
AbstractComponent
,AbstractVisibilityController
,ControllerFacade
Provides additional functions of controllers.
@Controller
class MyController extends AbstractController {
void foo(){
System.out.println( getRemoteAddress() );
}
}
-
フィールドの概要
フィールド -
コンストラクタの概要
コンストラクタ -
メソッドの概要
修飾子とタイプメソッド説明boolean
cancel()
Cancels the current request issued bytimeout
orinterval
methods, or the current task.boolean
cancel
(long id) Cancels the request of the specified ID issued bytimeout
orinterval
methods.boolean
Cancels the current task.void
Cancels all requests issued bytimeout
orinterval
methods.Future<?>
Requests to execute the specified runnable.void
Requests to execute methods annotated with theOnTime
of the specified name.<T> Future<T>
Requests to execute the specified callable.<T> T
Returns the active page or null.Returns the attributes.com.fasterxml.jackson.databind.node.ArrayNode
Returns the factory parameters.Returns the preferred locale.Returns the locale objects in decreasing order starting with the preferred locale.getName()
Returns the name of this controller.getParameter
(String key) Returns the first parameter of the specified key.Returns the map of parameters.String[]
getParameters
(String key) Returns the parameters of the specified key.<T> T
Returns the parent.Factory<?>
Returns the parent as a factory.<T> Collection<T>
Returns the parents.Returns the user principle.Returns the user's remote address.Returns the scheduler.Returns the session ID.Returns the sub session ID.void
hide()
Hides this controller.long
Requests to call the specified runnable at the specified interval and returns an ID of this request.long
Requests to call the specified runnable at the specified interval after the 'startAfter' milliseconds and returns an ID of this request.long
Requests to call methods annotated with theOnTime
of the specified name at the specified interval and returns an ID of this request.long
Requests to call methods annotated with theOnTime
of the specified name at the specified interval after the 'startAfter' milliseconds and returns an ID of this request.boolean
Returns true if the current task is canceled or if the current request issued bytimeout
orinterval
methods is canceled/non-existing.boolean
Returns true if the thread calling this method is the forefront executor of methods annotated withTracked
.boolean
isHidden()
Returns true if this controller is hidden.boolean
Returns true if this controller is historical.boolean
isLocked()
Returns true if this controller is locked.boolean
Returns true if this controller is locked by the current thread.boolean
Returns true if this controller is non-null.boolean
Returns true if this controller is read-only.boolean
isShown()
Returns true if this controller is shown.lock()
Locks this controller.void
Requests to call methods annotated with theOnNotice
of the specified name.void
notifyAsync
(String name, Object... parameters) Requests to call methods annotated with theOnNotice
of the specified name asynchronously.void
show()
Shows this controller.long
Requests to call the specified runnable after the specified delay and returns an ID of this request.long
Requests to call methods annotated with theOnTime
of the specified name after the specified delay and returns an ID of this request.<T> TimeoutFuture<T>
Requests to call the specified callable after the specified delay.void
Triggers the event of the given name at browsers.triggerAndWait
(String name, long timeout, Object... arguments) Triggers the event of the specified name at browsers and waits for responses from browsers.void
triggerDirect
(String name, Object... arguments) Triggers the event of the given name at browsers directly.boolean
tryLock()
Tries to lock this controller.boolean
Tries to lock this controller.void
unlock()
Unlocks this controller.
-
フィールド詳細
-
controllerContext
-
-
コンストラクタの詳細
-
AbstractController
public AbstractController()
-
-
メソッドの詳細
-
getName
インタフェースからコピーされた説明:ControllerContext
Returns the name of this controller.- 定義:
getName
インタフェース内ControllerContext
- 戻り値:
- the name of this controller
-
getParent
public <T> T getParent()インタフェースからコピーされた説明:ControllerContext
Returns the parent.- 定義:
getParent
インタフェース内ControllerContext
- 型パラメータ:
T
- the type of parent- 戻り値:
- the parent instance
-
getParentAsFactory
インタフェースからコピーされた説明:ControllerContext
Returns the parent as a factory.- 定義:
getParentAsFactory
インタフェース内ControllerContext
- 戻り値:
- the parent instance
-
getParents
インタフェースからコピーされた説明:ControllerContext
Returns the parents.- 定義:
getParents
インタフェース内ControllerContext
- 型パラメータ:
T
- the type of parents- 戻り値:
- the parent instances
-
getActivePage
public <T> T getActivePage()インタフェースからコピーされた説明:ControllerContext
Returns the active page or null.- 定義:
getActivePage
インタフェース内ControllerContext
- 型パラメータ:
T
- the type of the active page- 戻り値:
- the active page
-
show
public void show()インタフェースからコピーされた説明:ControllerContext
Shows this controller.- 定義:
show
インタフェース内ControllerContext
-
hide
public void hide()インタフェースからコピーされた説明:ControllerContext
Hides this controller.- 定義:
hide
インタフェース内ControllerContext
-
isShown
public boolean isShown()インタフェースからコピーされた説明:ControllerContext
Returns true if this controller is shown.- 定義:
isShown
インタフェース内ControllerContext
- 戻り値:
- true if this controller is shown.
-
isHidden
public boolean isHidden()インタフェースからコピーされた説明:ControllerContext
Returns true if this controller is hidden.- 定義:
isHidden
インタフェース内ControllerContext
- 戻り値:
- true if this controller is hidden.
-
isReadOnly
public boolean isReadOnly()インタフェースからコピーされた説明:ControllerContext
Returns true if this controller is read-only.- 定義:
isReadOnly
インタフェース内ControllerContext
- 戻り値:
- true if this controller is read-only.
-
isNonNull
public boolean isNonNull()インタフェースからコピーされた説明:ControllerContext
Returns true if this controller is non-null.- 定義:
isNonNull
インタフェース内ControllerContext
- 戻り値:
- true if this controller is non-null.
-
isHistorical
public boolean isHistorical()インタフェースからコピーされた説明:ControllerContext
Returns true if this controller is historical.- 定義:
isHistorical
インタフェース内ControllerContext
- 戻り値:
- true if this controller is historical.
-
getRemoteAddress
インタフェースからコピーされた説明:ControllerContext
Returns the user's remote address.- 定義:
getRemoteAddress
インタフェース内ControllerContext
- 戻り値:
- user's remote address
-
getPrincipal
インタフェースからコピーされた説明:ControllerContext
Returns the user principle.- 定義:
getPrincipal
インタフェース内ControllerContext
- 戻り値:
- user principle
-
getScheduler
インタフェースからコピーされた説明:ControllerContext
Returns the scheduler.- 定義:
getScheduler
インタフェース内ControllerContext
- 戻り値:
- the scheduler
-
getSessionId
インタフェースからコピーされた説明:ControllerContext
Returns the session ID.- 定義:
getSessionId
インタフェース内ControllerContext
- 戻り値:
- the session ID
-
getSubSessionId
インタフェースからコピーされた説明:ControllerContext
Returns the sub session ID.- 定義:
getSubSessionId
インタフェース内ControllerContext
- 戻り値:
- the sub session ID
-
lock
インタフェースからコピーされた説明:ControllerContext
Locks this controller.Please note that all the fields and controllers belonging to the same controller instance share a lock. Thus, the followings is not necessary:
When the 'onChange' method is called, the 'name' field is locked. And the 'name' field, the 'score' field and the 'MyController' controller share a lock. The 'score' field, therefore, is locked at the time the 'onChange' method is called. The only exception to this is a component annotated with@Controller class MyController { @Autowired SString name; @Autowired SInteger score; @OnChange("name") void onChange(){ try( Unlocker unlocker = score.lock() ){ // Unnecessary score.set( 0 ); } } }
SharedComponent
. Shared components and fields on them do not share a lock with the others. Because shared components do not share a lock, the lock ordering is necessary to avoid concurrency issues. If locking a shared component and one of its parents at once is unavoidable, must lock a parent at first. And then lock a shared component.@SharedComponent class MySharedComponent{} @Controller class MyController { @Autowired MySharedComponent component; void foo(){ // At first lock itself, the parent of the 'this.component' try( Unlocker parent = lock() ) { // Then lock a shared component try( Unlocker child = component.lock() ) { // Do something here } } } }
- 定義:
lock
インタフェース内ControllerContext
- 戻り値:
Unlocker
instance for unlocking this lock
-
tryLock
public boolean tryLock()インタフェースからコピーされた説明:ControllerContext
Tries to lock this controller.- 定義:
tryLock
インタフェース内ControllerContext
- 戻り値:
- true if succeeded
-
tryLock
インタフェースからコピーされた説明:ControllerContext
Tries to lock this controller.- 定義:
tryLock
インタフェース内ControllerContext
- パラメータ:
timeout
- the timeout for this trialunit
- the unit of the timeout- 戻り値:
- true if succeeded
-
isLocked
public boolean isLocked()インタフェースからコピーされた説明:ControllerContext
Returns true if this controller is locked.- 定義:
isLocked
インタフェース内ControllerContext
- 戻り値:
- true if this controller is locked.
-
isLockedByCurrentThread
public boolean isLockedByCurrentThread()インタフェースからコピーされた説明:ControllerContext
Returns true if this controller is locked by the current thread.- 定義:
isLockedByCurrentThread
インタフェース内ControllerContext
- 戻り値:
- true if this controller is locked by the current thread.
-
unlock
public void unlock()インタフェースからコピーされた説明:ControllerContext
Unlocks this controller.- 定義:
unlock
インタフェース内ControllerContext
- 定義:
unlock
インタフェース内Unlockable
-
execute
インタフェースからコピーされた説明:ControllerContext
Requests to execute methods annotated with theOnTime
of the specified name.- 定義:
execute
インタフェース内ControllerContext
- パラメータ:
name
- method name specified byOnTime
parameters
- parameters to be passed to the specified methods
-
execute
インタフェースからコピーされた説明:ControllerContext
Requests to execute the specified runnable.- 定義:
execute
インタフェース内ControllerContext
- パラメータ:
runnable
- runnable to be executed- 戻り値:
- future
-
execute
インタフェースからコピーされた説明:ControllerContext
Requests to execute the specified callable.- 定義:
execute
インタフェース内ControllerContext
- 型パラメータ:
T
- return type of the specified callable- パラメータ:
callable
- callable to be executed- 戻り値:
- future
-
timeout
インタフェースからコピーされた説明:ControllerContext
Requests to call methods annotated with theOnTime
of the specified name after the specified delay and returns an ID of this request. Use the returned ID andControllerContext.cancel(long)
for canceling the request.- 定義:
timeout
インタフェース内ControllerContext
- パラメータ:
name
- method name specified byOnTime
delay
- delay in millisecondsparameters
- parameters to be passed to the specified methods- 戻り値:
- request ID
- 関連項目:
-
timeout
インタフェースからコピーされた説明:ControllerContext
Requests to call the specified runnable after the specified delay and returns an ID of this request. Use the returned ID andControllerContext.cancel(long)
for canceling the request.- 定義:
timeout
インタフェース内ControllerContext
- パラメータ:
runnable
- runnable to be executeddelay
- delay in milliseconds- 戻り値:
- request ID
- 関連項目:
-
timeout
インタフェースからコピーされた説明:ControllerContext
Requests to call the specified callable after the specified delay. Use the returned ID andControllerContext.cancel(long)
for canceling the request.- 定義:
timeout
インタフェース内ControllerContext
- 型パラメータ:
T
- return type of the specified callable- パラメータ:
callable
- callable to be executeddelay
- delay in milliseconds- 戻り値:
- future
- 関連項目:
-
interval
インタフェースからコピーされた説明:ControllerContext
Requests to call methods annotated with theOnTime
of the specified name at the specified interval and returns an ID of this request. Use the returned ID andControllerContext.cancel(long)
, orControllerContext.cancel()
for canceling the request. The first call is taking place after the milliseconds specified as the interval.- 定義:
interval
インタフェース内ControllerContext
- パラメータ:
name
- method name specified byOnTime
interval
- interval in milliseconds- 戻り値:
- request ID
- 関連項目:
-
interval
インタフェースからコピーされた説明:ControllerContext
Requests to call methods annotated with theOnTime
of the specified name at the specified interval after the 'startAfter' milliseconds and returns an ID of this request. Use the returned ID andControllerContext.cancel(long)
, orControllerContext.cancel()
for canceling the request. The first call is taking place after the 'startAfter' milliseconds.- 定義:
interval
インタフェース内ControllerContext
- パラメータ:
name
- method name specified byOnTime
startAfter
- delay of the first call in millisecondsinterval
- interval in millisecondsparameters
- parameters to be passed to the specified methods- 戻り値:
- request ID
- 関連項目:
-
interval
インタフェースからコピーされた説明:ControllerContext
Requests to call the specified runnable at the specified interval and returns an ID of this request. Use the returned ID andControllerContext.cancel(long)
, orControllerContext.cancel()
for canceling the request. The first call is taking place after the milliseconds specified as the interval.- 定義:
interval
インタフェース内ControllerContext
- パラメータ:
runnable
- runnable to be executedinterval
- interval in milliseconds- 戻り値:
- request ID
- 関連項目:
-
interval
インタフェースからコピーされた説明:ControllerContext
Requests to call the specified runnable at the specified interval after the 'startAfter' milliseconds and returns an ID of this request. Use the returned ID andControllerContext.cancel(long)
, orControllerContext.cancel()
for canceling the request. The first call is taking place after the 'startAfter' milliseconds.- 定義:
interval
インタフェース内ControllerContext
- パラメータ:
runnable
- runnable to be executedstartAt
- delay of the first call in millisecondsinterval
- interval in milliseconds- 戻り値:
- request ID
- 関連項目:
-
cancel
public boolean cancel(long id) インタフェースからコピーされた説明:ControllerContext
Cancels the request of the specified ID issued bytimeout
orinterval
methods.- 定義:
cancel
インタフェース内ControllerContext
- パラメータ:
id
- request ID- 戻り値:
- true if succeeded
- 関連項目:
-
ControllerContext.timeout(String, long, Object...)
ControllerContext.timeout(Runnable, long)
ControllerContext.timeout(Callable, long)
ControllerContext.interval(String, long)
ControllerContext.interval(String, long, long, Object...)
ControllerContext.interval(Runnable, long)
ControllerContext.interval(Runnable, long, long)
-
cancel
public boolean cancel()インタフェースからコピーされた説明:ControllerContext
Cancels the current request issued bytimeout
orinterval
methods, or the current task. Under the hood, a thread local is used to distinguish requests/tasks.@Controller class MyController extends AbstractController { @OnCreate void onCreate(){ interval( "update", 1000 ); } @OnTime void update(){ // Stops the "update" by itself cancel(); } }
- 定義:
cancel
インタフェース内ControllerContext
- 戻り値:
- true if succeeded
- 関連項目:
-
ControllerContext.timeout(String, long, Object...)
ControllerContext.timeout(Runnable, long)
ControllerContext.timeout(Callable, long)
ControllerContext.interval(String, long)
ControllerContext.interval(String, long, long, Object...)
ControllerContext.interval(Runnable, long)
ControllerContext.interval(Runnable, long, long)
-
cancelAll
public void cancelAll()インタフェースからコピーされた説明:ControllerContext
Cancels all requests issued bytimeout
orinterval
methods.- 定義:
cancelAll
インタフェース内ControllerContext
- 関連項目:
-
ControllerContext.timeout(String, long, Object...)
ControllerContext.timeout(Runnable, long)
ControllerContext.timeout(Callable, long)
ControllerContext.interval(String, long)
ControllerContext.interval(String, long, long, Object...)
ControllerContext.interval(Runnable, long)
ControllerContext.interval(Runnable, long, long)
-
isCanceled
public boolean isCanceled()インタフェースからコピーされた説明:ControllerContext
Returns true if the current task is canceled or if the current request issued bytimeout
orinterval
methods is canceled/non-existing. Under the hood, a thread local is used to distinguish requests/tasks- 定義:
isCanceled
インタフェース内ControllerContext
- 戻り値:
- true if the current task is canceled or if the current request issued by
timeout
orinterval
methods is canceled/non-existing
-
isHeadCall
public boolean isHeadCall()インタフェースからコピーされた説明:ControllerContext
Returns true if the thread calling this method is the forefront executor of methods annotated withTracked
.- 定義:
isHeadCall
インタフェース内ControllerContext
- 戻り値:
- true if the thread calling this method is the forefront executor of methods annotated with
Tracked
-
trigger
インタフェースからコピーされた説明:ControllerContext
Triggers the event of the given name at browsers. Optional arguments are passed to browsers as event data.// JavaScript myController.on( 'hello', function( e, name ){ console.log( name ); // prints 'Cardinal' }); // Java @Controller class MyController extends AbstractController { @OnCreate void onCreate(){ timeout( "hello", 5000 ); } @OnTime void hello(){ trigger( "hello", "Cardinal" ); } }
- 定義:
trigger
インタフェース内ControllerContext
- パラメータ:
name
- event namearguments
- event data- 関連項目:
-
triggerDirect
インタフェースからコピーされた説明:ControllerContext
Triggers the event of the given name at browsers directly. Only difference betweenControllerContext.trigger(String, Object...)
and this is this method sends trigger events directly by bypassing the most of the costly synchronization processes. Thus, in general, supposed to be faster thanControllerContext.trigger(String, Object...)
. However, because of this, weak against network disconnections.- 定義:
triggerDirect
インタフェース内ControllerContext
- パラメータ:
name
- event namearguments
- event data- 関連項目:
-
triggerAndWait
インタフェースからコピーされた説明:ControllerContext
Triggers the event of the specified name at browsers and waits for responses from browsers. Optional arguments are passed to browsers as event data. When a browser send back responses within a given period of time, the callbackDoneCallback
set to thePromise.done(org.jdeferred.DoneCallback)
is called. Otherwise, the callbackFailCallback
set to thePromise.fail(org.jdeferred.FailCallback)
is called.// JavaScript myController.on( 'hello', function( e, name ){ console.log( name ); // prints 'Cardinal' return 'Hello, '+name; }); // Java @Controller class MyController extends AbstractController { @OnCreate void onCreate(){ timeout( "hello", 5000 ); } @OnTime void hello(){ trigger( "hello", 3000, "Cardinal" ) .done(new DoneCallback<List<JsonNode>>(){ public void onDone(List<JsonNode> result) { System.out.println( result.get( 0 ).asText() ); // prints "Hello, Cardinal" } }); } }
- 定義:
triggerAndWait
インタフェース内ControllerContext
- パラメータ:
name
- event nametimeout
- timeout for this trigger in millisecondsarguments
- event data- 戻り値:
- promise instance
- 関連項目:
-
getParameter
インタフェースからコピーされた説明:ControllerContext
Returns the first parameter of the specified key. The parameters are taken from the query string or posted form data.// HTML <script src="my-controller?name=Cardinal"></script> // Java @Controller class MyController { @OnCreate void onCreate(){ System.out.println( getParameter("name") ); // prints "Cardinal" } }
- 定義:
getParameter
インタフェース内ControllerContext
- パラメータ:
key
- the key of the parameter- 戻り値:
- the first parameter of the specified key
-
getParameters
インタフェースからコピーされた説明:ControllerContext
Returns the parameters of the specified key. The parameters are taken from the query string or posted form data.// HTML <script src="my-controller?name=Cardinal"></script> // Java @Controller class MyController { @OnCreate void onCreate(){ System.out.println( Arrays.toString(getParameters("name")) ); // prints ["Cardinal"] } }
- 定義:
getParameters
インタフェース内ControllerContext
- パラメータ:
key
- the key of the parameters- 戻り値:
- the parameters of the specified key
-
getParameterMap
インタフェースからコピーされた説明:ControllerContext
Returns the map of parameters. The parameters are taken from the query string or posted form data.// HTML <script src="my-controller?name=Cardinal"></script> // Java @Controller class MyController { @OnCreate void onCreate(){ System.out.println( getParameterMap("name") ); // prints {name=["Cardinal"]} } }
- 定義:
getParameterMap
インタフェース内ControllerContext
- 戻り値:
- the map of parameters
-
getFactoryParameters
public com.fasterxml.jackson.databind.node.ArrayNode getFactoryParameters()インタフェースからコピーされた説明:ControllerContext
Returns the factory parameters. The factory parameters are the parameters given to the methodFactory.create(Object...)
.@Controller class MyController { @Autowired ComponentFactory<MyComponent> factory; @OnCreate void onCreate(){ factory.create(1, "Cardinal"); } } class MyComponent extends AbstractComponent { @OnCreate void onCreate(){ System.out.println( getFactoryParameters() ); // prints [1, "Cardinal"] } }
- 定義:
getFactoryParameters
インタフェース内ControllerContext
- 戻り値:
- the factory parameters.
-
getAttributes
インタフェースからコピーされた説明:ControllerContext
Returns the attributes.- 定義:
getAttributes
インタフェース内ControllerContext
- 戻り値:
- the attributes.
-
getLocales
インタフェースからコピーされた説明:ControllerContext
Returns the locale objects in decreasing order starting with the preferred locale.- 定義:
getLocales
インタフェース内ControllerContext
- 戻り値:
- the locale objects
-
getLocale
インタフェースからコピーされた説明:ControllerContext
Returns the preferred locale.- 定義:
getLocale
インタフェース内ControllerContext
- 戻り値:
- the preferred locale
-
notify
インタフェースからコピーされた説明:ControllerContext
Requests to call methods annotated with theOnNotice
of the specified name. Notifications propagate to parents. To catch a notification triggered by a child, use a name prefixed with a child name.@Component class MyComponent extends AbstractComponent { void notifyBar(){ notify( "bar" ); } } @Controller class MyController { @Autowired MyComponent foo; @OnNotice("foo.bar") void onNotice(){ // Called when the child 'foo' sends a 'bar' notification } }
- 定義:
notify
インタフェース内ControllerContext
- パラメータ:
name
- notification nameparameters
- notification parameters- 関連項目:
-
notifyAsync
インタフェースからコピーされた説明:ControllerContext
Requests to call methods annotated with theOnNotice
of the specified name asynchronously. Notifications propagate to parents. To catch a notification triggered by a child, use a name prefixed with a child name.@Component class MyComponent extends AbstractComponent { void notifyBar(){ notifyAsync( "bar" ); } } @Controller class MyController { @Autowired MyComponent foo; @OnNotice("foo.bar") void onNotice(){ // Called when the child 'foo' sends a 'bar' notification } }
- 定義:
notifyAsync
インタフェース内ControllerContext
- パラメータ:
name
- notification nameparameters
- notification parameters- 関連項目:
-
cancel
インタフェースからコピーされた説明:ControllerContext
Cancels the current task. Under the hood, a thread local is used to distinguish tasks.- 定義:
cancel
インタフェース内ControllerContext
- パラメータ:
reason
- a cancel reason- 戻り値:
- true if succeeded
-