@Target(value=METHOD) @Retention(value=SOURCE) public @interface ModelOperation
@Model
requires
that all operations are perform from the originating thread - unless they
are invoked as @ModelOperation
methods.
A method in a class annotated by @Model
annotation may be
annotated by @ModelOperation
. The method has
to be static (unless instance mode
is on),
non-private and return void
. The first parameter
of the method must be the model class
followed
by any number of additional arguments.
As a result method of the same name and the same list of additional arguments
(e.g. without the first model class one) will be generated into the
model class
. This method can be invoked on any
thread, any time and it is the responsibility of model manipulating
technology to ensure the model is available and only then call back to
the original method annotated by @ModelOperation
.
The call may happen synchronously (if possible), or be delayed and invoked
later (on appropriate dispatch thread), without blocking the caller.
@Model
(className="Names", properties={@Property
(name = "names", type=String.class, array = true) }) static class NamesModel {@ModelOperation
static void updateNames(Names model,List
<String;gt; arr) { // can safely access the model model.getNames().addAll(arr); } static void initialize() { final Names pageModel = new Names(); pageModel.applyBindings(); // spawn to different threadExecutors
.newSingleThreadExecutor().execute({ List<String> arr = // ... obtain the names somewhere from network pageModel.updateNames(arr); // returns immediately, later it invokes the model operation }); } }
Copyright © 2018 NetBeans. All rights reserved.