at:tutorial:symbiosis
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
at:tutorial:symbiosis [2007/07/27 10:25] – changes tvcutsem | at:tutorial:symbiosis [2008/08/01 14:41] – * tvcutsem | ||
---|---|---|---|
Line 125: | Line 125: | ||
< | < | ||
>def test := / | >def test := / | ||
- | >>< | + | >>< |
> | > | ||
ping! | ping! | ||
Line 131: | Line 131: | ||
>>42 | >>42 | ||
</ | </ | ||
+ | |||
+ | ==== Starting an AmbientTalk interpreter from Java ==== | ||
+ | So far, the examples have illustrated how to reuse Java code from within AmbientTalk. They have shown how to access Java classes, instantiate them and invoke methods on the resulting objects. Moreover, | ||
+ | |||
+ | Embedding AmbientTalk in an application, | ||
+ | |||
+ | < | ||
+ | EmbeddedAmbientTalk vm = new EmbeddedAmbientTalk(); | ||
+ | vm.initialize( | ||
+ | NATParser.parse( | ||
+ | initFile.getName(), | ||
+ | Evaluator.loadContentOfFile(initFile)), | ||
+ | new SharedActorField[] { | ||
+ | vm.computeSystemObject(arguments), | ||
+ | vm.computeWorkingDirectory(), | ||
+ | vm.computeObjectPath(objectPath) }, | ||
+ | " | ||
+ | </ | ||
+ | The code excerpt also illustrates that the EmbeddableAmbientTalk class provides methods to create definitions for fields such as '' | ||
+ | |||
+ | Once the virtual machine is properly initialized, | ||
+ | |||
+ | < | ||
+ | public interface Controller { | ||
+ | public void executeEvent(ApplicationEvent evt); | ||
+ | public void executeEventWithoutUndo(ApplicationEvent evt); | ||
+ | public void undo(); | ||
+ | } | ||
+ | ... | ||
+ | private Controller controller = | ||
+ | (Controller) vm.evalAndWrap( | ||
+ | Evaluator.loadContentsOfFile(" | ||
+ | Controller.class); | ||
+ | </ | ||
+ | |||
+ | The corresponding AmbientTalk code should then return an object which implements the three methods to modify the model, and can be used to detect other reachable controllers with which it can exchange ApplicationEvents. | ||
+ | |||
+ | < | ||
+ | When starting an AmbientTalk virtual machine from a Java application, | ||
+ | </ |
at/tutorial/symbiosis.txt · Last modified: 2013/05/17 20:25 by tvcutsem