Example #1
0
  /** @see org.eclipse.cdt.debug.core.cdi.ICDISession#terminate(ICDITarget) */
  @Override
  public void terminate() throws CDIException {
    ProcessManager pMgr = getProcessManager();
    Target[] targets = pMgr.getTargets();
    for (int i = 0; i < targets.length; ++i) {
      if (!targets[i].getMISession().isTerminated()) {
        targets[i].getMISession().terminate();
      }
    }
    // Do not do the removeTargets(), Target.getMISession().terminate() will do it
    // via an event, MIGDBExitEvent of the mi session
    // removeTargets(targets);

    // wait ~2 seconds for the targets to be terminated.
    for (int i = 0; i < 2; ++i) {
      targets = pMgr.getTargets();
      if (targets.length == 0) {
        break;
      }
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        //
      }
    }
    // send our goodbyes.
    EventManager eMgr = (EventManager) getEventManager();
    eMgr.fireEvents(new ICDIEvent[] {new DestroyedEvent(this)});
    eMgr.removeEventListeners();
  }
 @Override
 public void onResume() {
   super.onResume();
   updateView();
   EventManager eventManager = SpellcastApplication.getInstance().getEventManager();
   eventManager.addEventListener(HANDLED_EVENTS, this);
 }
Example #3
0
  /** Obsługa zapytań */
  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    long start = System.currentTimeMillis();
    Document response = createDocument();
    Element root = response.createElement("response");
    response.appendChild(root);

    String action = req.getParameter("action");
    if (action == null) {

      root.appendChild(createTextNode(response, "status", "err"));
      root.appendChild(createTextNode(response, "message", "No action parameter defined"));

    } else {

      EventManager em = EventManager.getInstance();
      Event e = em.getByName(action);

      if (e == null) {
        root.appendChild(createTextNode(response, "status", "err"));
        root.appendChild(createTextNode(response, "message", "No such event (" + action + ")"));

      } else {
        root.appendChild(e.processEvent(response, req));
      }
    }
    root.appendChild(
        createTextNode(
            response, "Total_time", String.valueOf(System.currentTimeMillis() - start) + " ms"));
    XML2Writer(response, resp.getWriter());
    XML2Writer(response, new PrintWriter(System.out));
  }
  @Test
  public void testUnregister() {
    TargetEventTriggered trigger = new TargetEventTriggered();
    eventManager.register(ObservesEvent.class, trigger);
    eventManager.unregister(trigger);

    eventManager.trigger(new ObservesEvent());

    assertFalse(trigger.isTriggered());
  }
Example #5
0
  public static void main(String[] args) throws Exception {
    EventManager manager = new EventManager();

    manager.read("c:/dataset/event/short.txt");
    manager.read("g:/dataset/event/application.txt");
    System.out.println("Distinct event size:" + manager.distinctEventSize());
    System.out.println("Event length:" + manager.length());
    //		CodeCost codeCost = new CodeCost(manager);
    //		double cost = codeCost.optimalTL();
    //		System.out.println(cost);
  }
Example #6
0
  public final MapleMap getMapInstance(int args) {
    final MapleMap map = mapFactory.getInstanceMap(mapIds.get(args));

    // in case reactors need shuffling and we are actually loading the map
    if (!mapFactory.isInstanceMapLoaded(mapIds.get(args))) {
      if (em.getProperty("shuffleReactors") != null
          && em.getProperty("shuffleReactors").equals("true")) {
        map.shuffleReactors();
      }
    }
    return map;
  }
 @OnWebSocketMessage
 public void onText(Session session, String message) {
   //    	System.out.printf("message: %s\n",message);
   //        if (session.isOpen()) {
   //        	String response = "{\"eventType\": \"RobotStateNotification\", \"messageId\":25,
   // \"timestamp\": 1458450677922, \"state\":\"AutonomousPeriodic\"}";
   //            System.out.printf("response: %s\n", response);
   //            session.getRemote().sendString(response, null);
   //
   //        }
   if (eventManager.getCallback() != null) eventManager.getCallback().onText(session, message);
 }
 /**
  * Initializes the Transfer manager to use a protocol to open connections.
  *
  * @param protocol Protocol to be used
  * @param properties Location of the properties files
  * @param mh Handler for the events produced by the connections
  */
 public static void init(String protocol, String properties, MessageHandler mh) {
   if (protocol.contentEquals("NIO")) {
     em = new NIOEventManager(mh);
   }
   try {
     em.init(properties);
   } catch (Exception e) {
     LOGGER.error(PROPERTIES_ERROR, e);
   }
   mh.init();
   em.start();
 }
 /** Saves event into the list. */
 public synchronized void save() {
   myEvent.setNEID(myNE.getId());
   myEvent.setEnabled(true);
   myEvent.setDescription(desc.getText());
   int h = (Integer) hh.getValue();
   int m = (Integer) mm.getValue();
   double s = (Double) ss.getValue();
   myEvent.setTime(h + (m / 60.0) + (s / 3600.0));
   myEventManager.clearEvent(myEvent);
   myEventManager.addEvent(myEvent);
   if (eventTable != null) eventTable.updateData();
   return;
 }
Example #10
0
  public static void main(String[] args) {
    System.setProperty("fr.umlv.jbucks.factory", BuckFactoryImpl.class.getName());

    BuckFactory factory = BuckFactory.getFactory();
    Book book = factory.createBook("test");
    System.out.println(book.getName());

    book.setUserData("hello-UID", "12345");
    System.out.println("hello-UID " + book.getUserDataValue("hello-UID"));

    EventManager manager = factory.getEventManager();

    manager.addListener(
        Book.class,
        "accounts",
        PropertyEvent.TYPE_PROPERTY_ADDED | PropertyEvent.TYPE_PROPERTY_REMOVED,
        new PropertyListener() {
          public void propertyChanged(PropertyEvent event) {
            System.out.println(event);
          }
        });

    Account account = factory.createAccount(book, "remi");
    factory.createAccount(book, "gilles");

    List list = book.getAccounts();

    System.out.println(list);

    SortedSet transactions = account.getTransactions();

    manager.addListener(
        Account.class,
        "transactions",
        PropertyEvent.TYPE_PROPERTY_ADDED | PropertyEvent.TYPE_PROPERTY_REMOVED,
        new PropertyListener() {
          public void propertyChanged(PropertyEvent event) {
            System.out.println("transaction " + event);
          }
        });

    Transaction transaction =
        factory.createTransaction(new Date().getTime(), Collections.EMPTY_LIST);
    transactions.add(transaction);

    SortedSet tailSet = transactions.tailSet(transaction);

    System.out.println(tailSet);

    tailSet.add(factory.createTransaction(transaction.getDate() + 1, Collections.EMPTY_LIST));
  }
  /** Run program in non-interactive mode. */
  public void quickRun() {
    EventManager eventManager = new EventManager();

    try {
      // Create an Asynchronous event.
      int aEventId = eventManager.createAsync(60);
      System.out.println("Async Event [" + aEventId + "] has been created.");
      eventManager.start(aEventId);
      System.out.println("Async Event [" + aEventId + "] has been started.");

      // Create a Synchronous event.
      int sEventId = eventManager.create(60);
      System.out.println("Sync Event [" + sEventId + "] has been created.");
      eventManager.start(sEventId);
      System.out.println("Sync Event [" + sEventId + "] has been started.");

      eventManager.status(aEventId);
      eventManager.status(sEventId);

      eventManager.cancel(aEventId);
      System.out.println("Async Event [" + aEventId + "] has been stopped.");
      eventManager.cancel(sEventId);
      System.out.println("Sync Event [" + sEventId + "] has been stopped.");

    } catch (MaxNumOfEventsAllowedException
        | LongRunningEventException
        | EventDoesNotExistException
        | InvalidOperationException e) {
      System.out.println(e.getMessage());
    }
  }
  /** TransactionService interface implementation. */
  @Override
  public void start() throws CantStartServiceException {

    /** I will initialize the handling of com.bitdubai.platform events. */
    EventListener eventListener;
    EventHandler eventHandler;

    eventListener =
        eventManager.getNewListener(
            EventType.INCOMING_CRYPTO_TRANSACTIONS_WAITING_TRANSFERENCE_EXTRA_USER);
    eventHandler = new IncomingCryptoTransactionsWaitingTransferenceExtraUserEventHandler(this);
    eventListener.setEventHandler(eventHandler);
    eventManager.addListener(eventListener);
    listenersAdded.add(eventListener);

    this.serviceStatus = ServiceStatus.STARTED;
  }
Example #13
0
 /** This needs to be called if the ValManager is ever deleted. */
 public void dispose() {
   // currently nobody calls this method, because this instance is never removed, but the method is
   // here for completeness none the less.
   ValPrefManagerGlobal.getDefault().removeListener(this);
   ValPrefManagerProject.removeListener(this);
   FacetedProjectFramework.removeListener(this);
   EventManager.getManager().removeProjectChangeListener(this);
 }
Example #14
0
  public void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws IOException, ServletException {

    log.info("########## START EDIT EVENT POST ###########");

    // Check for valid user session
    lpo.User user = UserManager.GetUser();

    if (user == null) resp.sendRedirect("WelcomePage.jsp");

    // get event from datastore
    String eventKey = req.getParameter("k");

    // pull the event object out
    lpo.Event event = EventManager.GetEvent(eventKey);

    String eventName = req.getParameter("eventName").trim();
    String description = req.getParameter("description").trim();

    boolean formIsComplete = true;

    int minParticipants = 0;
    try {
      minParticipants = Integer.parseInt(req.getParameter("minParticipants"));
    } catch (Exception e) {
      log.info("ERROR PARSING MIN PARTICIPANTS: " + e.toString());
      formIsComplete = false;
    }

    log.info("FORM VARS : " + eventName + " " + description + " " + minParticipants);

    if (eventName == null
        || eventName.isEmpty()
        || description == null
        || description.isEmpty()
        || minParticipants < 1) {

      formIsComplete = false;
    }

    if (formIsComplete) {

      // create event and populate available attributes
      event.setName(eventName);
      event.setDescription(description);
      event.setMinParticipants(minParticipants);

      // persist to database
      DataAccessManager.UpdateEvent(event);

      resp.sendRedirect("/Menu");
    } else {
      // reshow the same jsp page with error message :
      req.getRequestDispatcher("/WEB-INF/EditEvent.jsp").forward(req, resp);
    }

    return;
  }
Example #15
0
 public void onMapLoad(final MapleCharacter chr) {
   try {
     em.getIv().invokeFunction("onMapLoad", this, chr);
   } catch (ScriptException ex) {
     ex.printStackTrace();
   } catch (NoSuchMethodException ex) {
     // Ignore, we don't want to update this for all events.
   }
 }
Example #16
0
 public final void leftParty(final MapleCharacter chr) {
   try {
     em.getIv().invokeFunction("leftParty", this, chr);
   } catch (ScriptException ex) {
     ex.printStackTrace();
   } catch (NoSuchMethodException ex) {
     ex.printStackTrace();
   }
 }
Example #17
0
  /**
   * Execute a command. Do not forget to initialize the CVS Root on globalOptions first! Example:
   * <code>
   *   GlobalOptions options = new GlobalOptions();
   *   options.setCVSRoot(":pserver:"+userName+"@"+hostName+":"+cvsRoot);
   * </code>
   *
   * @param command the command to execute
   * @param options the global options to use for executing the command
   * @throws CommandException if an error occurs when executing the command
   * @throws CommandAbortedException if the command is aborted
   */
  public boolean executeCommand(Command command, GlobalOptions globalOptions)
      throws CommandException, CommandAbortedException, AuthenticationException {
    BugLog.getInstance().assertNotNull(command);
    BugLog.getInstance().assertNotNull(globalOptions);

    this.globalOptions = globalOptions;

    getUncompressedFileHandler().setGlobalOptions(globalOptions);
    getGzipFileHandler().setGlobalOptions(globalOptions);

    try {
      eventManager.addCVSListener(command);
      command.execute(this, eventManager);
    } finally {
      eventManager.removeCVSListener(command);
    }
    return !command.hasFailed();
  }
Example #18
0
 public final void disbandParty() {
   try {
     em.getIv().invokeFunction("disbandParty", this);
   } catch (ScriptException ex) {
     ex.printStackTrace();
   } catch (NoSuchMethodException ex) {
     ex.printStackTrace();
   }
 }
 private void registerEvents() {
   eventManager.register(
       ObservesEvent.class,
       new EventObserver<ObservesEvent>() {
         @Override
         public void trigger(ObservesEvent event) {
           target.observes(event);
         }
       });
   eventManager.register(
       Object.class,
       new EventObserver<Object>() {
         @Override
         public void trigger(Object event) {
           target.observes(event);
         }
       });
 }
Example #20
0
 public void playerKilled(MapleCharacter chr) {
   try {
     em.getIv().invokeFunction("playerDead", this, chr);
   } catch (ScriptException ex) {
     ex.printStackTrace();
   } catch (NoSuchMethodException ex) {
     ex.printStackTrace();
   }
 }
Example #21
0
 // Separate function to warp players to a "finish" map, if applicable
 public final void finishPQ() {
   try {
     em.getIv().invokeFunction("clearPQ", this);
   } catch (ScriptException ex) {
     ex.printStackTrace();
   } catch (NoSuchMethodException ex) {
     ex.printStackTrace();
   }
 }
Example #22
0
 public final void removePlayer(final MapleCharacter chr) {
   try {
     em.getIv().invokeFunction("playerExit", this, chr);
   } catch (ScriptException ex) {
     ex.printStackTrace();
   } catch (NoSuchMethodException ex) {
     ex.printStackTrace();
   }
 }
  @Test
  public void testEventHierarchyTrigger() {
    registerEvents();

    Object event = new Object();
    eventManager.trigger(event);

    assertNull(target.getEvent());
    assertEquals(event, target.getObjectEvent());
  }
  @Test
  public void testRegistration() {
    registerEvents();

    ObservesEvent event = new ObservesEvent();
    eventManager.trigger(event);

    assertEquals(event, target.getEvent());
    assertEquals(event, target.getObjectEvent());
  }
Example #25
0
 /**
  * @param chr
  * @param mob
  */
 public void monsterKilled(final MapleCharacter chr, final MapleMonster mob) {
   try {
     Integer kc = killCount.get(chr);
     int inc = ((Double) em.getIv().invokeFunction("monsterValue", this, mob.getId())).intValue();
     if (kc == null) {
       kc = inc;
     } else {
       kc += inc;
     }
     killCount.put(chr, kc);
     if (chr.getCarnivalParty() != null) {
       em.getIv().invokeFunction("monsterKilled", this, chr, mob.getStats().getCP());
     }
   } catch (ScriptException ex) {
     ex.printStackTrace();
   } catch (NoSuchMethodException ex) {
     ex.printStackTrace();
   }
 }
Example #26
0
 public void changedMap(final MapleCharacter chr, final int mapid) {
   try {
     em.getIv().invokeFunction("changedMap", this, chr, mapid);
   } catch (NullPointerException npe) {
   } catch (ScriptException ex) {
     ex.printStackTrace();
   } catch (NoSuchMethodException ex) {
     ex.printStackTrace();
   }
 }
 public ParticleControllerInfluencerPanel(
     FlameMain editor,
     ParticleControllerInfluencer influencer,
     boolean single,
     String name,
     String desc) {
   super(editor, influencer, name, desc, true, false);
   controllerPicker.setMultipleSelectionAllowed(!single);
   EventManager.get().attach(FlameMain.EVT_ASSET_RELOADED, this);
 }
Example #28
0
  private static void doLogin(String name) {
    LoginRequest.isLoggingIn(true);

    try {
      ConcoctionDatabase.deferRefresh(true);
      LoginManager.initialize(name);
    } finally {
      ConcoctionDatabase.deferRefresh(false);
      LoginRequest.isLoggingIn(false);
    }

    // Abort further processing in Valhalla.
    if (CharPaneRequest.inValhalla()) {
      return;
    }

    // Abort further processing if we logged in to a fight or choice
    if (KoLmafia.isRefreshing()) {
      return;
    }

    if (Preferences.getBoolean(name, "getBreakfast")) {
      int today = HolidayDatabase.getPhaseStep();
      BreakfastManager.getBreakfast(Preferences.getInteger("lastBreakfast") != today);
      Preferences.setInteger("lastBreakfast", today);
    }

    if (Preferences.getBoolean("sharePriceData")) {
      KoLmafiaCLI.DEFAULT_SHELL.executeLine(
          "update prices http://kolmafia.us/scripts/updateprices.php?action=getmap");
    }

    // Also, do mushrooms, if a mushroom script has already
    // been setup by the user.

    if (Preferences.getBoolean(
        "autoPlant" + (KoLCharacter.canInteract() ? "Softcore" : "Hardcore"))) {
      String currentLayout = Preferences.getString("plantingScript");
      if (!currentLayout.equals("")
          && KoLCharacter.knollAvailable()
          && MushroomManager.ownsPlot()) {
        KoLmafiaCLI.DEFAULT_SHELL.executeLine(
            "call " + KoLConstants.PLOTS_DIRECTORY + currentLayout + ".ash");
      }
    }

    String scriptSetting = Preferences.getString("loginScript");
    if (!scriptSetting.equals("")) {
      KoLmafiaCLI.DEFAULT_SHELL.executeLine(scriptSetting);
    }

    if (EventManager.hasEvents()) {
      KoLmafiaCLI.DEFAULT_SHELL.executeLine("events");
    }
  }
  @Override
  public void stop() {

    /** I will remove all the event listeners registered with the event manager. */
    for (EventListener eventListener : listenersAdded) {
      eventManager.removeListener(eventListener);
    }

    listenersAdded.clear();

    this.serviceStatus = ServiceStatus.STOPPED;
  }
  public void ladderChallenge(final String rid, final int pos) {
    EventManager.getEventManager().sendEvent(eventType.ladderChallengeStart);
    Thread t =
        new Thread(
            new Runnable() {
              @Override
              public void run() {
                initHttp();
                System.out.println("challengeladder - getlogin passed");

                HttpGet get =
                    new HttpGet(getUrl() + "tournaments/ladder/challenge.php?tid=3&rid=" + rid);
                String res = directConnectExecute(get);
                System.out.println("challengeladder - got server answer");

                // check if challenge possible
                int i = res.indexOf("Defender is not");
                if (i >= 0) {
                  EventManager.getEventManager().sendEvent(eventType.ladderChallengeEnd);
                  EventManager.getEventManager()
                      .sendEvent(eventType.showMessage, "Defender is not any more challengeable");
                  return;
                }
                i = res.indexOf("Please confirm if you want to challenge this user");
                if (i < 0) {
                  EventManager.getEventManager().sendEvent(eventType.ladderChallengeEnd);
                  EventManager.getEventManager()
                      .sendEvent(eventType.showMessage, "Error when trying to challenge user");
                  return;
                }
                // challenge is possible.
                {
                  HttpGet cget =
                      new HttpGet(
                          getUrl()
                              + "tournaments/ladder/challenge.php?tl_challenge=Confirm+Challenge&tid=3&rid="
                              + rid
                              + "&confirm=1");
                  String cres = directConnectExecute(cget);
                  System.out.println("challengeladder - got server answer to challenge confirm");
                  System.out.println(cres);
                  EventManager.getEventManager()
                      .sendEvent(eventType.showMessage, "Challenge " + ladd.userList[pos] + " ok");
                }

                // warning: displaying this String may not be done completely, why ?
                //                System.out.println(res);
                EventManager.getEventManager().sendEvent(eventType.ladderChallengeEnd);
              }
            });
    t.start();
  }