コード例 #1
0
  public void incomingChatEventHandler(IncomingChat event) throws CantSaveEventException {
    // Logger LOG = Logger.getGlobal();
    // LOG.info("EVENT TEST, I GOT AN EVENT:\n"+event);
    try {
      //            this.chatMiddlewareDatabaseDao.saveNewEvent(
      //                    event.getEventType().getCode(),
      //                    event.getSource().getCode(),
      //                    event.getChatId());
      chatMiddlewareMonitorAgent.checkIncomingChat(event.getChatMetadata());
    } catch (Exception exception) {
      errorManager.reportUnexpectedPluginException(
          Plugins.CHAT_MIDDLEWARE,
          UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
          FermatException.wrapException(exception));
      throw new CantSaveEventException(
          exception, "Saving OutgoingChat event", "Unexpected Exception");
    }

    // LOG.info("CHECK THE DATABASE");
  }
コード例 #2
0
  @Override
  public void start() throws CantStartPluginException {
    try {

      /** Initialize database */
      // System.out.println("OPEN_CONTRACT DB");
      initializeDb();

      /*
       * Initialize Developer Database Factory
       */
      // System.out.println("OPEN_CONTRACT Facti");
      chatMiddlewareDeveloperDatabaseFactory =
          new ChatMiddlewareDeveloperDatabaseFactory(pluginDatabaseSystem, pluginId);
      chatMiddlewareDeveloperDatabaseFactory.initializeDatabase();

      /** Initialize Dao */
      ChatMiddlewareDatabaseDao chatMiddlewareDatabaseDao =
          new ChatMiddlewareDatabaseDao(pluginDatabaseSystem, pluginId, database);
      // chatMiddlewareDatabaseDao.initialize();
      /** Initialize manager */
      chatMiddlewareManager = new ChatMiddlewareManager(chatMiddlewareDatabaseDao);

      /** Init event recorder service. */
      ChatMiddlewareRecorderService chatMiddlewareRecorderService =
          new ChatMiddlewareRecorderService(chatMiddlewareDatabaseDao, eventManager);
      chatMiddlewareRecorderService.start();

      /** Init developer database factory */
      chatMiddlewareDeveloperDatabaseFactory =
          new ChatMiddlewareDeveloperDatabaseFactory(pluginDatabaseSystem, pluginId);
      chatMiddlewareDeveloperDatabaseFactory.initializeDatabase();
      /** Init monitor Agent */
      ChatMiddlewareMonitorAgent openContractMonitorAgent =
          new ChatMiddlewareMonitorAgent(
              pluginDatabaseSystem, logManager, errorManager, eventManager, pluginId, chatManager);
      openContractMonitorAgent.start();

      this.serviceStatus = ServiceStatus.STARTED;
      // Test method
      // sendMessageTest();
      // receiveMessageTest();
      // testPublicKeys();
    } catch (CantInitializeDatabaseException exception) {
      throw new CantStartPluginException(
          CantStartPluginException.DEFAULT_MESSAGE,
          FermatException.wrapException(exception),
          "Starting open contract plugin",
          "Cannot initialize plugin database");
    } catch (CantInitializeChatMiddlewareDatabaseException exception) {
      throw new CantStartPluginException(
          CantStartPluginException.DEFAULT_MESSAGE,
          exception,
          "Starting open contract plugin",
          "Unexpected Exception");
    } catch (CantStartServiceException exception) {
      throw new CantStartPluginException(
          CantStartPluginException.DEFAULT_MESSAGE,
          exception,
          "Starting open contract plugin",
          "Cannot start recorder service");
    } catch (CantSetObjectException exception) {
      throw new CantStartPluginException(
          CantStartPluginException.DEFAULT_MESSAGE,
          exception,
          "Starting open contract plugin",
          "Cannot set an object");
    } catch (CantStartAgentException exception) {
      throw new CantStartPluginException(
          CantStartPluginException.DEFAULT_MESSAGE,
          FermatException.wrapException(exception),
          "Starting open contract plugin",
          "Cannot start the monitor agent");
    } catch (Exception exception) {
      throw new CantStartPluginException(
          CantStartPluginException.DEFAULT_MESSAGE,
          FermatException.wrapException(exception),
          "Starting open contract plugin",
          "Unexpected Exception");
    }
  }