672329 members! Sign up to stay informed.

Sponsored Links


Resources

Enterprise Java
Research Library

Get Java white papers, product information, case studies and webcasts

News News News Messages: 4 Messages: 4 Messages: 4 Printer friendly Printer friendly Printer friendly Post reply Post reply Post reply XML XML XML

Gavin King's four-part (so far) "Web Beans Sneak Peek"

Posted by: Joseph Ottinger on September 24, 2007 DIGG
Gavin King is writing a sneak peek of Web Beans, a JSR based on JBoss Seam. Topics covered so far: quick introductions, binding annotations and component types, declaring components via XML, and scopes, contexts, and resolver messages (as Web Beans adds a conversational scope to the application, session, and request scopes provided through JSF.)

Some relevant extracts from "Introducing Web Beans:"
A Web Bean is an application component containing business logic. A Web Bean may be called directly from Java code, or it may be invoked via Unified EL. A Web Bean may access transactional resources. Dependencies between Web Beans are managed automatically by the Web Beans container. Most Web Beans are stateful and contextual. The lifecycle of a Web Bean is always managed by the container.

What does it mean to be contextual? Since Web Beans may be stateful, it matters which bean instance I have. Unlike a stateless component model (for example, stateless session beans) or a singleton component model (such as servlets), different clients of a component see the component in different states. The client-visible state depends upon which instance of the component the client has a reference to.

One great advantage of the contextual model is that it allows stateful components to be treated like services! The client need not concern itself with managing the lifecycle of the component it is using, nor does it even need to know what that lifecyle is. Components interact by passing messages, and the component implementations define the lifecycle of their own state.

...a Web Beans developer may define some kind of stereotype as an annotation, for example @Mock, @Staging or @AustralianTaxLaw that allows whole sets of components to be conditionally installed in particular deployments of the system.
From Injection, binding annotations and component types:
f we have more than one component that implements a particular API type, the injection point can specify exactly which component should be injected using a binding annotation. For example, there might be two implementations of PaymentProcessor:
@Component @PayByCheque
public class ChequePaymentProcessor implements PaymentProcessor {
public void process(Payment payment) { ... }
}

@Component @PayByCreditCard
public class CreditCardPaymentProcessor implements PaymentProcessor {
public void process(Payment payment) { ... }
}
A client component developer uses the binding annotation to specify exactly which component should be injected:
@In @PayByCheque PaymentProcessor chequePaymentProcessor;
@In @PayByCreditCard PaymentProcessor creditCardPaymentProcessor;
Equivalently, using constructor injection:
public Checkout(@PayByCheque PaymentProcessor chequePaymentProcessor, 
@PayByCreditCard PaymentProcessor creditCardPaymentProcessor) {
this.chequePaymentProcessor = chequePaymentProcessor;
this.creditCardPaymentProcessor = creditCardPaymentProcessor;
}
The third part, called "Declaring components using XML," discusses how to wire components through XML, which would be required if components are provided from an external library that presumably wouldn't know about the Web Beans annotations (or the specific business requirements for a given application.)

The most recent post, "Scopes, contexts and resolver methods," describes the four contextual scopes (application, session, request, and conversation), as well as a dependent "psuedo-scope" where the scope of a component is inherited from other components into which it's injected (i.e., component "A" is conversationally-scoped, and component "B" is declared as being in the dependent scope and injected into "A;" it will be conversationally scoped because it's dependent on "A.")

A resolver method allows a developer to hook into the injection mechanism to offer run-time polymorphism.

It's an interesting series. Web Beans is a JSR (JSR-299) and this is an excellent overview of some of its capabilities.

Threaded replies

·  Gavin King's four-part (so far) "Web Beans Sneak Peek" by Joseph Ottinger on Mon Sep 24 08:20:02 EDT 2007
  ·  WebBeans? Dumb Name! by Time Passx on Mon Sep 24 12:45:15 EDT 2007
  ·  Re: Gavin King's four-part (so far) "Web Beans Sneak Peek" by joost de vries on Mon Sep 24 14:27:09 EDT 2007
  ·  Web Beans in Java SE by Gavin King on Mon Sep 24 17:01:21 EDT 2007
    ·  Support for Non-Web Applications by Carlo Luib-Finetti on Tue Sep 25 06:03:11 EDT 2007
  Message #240129 Post reply Post reply Post reply Go to top Go to top Go to top

WebBeans? Dumb Name!

Posted by: Time Passx on September 24, 2007 in response to Message #240112
Maybe all the good names have been taken, but it seems easily confused with the open source NetBeans project which has been around for a decade. I think it reduce confusion if you chose another name.

  Message #240134 Post reply Post reply Post reply Go to top Go to top Go to top

Re: Gavin King's four-part (so far) "Web Beans Sneak Peek"

Posted by: joost de vries on September 24, 2007 in response to Message #240112
I hope Spring Webflow will support this nascent standard too.

  Message #240150 Post reply Post reply Post reply Go to top Go to top Go to top

Web Beans in Java SE

Posted by: Gavin King on September 24, 2007 in response to Message #240112
So far, I've had many comments on the blog articles requesting that this spec encompass Java SE use-cases such as Swing applications. This is definitely something we're looking for feedback on, please let us know if this is something you believe Web Beans should consider.

  Message #240173 Post reply Post reply Post reply Go to top Go to top Go to top

Support for Non-Web Applications

Posted by: Carlo Luib-Finetti on September 25, 2007 in response to Message #240150
During the last years everbody seemed to associate J2EE (or Java EE) with web applications. I suppose, there are a lot of us creating inhouse applications based on a Java GUI and an application server as middleware.

So I always thought that component specs for JavaEE should include non web apps. There should support for configurable binding of Java UI elements with serversided transactional components.

Therefore, in my humble opinion, "Web Beans" should only be part of a wider solution.

New content on TheServerSide.comNew content on TheServerSide.comNew content on TheServerSide.com

Dependency Injection in Java EE 6 - Part 2

Reza Rahman continues to explore the features of the proposed JSR 299, Contexts and Dependency Injection for Java EE (CDI). When approved, it promises to be a key feature of Java EE 6. (January 21, Article)

Ted Neward Q&A: What you must know about JavaScript, Scala and more

Ted Neward is an independent consultant specializing in high-scale enterprise systems, and an authority in Java and .NET technologies. He is the author and co-author of several books, including Effective Enterprise Java. At TheServerSide Java Symposium in March, he will be presenting sessions on pragmatic architecture, ECMAScript and Scala. (January 15, Article)

Developers split on open sourcing Java

Now that Oracle is absorbing Sun Microsystems, there mixed views on what should come of the Java Community Process (JCP). While some say Oracle should become the new steward of Java and keep the JCP much as it was, others argue that it may be time to open-source this widespread language. (November 24, Article)

Dependency Injection in Java EE 6 - Part 1

Reza Rahman explores the features of the proposed JSR 299, Contexts and Dependency Injection for Java EE (CDI). When approved, it promises to be a key feature of Java EE 6. (November 2, Article)

SAML: It's Not just for Web services

SAML is an XML-based standard for exchanging authentication and authorization data between security domains. The single most important problem that SAML was created to solve is the Web browser Single Sign-On problem. Many organizations are debating whether to stay with version 1.1 or move to 2.0. This article makes observations about both options. (September 28, Article)

Programming is Also Teaching Your Team

Joe Ottinger takes a look at how people learn, and applies it to the practice of programming. He notes that understanding how people learn is an essential part of working in a programming team. (September 22, Article)

Can Java EE Deliver The Asynchronous Web?

Stephen Maryka gave us an article about the Asynchronous Web and posed a number of questions that get examined like an approach to delivering Asynchronous Web capabilities through extensions to existing Java EE technologies. (July 14, Article)

JSF Flex

JavaServer Faces Flex goal is to provide users capability in creating standard Flex components, part of flexSDK which is open sourced through MPL license, as normal JSF components. This article by Ji Hoon Kim will provide an overview of creating a simple multilingual JSF page consisting of JSF Flex tags. (June 29, Article)

The Rules of SOA - A Road to a Successful SOA Implementation

In this session Jeff explores the key characteristics of successful SOA projects. He covers some of the patterns, and anti-patterns, tool sets, and strategies that he himself learned the hard way. Last, he provides a strategy and blueprint for achieving a high likelihood of success in your SOA project. (June 23, Tech Talk)

Ari Zilka Talks About Terracotta 3.1

Ari Zilka, CTO of Terracotta, Inc., talks about the new features in Terracotta 3.1, announced during JavaOne and available now. (June 15, Tech Talk)

Enterprise Application Integration, and Spring

In this Tech Talk, Josh Long explores an integration challenge using Spring Integration and walks through the implementation, employing and expanding on the basic patterns of Enterprise Application Integration to tie together components into a function integration solution, and then demonstrates how Spring Integration helps address the integration requirements. (June 15, Tech Talk)

Google Web Toolkit: An Introduction

In this Tech Talk, David Geary teaches you: The basics of Google Web Toolkit; How to implement Ajax-enabled applications in Java; Internationalization; Hooking into the browser history mechanism; Remote procedure calls. (June 4, Tech Talk)

Just Enough Early Architecture to Guide Development

Jon Kern discusses the best architecture/technical solutions and ensure that they are repeated by all developers. By tackling the architecture up-front in a serial manner, subsequent parallel development will be much more manageable and predictable. (May 28, Tech Talk)

Productive Programmer: On the Lam from the Furniture Police

This keynote describes the frustrations of modern knowledge workers in their quest to actually get some work done, and solutions for how to guard yourself against all those distractions. Neal Ford talks about environments, coding, acceleration, automation, and avoiding repetition as ways to defeat the misguided attempts to sap your ability to produce good work. (May 26, Tech Talk)

Auto-Scaling Your Existing Web Application

Gil demonstrates how new, aggressive uses of already abundant compute capacity by common applications offer competitive value for application designers. (May 21, Tech Talk)

Automating Hibernate Mapping and Queries For Java Web Development

Chris Keene introduces WaveMaker as a new way to automate the ability to generate Hibernate classes in order to more quickly bring OR mapping into an application. (May 19, Article)

Free Book PDF Download: Mastering EJB Third Edition

Mastering EJB was one of the original and most influential EJB books in the industry. Mastering EJB III now returns with two new expert co-authors, updated for EJB 2.1 and 30% new chapters including security, integration, best practices, open source, and more.
(Book PDF Download)

Application Server Matrix

The Application Server Matrix is a detailed listing of J2EE vendors and their application server products, with information on latest version numbers, J2EE spec support and licensing, pricing, platform support, and links to product downloads and reviews.
(Application Server Comparison Matrix)

News | Blogs | Discussions | Tech talks | Patterns | Reviews | White Papers | Downloads | Articles | Media kit | About
Java Solutions
All Content Copyright ©2007 TheServerSide Privacy Policy
Site Map