YOUR FEEDBACK
EJM wrote: Well versed article and nice explanation. Easy to understand especially for us w...


2008 East
DIAMOND SPONSOR:
Data Direct
Frontiers in Data Access: The Coming Wave in Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
Intel
Virtualization – Path to Predictive Enterprise
Green Hills
IT Security in a Hostile World
JBoss / freedom oss
Practical SOA Approach
GOLD SPONSORS:
Software AG
The Art & Science of SOA: How Governance Enables Adoption
PlateSpin
Effective Planning for Virtual Infrastructure Growth
Fujitsu
Automated Business Process Discovery & Virtualization Service
Ceedo
Workspace Virtualization
Click For 2007 West
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
TOP THREE LINKS YOU MUST CLICK ON


Facading on the Fly: A Framework Proposal For Improving Network Speed
A framework proposal for improving network speed

Network speed has improved tremendously over the years and has revolutionized enterprise computing, but even with today's network infrastructure sending messages across a network is of several orders slower than sending messages locally. The latency caused by the network is a function of the size of the messages and the number of round trips. The delay due to message size is more or less constant as long as the data size stays within the size of the buffer transmission but cutting down the network crossings could have a more significant and direct impact. In light of these considerations, this article proposes the design and implementation of a framework, using core Java principles like Reflection, Dynamic Proxies, Byte Code Engineering, Java Beans, and Thread Local, to club multiple network calls and have them execute at the server in one go.

Objective
In an Enterprise Computing model multiple users access applications and data stored on servers scattered across many locations. The applications offer low-level data in the form of services. But often, the user really needs a more consolidated and unified view rather than the low-level view these services offer. The Session Façade pattern helps by logically grouping services keeping in mind the business needs of the user. In doing so the façade serves two other purposes:

  • It precludes the clients from having to access the fine-grained remote interfaces thus reducing network traffic and latency.
  • It also decouples lower-level business components from one another allowing them to be conceived and built independently, making designs more flexible and comprehensible.
Thus the façade helps in getting over some of the limitations of network speed but, since it's tied to the user's requirements, as more and more users start using the applications, more and more facades have to be added. While this may sound simple, it often runs into the following impediments:
  • Maintainability issues due to uncontrolled growth in the number of views
  • Delays and disruptions of service for existing clients while incorporating new changes
  • Departmental politics may lead to some facades being preferred over others
In such a scenario it would be useful to have a framework that would help clients define, develop, and deploy their facades and have them execute on the server.

Approach
The semantics of the Java language don't support clubbing network calls into batches so we are proposing a framework that imposes certain minimal but non-intrusive changes in the regular style of programming to help overcome the limitation.

The basic idea includes:

  • Demarcating batch (façade) boundaries through a start and end call
  • Objects used in the façade need to be batch-aware, i.e., object behavior is dependent on whether or not it's executing in a batch
  • Delaying object state changes by postponing the execution of the code till the end of the batch
  • A new framework bean to comprehend and service such requests is needed
Implementation
Overview
  1. The client signals the start of the batch process by a call to begin the method of BatchContext. The call changes the state of the current thread by binding the BatchContext to a ThreadLocal variable.
  2. Objects modulate their behavior based on the availability/unavailability of the BatchContext in the current thread context. Unavailability triggers the usual behavior as programmed. On the other hand, availability results in:
    a.  An addition to the Participating-Objects list - All the objects created in the batch boundary are added to the list of participating objects and indexed (indexing helps reduce the final cost of serialization). Similarly, calls to methods with a non-void return type results in instantiation and initialization of the returned object by a no-argument constructor. The returned object is added to this participating objects list. The call execution doesn't result in any state changes.
    b.  The serialization of invocation - The serialized instruction is stacked in the InvocationHistory object bound to the BatchContext. Different types of invocation objects exist for the lookup instruction (LookupHomeInvocation), remote object creation (CreateRemoteInvocation), remote method invocation (RemoteMethodInvocation), instance method invocations (MethodInvocation), and constructor invocations (ConstructorInvocation). The invocation object maintains a reference, via an index, to the object invoked, the arguments passed, and the object returned besides information about the method invoked, i.e., method name.
  3. Use of ServiceLocator pattern for looking up the EJBs. The ServiceLocator acts as a batch-aware class; it registers the client's intent to do a lookup while the actual lookup happens later along with other network calls. The ServiceLocator is described in greater detail in the following sections.
  4. The client then signals the end of the batch process. This is done by a call to the end method of the BatchContext class. The call results in the entire list of objects and the instructions being submitted to the server. The results of the entire sequence are processed and returned together as one call.
Details
The following section describes in detail the internals of a batch call.
  1. Batch begin - The events accompanying a batch begin call are shown in Figure 1.
  2. Initialization of a Data Object in the batch call - The object is simply added to the list of Participating Objects. The conditional behavior of the service class's construction isn't the default behavior as programmed by the developer; instead it's injected post-build time through bytecode manipulation and is discussed in the components section later.
  3. Looking up an EJB using the modified ServiceLocator - In the batch mode the ServiceLocator would add a LookupHomeInvocation instruction and return a DynamicProxy implementation of the EJBHome and Home Interface as the home proxy. Returning a proxy implementation helps us trap and handle invocations to the home and remote interfaces.
  4. Calls on the Home interface - The home proxy (through it handler, EJBHomeHandler) in turn, on a create call on home proxy, adds a CreateRemoteInvocation instruction and returns a DynamicProxy implementation of the EJBObject and the Remote Interface as the remote proxy.
  5. Calls on the Remote interface - Calls on the remote proxy (through its handler, EJBRemoteHandler) translate to a RemoteMethodInvocation instruction and the return of a dummy instance of the relevant return type.
  6. Call to the end method of the BatchContext class - This call results in the entire list of objects and the instructions being submitted to the server. The server runs through the instructions sequentially and executes them. In the process it alters the state of the objects participating in the batch. The altered state is returned to the client where the original references are used to modify the client-side object states using accessor methods to reflect the new states. The lack of pointers restricts the return types to mutable types. Apache Commons BeanUtils libraries are used to facilitate copying the states.
About Ashish Garg
Ashish Garg is a Senior Technical Specialist with Infosys Technologies Ltd. He has more than 4 years of experience in J2EE Technologies.

About Ashwini Garg


YOUR FEEDBACK
SYS-CON Spain News Desk wrote: Facading on the Fly: A Framework Proposal For Improving Network Speed Network speed has improved tremendously over the years and has revolutionized enterprise computing, but even with today's network infrastructure sending messages across a network is of several orders slower than sending messages locally. The latency caused by the network is a function of the size of the messages and the number of round trips.
News Desk wrote: Facading on the Fly: A Framework Proposal For Improving Network Speed Network speed has improved tremendously over the years and has revolutionized enterprise computing, but even with today's network infrastructure sending messages across a network is of several orders slower than sending messages locally. The latency caused by the network is a function of the size of the messages and the number of round trips.
LATEST JAVA STORIES & POSTS
Join Scott Guthrie as he discusses Microsoft’s commitment to web standards development, Rich Internet Applications and how Microsoft is contributing to help move the web forward. Join Adobe’s Kevin Lynch as he demonstrates how Flash and HTML come together to make the most eng...
At last year's JavaOne Chris Oliver gave a presentation on JavaFX in which he discussed how he was interested in programming Java2D not in terms of JComponent paintEvent methods that launch into graphics.drawLine(…) or graphics.drawRect(…) code, but instead by allowing the de...
Before describing solutions available for rich client application development, it would be a good idea to explain what exactly a rich client application is and which rich client topologies can feasibly be built using the Java platform. In the main, a rich client is a part of a so...
It's sometimes argued that the Java Community Process's development procedures are secretive and that the general public is excluded from participating. While this may have been the case in the past, it's no longer true. The majority of JCP Expert Groups now do their work in an o...
The one thing that unifies the distributed computing style known as SOA, in most of its manifestations, is self-describing data via the Extensible Markup Language (XML). The benefits of XML over opaque message formats in data interchange are well established. No matter if your fo...
In the past couple of years, interest in Jetty has surged. Jetty is an open source Java-based web and application server and servlet container, but what else do you know about it? To commemorate the 12th anniversary of Jetty, here are 12 things that might surprise you
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON FEATURED WHITEPAPERS

SPONSORED BY INFRAGISTICS
In every field of design one of the first things students do is learn from the work of others. They ...
There are many forces that influence technological evolution. After a decade of building enterprise ...
2008 is going to be an important year for Rich Internet Applications. Most organizations are deliver...
The OpenAjax Alliance is developing an Ajax industry wishlist for future browsers, using a dedicated...
Infragistics announced the availability of two Community Technology Preview (CTP) User Interface (UI...
The YUI development team has released version 2.5.2; you can download the new release from SourceFor...
ADS BY GOOGLE