apache beehive bea user's group oct 2004
DESCRIPTION
An overview of the Apache Beehive projectTRANSCRIPT
Apache Beehive ProjectTechnical Overview
Scott Ryan, Denver BEA User’s Group Rich Feit , Beehive committer, BEA Systems
October 7, 2004
Agenda
• Introduction and Overview• Technology Requirements• XML Beans• Web Services• NetUI• Controls• WebLogic Workshop Demo• Pollinate Demo• Getting Involved
Introduction and Overview
Beehive Goals
• Beehive is an open-source software project designed to deliver a cross-container, ease-of-use programming model and application framework for J2EE- and SOA-based applications.
• Deliver a comprehensive, easy-to-use framework for building dynamic J2EE and SOA applications.o Based on over 3 years of experience “making it easy” with
WebLogic Workshopo Designed with tool-ability in mind from the outset
• Provide ultimate investment protection and transparency through open source and portability
• Strengthen the Java market by providing world-class ease-of-use to all Java developers
Beehive Components
• XMLBeans –Java-XML binding tool through which you can access the full power of XML in a Java-friendly way.
• Java Controls - JavaBean-based component model for resource access
• Java Web Services - Annotations for rapid Web Service development
• Java Page Flows - Struts-based MVC framework for Web application design
How Beehive Fits
• Beehive Application Frameworko A runtime component providing a higher-level programming abstraction
for J2EE and SOA-based applicationso Meta-data driven programming model and framework based on JSR-175
(Java Metadata)
WebLogic Application
Server
Web Services
Java Web Services
Unified Interconnection
Model
ControlsXMLBeans
XML Schema/ Java
<xml>
Java PageFlows
Visual Struts Editing
Beehive Application Framework
Pollinate Eclipse Plug-ins
UserInterface
Components
TomcatApplication
Server
Third-partyApplication
Servers
WebLogic Workshop
Beehive in WebLogic
Technology Requirements
Technology Requirements
• JAVA 1.5 beta3-b63 or latero http://java.sun.com/j2se/1.5.0/download.jsp
• JSR 175• JSR 173• Tomcat 5.x (Servlet 2.4 / JSP 2.0)• Ant 1.6.2• Eclipse 3.0.1M1• Log4j 1.2.8• XMLBeans 2.0• Velocity• Test Infrastructure
o JUnit, JAXP, Crimson, HttpUnit, regexp
XML Beans
XMLBeans: a Beehive Building Block
• XMLBeans provide a familiar, JavaBean-based view of XML datao Without losing access to the original, native XML structureo Beans are bound to the XML document…not imported/exported
• XML Schema used to compile strongly-typed Java interfaces and classeso XMLBeans supports all XML schema definitionso Full XML Infoset fidelityo Reflect into the XML schema itself through an XML Schema
Object model• XMLBeans access to XML is fast and rich:
o Strong-typed getters and setterso XQuery transformationso Loosely-typed via cursors
• Separate Apache Project but is bundled in Beehive distribution
XMLBeans make XML a first-class citizen in Java
XMLBean Usage
XML Schema
Address.xsd
Generated Classes
Address
AddressDocument
// create and populate a document
AddressDocument doc = AddressDocument.Factory.newInstance();Address ad = doc.addNewAddress();ad.setType("office");ad.setName("Eric Cartman");ad.setAddress1("101 Main");ad.setCity("Boulder");ad.setState("CO");
Web Services
Java Web Services
• JSR-181 defines annotations to enable easier Web service programming. Example:
@WebService public class StockQuoteService {@WebMethod public float getLastTradePrice(String tickerSymbol) { }}• Abstracts SOAP marshalling, Java-to-XML binding, WSDL file
creation, underlying bean deployment, and much more• Two development models:
o Start with Java: expose class as Web Service using metadatao Start with WSDL: tool produces classes o Metadata allows for alterations/customization
NetUI
Controls
Overview
• Provides a standard architecture for developing resource access frameworks.
• Designed to simplify code necessary to access J2EE resources
• Designed with tool-ability and IDE integration in mind.
• Based on the Java Bean component model.• Aimed at reducing the J2EE learning curve.
Overview
• Flexible configuration model• Extensibility by interface to extend existing controls
with additional functionality• Adaptable containment from J2EE to servlet to
standalone containment.• Resource Management with a defined lifecycle.• Supports composition model.• Well defined packaging model.
Configuration
• Programmatic Java Bean Property Access.o myTimerBean.setTimeOut(“3 Seconds”);
• Externally configured property value via Deployment Descriptor <timer:timer
xmlns:timer=“http://openuri.org/com/myco/TimerControl”> <timer:timeOut>3 Seconds</timer:timeOut> </timer:timer>
• JSR-175 Metadata property definition @Timer(timeout=“3 Seconds”) Public TimerControlBean myTimeBean;
Extensibility by Interface
Public interface CustomerDatabase extends ControlExtension, DatabaseControl{@sql statement=“INSERT INTO CUSTOMERDB(ID,NAME) VALUES({id},{name})”int newCustomer(int id, String name) throws SQLException;
@sql statement=“SELECT * FROM CUSTOMERDB WHERE ID = {id}”Customer findCustomer(int id);
}
• Defined by the author of the control.
Adaptable Containment
• Services are contextualo Allows support within multiple runtime contexts (J2EE,
Servlet, Java Native, etc.)o Must support resource access from within any contexto Implementation of services might vary depending on
container (i.e. security service)• Based on JavaBeans Runtime Containment and
Services Protocol
Resource Management
• Well defined lifecycleo onAcquire
Fired upon first client accesso onRelease
Fired if acquire was fired at the end of the resource scope.o Resource Scope is defined by the bounding container
Web Container – HTTP Request EJB Container – Method invocation or User Transaction
Programmatic Client Model
TimerControlBean myTimerBean = (TimerControlBean)ControlBean.instantiate(classloader, “com.myco.timerControlBean”);myTimerBean.setTimeout(“3 seconds”);myTimeBean.addTimerControlEventListener(// anonymous event handler classnew TimerControlEventListener(){public void onTimeout(long time){// timer event handling code}});
Declarative Client Model
@Timer(timeout=“3 seconds”)TimerControlBean myTimerBean;
public void myTimerBean_onTimeout(long time){ // timer event handling code }
Java Control Architecture
Control Parts
CODE TIME
• Sample Database Control that is extensible• DatabaseControl.java
o Interface• DatabaseControlImpl.jcs
o Base Implementation• TestDbControl.jcx
o Extension Implementation• DriveDatabaseControl.java
o Test class
Page Flow Programming Model
• Controls are service abstractionso A ‘façade’ layer for accessing data and services
• Actions are the core of the code in a web applicationo Do flow control for routing to UI based on stateo Invoke control methods to access the business tiero Break a webapp into manageable pieceso Send data to / consume data from pages
• Pages are ‘dumb’o But not simple!o They contain only UI related code / JSP tagso Preferably no Java code
Authoring Model
• JPF Fileso Metadata driven Javao Processed by Sun’s APT to produce
struts-config.xml validator-rules.xml Java class file
• JSP Fileso Actions expose data to JSPso NetUI tag libraries render UI
• Shared Flowso Used throughout a web application to handle actions /
exceptions across Page Flows
A Page Flow Action
@Jpf.Action(forwards={ @Jpf.Forward(name="success", path="viewOrder.jsp",actionOutputs = { @Jpf.ActionOutput(name = "order", type = org.apache.beehive.samples.petstore.model.Order.class,required = true)})})protected Forward viewOrder(CheckoutForm form){_sharedFlow.ensureLogin();_order=form.getOrder();
Forward f=new Forward("success");Boolean isCheckOut=new Boolean(form.isCheckOut());f.addActionOutput("order", _order);return f;}
Programming Model Details
• Single threaded actions• State management
o Request <= Page Flow <= Shared Flow <= Session • Declarative validation• Simple actions
o Navigation based entirely on metadata• Action Output / Page Input
o Data flow contracts enforced between actions and pages• Singleton Page Flows• Optimizations to prevent session serialization in cluster
Integrating all of Beehive
• Control compositiono WSM
Controls can be used as part of WS implementations Web service controls expose web services for use in JPFs
Don’t worry about marshalling, expose JavaBeanso Controls
Abstract J2EE resources in supported containers• Page Flow
o Consumes all of the above allowing web application developers to code to controls
o One abstraction for all back-end services
The Page Flow Compiler
• [TODO: picture]
Beehive/NetUI JSP Tags
• Integrated with a JSP 2.0 containero Uses the JSP 2.0 EL on almost all JSP tag attributes
• Render HTML or XHTMLo Configurable with a webapp-level setting
• New Data Grido Paging / sorting / filteringo Extensibility model for building new column types,
pagers, etc• Rich Tree component• Open SDK for building / extending tags
The Test Recorder
• Test infrastructure open sourced in Apache as part of NetUIo Based on JUnit
• How it workso “Records” user interactions with a webapp
Output is an XML “record” fileo Executes a test by “playing back” a recorded session
POSTs recorded request parameters Captures output during “playback” Diff’s the “record” and “playback” files to determine pass / fail
• NetUI BVTs have about 420 of these• Contributes significantly to stability of NetUI
Creating a Beehive Webapp
• Controls / NetUI enabled webappo Page Flow JARs
Struts / NetUI / XMLBeans / Log4J / JSTLo NetUI TLDso Controls JAR
• Building a Beehive webappo Compile XSDs into XMLBeanso Codegen Controls / Page Flows to .java fileso Comple Java sources to WEB-INF/classes
• Fully transparent• Build files provided with Beehive distribution
Beehive Petstore Demo
DEMO
The Webapp
• Sizeo 7 JPFs / 21 JSPso Various .tag files
• Highlightso Uses Beehive Controls
The JPFs code to a single API Implementation is backed by a naïve in-memory database Can be swapped out with other control implementations
Database WebServices Stay tuned for ApacheCon!
o Fully internationalizedo Zero code in the JSPso Built with site templates
• Not done yet!
WebLogic Workshop Demo
DEMO
Pollinate Demo
DEMO
Getting Involved
Resources
• Beehive : http://incubator.apache.org/beehive/
• Beehive : http://incubator.apache.org/beehive/mailinglists.html
• Beehive : http://wiki.apache.org/beehive • Beehive : http://dev2dev.bea.com/technologies/beehive
• XML Beans : http://xmlbeans.apache.org
• Pollinate : http://www.eclipse.org/pollinate/
• Pollinate : https://dev.eclipse.org/mailman/listinfo/pollinate-dev • BEA : http://dev2dev.com• Instantiations : http://www.instantiations.com/
• Genuitec : http://www.myeclipseide.com/
• Soaring Eagle LLC : http://www.soaringeagleco.com