Closed AdityaRandive closed 2 years ago
@AdityaRandive looks good. Couple of suggestions
Let's keep the web_agents cookbook as is for now. You can move your code under a new top-leve folder under cookbook and call it web_agents_server_recon
The validation of whether the property passed in matches the type is useful but not relevant for this cookbook. It will be simpler if all the agents have one string prpoerty, one boolean property, one integer and one floatr property with different values. That should suffice. Also it will be good to fallback to defaults in the code if the prop is not defined. Eg , you can do something like this:
final float propFloatValue = getProp("propFloat").floatValue(0.0f);
final boolean propBooleanValue = getProp("propBool").booleanValue(false);
final String propStringValue = getProp("propString").stringValue("");
You have node definitions with uris, it will be good to show agent definitions with uri patterns as well. So the server .recon
will look something like this:
@node {
uri: "/unit/1"
@agent(class: "swim.basic.UnitAgent") {
propString: "p1"
propInt: 1
propFloat: 1.1
propBool: true
}
}
@node {
uri: "/unit/2"
@agent(class: "swim.basic.UnitAgent") {
propString: "pfoo"
propInt: 2
propFloat: 2.2
propBool: true
}
}
@node {
uri: "/unit/:id"
@agent(class: "swim.basic.UnitAgent") {
propString: "defaultProp"
propInt: 9
propFloat: 9.9
propBool: false
}
}
This is useful to show since the agents with the uris i.e (/unit/1 and unit/2) will get instantiated by the swim runtime automatically when the server starts up. The agents that are started from the BasicPlane
using space.command("/unit/foo", "unusedForNow", Value.absent());
will get initialized using the properties in the properties defined under the /unit/:id
section in the server.recon
file
Looks good!
Super minor changes
server.recon
have 2 spaces on indentation. The new stuff has 4 spaces, i think we use 2 spaces in other appslogMessage
method to print from the UnitAgent
instead of using System.out.println
. That method already adds the nodeUri()
in the front. Once you make these changes, please merge them to master and remove this branch
This commit includes code to illustrate the utilization of server.recon configuration file for defining web agents. Also, illustrates the use of declaring and reading properties with different data-types.
Author: Aditya R Reviewers: Ajay G, Rohit B Test: Manual Issue: https://github.com/swimos/cookbook/issues/20