|
The sixth version of the Java platform, Standard Edition (Java SE), codenamed Mustang, released the second beta version.
At the beginning of this year, Mustang released the first beta version, which opened the secret of Java SE 6.
This is the second beta release after four months.
What are the new things in Java SE 6 beta 2 (Mustang? What is worth developers' attention?
Simplified Web Services
Mustang simplifies the development and release of Web Services. XML and web services have always been the focus of Mustang .. mustang introduced JAX-WS (Java architecture for XML-Web Services) 2.0 and jaxb (Java architecture for XML binding) 2. 0 .. the streaming API for XML (Stax) also provides a two-way API, which can read or write XML through an event stream, including skipping a part, then directly focus on the capabilities of another small part of the document.
Scripting, integrated scripting language
Currently, Java developers must use the non-Java scripting language independently of Java. This headache will be eliminated by Mustang, and developers will use Perl, PHP, Python, JavaScript, Ruby and other scripting languages more easily. The new framework will allow people to operate arbitrary scripting languages and use Java objects.
Java se6 implements jsr223. This is a script framework that provides methods for the scripting language to access Java. You can find the script engine and call it to execute the script. This script API allows you to provide Java support for the script language. In addition, the web Scripting framework allows script code to generate Web Content in any servlet container (such as Tomcat.
Database, bind Derby
Bind the open-source embedded database Derby (javadb) to JDK 1.6. For details, see: bind JDK 1.6 to the open-source database Derby.
Richer desktop APIs
Mustang has more powerful desktop APIs for developers. developers can develop more powerful desktop applications, such as startup Interface Support, System Tray support, and jtable sorting.
Monitoring and Management
In Java SE 6, memory leakage is enhanced in analysis and diagnosis. When a java. Lang. outofmemory exception occurs, a complete stack information is obtained. When the heap is full, a log file is generated to record this fatal error. In addition, the JVM also adds an option to allow you to run scripts when they are full. (This provides another method to diagnose errors)
The enhanced JMX monitoring API allows an application to send an event notification when the mbean property value passes in a specific parameter. (The attribute values here can be in complex types)
For users of Solaris 10, the hotspot JVM provided by Solaris provides a way to track and display activities in the JVM through Solaris dtrace (which is a system debugging tool, including garbage collection, class loading, threads, locks, and so on.
Pluggable annotations
Annotations, a new feature introduced from Java SE 5, will continue to play an important role in Mustang ..
Compiler API: access the Compiler
For developers of Java development tools or web frameworks, using compilers to compile dynamically generated code is a common requirement.
Mustang implements JSR 199 and provides Java compiler APIs (application interfaces ), allow you to compile other Java source programs from a Java application-for example, some source code dynamically generated in the application ..
Security: Security
Java SE 6 Security Section, added XML-digital signature (XML-DSIG) APIs, integrated GSS/Kerberos operation API, JAAS authentication on LDAP.
Instrumentation
Use Java code, that is, Java. lang. instrument's dynamic instrumentation is a new feature of Java SE 5. It frees Java's instrument function from local code so that it can solve the problem using Java code. In Java SE 6, the instrumentation package provides more powerful functions: the started instruments, native code instruments, and dynamically changing classpath. In Java SE 5, developers can only use their imagination in the premain, And the instrumentation is only limited to the method before the main function is executed. This method has some limitations. In the instrumentation of Java SE 6, there is an "agentmain" method that is "in parallel" with premain, which can be run after the main function starts to run.
HTTP
In Java SE 6, there are many new practical features around the HTTP protocol: NTLM authentication provides a safer authentication mechanism on the window platform; JDK provides a lightweight HTTP server, a more comprehensive HTTP cookie management function, a more practical networkinterface, and international support for DNS domain names.
HTTP cookie management can be used to save temporary variables, such as query conditions and current status.
JMX and system management
Management System Architecture
Figure 1. Management System Architecture
The basic architecture of the management system is analyzed. Among them, the agent/subagent is responsible for translation: The IT Resource report messages are transmitted in a way that the management system can understand.
Readers may ask why the agent and subagent systems are required? There are two practical reasons:
A management system is generally a central control software, and the subagent directly monitors some resources, which are usually distributed in the same physical location as these resources. When these subagents transmit status information to the management system or control commands of the management system, some network transmission functions need to be provided.
- Messages in the management system are standardized, and message translation is complicated and boring.
Generally, the management system groups sub-agents with the same physical distribution or similar functions into one group, which is managed by a shared agent. This agent encapsulates functions 1 and 2.
JMX and Management System
JMX is a standard, specification, interface, and framework of the Java Management System. Figure 2 shows the basic architecture of JMX.
Figure 2. The JMX architecture is the same as other resource systems. JMX is an interface between management systems and resources. It defines the criteria for interaction between management systems and resources.javax.management.MBeanServerImplemented the Agent Function and provided interfaces for the management system to access the JMX framework in a standard way. Whilejavax.management.MBeansImplemented the subagent function and provided the interface for JMX framework to access resources in a standard way. At the class library level, JMX includes the core class library.java.lang.managementAndjavax.managementPackage.java.lang.managementThe package provides basic VM monitoring functions, whilejavax.managementThe package provides you with the extension function. JMX helps developers monitor JVM information.
Editor API
JDK 6 provides an API for calling the compiler at runtime. In traditional JSP technology, the following six steps are usually required for servers to process JSP:
- Analyze JSP code;
- Generate Java code;
- Write Java code into memory;
- Start another process and run the compiler to compile Java code;
- Write class files into the memory;
- The server reads and runs class files;
However, if you use runtime compilation, You can simplify steps 4 and 5 at the same time, saving the overhead of new processes and writing Memory output overhead, and improving system efficiency. In fact, Sun also provides a programming interface for calling the compiler in JDK 5. However, the difference is that the programming interface of the old version is not part of the standard API, but provided as sun's proprietary implementation. The new version brings the advantages of standardization.
The second new feature of the new API is the ability to compile abstract files, theoretically any form of Object-as long as the object implements a specific interface. With this feature, step 3 in the preceding example can be omitted. The compilation of the entire JSP is completed in one process, and additional input and output operations are eliminated.
The third new feature is to collect diagnostic information during compilation. As a supplement to the first two new features, it allows developers to easily output necessary compilation errors or warning information, thus saving a lot of redirection troubles.
Some interesting new features:
1 Local behavior java. AWT. Desktop
For example, if you use the default program to open a file and use the default browser to open the URL, you no longer need the browserlauncher.
Now
Desktop desk = desktop. getdesktop ();
Desk. Browse (New uri ("http://www.google.com "));
Desk. Open (file)
Desk. Print (file)
2. Enter the java. Io. Console Password in the console.
No longer need to write the echo character in the thread.
Console console = system. Console ();
Char password [] = console. readpassword ("Enter Password :");
3. New method for obtaining disk space size java. Io. File
File roots [] = file. listroots ();
For (File root: roots ){
System. Out. println (root. getpath () + ":" + root. getusablespace ()
+ "/" + Root. gettotalspace ());
}
4. The patent expired and valid lzw gif encoder can be provided.
ImageIO. Write (input, "GIF", outputfile );
5 jaxb2.0 added the Java-to-XML schema to complete the Java Bean, which is very easy to convert between XML
6 XML Digital Signature javax. xml. crypto
7. Compiler: COM. Sun. Tools. javac. Now javax. Tools. javacompiler
Someone has written the process of generating source files, compiling, and reflection in the memory, which is quite fun.
8. The script engine, javax. script, is embedded with Mozilla rhino1.6r2 supporting ecmascript1.6 |