490 likes | 636 Views
Farvel til applikasjonsserveren. Fra kompleksitet til kontroll. Agenda. Fra kompleksitet til kontroll: Prosess og automasjon En kort historie om Java EE Demonstrasjon av prosess og verktøy Erfaringer Hvordan kommer man hit?. Om foredragsholderen. Johannes Brodwall Sjefsbråkmaker på BBS
E N D
Farvel til applikasjonsserveren Fra kompleksitet til kontroll
Agenda • Fra kompleksitet til kontroll: Prosess og automasjon • En kort historie om Java EE • Demonstrasjon av prosess og verktøy • Erfaringer • Hvordan kommer man hit?
Om foredragsholderen • Johannes Brodwall • Sjefsbråkmaker på BBS • Aktiv i miljøet rundt smidige metoder i Oslo • Med å arrangere ROOTS 2008 • I kveld: Kode dojo!
Hva lovet Java EE? • Skalering • Manageability (deployment) • Robusthet (failover) • Sikkerhet (yeah! Right!) • Programmeringsmodell • Component Transaction Monitor • 2-fase commit
Hva leverte Java EE • Kompleksitet • Utestbar kode • Vanskelig å debugge • Ikke-automatisebare rutiner
Prosessen: • Skriv en test • Implementer koden for å få den til å virke • Sjekk inn • Byggserver bygger automatisk • Testserver deployer automatisk • Iterasjonsslutt: Lever i preproduksjon • Leveranseslutt: Lever det samme i produksjon
port=9090 • shutdown_port=9190 • datasource.url=jdbc:mysql://localhost/nocontainer_dev • datasource.username=johannes • datasource.password=johannes
publicvoid testDeleteCategory() throws Exception { // Insert test data Category category = new Category(uniqueName()); Serializable key = getRepo().insert(category); getRepo().writeChanges(); // Ensure that data is displayed in index beginAt("categories/list.html"); assertTextPresent("Showing all categories"); assertLinkPresentWithText(category.getName()); // Delete it beginAt("categories/edit.html?id=" + key); submit("delete"); // Ensure that after delete, we go to index assertTextPresent("Showing all categories"); // Ensure that the category is no longer there assertLinkNotPresentWithText(category.getName()); }
publicvoid testDeleteCategory() throws Exception { // Insert test data Category category = new Category(uniqueName()); Serializable key = getRepo().insert(category); getRepo().writeChanges(); // Ensure that data is displayed in index beginAt("categories/list.html"); assertTextPresent("Showing all categories"); assertLinkPresentWithText(category.getName()); // Delete it // Ensure that the category is no longer there assertLinkNotPresentWithText(category.getName()); }
publicvoid testDeleteCategory() throws Exception { // Insert test data // Ensure that data is displayed in index // Delete it beginAt("categories/edit.html?id=" + key); submit("delete"); // Ensure that after delete, we go to index assertTextPresent("Showing all categories"); // Ensure that the category is no longer there }
publicvoid testDeleteCategory() throws Exception { // Insert test data // Ensure that data is displayed in index // Delete it beginAt("categories/edit.html?id=" + key); submit("delete"); // Ensure that after delete, we go to index assertTextPresent("Showing all categories"); // Ensure that the category is no longer there }
<html> <body> <h2 id="name">${category.name}</h2> #showErrors("category") <form method="POST"> <p><strong>Parent:</strong> #selectForObject("category.parent" $allCategories)</p> <p>Description: #springFormInput("category.description" "") #springShowErrors("<br>" "")</p> <p>Type: #selectForEnum("category.type" $categoryTypes)</p> <input type="submit" value="Submit" /> </form> <p><a href="list.html">List all</a></p> </body> </html>
<html> <body> <h2 id="name">${category.name}</h2> #showErrors("category") <form method="POST"> <p><strong>Parent:</strong> #selectForObject("category.parent" $allCategories)</p> <p>Description: #springFormInput("category.description" "") #springShowErrors("<br>" "")</p> <p>Type: #selectForEnum("category.type" $categoryTypes)</p> <input type="submit" value="Submit" /> </form> <form method="POST"> <input type="submit" name="delete" value="Delete" /> </form> <p><a href="list.html">List all</a></p> </body> </html>
publicvoid testDeleteCategory() throws Exception { // Insert test data // Ensure that data is displayed in index // Delete it beginAt("categories/edit.html?id=" + key); submit("delete"); // Ensure that after delete, we go to index assertTextPresent("Showing all categories"); // Ensure that the category is no longer there }
protected ModelAndView onSubmit( HttpServletRequest req, HttpServletResponse resp, Object command, BindException errors) { // DEBUG BREAKPOINT Category category = (Category)command; if (category.getId() == null) { Serializable key = repository.insert(category); returnnew ModelAndView(new RedirectView("show.html?id=" + key)); } repository.update(category); // Redirect on post - go back to the same page returnnew ModelAndView(new RedirectView(req.getRequestURI() + "?" + req.getQueryString())); }
protected ModelAndView onSubmit( HttpServletRequest req, HttpServletResponse resp, Object command, BindException errors) { Category category = (Category)command; if (category.getId() == null) { Serializable key = repository.insert(category); returnnew ModelAndView(new RedirectView("show.html?id=" + key)); } if (req.getParameter("delete") != null) { repository.delete(Category.class, category.getId()); return new ModelAndView(new RedirectView("list.html")); } repository.update(category); // Redirect on post - go back to the same page returnnew ModelAndView(new RedirectView(req.getRequestURI() + "?" + req.getQueryString())); }
Mon Sep 10 18:37:02 EDT 2007: Not upgraded, skipping restart • Mon Sep 10 18:38:13 EDT 2007: Installed new version • Stopping • Starting • Testing connection (user=johannes, url=jdbc:mysql://localhost/nocontainer_dev). • .. • OK! • Deploy 'nocontainer' from /home/nocontainer/test/nocontainer-app/curr/repo/com/b • rodwall/nocontainer/nocontainer-web/1.1-SNAPSHOT/nocontainer-web-1.1-SNAPSHOT.wa • r • Server started on http://localhost:9090 in 12.547s • Mon Sep 10 18:39:02 EDT 2007: Not upgraded, skipping restart
Forlat Java EE: Få kontroll • Enhetstester • Debugging • Automatisering • Enkel arkitektur • Forståelse • Gjenkjellelse • Kontroll
Problemer vi hadde • Skalering • Feiltoleranse • Sesjoner • 2PC • Administrasjon av et sett med noder • Open source anskaffelse
Open Source in the Enterprise(For Dummies) • Lisens: BSD, MIT, APL • Support • Robusthet • Test ytelse og krasj • Sikkerhet (sabotasje eller hull) • Bla, bla, bla • Utbredelse
Lettvektscontainer: Steg for steg • Maven 2 bygg • WAR-filer • XA, EJB, sesjoner • ZIP • Assembler, appassembly, Jetty • Install script (appassembly problemstillinger) • Continuous Integration