Server Development
As described below, the two annotations @HafService and @HafServerMain are required for server development. The @HafService annotation is added to the static function, indicating that the function is called remotely by the host node application. The @HafServerMain annotation is added to the main method, indicating the main function entry of the project.
public class TestMain {
@HafService
public static int testService(int a, int b) {
System.out.println("call add");
return a + b;
}
@HafServerMain
public static void main(String[] args) {
System.out.println("main start");
}
}
- In the project code on the server, the @HafServerMain annotation must be used to specify a function as the main function. You are advised to add the annotation to the main function.
- Apply a static public method when using the @HafService annotation to specify the service function.
Parent topic: Client/Server Pushdown Mode