001    package com.khubla.pragmatach.examples.startupexample;
002    
003    import java.util.Date;
004    
005    import com.khubla.pragmatach.framework.annotation.Controller;
006    import com.khubla.pragmatach.framework.annotation.OnShutdown;
007    import com.khubla.pragmatach.framework.annotation.OnStartup;
008    import com.khubla.pragmatach.framework.annotation.Route;
009    import com.khubla.pragmatach.framework.annotation.View;
010    import com.khubla.pragmatach.framework.api.PragmatachException;
011    import com.khubla.pragmatach.framework.api.Response;
012    import com.khubla.pragmatach.plugin.freemarker.FreemarkerController;
013    
014    @Controller()
015    @View(view = "index.ftl")
016    public class IndexController extends FreemarkerController {
017       /**
018        * the message
019        */
020       private String message = "OnStartup and OnShutdown Example";
021    
022       @OnStartup
023       public static void onStartup() {
024          System.out.println("startup");
025       }
026    
027       @OnShutdown
028       public static void onShutdown() {
029          System.out.println("shutdown");
030       }
031    
032       public String getMessage() {
033          return message;
034       }
035    
036       public String getTime() {
037          return new Date().toString();
038       }
039    
040       @Override
041       @Route(uri = "/")
042       public Response render() throws PragmatachException {
043          return super.render();
044       }
045    }