1.1 --- a/json/src/main/java/org/apidesign/html/json/spi/Proto.java Sat Aug 02 07:01:20 2014 +0200
1.2 +++ b/json/src/main/java/org/apidesign/html/json/spi/Proto.java Sat Aug 02 07:13:47 2014 +0200
1.3 @@ -86,18 +86,43 @@
1.4 return context;
1.5 }
1.6
1.7 - /** Before doing modification of the model properties, the
1.8 - * generated code enters write lock by calling this method.
1.9 + /** Acquires global lock to compute a {@link ComputedProperty derived property}
1.10 + * on this proto object. This proto object must not be locked yet. No
1.11 + * dependency tracking is performed.
1.12 + *
1.13 * @throws IllegalStateException if already locked
1.14 */
1.15 public void acquireLock() throws IllegalStateException {
1.16 acquireLock(null);
1.17 }
1.18 +
1.19 + /** Acquires global lock to compute a {@link ComputedProperty derived property}
1.20 + * on this proto object. This proto object must not be locked yet. The
1.21 + * name of the property is used to track dependencies on own
1.22 + * properties of other proto objects - when they are changed, this
1.23 + * {@link #valueHasMutated(java.lang.String) property is changed too}.
1.24 + *
1.25 + * @param propName name of property we are about to compute
1.26 + * @throws IllegalStateException thrown when there is a cyclic
1.27 + * call is detected
1.28 + * @since 0.9
1.29 + */
1.30 public void acquireLock(String propName) throws IllegalStateException {
1.31 Observers.beginComputing(this, propName);
1.32 }
1.33
1.34 - public void accessValue(String propName) {
1.35 + /** A property on this proto object is about to be accessed. Verifies
1.36 + * whether this proto object is accessible - e.g. it has not been
1.37 + * {@link #acquireLock() locked yet}. If everything is OK, the
1.38 + * <code>propName</code> is recorded in the chain of dependencies
1.39 + * tracked by {@link #acquireLock(java.lang.String)} and watched by
1.40 + * {@link #valueHasMutated(java.lang.String)}.
1.41 + *
1.42 + * @param propName name of the property that is requested
1.43 + * @throws IllegalStateException if the model is locked
1.44 + * @since 0.9
1.45 + */
1.46 + public void accessProperty(String propName) throws IllegalStateException {
1.47 Observers.accessingValue(this, propName);
1.48 }
1.49
2.1 --- a/json/src/main/java/org/netbeans/html/json/impl/ModelProcessor.java Sat Aug 02 07:01:20 2014 +0200
2.2 +++ b/json/src/main/java/org/netbeans/html/json/impl/ModelProcessor.java Sat Aug 02 07:13:47 2014 +0200
2.3 @@ -544,14 +544,14 @@
2.4
2.5 castTo = "java.util.List";
2.6 w.write(" public java.util.List<" + tn + "> " + gs[0] + "() {\n");
2.7 - w.write(" proto.accessValue(\"" + p.name() + "\");\n");
2.8 + w.write(" proto.accessProperty(\"" + p.name() + "\");\n");
2.9 w.write(" return prop_" + p.name() + ";\n");
2.10 w.write(" }\n");
2.11 } else {
2.12 castTo = tn;
2.13 w.write(" private " + tn + " prop_" + p.name() + ";\n");
2.14 w.write(" public " + tn + " " + gs[0] + "() {\n");
2.15 - w.write(" proto.accessValue(\"" + p.name() + "\");\n");
2.16 + w.write(" proto.accessProperty(\"" + p.name() + "\");\n");
2.17 w.write(" return prop_" + p.name() + ";\n");
2.18 w.write(" }\n");
2.19 w.write(" public void " + gs[1] + "(" + tn + " v) {\n");