| By Alexey Yakubovich, Alex Maclinovsky | Article Rating: |
|
| March 9, 2005 12:00 AM EST | Reads: |
30,188 |
All classes above PAProgramsCompaigns are reused by other blocks in the application and don't contain any code specific to the P&C compartment. As a result, the whole compartment implementation takes just 10 lines of code.
This example clearly demonstrates that code reuse in the Vitrage Framework can make a block implementation very simple. These examples were taken from an application that actually contains a dozen compartments that differ only slightly from the P&C compartment. With Java inheritance, implementing a slightly different compartment can be accomplished with a small number of Java statements. As discussed above, with custom tags, it would probably take another 29 tag occurrences and 129 lines of JSP code for each compartment.
The JSP fragment that invokes the block looks as simple as:
<blocks:useBlock blockId="PE12"/>
The parameter PE12 is a unique block identifier.
The last type of JSP-block in Vitrage is Composites. These blocks manage collections of other blocks and apply some logic to coordinate the code generation between inner blocks. Composites provide inter-block layout automation; this part of the framework was developed with a view to creating lightweight portlets usable outside portal platforms. In their present form, composites are used to manage HTML surrounding blocks, e.g., when several blocks share a single frame that should be rendered if at least one of them produces any content.
Building Compartmentalized Applications with Vitrage
Vitrage Framework can help save resources and improve the process of developing Web applications.
Use
When assembling a JSP from blocks, the most common syntax is to use a custom tag from the blocks library provided with the framework:
<blocks:useBlock blockId="PE1"/>
In this example, PE1 is a unique block ID that identifies a compartment in the page design. Alternatively, a JSP-block can be invoked directly from a scriplet:
<% BlockFacade.useBlock("PE1", request) %>
Runtime code behind these constructs is not exactly the same. Custom tag style invocation has a small overhead: an object of class InvokeBlockTag that implements custom tag blocks:useBlock will be created for each invocation of each JSP page. With a scriplet invocation, such overhead is eliminated. In either case, the HTML developer uses identical code, varying just the block ID.
Vitrage Container
Vitrage includes a containier that manages the lifecycle of JSP-blocks, including block initialization, caching and invocation, similar to the way the JSR 168 Portlet Container manages portlets. This similarity runs further: in Vitrage, only one instance of each JSP-block is created for the entire application. All JSP invocations reuse that single instance without the unnecessary creation and garbage collection overhead. JSP-blocks are thread-safe, and one instance of each block is created during application initialization and kept alive in the block cache. In some cases, that could save a significant amount of resources. By contrast, custom tags aren't thread-safe by design, and a new instance of each tag is created on each JSP invocation.
Resources & Prototypes
One of the selling points of tag library technology is the separation between content and layout. Normally, JSP content comes from a database and is rendered by custom tags, while the layout is specified directly in the JSP. This prevents content from affecting layout, as is often required by the presentation logic.
Since this approach doesn't work for compartmentalized applications, Vitrage has to use another way to support such separation. On the page level outside of the block scope, static layout elements are still kept in the JSPs. A compartment may contain both static and dynamic internal layout elements. The dynamic elements are generated in JSP-blocks, while static elements are located in resource bundles and loaded at application startup. This also lets the Vitrage Framework support JSP-block internationalization. While similar to how internationalization is provided in Struts, it could be more runtime effective; the only instance of a block is created on application initialization, while with custom tags, a resource will be read on each JSP invocation.
Development Tools
Vitrage provides a structured means for integration between compartments realized by JSP-blocks
and the application's back-end, which relies on strongly typed universal transport objects such as IblockData, Contentlet and ContentReference.
Taking advantage of this architecture, Vitrage supports two modes for serving content to JSP-blocks. In the production mode, each block obtains its content from the request, where it was put by the controller. In the test mode, all invocations of getData() are intercepted and forwarded to TestDataProvider component, which supplies test data in the format expected by the block. It takes some work to fill TestDataProvider with test data, but lets front-end development move forward independent of the application back-end. This way, Vitrage supports testing and integrating front-end components on several levels:
- As individual JSP-blocks with JUnit test suite, with output redirected to an HTML file, which can be viewed in browser; this method doesn't require any application or Web server or any application back-end
- As complete JSP pages inside the Web container without any Model or Controller components
- As a complete MVC application, bypassing the lack of test data in the database
- Conventional end-to-end integration testing.
Modern Web applications use increasingly complex pages with compartments and exhibit sophisticated presentation logic. Tag libraries, JSP templates and portlets don't give developers adequate support for effectively implementing such dynamic front-ends. Being highly compatible with various J2EE platforms, MVC frameworks and tag libraries, the Vitrage Framework offers extensive support for compartmentalized applications. In many cases it also improves support for the application development process and provides significant performance gains for the resulting application. In some cases it permits the development of applications that wouldn't be feasible with tag libraries, templates or portlets. Additionally, developing applications with the Vitrage Framework can economize resources and time.
References
Published March 9, 2005 Reads 30,188
Copyright © 2005 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Alexey Yakubovich
Alexey Yakubovich works as a framework architect at Roundarch, Inc. He received his PhD in mathematics in Moscow State University for research in mathematical logic, and has published more than two dozen articles in mathematical magazines. Alexey has spent 20 years in software development.
More Stories By Alex Maclinovsky
Alex works at Sun Microsystems as the Engineering Manager for Sun SOA Governance Solution. For nearly two decades he architected and built distributed systems on enterprise, national and global scale. Alex specializes in SOA Infrastructure, Security and Composite Applications. He blogs at http://blogs.sun.com/RealSOA/ and can be contacted at maclinovsky@yahoo.com
![]() |
Alex Maclinovsky 04/07/05 01:15:09 PM EDT | |||
I understand how immodest it is to leave feedback to my own article, however: |
||||
![]() |
Jack C. Holt 03/30/05 11:49:23 AM EST | |||
I just tried to send email to the email addresses for the authors and my email server is telling me that those email addresses don't exist. How can I reach the authors? |
||||
![]() |
Jack C. Holt 03/30/05 11:34:31 AM EST | |||
Unfortunately, I noticed some typos in this article. For instance the white paper for Vitrage is actually at http://www.roundarch.com/features/vitrage.html. I would have appreciated a link to where I can download the code Vitrage code. |
||||
![]() |
Marina Prikaschikova 03/22/05 09:54:46 AM EST | |||
>The reason custom tags lead to such complexity is that |
||||
- Kindle 2 vs Nook
- Why IBM’s Server Chief Got Busted
- Is Cloud Computing Like Teenage Sex?
- Industry Experts Discuss the State of Cloud Computing
- Performance Tuning Essentials for Java
- Confessions of a Ulitzer Addict
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- It's the Java vs. C++ Shootout Revisited!
- Cloud Computing Can Revitalize Your Career as Software Developer
- IBM Could "Reinvent" Java: Mills
- Oracle & Cloud Computing: Exclusive Q&A with SVP Richard Sarwal
- A Brief History of Cloud Computing
- Kindle 2 vs Nook
- Cloud CEOs, CTOs & SVPs to Speak at 4th International Cloud Computing Expo
- Why IBM’s Server Chief Got Busted
- Is Cloud Computing Like Teenage Sex?
- Industry Experts Discuss the State of Cloud Computing
- Performance Tuning Essentials for Java
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- A Cup of AJAX? Nay, Just Regular Java Please
- Java Developer's Journal Exclusive: 2006 "JDJ Editors' Choice" Awards
- The i-Technology Right Stuff
- JavaServer Faces (JSF) vs Struts
- Rich Internet Applications with Adobe Flex 2 and Java
- Java vs C++ "Shootout" Revisited
- Bean-Managed Persistence Using a Proxy List
- Reporting Made Easy with JasperReports and Hibernate
- Creating a Pet Store Application with JavaServer Faces, Spring, and Hibernate
- What's New in Eclipse?
- Why Do 'Cool Kids' Choose Ruby or PHP to Build Websites Instead of Java?
- i-Technology Predictions for 2007: Where's It All Headed?










































