Framework Adoption for Java Enterprise Application Development Clarence Ho Independent Consultant, Author, Java EE Architect http://www.skywidesoft.com clarence@skywidesoft.com Presentation can be downloaded from: http://www.skywidesoft.com/index.php/seminar 1
Outline - Part I Enterprise Java Framework Overview What is an Enterprise Java Framework? Overview of popular Enterprise Java Frameworks Spring vs Standard JEE Comparison 2
Outline - Part II Enterprise Java Framework Adoption Case Study Re-develop a legacy application in Java High level application architecture overview Main frameworks, libraries and tools adopted and the decision process Main challenges and lesson learnt 3
Outline - Part III Discussions and Chat Framework/Libraries/Tools selection how to choose the right one for your project? Other thoughts (e.g. Cloud computing, BYOD, Big Data, HTML5, etc.) Q&A 4
Enterprise Java Frameworks 5
What is a software framework? A software framework is an abstraction in which software providing generic functionality can be selectively changed by user code, thus providing application specific software. A software framework is a universal, reusable software platform used to develop applications, products and solutions. Software Frameworks include support programs, compilers, code libraries, an application programming interface (API) and tool sets that bring together all the different components to enable development of a project or solution. Source: Wikipedia 6
What is a software framework? (cont.) Frameworks contain key distinguishing features that separate them from normal libraries: 1. Inversion of control - In a framework, unlike in libraries or normal user applications, the overall program's flow of control is not dictated by the caller, but by the framework 2. Default behavior - A framework has a default behavior. This default behavior must actually be some useful behavior and not a series of no-ops. 3. Extensibility - A framework can be extended by the user usually by selective overriding or specialized by user code providing specific functionality. 4. Non-modifiable framework code - The framework code, in general, is not allowed to be modified. Users can extend the framework, but not modify its code. Source: Wikipedia 7
What is an application framework? An application framework consists of a software framework used by software developers to implement the standard structure of an application for a specific development environment (such as a standalone program or a web application). Application frameworks became popular with the rise of multi-tiers enterprise applications since these tended to promote a standard structure for applications. Programmers find it much simpler to program when using a standard framework, since this defines the underlying code structure of the application in advance. Developers usually use objectoriented programming techniques to implement frameworks such that the unique parts of an application can simply inherit from pre-existing classes in the framework. Source: Wikipedia 8
What is an enterprise application framework? An application framework designed for the implementation of enterprise class applications. In addition to an application framework, an enterprise application framework should supports the development of a layered architecture, and provide services that can address the requirements on performance, scalability, and availability. Layers within an enterprise application: - Persistence Layer - Services (Business Logic) Layer - Presentation Layer - Integration Layer (Web Services, Message-based) Services: - Security - Transaction (local and global transactions) - Caching - Batch processing - Task scheduling and asynchronous task execution - Management and monitoring - Testing - and many more 9
What is an enterprise Java framework? An enterprise application framework designed for the Java language. Components: - Dependency Injection - AOP (Aspect Oriented Programming) - Persistence - Transactions - Presentation Framework - Web Services - Messaging - Testing 10
Enterprise Java Frameworks 11
JEE 6 A collection of JCP (Java Community Process) standards Implemented by all JEE compliant application servers Oracle Glassfish 3.1 Oracle WebLogic 12c IBM WebSphere 8.5 JBoss Application Server 7.1 Apache TomEE 1.5.2 Source: Pro Spring 3 12
JEE 6 Features/API Overview Source: JavaOne Presentation by IBM 13
JBoss Seam Framework Designed around JEE standards Mainly supported by JBoss Application Server Provide a micro-container for use with other AS or Tomcat Tightly integrates with other JBoss frameworks and libraries 14
Jboss Seam Framework Features/API Overview Hibernate RichFaces Source: JavaOne Presentation by IBM 15
Google Guice Reference implementation of JSR330 (Dependency Injection for Java) Focus on DI only Not a full blown enterprise Java framework 16
Spring Framework The most popular enterprise Java framework Support all major application servers and web containers Support major JEE standards Integrates with other popular opensource frameworks and libraries 17
Spring Framework Features/API Overview Source: JavaOne Presentation by IBM 18
JEE vs Spring Features/API Overview * Similar patterns for validation, remoting, security, scheduling, XML binding, JMX, JCA, JavaMail, caching * Spring also support EJB 3.1, but not CDI Source: JavaOne Presentation by IBM 19
Enterprise Java Frameworks 20
Spring Framework Main Features Feature Description Sub-proj. IOC Container AOP Data Access Transaction Management Model-viewcontroller Authentication & Authorization Remote Management Messaging Testing Configuration of application components and lifecycle management of Java objects, done mainly via Dependency Injection Enables implementation of cross-cutting routines Working with relational database management systems on the Java platform using JDBC and object-relational mapping tools and with NoSQL databases Unifies several transaction management APIs (JDBC, JPA, JTA, etc.) and coordinates transactions for Java objects. An HTTP- and servlet-based framework providing hooks for extension and customization for web applications and RESTful Web Services. Configurable security processes that support a range of standards, protocols, tools and practices via the Spring Security sub-project Configurative exposure and management of Java objects for local or remote configuration via JMX Configurative registration of message listener objects for transparent message-consumption from message queues via JMS, improvement of message sending over standard JMS APIs support classes for writing unit tests and integration tests Spring Data projects Spring Security 21 Source: Wikipedia
Spring Framework Latest Features (3.X) Feature Description Version Java-based Configuration Embedded JDBC DataSource Validation with Type Conversion and Formatting Persistence with Spring Data JPA Use Java classes to configure Spring s ApplicationContext (Spring JavaConfig was merged into the core Spring Framework since 3.0). Embedded database support (by using the <jdbc:embeddeddatabase id="datasource" type="h2"> tag) Spring 3 introduce a new type conversion and formatting system, and support of JSR303 Bean Validation API. Spring Data JPA s Repository abstraction greatly simplifies the development of persistence layer with JPA. Spring MVC Improved support of RESTful-WS. 3.1 3.0 3.1 3.0 3.0 Spring Expression Language Profiles Cache Abstraction TaskScheduler Abstraction A powerful expression language that supports querying and manipulating an object graph at run time. A profile instructs Spring to configure only the ApplicationContext that was defined when the specified profile was active A caching abstraction layer that allows consistent use of various caching solutions with minimal impact on the code. Provides a simple way to schedule tasks and supports most typical requirements. 3.0 3.1 3.1 3.0 22
Other Useful Spring Projects Project Description Version Spring Security Spring Data Spring Batch Spring Integration Spring WebFlow Spring Mobile Spring Roo SpringSource Tool Suite Configurable security processes that support a range of standards, protocols, tools and practices An umbrella project includes many modules that simplifies the development of persistence layer with various data sources (e.g. JPA, NoSQL, JDBC, Hadoop, etc.) Provides a standard template and framework for implementing and executing various kinds of batch jobs in an enterprise environment. Provides an excellent integration environment for enterprise applications. Building on top of Spring MVC s foundation, Spring Web Flow was designed to provide advanced support for organizing the flows inside a web application. An extension to Spring MVC that aims to simplify the development of mobile web applications. A rapid application development solution for Spring-based enterprise applications An IDE tools with Eclipse and Spring IDE bundled, together witn numerous tools for developing Spring applications. 3.1.2 1.X 2.1.8 2.1.3 2.3.1 1.0.0 1.2.2 3.0.0 23
Enterprise Java Frameworks 24
SpringBlog Main Features Allow users to view and post blog entries Allow users to post comments on blog entries Allow users to upload attachment for blog entries Support AOP for filtering bad words Support multiple languages (English, Chinese) Support multiple databases (H2, MySQL) Support multiple data access frameworks (Hibernate, MyBatis) Provides RESTful-WS for retrieving blog entries Supports batch upload of blog entries from XML files Presentation layer Built with Spring MVC, JSPX and jquery JavaScript library 25
SpringBlog Application Layered Architecture 26
Enterprise Java Frameworks Adoption 27
Case Study Project Overview Application Description A Transfer Agency System within an Asset Management Company Handle customer interactions and transaction processing on subscription/redemption of various funds, as well as business actions (e.g. dividend, split, merge, etc.) Integrating with numerous peripheral systems (IVRS, document workflow, online e-commerce web site, financial system, fund A/C system, reporting platform, etc.) Running on AS400, written in RPG Character based UI, terminal emulation Source: Wikipedia 28
Case Study Project Overview Mission Technology migration OS: Open Platform (Unix/Linux) Database: RDBMS Application Server: JEE Compliance Language: Object-Oriented Programming Integration: Messaging, Web Services Benefits Openness, scalable, ease of maintenance Align with corporate direction Source: Wikipedia 29
Case Study System Architecture Swift MQ Backend (Vendor Package) Core processing (A/C, Txn, Allocation) Interface WebSphere Oracle Solaris Oracle Data Warehouse Browser Client Middle end (In-house Developed) Data interface, Integration, EOD, Extra processing ETL RESTful-WS Reporting (BO) Scheduling Peripheral Systems IVRS Document Workflow Online E-commerce Source: Wikipedia 30
Case Study Framework Adoption Data Access Layer Hibernate (corporate standard) Business Logic Layer Spring Framework (corporate standard) Presentation Layer (interim solution) Spring Webflow Java Server Faces (JBoss Richfaces) Batch Processing (new and propose) Spring Batch Web-service Based Integration (interim solution) RESTful-WS (Jersey) Security (corporate standard) Spring Security (integration with Siteminder) Source: Wikipedia 31
Case Study Tools and Library Adoption Reporting (Business Objects) Integration Use BO s Java SDK Developed a simple RAO (Report Access Object) layer PDF Processing itext Job Scheduling Integration with Autosys via RESTful-WS Other Libraries Apache Commons Source: Wikipedia 32
Case Study Challenges Introducing a middle-end system Added a layer of complexity Integration with numerous peripheral systems (with different formats and integration method) Large number of batch jobs (~30 EOD jobs, many intraday jobs) Maintenance and support Complex support/deploy/troubleshooting procedure Front end No corporate standard at that moment Lack of skills Source: Wikipedia 33
Case Study Lesson Learnt Problem Cause If I have a 2 nd Chance Batch processing Reporting platform integration Presentation layer Testing Hibernate is not batch processing friendly Tightly coupled to BO (if BO was stopped, middleend not able to start) Performance problem Difficult to maintain Lack of skills Numerous performance problem Use JDBC to read all data, Hibernate for update only Use message queue for loosely coupled integration Use Spring MVC, JSP, jquery Perform load testing asap (even too late in SIT) Source: Wikipedia 34
The Power of Enterprise Java Frameworks 35
Other Thoughts Use JEE or Open Source Frameworks? Considerations Maturity Reliable and proven Developer skill (easy to learn and hire developers) Resources (forums, communities, tutorials, sample codes, etc.) Spring and Hibernate are the most popular choices among enterprise 36
Other Thoughts Emerging Technologies Cloud Computing, Big Data (NoSQL), Mobile (BYOD), HTML5, So far, no JEE standards for those emerging technologies yet!!! JEE 7 (Sep 2013) will include some HTML5 technologies (e.g. WebSockets) NoSQL Hibernate OGM (Object-Grid mapping) Spring data projects (commons, MongoDB, Apache Hadoop, Redis, Neo4j) 37
Other Thoughts 38 Experience sharing No matter what framework you use (or use JEE), still need to make a lot of decisions It doesn t matter whether a framework/library is JEE standard or not. Most important is that it s the one most suitable for your environment A good ALM (application life-cycle management) platform and workflow is another key to success Source code control and issue tracking Code review Continuous build, code style check, automated test, Learn, learn, learn. Research, research, research
Enterprise Java Frameworks Adoption 39