1 / 13

Java Pet Store 2.0 Reference Application

Java Pet Store 2.0 Reference Application. Guilherme Oliveira ( gkmo ). O projeto. Desenvolvida pelo programa Java BluePrints da Sun Microsystems. Desenvolvida para ilustrar como J2EE 5 pode ser usado para desenvover aplicações Web 2.0. O projeto. O projeto. Pontos importantes:

sinjin
Download Presentation

Java Pet Store 2.0 Reference Application

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Java Pet Store 2.0 Reference Application Guilherme Oliveira (gkmo)

  2. O projeto • Desenvolvida pelo programa Java BluePrints da Sun Microsystems. • Desenvolvida para ilustrar como J2EE 5 pode ser usado para desenvover aplicações Web 2.0

  3. O projeto

  4. O projeto • Pontos importantes: • Componentes JSF “AJAX-enabled” • Java Persistence APIs • Aplica o MVC e outros padrões de projeto • Mashups como Google Maps e PayPal • Usa um feed RSS • E um bocado de outras coisas…

  5. Métricas • Total de Linhas de Código • 3807 • Total de Classes • 40 • Total de Pacotes • 8 * Páginas HTML/JSF/JSP não foram incluídas

  6. Concerns • Concerns identificados • Maintain pet (858 LOC) • Search for pets (1245 LOC) • Rate a pet (30 LOC) • Map pets (940 LOC) • Buy a pet (16 LOC) • Catalog (662 LOC) • Persistency (349 LOC) • Logging (799 LOC) • Transactions (102 LOC)

  7. Tempo de marcação • Cerca de 6~7 horas para escolher os concerns e realizar a marcação

  8. Hierarquia de Concerns

  9. Exemplo Concerns public String addItem(Item item){ EntityManager em = emf.createEntityManager(); try{ utx.begin(); em.joinTransaction(); for(Tagtag : item.getTags()) { tag.incrementRefCount(); tag.getItems().add(item); em.merge(tag); } em.persist(item); utx.commit(); // index item if(bDebug) System.out.println("\n***Item id of new item is : " + item.getItemID()); indexItem(newIndexDocument(item)); } catch(Exception exe){ try { utx.rollback(); } catch (Exception e) {} throw new RuntimeException("Error persisting item", exe); } finally { em.close(); } return item.getItemID(); } Maintain pet Search Persistency Transaction Logging

  10. Exemplo Concerns publicvoidupdateItem(Item item){ EntityManager em = emf.createEntityManager(); try{ utx.begin(); em.merge(item); utx.commit(); // update index using delete/insert method (only one available) UpdateIndex.deleteIndex(PetstoreConstants.PETSTORE_INDEX_DIRECTORY, item.getItemID()); indexItem(newIndexDocument(item)); } catch(Exception exe){ try { utx.rollback(); } catch (Exception e) {} throw new RuntimeException("Error updating rating", exe); } finally { em.close(); } } Maintain pet Search Persistency Transaction

  11. Dificuldades • Compilar e rodar a aplicação • Escolher casos de uso como concerns • Como realizar as marcações quando se usa Annotations (JPA) e JSF/JSP

  12. Métricas

  13. Conclusão • Transation crosscuts Persistency • Logging crosscuts “everything” • Search for pets crosscuts Maintain pet • As métricas foram úteis para os concerns relacionados aos casos de uso, para o restante não seria necessário.

More Related