Das ist ja sooo 200x!
-
Upload
open-knowledge-gmbh -
Category
Technology
-
view
81 -
download
1
Transcript of Das ist ja sooo 200x!
![Page 1: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/1.jpg)
Das ist ja sooo 200x!Jens Schumann – open knowledge GmbH
![Page 2: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/2.jpg)
(Sorry – kurzer Werbeblock)
![Page 3: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/3.jpg)
Was wir heute (trotz Testspiel) machen
• Klagen auf hohem Niveau...
• Ja, genau da sind wir gestartet!
• Diese Irrwege haben wir uns erlaubt. Leider.
• Genau genommen gibt es vieles noch heute.
• Das können und sollten wir davon lernen.
![Page 4: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/4.jpg)
Enterprise Java im Jahr 2014
![Page 5: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/5.jpg)
Enterprise Java im Jahr 2014 - Wicket
<!DOCTYPE html><html> <head lang="en"> <meta charset="UTF-8"> <title>Hello World</title> </head> <body>
<p wicket:id="message">Message goes here</p>
</body></html>
![Page 6: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/6.jpg)
Enterprise Java im Jahr 2014 - JSF
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE ...><html ...>
<f:view> Hello World! Today is
<h:outputText value="#{currentTimeBean.currentDate}"> <f:convertDateTime dateStyle="long" timeStyle="long"/> </h:outputText> .
</f:view></html>
![Page 7: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/7.jpg)
Enterprise Java im Jahr 2014 - Spring
@Named
public class CurrentTimeBean {
public Date getCurrentDate() { return new Date(); }
}
![Page 8: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/8.jpg)
Enterprise Java im Jahr 2014 - CDI
@Named@ApplicationScopedpublic class CurrentTimeBean {
public Date getCurrentDate() { return new Date(); }
}
![Page 9: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/9.jpg)
Was wir heute machen
• Jammern auf hohem Niveau...
• Ja, genau da sind wir gestartet!
• Diese Irrwege haben wir uns erlaubt. Leider.
• Genau genommen gibt es vieles noch heute.
• Das können und sollten wir davon lernen.
![Page 10: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/10.jpg)
Am Anfang war...
New Economy
(na gut, nicht ganz am Anfang)(ob Henne oder Ei soll hier nicht geklärt werden)
![Page 11: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/11.jpg)
Am Anfang war...
![Page 12: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/12.jpg)
Web? Ja, mit Applets! Applets?!
public class HelloWorld extends Applet {
public void paint(Graphics g) { Date currentDate = new Date();
DateFormat formatter = DateFormat.getDateTimeInstance(...);
g.drawString( "Hello world! Today is " + formatter.format(currentDate) + "." , 50, 25); }}
![Page 13: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/13.jpg)
Ein Servlet ist ein Applet! Hmmm?!
Although servlets can respond to any types of requests [...],
so they can be thought of as Java applets
that run on servers instead of in web browsers!
![Page 14: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/14.jpg)
Applets mit Java Backend*
public class AppletBackendServlet extends HttpServlet {
protected void doGet(HSR req, HSR resp) throws ... { ObjectOutputStream out = ...; ObjectInputStream in = ...;
Integer customerId = (Integer) in.readObject(); Customer customer = getCustomer(customerId);
out.writeObject(customer); out.flush();
resp.flushBuffer(); ...}}
*Exception and Stream Handling omitted
![Page 15: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/15.jpg)
Web ist Web, also HTML
<html> <head> <title>Hello World!</title> </head>
<body> <script type="application/javascript"> document.write( 'Hello World! Today is ' + new Date() + + '.') </script> </body></html>
![Page 16: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/16.jpg)
Web ist Web, also HTML – Servlet Style
public class DynamicContentServlet extends HttpServlet {protected void doGet(HSR req, HSR resp) throws ... { ... PrintWriter writer = resp.getWriter(); writer.write("<html>"); writer.write("<head><title>Hello World</title>" + "</head><body>");
writer.write("Hello World! Today is "); writer.write(formatter.format(currentDate)); writer.write(".");
writer.write("</body></html>");
resp.flushBuffer();}}
![Page 17: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/17.jpg)
Was wir heute machen
• Klagen auf hohem Niveau...
• Ja, genau da sind wir gestartet!
• Diese Irrwege haben wir uns erlaubt. Leider.
• Genau genommen gibt es vieles noch heute.
• Das können und sollten wir davon lernen.
![Page 18: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/18.jpg)
Microsoft... to the rescue!
![Page 19: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/19.jpg)
Java Server Pages. At it‘s best.
<html> <head><title>Hello World!</title></head> <body>
Hello World! Today is ! Dynamic content here ! . </body></html>
![Page 20: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/20.jpg)
Java Server Pages. At it‘s best.
<html> <head><title>Hello World!</title></head> <body> <% Locale locale = request.getLocale(); Date currentDate = new Date(); DateFormat formatter = DateFormat.getDateTimeInstance(...); %>
Hello World! Today is <%= formatter.format(currentDate) %>. </body></html>
![Page 21: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/21.jpg)
Java Server Pages. Ahh! - JSTL
<html> <head><title>Hello World!</title></head> <body>
<jsp:useBean id="now" class="java.util.Date" />
Hello World! Today is <fmt:formatDate value="${now}" ... />. </body></html>
![Page 22: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/22.jpg)
Wir hatten doch auch Frameworks!
![Page 23: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/23.jpg)
FooBarWizzBangCompany Framework
„Sobald das Framework fertig gestellt ist, wird alles wirklich gut!“
![Page 24: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/24.jpg)
Open Source schließt die Lücke
public class TestAction extends Action {
public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws E... {
request.setAttribute("currentTime", new Date());
return mapping.findForward("success"); }
}
![Page 25: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/25.jpg)
Enterprise ist Enterprise
![Page 26: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/26.jpg)
Enterprise ist Enterprise
The Enterprise JavaBeans architecture will be the standard component architecture
for building distributed object-oriented business applications in the JavaTM
programming language.
![Page 27: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/27.jpg)
Enterprise ist Enterprise
The Enterprise JavaBeans architecture will make it easy to write applications:
Application developers will not have to understand low-level transaction and state
management details, multi-threading, connection pooling, and other
complex low-level APIs.
![Page 28: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/28.jpg)
Verteilte Persistenz – BMP 1.1
public class Bmp11CustomerBean implements EntityBean { private Integer customerId; private String firstName; private String lastName; // getter/setter
public Integer ejbCreate(...) throws CreateException {...}
public void ejbLoad() throws EJBException {...} public void ejbStore() throws EJBException {...} public void ejbRemove() throws EJBException {...}
...
}
![Page 29: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/29.jpg)
Verteilte Persistenz – BMP 1.1*
public class Bmp11CustomerBean implements EntityBean { ... public void ejbStore() throws EJBException { Connection con = dataSource.getConnection(); PreparedStatement ps = con.prepareStatement( "UPDATE CUSTOMER " + "CUS_FIRST_NAME=?, ... WHERE CUS_ID=?"); ps.setString(1, firstName); ... ps.setInt(4, customerId);
int i = ps.executeUpdate(); ... }}
*Exception and Resource Handling omitted
![Page 30: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/30.jpg)
Verteilte deklarative Persistenz – CMP 1.1
public class Cmp11CustomerBean implements EntityBean { private Integer customerId; private String firstName; private String lastName; // getter/setter
public Integer ejbCreate(...) throws CreateException {...}
public void ejbLoad() throws EJBException {...} public void ejbStore() throws EJBException {...} public void ejbRemove() throws EJBException {...}
...
}
![Page 31: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/31.jpg)
Verteilte deklarative Persistenz – CMP 1.1
<enterprise-beans> <entity> ... <persistence-type>Container</persistence-type> <prim-key-class>java.lang.Integer</prim-key-class> <cmp-field> <field-name>customerId</field-name> </cmp-field> ... <primkey-field>customerId</primkey-field> </entity>
</enterprise-beans>
![Page 32: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/32.jpg)
Verteilte deklarative Persistenz – CMP 1.1
<orion-ejb-jar> <enterprise-beans> <finder-method partial="false" query="select * from CUSTOMER " + "WHERE $customerId = $1"> <method> <ejb-name>Cmp11CustomerEntity</ejb-name> <method-name>findByPrimaryKey</method-name> <method-params> <method-param>...</method-param> </method-params> </method> </finder-method> </enterprise-beans> </orion-ejb-jar>
![Page 33: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/33.jpg)
Verteilte deklarative Persistenz – CMP 2.0
public abstract class Cmp20CustomerBean implements EntityBean { public abstract String getFirstName(); public abstract void setFirstName(...); public abstract String getLastName(); public abstract void setLastName(...);
public Integer ejbCreate(String firstName, String lastName) throws CreateException { this.setFirstName(firstName); this.setLastName(lastName); return null; } ...}
![Page 34: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/34.jpg)
Verteilte (deklarative) Persistenz. Oh Gott!
![Page 35: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/35.jpg)
Im Business Tier ist alles gut!*
public class CustomerServiceBean implements SessionBean {
public void activate(Integer customerId) {
Cmp11CustomerHome home = ...;
Cmp11Customer customer = home.findByPK(customerId); customer.activate();
}
}
*Exception and Resource Handling omitted
![Page 36: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/36.jpg)
Wir können auch lokal*.
public class CustomerServiceBean implements SessionBean {
public void activate(Integer customerId) {
Cmp20CustomerLocalHome home = ...;
Cmp20CustomerLocal customer = home.findByPK(customerId); customer.activate();
}
}
![Page 37: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/37.jpg)
So schlimm ist es nun doch gar nicht
![Page 38: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/38.jpg)
Doch! Please repeat yourself!
If you can say it once, you can say it multiple times too!
EJBInterface
HomeInterface
Bean Klasse
DDSpec
DDSpecial
![Page 39: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/39.jpg)
Das Programmier-Modell – Never implement!
public interface BmpCustomerHome extends EJBHome {
public BmpCustomer create(...) throws ...;
public BmpCustomer findByPK(...) throws ...;
}
public class BmpCustomerBean implements EntityBean { public Integer ejbCreate(...) throws ...;
public Integer ejbFindByPK(...) throws ...;
}
![Page 40: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/40.jpg)
Das Programmier-Modell – Remoting!
public interface CustomerService extends EJBObject {
public void activate(Integer customerId) throws RemoteException;}
public class CustomerServiceBean implements SessionBean {
public void activate(Integer customerId) {...}}
![Page 41: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/41.jpg)
Und diese Infrastruktur – JNDI Lookup
try { InitialContext ic = new InitialContext(); DataSource ds = (DataSource) ic.lookup(".../customerDS");
Connection con = ds.getConnection(); // use SQL Connection
} catch (NamingException e) { throw new EJBException(...);}
// TODO Resource Handling
![Page 42: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/42.jpg)
Und diese Infrastruktur – Lookup & Narrow
try { InitialContext ctx = new InitialContext(); Object obj= ctx.lookup(".../CustomerHome"); CustomerHome home = (CustomerHome)PortableRemoteObject.narrow( obj, CustomerHome.class);
// do something with the EJB
} catch (NamingException e) { throw new EJBException(e);}
![Page 43: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/43.jpg)
API-Call? Wo ist da die Fachlichkeit?
try { CmpCustomerHome home = ...; // lookup and narrow
CmpCustomer customer = home.findByPK(customerId); customer.activate();
} catch (NamingException e) {...} catch (FinderException e) {...} catch (RemoteException e) {...} finally { if (ctx != null) { try { ctx.close(); } catch (NamingException e) {/* ignored */ } }}
![Page 44: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/44.jpg)
Oh je! Try/catch/finally!
InitialContext ic = null;DataSource ds = null; try { ic = new InitialContext(); ds = (DataSource) ic.lookup(".../customerDS");} catch (NamingException e) { throw new EJBException(...);} finally { if (ic != null) { try { ic.close(); } catch (NamingException e) { // ignored } }}
![Page 45: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/45.jpg)
Zur Erinnerung: Das ist JDBC!
DataSource ds = ...; Connection con = null;PreparedStatement ps = null; ResultSet rs = null;
try { con = dataSource.getConnection(); ps = con.prepareStatement(...); rs = ps.executeQuery(); ... } finally { if (rs != null) { try {rs.close();} catch (SQLException e){...}}
if (ps != null) { try {ps.close();} catch (SQLException e){...}} if (con != null) { try {con.close();} catch (SQLException e){...}}}
![Page 46: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/46.jpg)
Mit Pattern wird alles einfacher.
![Page 47: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/47.jpg)
Mit Pattern wird das alles einfacher
> The evil ValueObject, SessionFacade, BusinessDelegate Combo
> Aus 5 mach 10!
> ServiceLocator clearance!
> FastLaneReader makes you scream.
Free
![Page 48: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/48.jpg)
Who cares? Wir sind im Jahr 2014!
![Page 49: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/49.jpg)
Was wir heute machen
• Klagen auf hohem Niveau...
• Ja, genau da sind wir gestartet!
• Diese Irrwege haben wir uns erlaubt. Leider.
• Genau genommen gibt es vieles noch heute.
• Das können und sollten wir davon lernen.
![Page 50: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/50.jpg)
You care!
![Page 51: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/51.jpg)
You care! Really!
„Java EE Programmiermode
ll versteckt Java EE
Laufzeitmodell!“
![Page 52: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/52.jpg)
You care! Really!
> Resource Lookup
> Ressource Handling
> Remote Lookup & Remoting
> Pooling
> Interceptoren
> Proxies & Delegates
ClientClient
RoutingRouting
RoutingRouting
DispatchingDispatching
SecuritySecurity
TransactionTransaction
POJOPOJO
![Page 53: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/53.jpg)
Was wir heute machen
• Klagen auf hohem Niveau...
• Ja, genau da sind wir gestartet!
• Diese Irrwege haben wir uns erlaubt. Leider.
• Genau genommen gibt es vieles noch heute.
• Das können und sollten wir davon lernen.
![Page 54: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/54.jpg)
Und was lernen wir daraus?
Beware of obtrusiveness
> Anforderungen und Fachlichkeit stehen im Vordergrund
> Frameworks und Technologien mit großen Auswirkungen auf das Programmiermodell sind die falschen Frameworks und Technologien
![Page 55: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/55.jpg)
Und was lernen wir daraus?
Beware of abstractions
> Die Zeit des Versteckens ist längst vorbei
> Frameworks und Technologie, die abstrahiert werden müssen, sind die falschen Frameworks und Technologien
![Page 56: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/56.jpg)
Und was lernen wir daraus?
Monitor infrastructure code
> Gute Frameworks und Technologien benötigen wenig Infrastruktur-Code
> Erfordern Frameworks und Technologien einen hohen Anteil an Infrastruktur-Code, so sind es die falschen Frameworks und Technologien
![Page 57: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/57.jpg)
Und was lernen wir daraus?
Avoid code generation
> Auch generierter Infrastruktur-Code ist schlechter Code
> q.e.d
> (Dazu gehört auch ein anemic domain Model)
![Page 58: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/58.jpg)
Und was lernen wir daraus?
If something is too complex
to use or to introduce
and focuses on technology
rather than business requirements
it‘s just too complex!
![Page 59: Das ist ja sooo 200x!](https://reader035.fdocuments.net/reader035/viewer/2022062313/5588f6bbd8b42aa8418b460d/html5/thumbnails/59.jpg)
Gibt es noch Fragen?
Dann los ...
Das ist ja sooo 200x!