コード例 #1
0
  public void init(ServletConfig config) throws ServletException {

    try {

      APNSHandler handler = APNSHandler.getInstance();
      handler.setCertificateStorePath("/pns-provider");
      try {
        loadConfigFromDatabase();
      } catch (Exception e) {
        System.out.println("Caught exception " + e);
        e.printStackTrace();
      }
    } catch (Exception e) {
      System.out.println("Caught exception " + e);
      e.printStackTrace();
    }
  }
コード例 #2
0
  public void loadConfigFromDatabase() throws Exception {
    // DBAccess db = new DBAccess();
    // MobileApplicationDAO mobileApplicationDAO = new
    // MobileApplicationDAO();
    try {
      // List<AppDetails> appDetails =
      // mobileApplicationDAO.getAppDetails();
      // TODO: call db to load all the application details
      /*
       * ------------------------------------------------------------------
       * APP_DETAILS_TABLE
       * -------------------------------------
       * Appname |certificateFileName 			| path 					|keyPassword | isProduction
       * ==============================================================================================
       * Testapp |testapp_sandbox_cert.p12 	    |  /weblogic/testaapp/ 	|mypass 	 |		false
       */
      List<AppDetails> appDetails = new ArrayList<AppDetails>();

      // appDetails = dao call here
      APNSHandler handler = APNSHandler.getInstance();
      System.out.println("Adding apps");

      int nrThreads = 1;
      for (AppDetails item : appDetails) {
        System.out.println("Adding app - " + item);
        try {
          handler.addApp(
              item.getAppName(),
              item.getSslKeyFilename(),
              item.getSslKeypassword(),
              item.isProduction(),
              nrThreads);
        } catch (Exception e) {
          System.out.println("Caught exception " + e);
          e.printStackTrace();
        }
      }

    } catch (Exception e) {
      System.out.println("Caught exception " + e);
      e.printStackTrace();
    }
  }