Keyword "mainbody"For making it easier to test or quickly use a generated service implementation class, you can now add code to the definition, that will go into the main() method of the implementation class. IdeaImagine that you want to have a main() method in your implementation class, that will contain some custom code like the following line:
Then just put the following in the amalegeni service definition as follows:
Run amalegeni, and have a look at the generated Service Implementation class. You'll find your code, wrapped by a try/catch, in the body of the main(..) method:
Can you spot your line of code? Perfect! Note for the people with an eye for detail: the above main() will not compile because of no Application Exception being thrown in the try{} body. But now you have an impression of what the idea is. ExampleNote: the data used in this example is that of examples/masterdetail, of which we are only using the MasterBean.
Service method definition:
The code calling the 'getMasterList()' function looks like this:
Now generate the code with amalegeni, and have a look at the service implementation class:
If the other classes (eg. BaseService etc) are correctly setup, then execute your class and admire the output... Example codeThe example code, with all necessary other code bits, can be downloaded here: It should be pretty easy to tweak a file (or two) and have this stand-alone example up and running in 5-min. See the instructions in the included readme.txt file. For the sql scripts (create the table, insert data) use: |