JBoss Seam framework-next-generation Enterprise Java Development

Source: Internet
Author: User
Tags jbpm

Seam is an enterprise-level Java application framework. It is inspired by the following principles:

There is only one "tool"

Seam defines a unified component model for all the business logic of your application. The Seam component may be stateful and contain any State associated with several well-defined contexts, including long running context, persistent context,Business process contextAnd can be stored across multiple Web requests in user interactionDialog Context.

There is no difference between the presentation layer component and the business logic component in Seam. You can layer applications based on any architecture you design, instead of forcing your application logic into an inappropriate layered configuration that is imposed on you by any framework combination you are currently using.

Unlike a simple Java EE or J2EE component, the Seam component canAt the same timeAccess the status related to the Web request and the status stored in the transaction Resource (instead of manually spreading the Web Request status through method parameters ). You may be opposed to saying that the layer imposed by the old J2EE platform on your applications is a good thing, and there is nothing to prevent you from using Seam to create a quite layered architecture-the difference is that,YouYou need to build your own applications and decide which layers are there and how they work together.

Integrate JSF with EJB 3.0

JSF and EJB 3.0 are two of the best new features of Java EE5. EJB3 is a new component model of server-side business and persistent logic. At the same time, JSF is also an excellent component model of the presentation layer. Unfortunately, both of them cannot solve all computing problems on their own. In fact, JSF works best with EJB3. However, the Java EE5 specification does not provide a standard method for integrating the two component models. Fortunately, the creators of both models looked forward to this situation and provided standard extension points that allowed individual extensions or integration with other solutions.

Seam merges the component models of JSF and EJB3 into one, eliminating the need for code bonding and allowing developers to focus on business issues.

It is possible to write a "everything" as an EJB Seam application. If you are used to using EJB as a fine-grained object, this may surprise you. However, from the perspective of developers, version 3.0 has completely changed the nature of EJB. EJB is a fine-grained object-nothing is more complex than the annotated JavaBean. Seam even encourages you to use Session Bean as the listener of JSF actions!

On the other hand, if you prefer not to use EJB 3.0 at this time, you do not have to be reluctant. In fact, any Java class can be a Seam component, and Seam provides all the functions you expect from "lightweight" containers, or even any components, ejbs, or other things.

Integrate AJAX

Seam supports two best open-source JSF-based AJAX solutions: JBoss RichFaces and ICEfaces. These two solutions allow you to add AJAX functions to your interface without writing any ctipt code.

Seam also provides the built-in javaspt remote access layer, which allows you to call components asynchronously from the client JavaScript without the intermediate action layer. You can also subscribe to the JMS topic on the server side and receive information through the AJAX push method.

Without the built-in concurrency and status management capabilities of Seam, these methods will not work well. These two methods ensure that the server can safely and efficiently process multiple concurrent and fine-grained asynchronous AJAX requests.

Use business processes as the primary infrastructure

Seam can provide transparent business process management through jBPM. Using jBPM and Seam to implement complex workflows, collaboration, and task management is incredibly simple.

Seam even allows you to use the same language (jPDL) as jBPM used to define a business process to define a page stream at the presentation layer.

JSF provides a rich array of event models for the presentation layer. By exposing events related to jBPM business processes with the same event processing mechanism, Seam reinforces this model, which provides a unified event model for Seam's unified component model.

Declarative state management

From the early days of EJB, we were used to declarative Transaction Management and J2EE declarative security. EJB 3.0 also introduces declarative persistent context management. A broader management status problem-management and a specialContextThe associated status has three special cases, which ensure that all necessary cleanup is performed at the end of the context. Seam promotes the concept of declarative state management far and applies itApplication state). J2EE applications generally implement status management manually by obtaining and setting Servlet Session and Request attributes. If the program fails to clear the Session attribute or conflicts with the Session data associated with different workflows in a Multi-Window application, this state management method will become the root cause of many bugs and memory leaks. Seam may almost completely eliminate such bugs.

Declarative Application Status management is defined using a wide range of SeamContext model)And become possible. Seam extends Servlet specifications-defined context models-requests, sessions, and applications-adds two new contexts-dialogs and business processes -, from the perspective of business logic, they are more meaningful.

Once you start using conversations, you will be surprised that many things have become easier. Have you ever struggled with delayed Association crawling in An ORM solution like Hibernate or JPA? The persistence context of the Seam dialog scope means that you will hardly see itLazyInitializationException. Have you ever encountered a Refresh or Back button problem? Or have you ever submitted the form repeatedly? Is there any problem of transmitting information through post-then-redirect? The conversation management of Seam solves these problems, and you don't even need to pay attention to them. They are all signs of a poor state management architecture that has been common since the beginning of the Web.

Bijection (bidirectional injection)

Inversion of Control)OrDependency injection (dependency injection)The concept appears in JSF, EJB3, and many so-called "lightweight containers. Most of these containers focus on implementation.Stateless services (stateless Service). Even with support for injection of stateful components (such as JSF), it is actually difficult to process application states, because the scope of stateful components is difficult to be effectively and flexibly defined, in addition, components of a wider scope cannot be injected into components of a narrower scope.

Bijection (bidirectional injection)What is different from IoC is that it isDynamic,Context-relatedAndBidirectional. You can understand this mechanism to map context-related variables (names in various contexts bound to the current thread) to component attributes. Bidirectional injection allows containers to automatically assemble stateful components. It even allows the component to safely and simply process the value of the context variable. You only need to assign it to the attributes of the component.

Workspace Management and multi-window browsing

The Seam application allows you to freely switch between multiple browser windows. Each window is associated with a different, secure, and isolated dialog. Applications can even useWorkspace managementAllows you to switch between multiple dialogs (Work zones) in a browser window. Seam not only provides correct multi-window operations, but also simulates operations on multiple windows in one window.

Prefer XML annotations

Traditionally, the Java Community has been in a very messy state as to which metadata can be counted as configuration. J2EE and popular "light" containers provide XML-based deployment descriptors for things that can be really configured between different System deployments and any other declarations that are not easy to use in Java. Java 5 annotations change everything.

EJB3.0 accepts annotations and "configure exceptions", which is the easiest way to provide information to containers in declaration form. Unfortunately, JSF is still very dependent on the bulky XML configuration file. Seam extends the annotations provided by EJB 3.0 for declarative State management and explicit context division. This frees you from the tedious configuration of JSF managed bean (JSF managed bean), reduces the required XML, and only the information that actually belongs to the XML (JSF navigation rules ).

Easy integration testing

As a POJO, the Seam component is inherently capable of unit testing. However, for complex applications, only unit tests are not enough. For Java Web applications, integration testing is generally a clumsy and difficult task. Therefore, Seam provides the Seam application with testability as a core function of the framework. You can easily compile and reproduce the JUnit or TestNG tests that interact with users in order to drill all system components except View (JSP or Facelets page. You can run these tests directly from your IDE, where Seam will automatically deploy the EJB component using JBoss Embeddable.

The specifications are not perfect.

We think the latest Java EE specification is good. But we know it is far from perfect. There are many vulnerabilities in the Specification (for example, limitations in the JSF lifecycle of GET requests), and Seam fixes these vulnerabilities. The creators of Seam are working with the JCP Expert Group to ensure that these amendments are restored to the next revision of the standard.

Web applications not only serve HTML pages

Today's Web framework is too small. They allow you to enter the form and enter your Java object. Then they will hold you up. A truly complete Web application framework should address issues such as persistence, concurrency, Asynchronization, status management, security, email, information, PDF and chart generation, workflow, wikitext rendering, Web Services, and caching and so on. Once you have tasted the sweetness of Seam, you will be surprised to find that many problems have become simpler ......

Seam integrates JPA and Hibernate 3 for persistence, EJB Timer Service and Quartz for lightweight Asynchronization, jBPM for workflow integration, and JBoss rules for business rules, meldware Mail is integrated with emails, Hibernate Search and Lucene are integrated for complete text Search, JMS is integrated for messages, and JBoss Cache is integrated for page capture. Seam creates a new rule-based security framework based on JAAS and JBoss rules. It can even be used to render PDF, online emails, charts, and the JSF tag library of wikitext. The Seam component can be called as a Web Service at the same time, asynchronously from the client JavaScript or Google Web Toolkit, or, of course, can also be called directly from JSF.

Start now!

Seam can run on any Java EE application server, or even Tomcat. If your environment supports EJB 3.0, great! If not, you can use Seam to manage transactions that contain JPA or Hibernate3. Alternatively, you can deploy JBoss Embedded in Tomcat and enjoy full support for EJB 3.0.

In the end, you will find that the combination of Seam, JSF, and EJB3 is to write complex Web applications in Java.MostA simple method. You won't believe how little code is needed!

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.