The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
What is new and cool j2se & java
1. What is new in Java SE
7 and – Java Enterprise
Edition 6
Eugene Bogaart
Solution Architect
Sun Microsystems
1
2. JDK 7 Features
> Language
• Annotations on Java types
• Small language changes (Project Coin)
• Modularity (JSR-294)
> Core
• Modularisation (Project Jigsaw)
• Concurrency and collections updates
• More new IO APIs (NIO.2)
• Additional network protocol support
• Eliptic curve cryptography
• Unicode 5.1
2
3. JDK 7 Features
> VM
• Compressed 64-bit pointers
• Garbage-First GC
• Support for dynamic languages (Da Vinci Machine
project)
> Client
• Forward port Java SE6 u10 features
• XRender pipeline for Java 2D
3
5. New Module System for Java
• JSR-294 Improved Modularity Support in the Java
Programming Language
• Requirements for JSR-294
> Integrate with the VM
> Integrate with the language
> Integrate with (platform's) native packaging
> Support multi-module packages
> Support “friend” modules
• Open JDK's Project Jigsaw
> Reference implementation for JSR-294
> openjdk.java.net/projects/jigsaw
> Can have other type of module systems based on OSGi, IPS,
Debian, etc.
5
10. Better Integer Literals
• Binary literals
int mask = 0b1010;
• With underscores
int bigMask = 0b1010_0101;
long big = 9_223_783_036_967_937L;
• Unsigned literals
byte b = 0xffu;
10
11. Better Type Inference
Map<String, Integer> foo =
new HashMap<String, Integer>();
Map<String, Integer> foo =
new HashMap<>();
11
12. Strings in Switch
• Strings are constants too
String s = ...;
switch (s) {
case "foo":
return 1;
case "bar":
Return 2;
default:
return 0;
}
12
13. Resource Management
• Manually closing resources is tricky and tedious
public void copy(String src, String dest) throws IOException {
InputStream in = new FileInputStream(src);
try {
OutputStream out = new FileOutputStream(dest);
try {
byte[] buf = new byte[8 * 1024];
int n;
while ((n = in.read(buf)) >= 0)
out.write(buf, 0, n);
} finally {
out.close();
}
} finally {
in.close();
}}
13
14. Automatic Resource Management
static void copy(String src, String dest)
throws IOException {
try (InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dest)) {
byte[] buf = new byte[8192];
int n;
while ((n = in.read(buf)) >= 0)
out.write(buf, 0, n);
}
//in and out closes
}
14
15. Index Syntax for Lists and Maps
List<String> list =
Arrays.asList(new String[] {"a", "b", "c"});
String firstElement = list[0];
Map<Integer, String> map = new HashMap<>();
map[Integer.valueOf(1)] = "One";
15
17. JVM Specification
“The Java virtual machine knows nothing
about the Java programming language, only
of a particular binary format, the class file
format.”
1.2 The Java Virtual Machine
17
18. Languages Running on the JVM
Tea iScript
Zigzag JESS Jickle
Modula-2 Lisp
Correlate Nice
CAL
JudoScript
JavaScript
Simkin Drools Basic
Icon Groovy Eiffel Luck
v-language Pascal
Prolog Mini
Tcl PLAN Hojo Scala
Rexx JavaFX Script Funnel
Tiger Anvil Yassl FScript
Oberon
E Smalltalk
Logo Tiger JHCR JRuby
Ada G Scheme Sather
Clojure
Phobos
Processing WebL Dawn TermWare
Sleep
LLP Pnuts Bex Script
BeanShell Forth PHP
C#
Yoix SALSA ObjectScript
Jython Piccola 18
18
19. InvokeDynamic Bytecode
• JVM currently has four ways to invoke method
> Invokevirtual, invokeinterface, invokestatic, invokespecial
• All require full method signature data
• InvokeDynamic will use method handle
> Effectively an indirect pointer to the method
• When dynamic method is first called bootstrap code
determines method and creates handle
• Subsequent calls simply reference defined handle
• Type changes force a re-compute of the method location
and an update to the handle
> Method call changes are invisible to calling code
19
24. Java EE: Past & Present
Rightsizing
Ease of
Development Java EE 6
Web
Services Pruning
Java EE 5 Extensibility
Robustness Profiles
Enterprise Java Ease of
Platform
J2EE 1.4 Development Ease of
Development
Annotations
J2EE 1.3 Web EJB Lite
J2EE 1.2 Services EJB 3.0
RESTful
Management
CMP Persistence Services
Servlet Deployment
JPE Connector New and Dependency
Project JSP Architecture Async. Updated Ejection
EJB Connector Web Services
JMS Web Profile
RMI/IIOP
24
28. Java EE 6 Platform
Goals
• Rightsizing
> Flexible
> Lighter weight
• Extensible
> Embrace Open Source
Frameworks
• Productive
> Improve on Java EE 5
28
29. Rightsizing the Platform
Platform Flexibility
• Decouple specifications to
allow more combinations
• Expand potiential licensee
ecosystem
• Profiles
> Targeted technology bundles
> Web Profile
29
30. About Profiles
• Profiles are targeted bundles of technologies
• (Simple) rules set by platform spec
• Profiles can be subsets, supersets or overlapping
• First profile: the Web Profile
• Decoupling of specs to allow more combinations
• Future profiles defined in the Java Community
Process
30
31. Rightsizing the Platform
Web Profile
• Fully functional mid-sized
profile
• Actively discussed
> Expert Group
> Industry
• Technologies
> Servlet 3.0, EJB Lite 3.1, JPA 2.0, JSP
2.2, EL 1.2, JSTL 1.2, JSF 2.0, JTA
1.1, JSR 45, Common Annotations
31
32. Rightsizing the Platform
Pruning (Deprecation)
• Some technologies optional
> Optional in next release
> Deleted in subsequent release
> Marked in Javadocs
• Pruning list
> JAX-RPC
> EJB 2.x Entity Beans
> JAXR
> JSR-85 (Rules based Auth & Audit)
32
33. About Pruning
• Make some technologies optional
• Reduce the real and conceptual footprint
• Same rules as proposed by the Java SE
> “pruned now, optional in the next release”
• Pruned technologies will be marked in the javadocs
• Current pruning list:
> JAX-RPC, EJB Entity Beans, JAXR, JSR-88
33
34. Rightsizing the Platform
Extensibility
• Embrace open source
libraries and frameworks
• Zero-configuration, drag-n-
drop web frameworks
> Servlets, servlet filters
> Framework context listeners
are discovered & registered
• Plugin library jars using Web
Fragments
34
35. Ease of Development
Extensibility
• Continue Java EE 5 advancements
• Primary focus: Web Tier
• Multiple areas easier to use: EJB 3.1
• General Principles
> Annotation-based programming model
> Reduce or eliminate need for
deployment descriptors
> Traditional API for advanced users
35
36. About Extensibility
• Embrace open source libraries and frameworks
• Zero-configuration, drag-and-drop for web
frameworks
> Monolithic web.xml can become complex to maintain as
the dependencies of the application increases
> Servlets, servlet filters, context listeners for a framework
get discovered and registered automatically
• Completely general solution using web fragments
• Scripting languages can use the same mechanism
36
37. Ease of Development
• Ongoing effort
• This time focus is the web tier
• Lots of opportunities in other areas, e.g. EJB
• General principles:
> Use of annotations across all web APIs
> Reduce or eliminate need for deployment descriptors
– No editing of web.xml required
> Self-registration of third-party libraries
> Simplified packaging
> JAX-RS for RESTful web services
> Get technologies to work together well
37
43. Ease of Development
Adding an EJB to a Web Application
ShoppingCart
BuyBooks.war EJB Class BuyBooks.war
ShoppingCart.jar
ShoppingCart
EJB Class
BuyBooks.ear
43
47. Ease of Development - Annotations
Servlet in Java EE 5: Create two source files
/* Code in Java Class */ <!--Deployment descriptor web.xml
-->
package com.foo; <web-app>
public class MyServlet extends <servlet>
HttpServlet { <servlet-name>MyServlet
public void </servlet-name>
doGet(HttpServletRequest <servlet-class>
req,HttpServletResponse res) com.foo.MyServlet
</servlet-class>
{ </servlet>
<servlet-mapping>
... <servlet-name>MyServlet
</servlet-name>
} <url-pattern>/myApp/*
</url-pattern>
... </servlet-mapping>
...
} </web-app>
47
48. Ease of Development - Annotations
Servlet in Java EE 5: Java Class
/* Code in Java Class */
package com.foo;
public class MyServlet extends HttpServlet {
public void doGet(HttpServletRequest req,HttpServletResponse res) {
/* doGet body */
}
}
48
49. Ease of Development - Annotations
Servlet in Java EE 5: Descriptor
<!--Deployment descriptor web.xml -->
<web-app>
<servlet>
<servlet-name>MyServlet
</servlet-name>
<servlet-class>
com.foo.MyServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet
</servlet-name>
<url-pattern>/myApp/*
</url-pattern>
</servlet-mapping>
...
</web-app>
49
50. Ease of Development - Annotations
Java EE 6 Servlet: Single Source file (many cases)
package com.foo;
@WebServlet(name=”MyServlet”, urlPattern=”/myApp/*”)
public class MyServlet extends HttpServlet {
public void doGet(HttpServletRequest req,
HttpServletResponse res)
{
...
}
50