/** Service Interface implementation */ @Override public void start() throws CantStartPluginException { System.out.println("********* Crypto Payment Request: Starting. "); try { loadKeyPair(pluginFileSystem); } catch (CantLoadKeyPairException e) { errorManager.reportUnexpectedPluginException( this.getPluginVersionReference(), UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN, e); throw new CantStartPluginException( e, "", "Problem trying to load the key pair of the plugin."); } /* * Validate required resources */ validateInjectedResources(); // initialize crypto payment request dao try { cryptoPaymentRequestNetworkServiceDao = new CryptoPaymentRequestNetworkServiceDao(pluginDatabaseSystem, pluginId); cryptoPaymentRequestNetworkServiceDao.initialize(); } catch (CantInitializeCryptoPaymentRequestNetworkServiceDatabaseException e) { CantStartPluginException pluginStartException = new CantStartPluginException( e, "", "Problem initializing crypto payment request network service dao."); errorManager.reportUnexpectedPluginException( this.getPluginVersionReference(), UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN, pluginStartException); throw pluginStartException; } try { /* * Initialize the data base */ initializeCommunicationDb(); /* * Initialize listeners */ initializeListener(); /* * Verify if the communication cloud client is active */ if (!wsCommunicationsCloudClientManager.isDisable()) { /* * Initialize the agent and start */ communicationRegistrationProcessNetworkServiceAgent = new CommunicationRegistrationProcessNetworkServiceAgent( this, wsCommunicationsCloudClientManager.getCommunicationsCloudClientConnection()); communicationRegistrationProcessNetworkServiceAgent.start(); } remoteNetworkServicesRegisteredList = new CopyOnWriteArrayList<>(); // change message state to process again first time reprocessMessage(); // declare a schedule to process waiting request message Timer timer = new Timer(); timer.schedule( new TimerTask() { @Override public void run() { // change message state to process retry later reprocessMessage(); } }, 2 * 3600 * 1000); /* * Its all ok, set the new status */ this.serviceStatus = ServiceStatus.STARTED; } catch (CantInitializeNetworkServiceDatabaseException exception) { StringBuffer contextBuffer = new StringBuffer(); contextBuffer.append("Plugin ID: " + pluginId); contextBuffer.append(CantStartPluginException.CONTEXT_CONTENT_SEPARATOR); contextBuffer.append( "Database Name: " + CommunicationNetworkServiceDatabaseConstants.DATA_BASE_NAME); String context = contextBuffer.toString(); String possibleCause = "The Template Database triggered an unexpected problem that wasn't able to solve by itself"; CantStartPluginException pluginStartException = new CantStartPluginException( CantStartPluginException.DEFAULT_MESSAGE, exception, context, possibleCause); errorManager.reportUnexpectedPluginException( this.getPluginVersionReference(), UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN, pluginStartException); throw pluginStartException; } System.out.println("********* Crypto Payment Request: Successful start. "); }