96 |
96 |
97 // Subclass a class with a protected constructor, and one that takes |
97 // Subclass a class with a protected constructor, and one that takes |
98 // additional constructor arguments (a token). Also demonstrates how can |
98 // additional constructor arguments (a token). Also demonstrates how can |
99 // you access the Java adapter instance from the script (just store it in the |
99 // you access the Java adapter instance from the script (just store it in the |
100 // scope, in this example, "cwa") to retrieve the token later on. |
100 // scope, in this example, "cwa") to retrieve the token later on. |
101 var cwa = new (Java.extend(model("ConstructorWithArgument")))(function() { print(cwa.token) }, "cwa-token") |
101 var cwa = new (Java.extend(model("ConstructorWithArgument")))("cwa-token", function() { print(cwa.token) }) |
102 cwa.doSomething() |
102 cwa.doSomething() |
|
103 |
|
104 // Do the same thing with proprietary syntax and object literal |
|
105 var cwa2 = new (model("ConstructorWithArgument"))("cwa2-token") { doSomething: function() { print("cwa2-" + cwa2.token ) } } |
|
106 cwa2.doSomething() |