示例#1
0
  // ---------------------------------------------------------------------------
  private void writeCache() {
    try {
      Debug.print("Writing cache");
      FileOutputStream fos = new FileOutputStream(m_cacheFile);
      ObjectOutputStream oos = new ObjectOutputStream(fos);

      oos.writeObject(m_depCache);

      oos.writeInt(m_newModificationCache.size());

      Iterator<String> it = m_newModificationCache.keySet().iterator();

      while (it.hasNext()) {
        String key = it.next();

        oos.writeUTF(key);
        oos.writeLong(m_newModificationCache.get(key));
      }

      oos.close();
    } catch (Exception e) {
      Debug.print(e.getMessage());
      StringWriter sw = new StringWriter();
      e.printStackTrace(new PrintWriter(sw));
      Debug.print(sw.toString());
    }
  }
  /* (non-Javadoc)
   * @see android.app.Activity#onCreate(android.os.Bundle)
   */
  @Override
  public void onCreate(Bundle savedState) {
    super.onCreate(savedState);
    Debug.print("onCreate()");
    try {
      MotionEventWrapper5.checkAvailable();
      Rokon.motionEvent5 = new MotionEventWrapper5();
    } catch (VerifyError e) {
    }

    try {
      MotionEventWrapper8.checkAvailable();
      Rokon.motionEvent8 = new MotionEventWrapper8();
    } catch (VerifyError e) {
    }
    if (engineCreated) {
      Debug.print("onCreate() when already started, creating new GLSurfaceView");
      // surfaceView = new RokonSurfaceView(this);
      // setContentView(surfaceView);
      return;
    }
    Debug.print("Engine Activity created");
    onCreate();
    if (!engineCreated) {
      Debug.error("The engine was not created");
      Debug.print("#################### FINISH ME HERE");
      finish();
      return;
    }
  }
  /* note - use currently running jre if match, otherwise use first match */
  private static void matchJRE(
      JREDesc jd,
      String[] versions,
      ConfigProperties.JREInformation[] selectedJRE,
      JREDesc[] selectedJREDesc) {
    URL location = jd.getHref();
    VersionString vs; // Make sure to use passed in versions

    ConfigProperties cp = ConfigProperties.getInstance();
    ArrayList al = cp.getJREInformationList();
    if (al == null) return;

    for (int j = 0; j < versions.length; j++) {
      vs = new VersionString(versions[j]);
      for (int i = 0; i < al.size(); i++) {
        ConfigProperties.JREInformation je = (ConfigProperties.JREInformation) al.get(i);

        // first check if JRE osName and osArch matches
        // (only if osName and osArch exist)
        if (je.isOsInfoMatch(Globals.osName, Globals.osArch)) {

          if (je.isEnabled()) {

            boolean jreMatch =
                (location == null && je.isPlatformMatch(vs))
                    || (location != null && je.isProductMatch(location, vs));
            boolean pathMatch = je.isCurrentRunningJRE();
            boolean heapMatch = JnlpxArgs.isCurrentRunningJREHeap(jd.getMinHeap(), jd.getMaxHeap());

            if (jreMatch && pathMatch && heapMatch) {
              if (Globals.TraceStartup) {
                Debug.println("LaunchSelection: findJRE: Match on current JRE");
              }
              // Match on current JRE!
              selectedJRE[0] = je;
              selectedJREDesc[0] = jd;
              return; // We are done
            } else if (jreMatch && (selectedJRE[0] == null)) {
              // Match, but not on current. Remember the first match ,
              // and keep scanning to see if we get a
              // match on current running JRE
              if (Globals.TraceStartup) {
                Debug.print("LaunchSelection: findJRE: No match on current JRE because ");
                if (!jreMatch) Debug.print("versions dont match, ");
                if (!pathMatch) Debug.print("paths dont match, ");
                if (!heapMatch) Debug.print("heap sizes dont match");
                Debug.println("");
              }

              selectedJRE[0] = je;
              selectedJREDesc[0] = jd;
            }
          }
        }
      }
    }
    // Always remember the first one
    if (selectedJREDesc[0] == null) selectedJREDesc[0] = jd;
  }
 /**
  * Sets the game width and height of the OpenGL surface The width will altered depending on screen
  * resolution
  *
  * @param width
  * @param height
  * @return final game width
  */
 public float setGameSize(float width, float height) {
   Graphics.determine(this);
   float aspect = width / height;
   gameWidth = width;
   gameHeight = height;
   if (Graphics.getAspectRatio() < aspect) {
     Debug.print("Thinner than expected");
   } else if (Graphics.getAspectRatio() > aspect) {
     Debug.print("Wider than expected");
   }
   gameWidth = Graphics.getAspectRatio() * gameHeight;
   return gameWidth;
 }
示例#5
0
  // ---------------------------------------------------------------------------
  public Rule findTargetRule(String target) throws TablesawException {
    Rule rule = null;

    if (m_resolved) {
      ArrayList<String> posTargets;
      String posTarget = target;

      if (m_noRulesList.contains(target)) return (null);

      if ((rule = m_locatedRules.get(target)) != null) return (rule);

      // First look in name map
      rule = m_nameRuleMap.get(target);

      if (rule == null) { // Now look for targets
        rule = m_targetRuleMap.get(posTarget);
        if (rule == null) {
          posTargets = m_fileManager.getPossibleFiles(posTarget);
          for (String t : posTargets) {
            rule = m_targetRuleMap.get(t);
            if (rule != null) break;
          }
        }
      }

      Debug.print("Rule for " + target + " is " + rule);
      if (rule != null) {
        m_locatedRules.put(target, rule);
      } else m_noRulesList.add(target);
    }

    return (rule);
  }
示例#6
0
  public Codegen(Irt irt1) {
    sStage = "codegen"; // Who am I?

    // Log.write("stage: [codegen]");
    // System.out.println("stage: [codegen]");
    Debug.print("debug: [codegen]", sStage);
  }
示例#7
0
 // ---------------------------------------------------------------------------
 private void addRule(String key, Rule rule) throws TablesawException {
   Debug.print("Adding rule for " + key);
   Rule old = m_targetRuleMap.put(key, rule);
   if ((old != null) && (!rule.getOverride()) && (!(old instanceof Overridable)))
     throw new TablesawException(
         "Duplicate rules for " + key + " rule1: " + old + " rule2: " + rule, 1);
 }
 /* (non-Javadoc)
  * @see android.app.Activity#onDestroy()
  */
 @Override
 public void onDestroy() {
   Debug.print("onDestroy()");
   if (isFinishing()) {
     dispose();
   }
   super.onDestroy();
 }
 /* (non-Javadoc)
  * @see android.app.Activity#onPause()
  */
 @Override
 public void onPause() {
   Debug.print("onPause()");
   if (currentScene != null) {
     currentScene.onPause();
   }
   // RokonMusic.onPause();
   surfaceView.onPause();
   super.onPause();
 }
示例#10
0
 /* (non-Javadoc)
  * @see android.app.Activity#onResume()
  */
 @Override
 public void onResume() {
   Debug.print("onResume()");
   Rokon.currentActivity = this;
   surfaceView.onResume();
   if (currentScene != null) {
     currentScene.onResume();
   }
   // RokonMusic.onResume();
   super.onResume();
 }
示例#11
0
  /**
   * This fills in the m_targetRuleMap. The keys are the names of the rules and the targets they
   * produce
   */
  private void resolveRules() throws TablesawException {
    for (Rule rule : m_ruleList) {
      // Add rule by name if it has one
      String name = rule.getName();
      if (name != null) {
        Debug.print("Adding rule name: " + name);
        Rule namedRule = m_nameRuleMap.get(name);
        if (namedRule == null) {
          m_nameRuleMap.put(name, rule);
        }
        /*else if (namedRule instanceof CompoundNameRule)
        {
        ((CompoundNameRule)namedRule).addDepends(rule);
        }*/
        else if ((namedRule instanceof Overridable) || (rule.getOverride())) {
          m_nameRuleMap.put(name, rule);
        } else {
          throw new TablesawException(
              "Multiple rules exist for '"
                  + name
                  + "'.  Call Rule.override() if you wish to override an existing rule.");
          /*System.out.println("GGGGGGGGGGGGGGGGGGGAAAAAAAAAAAAAHHHHHHHHHHH");
          CompoundNameRule cnr = new CompoundNameRule(name);
          cnr.addDepends(namedRule);
          cnr.addDepends(rule);
          m_nameRuleMap.put(name, cnr);*/
        }
      }

      // Add rule by each target it declares
      Iterable<String> targets = rule.getTargets();
      for (String t : targets) {
        Debug.print("Add target " + t);
        addRule(t, rule);
      }
    }

    m_resolved = true;
  }
示例#12
0
  // ---------------------------------------------------------------------------
  private void readCache() {
    Debug.print("Cache file %s", m_cacheFile);
    File cacheFile = new File(m_cacheFile);
    m_depCache = null;
    m_modificationCache = null;

    if (cacheFile.exists()) {
      try {
        Debug.print("Reading cache");
        FileInputStream cacheIs = new FileInputStream(cacheFile);
        ObjectInputStream ois = new ObjectInputStream(cacheIs);

        m_depCache = (DependencyCache) ois.readObject();

        Map<String, Long> modCache = new HashMap<String, Long>();
        int modCacheSize = ois.readInt();
        for (int I = 0; I < modCacheSize; I++) {
          String file = ois.readUTF();
          Debug.print("  Read %s", file);
          long ts = ois.readLong();

          modCache.put(file, ts);
        }

        m_modificationCache = modCache;
        ois.close();
      } catch (Exception e) {
        Debug.print(e.getMessage());
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        Debug.print(sw.toString());
      }
    }

    if ((m_depCache == null) || (m_modificationCache == null)) {
      m_depCache = new DependencyCache();
      m_modificationCache = new HashMap<String, Long>();
    }
  }
示例#13
0
  // ---------------------------------------------------------------------------
  public void addRule(Rule rule) {
    Debug.print("AddRule() " + rule.getName() + " " + rule);
    // do not get the rule name as it may not be set yet
    // rules are added often in the constructor when other values
    // have not been set yet.

    // todo: Get a list of provides and consumes annotations
    m_ruleList.add(rule);

    Class ruleClass = rule.getClass();
    DependencyAnnotations da = m_classAnnotations.get(ruleClass);
    if (da == null) m_classAnnotations.put(ruleClass, createDependencyAnnotations(ruleClass));
  }
示例#14
0
 /**
  * Removes everyting from the memory, and resets statics. This is automatically called at
  * onDestroy() when isFinishing() is TRUE You shouldn't need to call this yourself
  */
 public void dispose() {
   Debug.print("dispose()");
   engineCreated = false;
   currentScene = null;
   forceLandscape = false;
   forcePortrait = false;
   forceFullscreen = false;
   surfaceView = null;
   engineLoaded = false;
   gameWidth = 0;
   gameHeight = 0;
   graphicsPath = "";
   Rokon.currentActivity = null;
   System.gc();
 }
示例#15
0
 public void setOperation(int operation) {
   this.operation = operation;
   Debug.print("Setting operation to: " + operation);
 }
示例#16
0
  // ---------------------------------------------------------------------------
  private BuildAction addToBuildQueue(String target, boolean primaryTarget, int insertPosition)
      throws TablesawException {
    // The target was already checked and does not need to be built
    if (m_noBuildCache.contains(target)) return (null);

    Debug.print("addToBuildQueue(" + target + ", " + primaryTarget + ", " + insertPosition + ")");
    Debug.indent();

    Rule trule = findTargetRule(target);

    CachedFile targetFile = null;
    BuildAction[] buildDep = null;
    BuildAction targetBA = null;
    BuildAction depBA = null;
    BuildAction ret = null;

    if (trule == null) {
      targetFile = m_fileManager.locateFile(target);

      // TODO: Add the rule that required this target to the error message
      if (targetFile == null)
        throw new TablesawException("Unable to locate rule for '" + target + "'");

      if (m_sourceFiles != null)
        m_sourceFiles.add(
            new File(
                targetFile.getPath())); // Doing this because locateFile will return a CachedFile

      // TODO: check file against cache file stamps and if changed return dummy rule
      Debug.print("Cache lookup for " + targetFile.getPath());

      // Add file to cache for next run
      m_newModificationCache.put(targetFile.getPath(), targetFile.lastModified());

      Long cacheModTime = m_modificationCache.get(targetFile.getPath());
      if (cacheModTime != null) {
        Debug.print("Cache hit " + cacheModTime + ":" + targetFile.lastModified());
        if (cacheModTime != targetFile.lastModified()) {
          Debug.print("returning obj for " + targetFile);
          Debug.popIndent();
          targetBA =
              new BuildAction(
                  m_fileManager, new ModifiedFileRule(targetFile.getPath()), m_classAnnotations);
          m_buildQueue.add(insertPosition, targetBA);
          return (targetBA);
        }
      } else Debug.print("Cache miss");

      // System.out.println("File "+targetFile);
      m_noBuildCache.add(target);
      Debug.print("Target " + target + " is a file with no rule");
      Debug.popIndent();
      return (null);
    }

    if ((m_sourceFiles != null) && (trule instanceof SourceFileSet)) {
      m_sourceFiles.addAll(((SourceFileSet) trule).getSourceFiles());
    }

    long targetTime = 0;
    boolean tExists = true;
    boolean tDir = false;
    boolean tPhony = true;

    boolean rebuild = false;

    targetBA = new BuildAction(m_fileManager, trule, m_classAnnotations);
    int index;

    if (m_buildQueueCache.containsKey(targetBA)) {
      // Get the build action from the queue
      targetBA = m_buildQueueCache.get(targetBA);

      Debug.print("target: " + trule + " already in build queue.");
      // Target has already been added to build queue
      Debug.popIndent();
      return (targetBA);
    }

    File f;

    trule.preBuild(m_depCache, m_modificationCache);

    // NOTE: need to add in dependencies that are individually declared
    // NOTE: getPrerequisites is also where dependency parsing happens to include C headers and
    // other java classes
    // String[] prereqs = getPrerequisites(trule, true);
    List<String> prereqs = new ArrayList<String>();

    for (String dn : trule.getDependNames()) {
      Debug.print("adding depend name " + dn);
      prereqs.add(dn);
    }

    for (Rule r : trule.getDependRules()) {
      Debug.print("adding depend rule " + r);
      if (r.getName() == null) {
        // Generate name for rule
        String genRuleName = NAMED_RULE_PREFIX + (m_ruleNameCounter++);
        r.setName(genRuleName);
        m_nameRuleMap.put(genRuleName, r);
      }

      prereqs.add(r.getName());
    }

    Debug.print("rule dependents " + prereqs.size());

    if (prereqs.size() > 0) {
      ListIterator<String> it = prereqs.listIterator();

      while (it.hasNext()) {
        String prereq = it.next();

        if (prereq.equals(target))
          throw new TablesawException("Target " + target + " depends on itself");

        /* //See if the prereq is the name of a rule first
        Rule nameRule = m_nameRuleMap.get(prereq);

        //Add the new rule targets to the prereqs list
        // TODO: some kind of check so we dont add the same named rule again and again.
        if (nameRule != null)
        	{
        	Iterable<String> ruleTargets = nameRule.getTargets();
        	boolean hasTargets = false;
        	for (String t : ruleTargets)
        		{
        		hasTargets = true;
        		it.add(t);
        		it.previous();
        		}

        	if (hasTargets)
        		continue;
        	} */

        // Add dependencies to build queue first.
        // f = m_fileManager.getFile(prereq);
        if ((depBA = addToBuildQueue(prereq, false, insertPosition)) != null) {
          targetBA.addDependency(depBA);
          // trule.addNewerDepend(prereq);
          if (depBA.isBinding()) {
            Debug.print("Rebuild: " + trule + " because rebuild of " + depBA.getTargetRule());
            rebuild = true;
          }
        }
      }
    }

    if (!rebuild) {
      rebuild = trule.needToRun();
      Debug.print("Rule needToRun() returned " + rebuild);
    }

    // TODO: change this to get depends from above and check if no depends
    if ((!rebuild)
        && (primaryTarget
            && (!trule
                .getTargets()
                .iterator()
                .hasNext()))) { // If target is the primary target and it has no targets
      Debug.print("Adding primary target: " + trule + " to build queue.");
      rebuild = true;
    }

    if (rebuild) { // Add target to build queue
      m_buildQueue.add(insertPosition, targetBA);
      m_buildQueueCache.put(targetBA, targetBA);
      Debug.print("Adding " + targetBA + " to build queue at pos " + insertPosition);
      // System.out.println("Adding "+targetBA+" to build queue at pos "+insertPosition);

      ret = targetBA;
    }

    // Add target to cache if it does not need to be built
    // This is to speed up incremental builds
    if (ret == null) m_noBuildCache.add(target);

    Debug.popIndent();
    return (ret);
  }
示例#17
0
  public static void main(String[] args) {
    Config.parseCommandLine(args);
    Config.dumpParams(System.out);

    if (Config.getPrepare() && Config.getUnion() && Config.getStratified()) {
      throw new RuntimeException(
          "Current Implementation of stratified deletions"
              + " with prepared statements maps one list of parameters to every query"
              + " and thus doesn't work with union");
    }

    try {
      // NOTE:  a general user will actually call open, importUpdates, etc.
      // but instead we are calling lower-level routines right now, to test.

      RepositorySchemaDAO dao = new FlatFileRepositoryDAO(Config.getSchemaFile());
      OrchestraSystem system = dao.loadAllPeers();
      List<String> tables = SqlEngine.getNamesOfAllTables(system, false, false, true);
      //			List<String> tables = SqlEngine.getNamesOfAllTables(system, true, true, true);

      SqlDb d = new SqlDb(tables, system.getAllSchemas(), system);
      if (Config.getApply()) {
        d.connect();
      }
      SqlEngine tcd =
          new SqlEngine(
              d, // null,
              system);

      Peer p = system.getPeers().iterator().next();

      try {
        if (Config.getApply() && !Config.getBoolean("scalability2"))
          createDatabase(Config.getProperty("schema"), d);

        Debug.println("+++ Basic System Schema +++");
        for (String t : tables) Debug.print(t + "\t");
        Debug.println("");

        Debug.println("+++ Mappings +++");
        List<Mapping> mappings = system.getAllSystemMappings(true);
        for (Mapping s : mappings) Debug.println(s.toString());

        Debug.println("+++ Inverted/Composed Mappings with Provenance Relations +++");
        List<Rule> ruleSet = tcd.computeTranslationRules();

        //				for(RelationContext rel : tcd.getState().getIdbs()){
        //					List<RelationContext> p = tcd.getState().provenanceTablesForRelation(rel);
        //
        //					System.out.println("Provenance tables for " + rel + ": " + p);
        //				}

        for (Rule r : ruleSet) Debug.println(r.toString());

        boolean origApply = true;
        if (Config.getBoolean("scalability2")) {
          origApply = Config.getApply();
          Config.setApply(false);
        }

        if (Config.getApply()) tcd.migrate();

        if (Config.getBoolean("scalability2")) {
          Config.setApply(origApply);
        }

        // DeltaRules ourRules =
        tcd.computeDeltaRules();

        Debug.println("+++ Insertion Rules +++");
        List<DatalogSequence> insRules = tcd.getIncrementalInsertionProgram();
        insRules.get(0).printString();
        insRules.get(1).printString();
        insRules.get(2).printString();

        List<DatalogSequence> delRules = tcd.getIncrementalDeletionProgram();
        Debug.println("+++ Deletion Rules +++");
        delRules.get(0).printString();
        delRules.get(1).printString();
        delRules.get(2).printString();

        List<String> newTables =
            SqlEngine.getNamesOfAllTablesFromDeltas(/*ourRules,*/ system, true, true, true);
        d.setAllTables(newTables);

        if (Config.getBoolean("scalability")) {
          runScalability(tcd, d, p);
        } else if (Config.getBoolean("scalability1")) {
          runScalability1(tcd, d, p);
        } else if (Config.getBoolean("scalability2")) {
          runScalability2(tcd, d, p);
        } else if (Config.getBoolean("nullscycles")) {
          runAllnoMigrateInsOnly(tcd, p);
        } else if (Config.getDebug()) {
          runOnce(tcd, p);
        } else {
          //					runAllmigrateEveryTime(system, tcd, d, tables);
          runAllnoMigrate(tcd, d, p);
        }

        tcd.finalize();
        //				tcd.clean();
        if (Config.getApply()) {
          d.disconnect();
        }

      } catch (Exception e) {
        e.printStackTrace();
        tcd.clean();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
示例#18
0
  public String doTx() {
    String message = null;
    TxController txctl = beanManager.getTxController();

    operationString = messages.getString("WithdrewString");
    prepString = messages.getString("FromString");
    Debug.print(accountId);

    beanManager.setAccount(accountId);
    selectedAccount = beanManager.getAccountDetails();

    boolean isCreditAcct = false;
    if (selectedAccount.getType().equals("Credit")) isCreditAcct = true;

    if (isCreditAcct) {
      if (operation == 0) {
        try {
          txctl.makeCharge(amount, "ATM Withdrawal", accountId);
        } catch (RemoteException e) {
          Debug.print(message);
          return e.getMessage();
        } catch (InvalidParameterException e) {
          // Not possible
        } catch (AccountNotFoundException e) {
          // Not possible
        } catch (InsufficientCreditException e) {
          message = messages.getString("InsufficientCreditError");
          Debug.print(message);
        } catch (IllegalAccountTypeException e) {
          // Not possible
        }
      } else {
        operationString = messages.getString("DepositedString");
        prepString = messages.getString("ToString");
        try {
          txctl.makePayment(amount, "ATM Deposit", accountId);
        } catch (RemoteException e) {
          Debug.print(message);
          return e.getMessage();
        } catch (InvalidParameterException e) {
          // Not possible
        } catch (AccountNotFoundException e) {
          // Not possible
        } catch (IllegalAccountTypeException e) {
          // Not possible
        }
      }
    } else {
      if (operation == 0) {
        try {
          txctl.withdraw(amount, "ATM Withdrawal", accountId);
        } catch (RemoteException e) {
          Debug.print(message);
          return e.getMessage();
        } catch (InvalidParameterException e) {
          // Not possible
        } catch (AccountNotFoundException e) {
          // Not possible
        } catch (IllegalAccountTypeException e) {
          // Not possible
        } catch (InsufficientFundsException e) {
          message = messages.getString("InsufficientFundsError");
          Debug.print(message);
        }
      } else {
        operationString = messages.getString("DepositedString");
        prepString = messages.getString("ToString");
        try {
          txctl.deposit(amount, "ATM Deposit", accountId);
        } catch (RemoteException e) {
          Debug.print(message);
          return e.getMessage();
        } catch (InvalidParameterException e) {
          // Not possible
        } catch (AccountNotFoundException e) {
          // Not possible
        } catch (IllegalAccountTypeException e) {
          // Not possible
        }
      }
    }
    selectedAccount = beanManager.getAccountDetails();
    return message;
  }
示例#19
0
 public void setAmount(BigDecimal amount) {
   this.amount = amount;
   Debug.print("Setting amount to: " + amount);
 }
示例#20
0
  /** Method to process the build queue, can be called by more than one thread */
  public void processBuildQueue() throws TablesawException {
    BuildAction ba;
    Rule rule;
    String target;

    synchronized (m_threadList) {
      m_threadList.add(Thread.currentThread());
    }

    try {
      doloop:
      do {
        synchronized (this) {
          try {
            ba = (BuildAction) m_buildQueue.removeLast();
          } catch (NoSuchElementException nsee) {
            break doloop;
            // ba = new BuildAction(m_fileManager, null);
          }

          if (m_printDebug) Debug.print("Processing: " + ba);

          if (m_makeException != null) break doloop;

          ba.waitForDependencies();

          if (m_makeException != null) break doloop;
        }

        rule = ba.getTargetRule();
        MakeAction action = rule.getMakeAction();

        // target = ba.getTarget();
        if (action != null) {
          action.doMakeAction(rule);

          rule.verify();
        }

        Debug.print("COMPLETE - " + ba);
        ba.complete(); // Complete the BuildAction
      } while (m_makeException == null);
    } catch (Exception e) {
      TablesawException cpe;

      if (e instanceof TablesawException) cpe = (TablesawException) e;
      else cpe = new TablesawException(e);

      synchronized (this) {
        m_makeException = cpe;

        for (Thread t : m_threadList) t.interrupt();
      }

      throw cpe;
    }

    // This causes worker threads to die off and the exception to
    // pass to the main thread
    if (m_makeException != null) throw m_makeException;
  }
示例#21
0
 public void setAccountId(String accountId) {
   this.accountId = accountId;
   Debug.print("Setting account id to: " + accountId);
 }