legacy: как победить в гонке (joker)

Download Legacy: как победить в гонке (Joker)

If you can't read please download the document

Upload: victorcr

Post on 21-Jan-2018

3.455 views

Category:

Engineering


3 download

TRANSCRIPT

  1. 1. Legacy
  2. 2. @ Infopulse , E-mail: [email protected] Skype: victor-cr Twitter: @alkovictor
  3. 3. 2004 Java 2014 Java
  4. 4. ?
  5. 5. - -
  6. 6.
  7. 7. ? ,
  8. 8. ?
  9. 9. ?
  10. 10. ...
  11. 11.
  12. 12.
  13. 13.
  14. 14.
  15. 15. !!!
  16. 16. - ?
  17. 17.
  18. 18. -
  19. 19.
  20. 20.
  21. 21.
  22. 22. Regexp: (?ms)publics+statics+([^{]+).*?(?=s+publics+|}s+z) XSLT:
  23. 23.
  24. 24. Visio Rational Rose Power Designer
  25. 25.
  26. 26. Dependency Injection Transaction Management Multi- threading Executor- Migration ,
  27. 27.
  28. 28. , ?
  29. 29. ResultSet aResultSet = null; ArrayList theAttribute1List = new ArrayList(); ArrayList theAttribute2List = new ArrayList(); ArrayList theAttribute30List = new ArrayList(); StringBuffer aQuery = new StringBuffer("select ") .append("ATTRIBUTE1,") .append("ATTRIBUTE2,") while (aResultSet.next()) { if (aResultSet.getString("ATTRIBUTE1") != null) theAttribute1List.add(aResultSet.getString("ATTRIBUTE1")); htAttributeList.put("ATTRIBUTE1", distinct(theAttribute1List)); htAttributeList.put("ATTRIBUTE2", distinct(theAttribute2List)); 010
  30. 30. ...
  31. 31. public class UniversalComparator implements Comparator { if (value1 instanceof GregorianCalendar) { GregorianCalendar lcal_obj1 = (GregorianCalendar) value1; GregorianCalendar lcal_obj2 = (GregorianCalendar) value2; boolean lb_value = lcal_obj1.before(lcal_obj2); if (ii_comparatorDirection == COMP_ASC) { if (lb_value == true) { return 1; } else { return -1; } } else { if (lb_value == true) { return -1; } else { return 1; } } } 07
  32. 32. if (value1 instanceof Boolean) { Boolean lv_obj1 = (Boolean) value1; Boolean lv_obj2 = (Boolean) value2; String ls_value1 = lv_obj1.toString(); String ls_value2 = lv_obj2.toString(); logService.debug("compare: lb_value1, lb_value2: " + ls_value1 + ", " + ls_value2); int lv_value1 = (ls_value1 == "true") ? 1 : 0; int lv_value2 = (ls_value2 == "true") ? 1 : 0; if (ii_comparatorDirection == COMP_ASC) { int val = (lv_value1 < lv_value2) ? -1 : 1; // log("val: " + val); return (lv_value1 < lv_value2) ? -1 : 1; } else return (lv_value1 < lv_value2) ? 1 : -1; } 06
  33. 33. ??? ,
  34. 34. private void moveFile(String from, String to) throws Exception { //move files from 'from' to 'to' String[] cmd; if (File.separator.compareTo("") == 0) { //windows cmd = new String[] {"cmd", "/c", "move", from.trim().replace("/", File.separator), to.trim().replace("/", File.separator) }; } else {//linux like, simple mv command does not work, using script cmd = new String[] {parameters.get("movePath") + ".sh", from.trim().replace("/", File.separator), to.trim().replace("/", File.separator) }; } System.gc(); //reduces current process size before fork Process p = Runtime.getRuntime().exec(cmd); p.waitFor(); p.destroy(); //free up memory } 05
  35. 35. ? ,
  36. 36. private static final List DEFAULT_OPTIONS = new ArrayList(4); { DEFAULT_OPTIONS.add(new Option(1, "Unavailable")); DEFAULT_OPTIONS.add(new Option(2, "Unidirectional")); DEFAULT_OPTIONS.add(new Option(3, "Bidirectional")); DEFAULT_OPTIONS.add(new Option(4, "Not applicable")); } 04
  37. 37.
  38. 38. public static void lockPartyWithLog(Party p, UnitOfWork uow) { // Local variables Party partyClone = null; // Lock the object // LOCK_NOWAIT : an exception occurs if the object is being locked try { partyClone = (Party) uow.refreshAndLockObject(p, ObjectLevelReadQuery.LOCK_NOWAIT); } catch (DatabaseException dbe) { logService.info("The party ID = " + p.getId() + " is locked by an other process"); try { Thread.currentThread().sleep(1000); } catch (Exception e) { logService.error("Thread Exception ", e); } lockPartyWithLog(p, uow); } } 03
  39. 39. - API
  40. 40. public interface Parser { void setReport(InputStream inputstream); void setReport(String s); String getReport(); void save(); void delete(String Query) throws HibernateException; void setParams(Map map); Map getParams(); void saveReport(String reportPath); Boolean isDuplicated(String fileName); } 23: public class PMScanReport extends AbstractParser 23: implements Parser { .......... 1556: } 02
  41. 41. !
  42. 42. public int compare(TradeConfirmation tc1, TradeConfirmation tc2) { int value; Offer o1 = (Offer) tc1.getOffer(); Offer o2 = (Offer) tc2.getOffer(); if (o1.getTradingInterval() < o2.getTradingInterval()) { value = -1; } else { if (o1.getTradingInterval() == o2.getTradingInterval()) { if (o1.getType() < o2.getType()) { value = -1; } else { if (o1.getType() == o2.getType()) { PartyDef p1 = o1.getParty().getEffectiveNow(); PartyDef p2 = o2.getParty().getEffectiveNow(); if (p1.getName().compareTo(p2.getName()) < 0) { value = -1; } else { if (p1.getName().compareTo(p2.getName()) == 0) { if (o1.getTradingZone().getEffectiveNow().getIdentification().compareTo() < 0) { value = -1; } else { if (o1.getTradingZone().getEffectiveNow().getIdentification().compareTo()) == 0) { value = 0; } else { value = 1; } } } else { value = 1; } } } else { value = 1; } } } else { value = 1; } } return value; } 01
  43. 43.
  44. 44.
  45. 45.
  46. 46.
  47. 47. , ,
  48. 48. ?
  49. 49. -
  50. 50. - , :
  51. 51.