예제 #1
0
  public boolean initialize() {

    try {
      initParams = new RemoteWrapperParamParser(getActiveAddressBean(), true);
      uid = Math.random();

      postParameters = new ArrayList<NameValuePair>();
      postParameters.add(
          new BasicNameValuePair(PushDelivery.NOTIFICATION_ID_KEY, Double.toString(uid)));
      postParameters.add(
          new BasicNameValuePair(
              PushDelivery.LOCAL_CONTACT_POINT, initParams.getLocalContactPoint()));
      // Init the http client
      if (initParams.isSSLRequired()) {
        KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
        trustStore.load(
            new FileInputStream(new File("conf/servertestkeystore")),
            Main.getContainerConfig().getSSLKeyStorePassword().toCharArray());
        SSLSocketFactory socketFactory = new SSLSocketFactory(trustStore);
        socketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
        int sslPort =
            Main.getContainerConfig().getSSLPort() > 0
                ? Main.getContainerConfig().getSSLPort()
                : ContainerConfig.DEFAULT_SSL_PORT;
        Scheme sch = new Scheme("https", socketFactory, sslPort);
        httpclient.getConnectionManager().getSchemeRegistry().register(sch);
      }
      Scheme plainsch =
          new Scheme(
              "http",
              PlainSocketFactory.getSocketFactory(),
              Main.getContainerConfig().getContainerPort());
      httpclient.getConnectionManager().getSchemeRegistry().register(plainsch);
      //
      lastReceivedTimestamp = initParams.getStartTime();
      structure = registerAndGetStructure();
    } catch (Exception e) {
      logger.error(e.getMessage(), e);
      NotificationRegistry.getInstance().removeNotification(uid);
      return false;
    }

    return true;
  }