`
dexterfeng
  • 浏览: 3390 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
最近访客 更多访客>>
社区版块
存档分类
最新评论

【转载】Java EE 6 vs. Spring Framework: A technology decision making process

阅读更多

原文出自: http://www.javacodegeeks.com/2012/01/java-ee-6-vs-spring-framework.html

 

In the last few month we’ve went through this decision making process: which technology stack to choose for enterprise development on the Java platform? There are various alternatives. However, the ones we’ve discussed intensively were: Pure Java EE 6 Stack vs. Spring with Java EE.

The following blog article summarizes key issues I found interesting when you consider one of those technology stack options. I will not try to convince somebody to choose either of the two. It’s the decision making process and the key arguments that are important to me and that I want to share.

What is a “standard”?
The word “standard” was a very important one in our discussions, especially for executive management. I think it gives decision makers a warm feeling with regards to protection of investment. But what is a standard and what can we consider as standard in the Java ecosystem? Mirko Novakovic, founder and board member of codecentric AG, wrote a very interesting blog article called: “Java EE vs Spring. Or: What is a standard?” Mirko states the following:
  • for him a standard is something that is established, accepted and dominant
  • following this definition only some of the Java EE APIs like the Servlet specification can be considered as a standard, because they are widely applied in the Java production technology landscape
  • he looks in the past saying that there was little investment protection in some of the Java EE Standard APIs, like for example the EJB specification (massive API changes over the last decade)
  • he also claims that JPA and JSF in their 1.0 Versions weren’t sufficient to fulfill the technical requirements in large scale enterprise development projects
  • he looks at CDI as another young standard that needs to proove a long term stability before it can be considered as a standard IOC mechanism in Java enterprise applications
  • consequently, his conclusion for the moment is: Sping and Hibernate are still “the de-facto” standards for Java enterprise development
Mirko describes a valid perspective. Another valid perspective is the following: all (and only) APIs specified and released in a Java Specification Request (JSR) can be considered as standard. Application server vendors build their products according to these JSRs. Therefore, Java developers can build web applications that run on any application server plattform if they use these standard APIs. In Java EE 6 they can build enterprise scale web applications without any further dependency to a third library. The result is a very light weight web application (WAR or EAR file) that only contains the code that you have developed. That’s the Java EE case and that’s also valid and conclusive.
When you have to decide which APIs to use in your programming model, what would be the most important thing to you? There are lots of decision parameters like simplicity, completeness of the API, prooved production stability and many more. We have made a long list of parameters in our study. Some of them were more important then others, those were: maturity level of the API, supplier independence, production readiness, investment protection and shared judgement.
Life cycle of Standard APIs
Our assumption is that every API walks through an idealized life cycle when it enters the Java EE Standard (we observed that in the past). Those phases are: Newby, Storm, Stabalize, Mature, Dead. The first (Newby) Version 1.0 of the Standard API has little functionality. Typically it is not sufficient to fullfill the technical requirements for functionality and performance of large scale development projects. This is Mirko’s argument against CDI or JPA 1.0. Some use these APIs, but they also have to program many work arounds to get the full functionality they need (e.g. for 2nd level caching in JPA 1.0).

The lessons of these phase make their way into the subsequent API versions and therefore – for a while – the API gets instable. Functionality is added, APIs are reduced adopted, simplified and so on. This turbulent and uncertain storming phase leads to increasing migration costs if customers want to follow the standard. Even if the 2.0 Version is downwoards compatible, using the nice new features instead of the many workarounds means refactoring efforts. If the API is not downwoards compatible API changes enforce migration effort, there is no choice. After a while however the API gets mature and these refactoring costs decrease, the API entered the phase of stabalization.

A mature API has constantly low costs of migration and refactoring because no fundamental changes are applied. After a while a technology is not used anymore, because it’s replaced by other innovative APIs. The technology is dead – there is no investment anymore in these APIs, the community stopped the project. Image 1 shows the idealized API life cycle.

Image 1: Idealized life cycle of Java EE APIs
The key assumption of the life cycle model is: the earlier you decide to use an API standard the more refactoring cost you may probably pay when the API is enhanced in subsequent releases. So the advice is: you have to judge the state of the (Java EE) API in the life cycle. Then you decide whether you want to use mature APIs and lower refecatoring costs. Or whether you want to be one of the pioneers using the technology strait away. One advantage of early adoption may be early achievement of higher development efficiencies or higher integration with other standard APIs or developing consulting knowledge.
We have decided to use mature APIs only, we do not want to have the migration costs associated with “Newby” state APIs. Our level of trust is rather low, because we have suffered a lot in the EJB era. If we look at the history of some Java EE standards, the changes associated with stabilization of the API were enormous. Therefore we prefer to wait until the API is mature and is a prooven technology for large application systems in production. If we believe the Java EE API is mature we consider to use it.
Independence (development, operations and OE supplier)
Another important factor in architectural decision making to us: we want to maximize flexibility for subsequent architecural, design or implementation decisons. What do I mean by that? If, for instance, you choose a technology stack that is part of your application server then your application development department, your infrastructure people and your original equipment (OE) vendor will have a very close relationship. Why? Because new application server releases consist of new API versions that you use in your business application. The consequence is that you may have to change your exisiting code when you decide to use a new version of your application server. All this reduces flexibility.
Also, the OE vendor may rush you to migrate because “if you want to have this unique monitoring or integration feature of our application server you will have to use the very latest release of our XY Java EE server”. OE suppliers often have an inherent interest in that they want you to use their latest releases. For them it’s simply cheaper to support fewer production releases. It generates less maintenance costs and higher consultancy revenue for them.
We run over 50 Java EE applications in production. For the described reasons it is very important to us to stay independent of the runtime infrastructure. Therefore we often prefer a “layer between” our business applications and the application server. In other words: we usualy do not use Newby APIs directly, we usually have a wrapper API hiding them (see Image 2). 

This wrapper is used as API to build the business applications. The wrapper API could be the Spring Framework, or your own set of custom framework APIs. This way it’s easier and more efficient to make required changes when we moove to new application server releases or Java EE versions respectively. The wrapper absorbes Java EE API changes and saves us from the burden to change 50 applications. Instead, we do the changes once in a central place. Our development groups are not affected by application server upgrades. OE suppliers and the Java Communication Process (JCP) do not influence our decisions and efforts.

Production-readiness of infrastructure (or: now or later?)
Is there a production ready release of your application server that implements the new Java EE 6 standard? In our case (IBM WebSphere) we do not have any Java EE 6 Version available on Z Series. So there is only little sense in thinking about Java EE 6 if we can’t run our applications in production yet. You have to decide whether you want to use a technology now or later when it is available. CDI (JSR 299/330) as IOC mechanism for example is not mature enough for large applications. Therefore you may have to choose alternatives like the Spring Framework or Google Guice to do the job, if you want to have the (effeciency) value brought to your clients now.
Investment Protection (or: downwoards compatability)
I already mentioned it earlier: using the Java EE API directly for many production applications, may be 50 or 100, will probably create lower flexibility in design and implementation decisions. The same arguments apply when we look at investment protection. To me investment protection is a lot about low technical (refactoring) costs over a specific period of time. You want to spend money to achieve business value, you want to concentrate on implementing business functions. You do not want to spend to much effort in technical necessities (e.g. release upgrades, platform migrations, develop custom APIs). To achieve this choosing the right development API is critical. According to our life cycle model a good option is to choose APIs at the beginning of a long maturity phase in the life cycle. This lowers refactoring cost, thus increases investment protection.
We have already explained that Java EE does not only provide mature APIs. CDI, for example, is not mature in its JSR 299/330 version. A possible solution to that dilemma is to combine APIs from different sources, you could configure your own set of APIs for your business applications. If you use your own set of real standard APIs, then you protect your investment.

I am saying your own set because you may use a mixed technology stack (Image 2): some mature Java EE APIs (e.g. Servlets, JPA 2.0), some de-facto standards (e.g. Spring IOC) and some proprietary custom APIs that you have developed as wrappers around Newby Java EE APIs. The most important thing is that those APIs support  downwoards compatability for your production applications. You have to find a set of APIs that saves you from large migration efforts when you want to move to new Java EE application server releases.

Image 2: Mixed technology stack for Java enterprise development
 
Shared judgement
Something I do when I make decisions is shared judgement. What do other experts think? What ideology do they have? What interest do they have to make the one or the other recomendation? If you look at the large Java enterprise development framewors like Spring Framework you can observe that they use standard Java EE APIs, but only those that they consider as being mature. That’s a good hint for me whether or not to use a specific API. It does not metter whether you look at Spring, or whether you observe other frameworks. The point is that you can validate your opinion against the opinions of other prooved (preferably independent) experts.
Summary
There is a long list of parameters when you decide what technology stack to use. Those I have described in this article were very imprtant ones in our decision making process. Our conclusion is that the best way forward for now is to use a mixed technology stack. Some APIs are de-facto standards, some are Java EE standards, others are custom APIs that we have developed. Our main objective is to stay flexible at a constantly low level of refactoring costs over time.
A last thought on standards: Have you ever asked yourself whether it’s really important to follow the standard? Sometimes I have the impression that – to some people – using a standard is something that is close to absolute truth, something that is a universally right thing to do. Water is wet, the sky is blue and using a standard is right. You know what I am trying to say? How did all those de-facto standards like Spring and Hibernate became standards? 

The answer is: because someone had the courage to use it and others (including Java EE) followed. A “standard” is what a large part of the community uses to run large applications in production. A standard is not necessarily a Java EE standard. In the past Java EE standards followed the de-facto standard frameworks (e.g. Hibernate, Spring). There is a high probability that any new technologies first reach a certain level of maturity in open source frameworks. Then they will become Java EE standards. That’s because the vast majority of Java technology innovation has its source in the community – at least for the last decade.

Reference: Java EE 6 vs. Spring Framework: A technology decision making process from our JCG partner Niklas.

分享到:
评论

相关推荐

    spring-framework-4.1.0.RELEASE官方完整包加官方文档

    Spring Framework作为Java领域中的核心框架,以其强大的功能和灵活的设计理念,深受广大开发者喜爱。本篇文章将聚焦于Spring Framework 4.1.0.RELEASE版本,详细阐述其特性、核心组件以及如何利用官方提供的完整包和...

    Apress.Pro.Java.EE.Spring.Patterns.Aug.2008.rar

    《Apress.Pro.Java.EE.Spring.Patterns.Aug.2008》这本书是关于Java企业级应用和Spring框架设计模式的深度探讨。该压缩包包含了2008年8月出版的完整电子书版本,主要文件为"Apress.Pro.Java.EE.Spring.Patterns.Aug....

    spring-framework-2.5-rc2-with-dependencies\spring-framework-2.5-rc2\spring-framework-2.5-rc2源代码

    总之,Spring Framework 2.5 RC2的源代码是一个宝贵的资源,它不仅展示了Spring如何优雅地解决企业级开发中的问题,也为开发者提供了深入学习Java EE、Java、Spring和Struts等技术的实践素材。通过分析和研究这些...

    Professional.Java.Development.with.the.Spring.Framework

    《Professional Java Development with the Spring Framework》是一本专为Java开发者准备的权威指南,它深入探讨了Spring框架在专业Java开发中的应用。Spring是Java企业级应用程序开发中的一个核心框架,以其模块化...

    Java.EE.Web编程:Eclipse平台(2/2)

    [Java.EE.Web编程:Eclipse平台].李芝兴等.扫描版.part2.rar 共两部分,这是第二部分

    Spring Recipes: A Problem-Solution Approach, Second Edition

    This book is for Java developers who would like to rapidly gain hands-on experience with Java/Java EE development using the Spring framework. If you are already a developer using Spring in your ...

    Spring-3-2-1 jar包+源码

    Spring 3.2.1版本在当时是一个稳定且广泛使用的版本,它提供了许多增强的功能,包括更好的类型安全的依赖注入,以及对Java EE 6的支持。学习和研究这些源码,对于提升Java开发技能和理解企业级应用的构建有着极大的...

    官方原版完整包 spring-framework-5.3.6.RELEASE-dist.zip

    Spring Framework 是一个广泛使用的Java应用程序开发框架,它以其模块化、灵活性和强大的功能而闻名。5.3.6.RELEASE是该框架的一个稳定版本,包含了众多优化和改进。本资源包含三个子文件:spring-5.3.6-dist.zip、...

    Apress.Beginning.Java.EE.6.with.GlassFish.3.2nd.Edition

    Written by an expert member of the Java EE 6 specification request and review board in the Java Community Process (JCP), this book contains the best information possible, from an expert’s perspective...

    Java.EE.7.Development.with.NetBeans.8

    This is a practical guide that covers how to leverage NetBeans 8 functionality to quickly and easily develop enterprise applications compliant with the Java EE 7 standard. Table of Contents Chapter 1...

    Java EE设计模式:Spring企业级开发最佳实践

    Java EE 设计模式:Spring 企业级开发最佳实践 Java EE 设计模式是指在 Java 企业版(Java Enterprise Edition)中应用的设计模式,旨在提高软件系统的可维护性、可扩展性和可重用性。Spring 是当前最流行的 Java ...

    spring framework

    相比于传统的Java EE开发方式,Spring框架更加简洁高效,能够显著提高软件开发的速度和质量。 #### 二、Spring框架产生的背景 随着互联网的发展,开发基于Browser/Server模式的应用程序变得越来越重要。传统的J2EE...

    Java.EE.Web编程:Eclipse平台

    全面介绍java EE技术 介绍Servlet、JSP、数据库技术基础 重点讲解Hibernate、Struts、Spring 轻型框架整合应用案例

    spring-framework-4.1.5.RELEASE

    总结起来,Spring Framework 4.1.5.RELEASE版本是一个全面、成熟的Java企业级开发解决方案,它的各个模块协同工作,为开发者提供了强大而灵活的工具,降低了开发复杂度,提升了应用的可维护性和扩展性。无论是Web...

    spring-framework-4.0.4.RELEASE-jar包

    Spring Framework 4.0.4.RELEASE还强化了对Java EE标准的支持,包括Servlet 3.1、JMS 2.0等,使它能更好地融入企业级应用环境。同时,这个版本对异步处理和多线程的支持也有所提升,提高了系统的并发性能。 在测试...

    spring framework reference 3.0.0 RC1

    - **Java EE 6的早期支持**:为开发者提供了与Java EE 6集成的能力,包括对嵌入式数据库的支持。 ### III. 核心技术详解 #### 1. IoC容器 IoC容器是Spring Framework的核心,负责管理对象的生命周期和依赖关系。...

    spring-framework-5.2.25.RELEASE.tar.gz

    Spring Framework是Java开发领域中最受欢迎的开源框架之一,以其模块化、松耦合和强大的功能特性,深受开发者喜爱。5.2.25.RELEASE作为Spring框架的一个稳定版本,为开发者提供了许多改进和新特性。本文将对这个版本...

    spring-framework-5.0.x.zip

    Spring框架的设计理念是简化Java EE开发,提高代码的可测试性和可维护性。 二、Spring 5.0主要改进 1. Java 8支持:Spring 5.0全面支持Java 8,包括Lambda表达式、Stream API以及日期时间API,使代码更加简洁、易读...

Global site tag (gtag.js) - Google Analytics