Struts Roadmap
Total Page:16
File Type:pdf, Size:1020Kb
Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. Struts Roadmap Gary Ashley Jr. CTA, Inc. garyashley at cta dot com Gary Ashley Jr. — Struts Roadmap Page 1 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. Agenda What is Struts? What does Struts do for me? How does Struts work? Where did Struts originate? What is the future of Struts? What are the latest features? Gary Ashley Jr. — Struts Roadmap Page 2 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. Agenda (Continued) What extensions are available? Should I choose Struts? Where can I find additional information? Demo Gary Ashley Jr. — Struts Roadmap Page 3 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. What Is Struts? The official site: ¾http://struts.apache.org An open source framework for building Java web applications. Encourages application architectures based on Model 2 (a variation of MVC) Gary Ashley Jr. — Struts Roadmap Page 4 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. Model 2 Request (Controller) ActionServlet 1 (Model) LDAP 2 JavaBean 3 DB Browser 5 (View) Response JSP 4 Application Server Enterprise Resources Gary Ashley Jr. — Struts Roadmap Page 5 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. Core Technology Core based on: ¾Java Servlets ¾JavaBeans ¾Resource Bundles ¾XML ¾Open source technologies like Jakarta-Commons Gary Ashley Jr. — Struts Roadmap Page 6 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. What Does Struts Do for Me? Struts provides a framework to collect input from a user, direct that input to server-side code, and forward to output page(s). Solves common problems found by “the community” while building enterprise web applications. Gary Ashley Jr. — Struts Roadmap Page 7 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. Compelling Features Validation – a very robust XML based validation framework is built into Struts. Security – you can add role based security. Internationalization (i18n) – built in support using Java resource bundles Gary Ashley Jr. — Struts Roadmap Page 8 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. How Does Struts Work? It uses a deployment descriptor very similar to servlets. ¾struts-config.xml vs. web.xml Struts “processes” HTTP requests using a handful of components configured in the struts-config.xml file. Gary Ashley Jr. — Struts Roadmap Page 9 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. Basic Steps User fills in form & clicks “submit” HttpRequest is sent to the ActionServlet ActionServlet delegates processing to the RequestProcessor RequestProcessor loads form values into an ActionForm RequestProcessor sends ActionForm to Action Gary Ashley Jr. — Struts Roadmap Page 10 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. Basic Steps (Continued) Action implements Business Logic as the execute() method Business Logic performs application specific instructions CRUD operations, Workflow, Email, LDAP, Legacy Integration, etc. Action saves any Model data as JavaBeans to appropriate Scope Gary Ashley Jr. — Struts Roadmap Page 11 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. Basic Steps (Continued) Action returns ActionForward to RequestProcessor RequestProcessor forwards / includes / redirects to appropriate View defined in the ActionMapping View “renders” presentation including any Model data stored in JavaBeans or MessageResources to provide i18n. Gary Ashley Jr. — Struts Roadmap Page 12 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. Sample Config File <struts-config> <form-beans> <form-bean name="logonForm“ type="app.LogonForm"/> </form-beans> <action-mappings> <action path="/Welcome" forward="/pages/Welcome.jsp"/> <action path="/Logon" forward="/pages/Logon.jsp"/> <action path="/LogonSubmit" type="app.LogonAction" name="logonForm” validate="true" input="/Logon.do"> <forward name="success" path="/Welcome.do"/> <forward name="failure" path="/Logon.do"/> </action> </action-mappings> <message-resources parameter="resources.application"/> </struts-config> Gary Ashley Jr. — Struts Roadmap Page 13 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. ActionServlet Responsibility: ¾Boot strap configuration upon init(). Config: ¾<struts-config> API: ¾This class is provided. Gary Ashley Jr. — Struts Roadmap Page 14 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. RequestProcessor Responsibility: ¾Handles all processing of Request/Response lifecycle. Config: ¾<controller processorClass=“”/> API: ¾This class is provided, but if default behavior is not suitable then subclass: org.apache.struts.action.RequestProcessor • Override any of the process methods required Gary Ashley Jr. — Struts Roadmap Page 15 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. ActionMapping (aka ActionConfig) Responsibility: ¾Contains configuration information that relates the path, form-bean, and action together along with other basic instructions. This is the primary “instruction set” for the controller. Config: ¾<action path=“” name=“” type=“”/> API: ¾This class is provided, but to include additional information you can subclass org.apache.struts.action.ActionMapping Gary Ashley Jr. — Struts Roadmap Page 16 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. Action Form Responsibility: ¾ Holds all information from the client, typically HTML form data. Perform validation of client input. Config: ¾ Uses an associated ActionFormBean (aka FormBeanConfig) for configuration: • <form-bean name=“” type=“”/> API: ¾ Subclass (or use one of the DynaForm classes) org.apache.struts.action.ActionForm • Override reset() and validate() methods. Gary Ashley Jr. — Struts Roadmap Page 17 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. Action Responsibility: ¾This is the binding layer to business logic. Should also store any JavaBeans required by view. Config: ¾Associated to a path and form-bean, and configured using the ActionMapping API: ¾Subclass org.apache.struts.action.Action • Override the execute() method. Gary Ashley Jr. — Struts Roadmap Page 18 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. ActionForward (aka ForwardConfig) Responsibility: ¾Typically contains the location of a JSP, tile definition, or other view component. Config: ¾<forward name=“” path=“”/> API: ¾This class is provided. Gary Ashley Jr. — Struts Roadmap Page 19 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. ActionMessage Responsibility: ¾Constructs a message string from the resource bundle. Config: ¾<message-resources parameter=“” /> API: ¾This class is provided. Gary Ashley Jr. — Struts Roadmap Page 20 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. Where Did Struts Originate? Initial releases 0.5 (May 2000) –1.0 (Mar 2001 )\ ¾Implemented core Model2 concept • Action perform() • FormBean validate() • ActionMapping path=“xxx.do” • ActionForward path=“nextStep.jsp” • Struts Taglibs Donated to the Apache foundation by Sun’s Chief Web Architect, Craig McClanahan Gary Ashley Jr. — Struts Roadmap Page 21 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. 1.1 Release Struts 1.1 (Aug 2003) ¾Expanded Core Features • Tiles • Plugins • Module Support • Validation ¾Explore interoperability with emerging standards • EL • JSTL • JSF Gary Ashley Jr. — Struts Roadmap Page 22 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. Latest Release Struts 1.2.4 (Sep 2004) ¾Remove deprecations from 1.0 to 1.1, and prior ¾Building greater stability and feature integration • Further module integration • Further support EL and JSTL ¾New Features • Wildcard mappings • DigestingPlugIn • MappingDispatchAction • Migrate build from Ant to Maven Gary Ashley Jr. — Struts Roadmap Page 23 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. What Is the Future of Struts? With so many emerging standards, the future of Struts is still unclear. The current thinking is to begin 2 main branches for ongoing development: ¾1.x series – Servlet 2.2 / JSP 1.1 ¾2.x series – Servlet 2.4 / JSP 2.0 Gary Ashley Jr. — Struts Roadmap Page 24 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. Development Release Struts 1.2.5 (Oct. 17, 2004) ¾Continuing to correct bugs and cleanup codebase. ¾Migrated to Subversion ¾Website updates ¾Any new enhancements will most likely be in the 1.3.x series. Gary Ashley Jr. — Struts Roadmap Page 25 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. Future Release Struts 1.3 (late 2004, 2005) ¾Use jakarta-commons Resources ¾Separate into multiple builds • * core, apps, el, faces, site, taglib • * flow, scripting (new) ¾Allow configuration extends=“” in all other elements (similar to tiles) ¾Move core to "Struts Chain" Request Processor ¾Complete Maven migration Gary Ashley Jr. — Struts Roadmap Page 26 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, CTA, Inc. Future Release Struts 1.4 (2005, 2006) ¾Review approach to RequestProcessor ¾Consider ActionContext ¾Enhanced support for newer servlet and jsp specs. ¾Consider adding support for Porlets by