13 kinds of core technologies of J2EE (2)

xiaoxiao2021-03-06  20

Source: UML Software Engineering

Java Naming and Directory Interface (JNDI) JNDI API is used to perform names and directory services. It provides a consistent model to access and operate enterprise resources such as DNS and LDAP, local file systems, the latter objects in the application server. In JNDI, each node in the directory structure is called Context. Each JNDI name is relative to Context. There is no absolute name of the absolute name. For an application, it can get its first context by using the InitialContext class:

Context ctx = new initialContext ();

Applications can locate the resources or objects they need via this initialized context. For example, suppose you expand an EJB in the WebLogic server and bind the Home interface to the name myapp.myejb, then a customer of the EJB can locate the Home interface by getting a initialization Context, you can locate the home interface:

Myejbhome Home = CTX.lookup ("MyApp.myejb");

In this example, once you have a reference to the requested object, the HOME interface of the EJB can call the method on it. We will do more in the "Enterprise Java Beans" chapters.

The above discussion about JNDI is just a corner of the iceberg. If you want to find objects in Context, JNDI also provides some ways to do the following:

Insert an object into or bind to context. This is very effective when you start an EJB.

Transfer objects from Context.

List all objects in Context.

Create or delete contexts of sub-level.

Next, we have to pay attention to EJB.

Enterprise Java Beans (EJB)

One of the reasons why J2EE technology wins some of the extensive attention is EJB. They provide a framework to develop and implement distributed business logic, which significantly simplifies the development of enterprise applications with scalability and highly complex. The EJB specification defines how EJB components interact with their containers. The container is responsible for providing public services, such as directory services, transaction management, security, resource buffer pools, and fault tolerance.

The EJB specification defines the basic bean type in 3:

Stateless Session Beans: Provides a single service, not maintaining any status, cannot continue when the server failure occurs, and the life period is relatively short. For example, a StateLess Session bean may be used to perform temperature conversion calculations.

Stateful Session Bean: T provides a session interaction with the client, which can store status to represent a customer. A typical example is a shopping cart. Stateful session bean cannot continue to survive when the server fails, and life is relatively short. Each instance is only used for a single thread.

Entity Beans: Provides conformance data - usually stored in the database - can continue after the server failure occurs. Multi-user can use EJB to represent the same data. A typical example of Entity EJB is the customer's account information.

Although there are more differences, all EJBs have a lot of common. They all handle home interface. It defines how a client creates and demise EJB. The remote interface defined in the client method can be called; the Bean class performs the main business logic.

The development of EJB has exceeded the scope of this article. However, if an EJB has been developed or purchased from a third party, it must be published in the application server. WebLogic Server 5.1 has an EJB Deployer Tool to help process the release of EJB. When you use the EJB Deployer Tool, you want to define the JNDI name used by the client to locate the EJB. Deployer Tool will generate a Wrapper class to process communication with the container and bind the requested Java class in a JAR file. Once EJB is released, the client can use its JNDI name to locate EJB. First, it must get a Reference to the home interface. Then, the client can use the interface to call a CREATE () method to get the handle of a bean instance running on the server; Finally, the client can use the handle to call the method in the bean.

After learning EJB, let's look at JSP.

JavaServer Pages (JSPS)

There may already be many people in the middle of the Active Server Pages (ASP) technology that have been familiar with Microsoft. JSP and ASP correspond to, but more platform conflict. They are designed to help web content developers create dynamic web pages and only require relatively small code. Even if the web designer doesn't know how to program how JSP is also used, JSP applications are very convenient. The JSP page is composed of HTML code and embedded Java code. The server is processed after the page is requested by the client, and then returns the generated HTML page to the client's browser.

Let's take a simple instance of JSP. It only shows the current date and time of the server. Although the specific interpretation of the grammar has exceeded the scope of this article, we can still be visually visually seen, the Java code is placed in the middle of the symbol, while Java's expression is located between the symbols.

Date JSP SAMPLE

The Current Date IS.

You may sometimes have heard JHTML. This is an older standard for JSP. The WebLogic server can support JSP and support JHTML. Note that in the default situation, JSP is not active in the WebLogic server. To make it valid, you can edit the WebLogic.Properties file. If the web server is not in a valid state, you must first make it. The situation of servlet is the same as JSP.

Below is: Java Servlets

Java servlets

Most of the functionality provided by servlet is similar to JSP, but the implementation is different. JSP is usually embedded in a small amount of Java code in most HTML code, while servlets are written by Java and generate HTML.

Servlet is a small Java program that extends the functionality of the web server. As a server-side application, starting when the request is performed, which is similar to the CGI Perl script. A great difference between servlets and CGI scripts is that every CGI requires a new process when starting - and servlets are running in the servlet engine. Therefore, servlets provides a good improvement in scalability.

When developing servlets, you often need to extend the javax.servlet.http.httpservlet class, and Override some of its methods, including:

Service (): As a Dispatcher to implement command - definition method

DOGET (): Hands the client's HTTP GET request.

Dopost (): Perform HTTP POST operation

Other methods also include handling different types of HTTP requests - can refer to the HTTPSERVLET API document.

The above is described above is a variety of methods of the standard J2EE Servlet API. The WebLogic server provides a complete way of implementation of the API. Once you have developed a servlet, you can register in WebLogic.properties and thus configure it in the WebLogic server. With Java Servlets, we have reached the end of J2EE main technology. But J2EE is not allowed to be there. In the following paragraphs, we will briefly look at some of the existing technologies, including RMI, Java IDL, and CORBA, JTA, and XML, and so on.

Remote Method Invocation (RMI)

As indicated by its name, the RMI protocol is called some methods on the remote object. It uses a continuous sequence to pass data on the client and server side. RMI is a lower level of protocol used by EJB.

Java IDL / CORBA

With the support of Java IDL, developers can integrate Java and Corba. They can create Java objects and make it expanded in Corba ORB, or they can also create Java classes and customers who are expanded with other ORBs. The latter approach provides another way, through which Java can be used to integrate your new application and Legacy system.

Java Transaction Architecture (JTA) / Java Transaction Service (JTS)

JTA defines a standard API that can be accessed by various transaction monitoring.

JTS is the basic implementation of CORBA OTS transaction monitoring. JTS specifies the implementation of the transaction manager. This transaction manager is a Java Transaction API (JTA) specification in the high-level, and implements the Java image of OMG OTS Specification at a lower layer. JTS Transaction Manager provides transactional services for application servers, resource manager, independent app, and communication resource manager.

JavaMail and JavaBeans Activation Framework

JavaMail is an API for accessing a mail server, which provides an abstract class of a mail server. Not only supports SMTP servers, but also supports IMAP servers.

JavaMail uses JavaBeans Activation Framework (JAF) to handle MIME-encoded mail attachments. MIME's byte stream can be converted to a Java object, or converted from Java objects. From this major, you can use JAF directly.

Java Messaging Service (JMS)

JMS is an Application Interface (API) for communication with a message-oriented middleware. It supports the domain of point-to-point, with domains that support publish / subscribe / subside types, and provide support for the following types: approved messaging, transaction messages, consistent messages, and subscriptions with persistence Support. JMS also provides another way to integrate your application with the Legacy Backend system.

EXTENSIBLE MARKUP LANGUAGE (XML)

XML is a language that can be used to define other tag language. It is used to share data in different business processes. The development of XML and Java are independent of each other, but it is the same objective as Java is platform independence. By combining Java and XML, you can get a perfect platform-independent solution. There are currently many different companies working on Java and XML. If you want to learn more about this, you can access the Sun's Java-XML page, or the XML Zone of IBM DeveloperWorks.

转载请注明原文地址:https://www.9cbs.com/read-44010.html

New Post(0)