J2EE technology-Application of EJB in Java

Source: Internet
Author: User

This article targets audiences who are interested in J2EE technology.

Java language

Java was first known as Oak, which was generated to implement embedded consumer electronic product applications. its author is James Gosling. Ed Frank, Patrick Naughton, Jonathan Payne, and Chris Warth added a lot of features to the Java language in the following years, and made a new positioning for the Java language goal, it is positioned in a language suitable for the Internet.

Java is a multi-purpose language, concurrent language, class-based, object-oriented language. It is designed to be as unrelated to the operating system as much as possible, that is, the statement promoted by Java: "One write, run everywhere ." Java is designed based on the C and C ++ languages. Therefore, programmers familiar with C and C ++ can quickly get started with the Java language, the Java design principle is to use the Java language to quickly write applications, so we can find that in Java, there is no complex mechanism in C and C ++. The most obvious is the pointer widely used in C, which is replaced by a reference in Java due to its randomness. The features of operator overloading, templates, and generics in C ++ are also complicated and Java is not used. However, Java is still introducing new features to meet the development of applications. For example, in JDK1.4, Java supports the Assertment mechanism and the most useful regular expression mechanism in Perl.

The Java language consists of the following five elements: identifier, keyword, text, operator, and separator. These five elements have different syntax meanings and composition rules. They work together to complete the semantic expression of the Java language.

1: identifier. Variables, classes, and methods all need a certain name. We call this name an identifier.

2: keyword. The keyword is the identifier used by the Java language. It has its specific syntax meaning. All Java keywords cannot be used as identifiers.

3: data type. Java has different data types. It is worth mentioning that the String data type is a String data type that is enclosed by a pair of double quotation marks. The String data is actually implemented by the String class, instead of the character array used in C. Every String data will generate a new instance of the String class. You don't have to worry about the relationship between the String and the class concept. Due to the characteristics of the class, you don't have to worry about how to implement them, they take care of themselves. It should be noted that strings are used as classes in Java only for security considerations.

4: operator. Any language has its own operators. Java is no exception, for example, +,-, *,/, and so on are all operators, the operator is used to form an expression with a certain amount of operational data to complete corresponding operations. Different operators are used for different data types.

5: delimiter. The Delimiter is used by the compiler to determine where the code is separated. '''''; '': 'Are the separators of the Java language.

It is very easy to learn the Java language. After all, the Java language only contains more than 50 keywords (keyword) and dozens of operators (operator), and the Java syntax (syntax) is also very simple, so most people can quickly learn the Java language. The danger is that many people think that they have full control over the Java language, but they still cannot master the internal operating mechanism. These blind spots sometimes make you unable to fully control the Java language. To overcome these blind spots, see The Java Language Specification, 2nd Ed. (no Chinese version) to thoroughly understand the Java programming language, and read "Inside the Java Virtual Machine, 2nd Ed. to thoroughly understand how Java virtual machines operate. Learning a language doesn't mean you can design a good object-oriented system architecture. To become an object-oriented expert, you often need to: (1) read more relevant books, especially the Design Pattern and Refactoring books. (2) observe other people's programs (such as Java API design and implementation) (3) write more programs. After learning the Java language, you also need to learn some APIs to write useful programs. Java has many APIs. You must plan a learning path so that you will not be lost in the vast sea of APIs. Essential APIs include: IO, New IO, Collection Framework, Network, RMI, JAXP. Other APIs depend on your needs:

* GUI: JavaBean-> Swing-> JavaHelp-> Java2D-> Image IO-> JAI-> Java 3D...
* Enterprise class: JDBC> JDO> Servlet> JSP> EJB> JMS> JTA/JTS...
* J2's class (this class is not my specialty and cannot provide learning sequence suggestions)

Generally, The Java language is compiled into bytecode instruction sets and binary formats according to The definition in The Java Virtual Machine Specification (The Java Virtual Machine Specification. Therefore, we will discuss the Java Virtual Machine (JVM)

JVM

We have talked about the syntax of the Java language similar to C and C ++, but we have abandoned the complex, confused, and insecure features in C and C ++. The Java language was first used to build software for consumer network devices. Therefore, it must support multi-host architecture and provide secure software components. To meet these requirements, compiled code must be transmitted over the network, run on any client, and ensure that the client is secure enough.

Java virtual machine is the cornerstone of Java and Java 2 platforms. It ensures that the Java language has nothing to do with hardware and operating systems, minimizes the compiled code, and protects users from malicious program attacks. What is a Java Virtual Machine. In fact, it is an unrealistic computer. Similar to a real computer, it also has its own instruction set and can allocate memory areas in the runtime environment. Using the virtual machine mechanism to implement programming languages is not a Java initiative. This is already a very common practice. Perhaps the most famous is the UCSD Pascal P-Code machine.

As long as the browser detects that the content of the currently processed Web file contains a Java Applet, the browser will open another JVM for this Java Applet and execute this Java application Applet. Java applets executed in JVM can be fully protected. As we have mentioned above, JVM is a self-sufficiency job environment, just like an independent computer. For example, an Applet running on JVM cannot access the host operating system. Advantages:

1. system neutral. Java applications can operate in any JVM, regardless of the hardware or software used by the system.

2. Security. Because the JVM has no access to the operating system, it is difficult for Java programs to damage other files or applications.

The disadvantage is that the programs running on the JVM are independent of the operating system, so they cannot enjoy the special features of the operating system.

Java has been widely used today, and its security cannot be avoided. Unlike other technologies (such as Microsoft ActiveX), Java takes security into account from the beginning of design as an additional design and patch. Therefore, Java security is implemented at the language level. Java security is guaranteed in the following three aspects:

1. language features (including array boundary check, type conversion, and cancelling pointer variables ).

2. Resource Access Control (including local file system access and Socket connection access ).

3. Code digital signature (use a digital signature to check whether the code source and code are complete ).

The source code of Java is first compiled into an intermediate code of bytecode. The file that stores this code is a. class file. During actual execution, the class file is loaded into the JVM (Virtual Machine) and then interpreted and executed by the JVM. Therefore, the upper and lower bounds check of arrays and valid type conversion are ensured through JVM. Java loads the virtual machine code file (that is, the class file) to the JVM through a class loader class (ClassLoader). After loading, a security manager is called) for example, when the class file of an Applet is loaded into the JVM by the default class loader, the JVM will immediately load the AppletSecurity subclass of SecurityManager for it, this manager is used to verify the operation. All the code actions (such as file read/write) must be verified first. Only the actions accepted by the security manager can be completed. Otherwise, a SecurityException exception will be thrown.

For JDK1.0, permissions are divided into two major parts in general. One is to have all permissions, and the other is to have only the "sandBox" permission, which is also the permission of a common Applet. In this case, local file reading and writing or connection to a host other than the source host (Orignal Server) is disabled. The biggest problem with this division is the lack of flexibility. For example, we want an Applet to read and write a directory in the local file system with the trust of the user, but do not connect to other hosts through Socket. This is why permissions of JDK cannot meet the requirements. After JDK1.1, the permission division was improved and the concept of PermissionSet was introduced.

Since our article does not discuss JVM, we just give a brief introduction to JVM. For more information, see The "The JavaTM TMVirtual Machine Specification 』.

Java

Compared with other programming speech, Java has the following advantages: Users and compilers do not have to understand the specific CPU details for generating executable code for the first time. Java introduces a compilation code middle layer called byte code, and uses a virtual abstract machine instead of a real machine. After the Java compiler finishes compiling a source file, what you get is not the code that can be run on a given platform immediately, but the byte code that can be run on any real platform, unique Condition

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.