1010import org .tinystruct .system .ApplicationManager ;
1111
1212import custom .objects .User ;
13+ import org .tinystruct .system .Dispatcher ;
14+ import org .tinystruct .system .annotation .Action ;
15+ import org .tinystruct .system .annotation .Argument ;
1316
1417public class firstApplication extends AbstractApplication {
1518
1619 @ Override
1720 public void init () {
1821 // TODO Auto-generated method stub
19- this .setAction ("praise" , "praise" );
20- this .setAction ("say" , "say" );
21- this .setAction ("youhappy" , "happy" );
22-
23- this .setAction ("user" , "findUser" );
24- this .setAction ("users" , "findUsers" );
25-
26- this .setAction ("version" , "version" , "GET" );
27- this .setAction ("version" , "setVersion" ,"POST" );
28-
29- this .setAction ("read" , "read" );
30-
31- this .setAction ("generate" , "generate_with_user_table" );
3222 }
33-
23+
24+ @ Action ("praise" )
3425 public String praise (){
3526 return "Praise to the Lord!" ;
3627 }
37-
28+
29+ @ Action ("youhappy" )
3830 public boolean happy (){
3931 return true ;
4032 }
41-
33+
34+ @ Action ("read" )
4235 public Object read (String json ,String name ){
4336 Builder builder = new Builder ();
4437 try {
@@ -51,35 +44,43 @@ public Object read(String json,String name){
5144 return builder .get (name );
5245 }
5346
47+ @ Action ("say" )
5448 public String say () throws ApplicationException {
5549 if (null != this .context .getAttribute ("words" ))
5650 return this .context .getAttribute ("words" ).toString ();
5751
5852 throw new ApplicationException ("Could not find the parameter <i>words</i>." );
5953 }
6054
55+ @ Action ("say" )
6156 public String say (String words ){
6257 return words ;
6358 }
6459
60+ @ Action ("version" )
6561 @ Override
6662 public String version () {
6763 // TODO Auto-generated method stub
6864 return this .context .getAttribute ("name" ) + this .context .getAttribute ("number" ).toString ();
6965 }
70-
66+
67+ @ Action (value = "version" , options = {
68+ @ Argument (key = "POST" , description = "POST method" ),
69+ })
7170 public void setVersion (float number ){
7271 this .context .setAttribute ("name" , "struct" );
7372 this .context .setAttribute ("number" , number );
73+ Dispatcher d ;
7474 }
75-
75+
76+ @ Action ("generate" )
7677 public void generate_with_user_table (){
7778 try {
7879 String [] list =new String []{"User" };
7980 Generator generator =new MySQLGenerator ();
8081 for (String className :list )
8182 {
82- generator .setFileName ("src/custom/objects/" );
83+ generator .setPath ("src/custom/objects/" );
8384 generator .setPackageName ("custom.objects" );
8485 generator .importPackages ("java.util.Date" );
8586 generator .create (className ,className );
@@ -91,7 +92,8 @@ public void generate_with_user_table(){
9192 e .printStackTrace ();
9293 }
9394 }
94-
95+
96+ @ Action ("user" )
9597 public User findUser (Object userId ) throws ApplicationException {
9698
9799 if (userId !=null ){
@@ -104,7 +106,8 @@ public User findUser(Object userId) throws ApplicationException{
104106
105107 return null ;
106108 }
107-
109+
110+ @ Action ("users" )
108111 public Table findUsers () throws ApplicationException {
109112 return new User ().findAll ();
110113 }
0 commit comments