Create an asynchronous message framework with Ajax and Apache Geronimo

Source: Internet
Author: User
Tags object model

Overview of Framework Components

A well-designed service-oriented business layer can help you to compose loosely coupled services into processes and composite applications. This service mix in service-oriented architecture (service-oriented Architecture,soa) enables you to build applications and processes with services in different environments without having to understand the details of each environment. The benefits of using SOA depend on services that are designed and implemented using a generic, rough interface.

Ajax programming provides you with great functionality and flexibility when developing a browser-based UI. Using this UI feature in conjunction with service-oriented business tiers will also provide you with greater flexibility. Ajax programming itself is well suited for asynchronous requests and responses. When using Ajax's asynchronous nature in conjunction with an asynchronous messaging system, you can build browser-based applications that will make the user experience more akin to desktop applications, giving users a more real-time feel.

Apache Geronimo is a modular application server platform that conforms to the java™2 Platform, Enterprise Edition (Java EE) specification, based on a schema decoupling using control inversion (inversion of CONTROL,IOC) Components and services to build enterprise-class applications and services.

In this article, you will learn how to handle asynchronous business requests from clients using a message-based framework or bus to interact with a Geronimo-based server between multiple Ajax-based clients. Learn how to track Ajax-based client requests between browsers and servers. and learn how to track these requests on the server side through the message-oriented service bus of the target business service.

Introduction to Ajax

Ajax is a framework that is driven by an xml-based request and response server to invoke the UI features and concepts of the model. Most of these concepts are inherently uncertain, but are standardized by convention. Most of these concepts appear in standard form in Ajax application development and have become the function of mainstream Web browsers.

The Ajax UI relies on the Document Object Model (Model,dom) feature and JavaScript components in the browser, which are used to parse and display Web pages at any given time. Many, but not all, such features and components are shared by most mainstream Web browsers. So much content may be difficult to master, so this article only discusses the most basic features of DOM and Ajax-oriented JavaScript code.

Almost all Ajax-enabled applications create components called XMLHttpRequest objects. This JavaScript object is used to construct the request and to transfer the request back and forth between the browser and the server. The code fragment in Listing 1 creates an instance of the XMLHttpRequest object that can be used between the Mozilla Firefox browser or the Microsoft®windows®internet explorer® browser and the server.

Listing 1. Creating XMLHttpRequest Objects

function getHTTPObject()
{
  var xmlhttp = null;
  var success = false;
 
  // List of MS XMLHTTP versions - newest first
  var MSXML_XMLHTTP_PROGIDS = new Array(
    'MSXML2.XMLHTTP.5.0',
    'MSXML2.XMLHTTP.4.0',
    'MSXML2.XMLHTTP.3.0',
    'MSXML2.XMLHTTP',
    'Microsoft.XMLHTTP'
  );
  for (var i = 0; i < MSXML_XMLHTTP_PROGIDS.length && !success; i++)
  {
   try
   {
     xmlhttp = new ActiveXObject(MSXML_XMLHTTP_PROGIDS[i]);
     success = true;
     return xmlhttp;
   }
   catch (e)
   {
     xmlhttp = false;
   }
  }
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
  {
   try
   {
     xmlhttp = new XMLHttpRequest();
   }
   catch (e)
   {
     xmlhttp = false;
   }
  }
  return xmlhttp;
}

Related Article

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.