`
xnnyygn
  • 浏览: 44141 次
  • 性别: Icon_minigender_1
  • 来自: 上海
最近访客 更多访客>>
社区版块
存档分类
最新评论

摘录的Grails的首段,非常不错的一段

阅读更多
Have you ever wanted a Java web application framework that required less configuration? Maybe
one that magically reads your mind and guesses what you want to achieve based on the busi-
ness logic rather than mountains of surrounding configuration. The amount of work it takes to
develop web applications in current Java web application frameworks has seen a dramatic rise
in code-generation utilities whose sole purpose is to generate surrounding configuration or
jump-start application development. If you’re reading this book as a developer interested in
Grails I hazard a guess that you’ve experienced the often cumbersome multistep process it can
be to work with web frameworks on the Java platform.
     Trust me though, you’re not alone. The search has been on for years to transform the land-
scape of the way we develop web applications with the Java platform and extends way beyond
just the frameworks themselves, but into the entire stack. It started with the initial specification
of the much heralded Java 2 Enterprise Edition (J2EE) stack, described lovingly by Bruce Tate2
as an “elephant.” The specification created a configuration-heavy, time-consuming environ-
ment, and acknowledgement of these mistakes were made particular in the area of Enterprise
JavaBeans (EJB).

      Before the mistakes could be corrected, the open source community reacted with frame-
works such as Spring, inspired by Rod Johnson’s book J2EE Development Without EJB, allowing
simplified development models, while ease of use in the object-relational mapping (ORM)
arena was driven by simplified POJO (Plain Old Java Object) frameworks such as Hibernate.
      It was not, however, the statically typed Java world that prompted the real innovation in
web framework design. Dynamic languages were already gaining prominence in other arenas,
but thanks to frameworks such as Ruby on Rails (henceforth simply referred to as Rails), Django,
and TurboGears, particular focus has been placed on their usage as web application frameworks.
After years of being ridiculed as toys, dynamic languages finally started to turn heads and kick-
start a rethink into how web applications can be simplified.
      Built with scripting languages such as Ruby and Python, this new generation of web frame-
works introduced the concept of “convention over configuration” in an object-oriented
environment. Instead of configuring everything via reams of XML, the convention within the
files or code itself dictated how the application was configured. Suddenly there was no need to
configure, and with that, the time spent on a typical development cycle was dramatically reduced.
Given their dynamic nature, the frameworks in question provided the ability to save a particular
class or resource and have the changes automatically propagated without any need to restart
an application server. Applications could be developed with a save/reload paradigm, and state
could be maintained; agile and iterative development had finally arrived.
      Since much of the functionality of these frameworks can be configured and dispatched at
runtime, the available APIs are significantly richer and often more domain-specific.
      Scripting languages themselves have always been popular for the development of web
applications because of their ability to realize changes immediately (no deployment step) and
their often more simple and concise syntax. Unfortunately they’ve rarely been seen as appro-
priate for usage on large-scale systems, usually due to a lack of object-oriented features and
issues with performance and scalability and/or legacy integration.
      Given the advancements in the platforms in which these languages operate and the hard-
ware on which they are executing, these issues have become less and less of a problem. Modern,
dynamic virtual machines (VMs) suffer from fewer of these deficiencies and have become a real
viable alternative, attracting many Java developers away from the Java platform.

Over the past few years the web has seen significant change. The Internet bubble burst, search
became the doorway to the web, and the rise of weblogs and open information saw the web
become even more opinionated. On the technology front, one of the most significant changes
to occur was the appearance of web applications that come close to rivaling the desktop
environment. Web developers had long been dismissed as mere hackers compared to their
counterparts in the desktop GUI programming world. But this was all about to change, and it
all started with essentially one object: the XMLHttpRequest.
      The XMLHttpRequest object has, in reality, been around for quite some time. Microsoft
started the revolution by including it as a custom ActiveX object to support its Outlook web
access service that integrated with Microsoft’s Exchange Server.
      Essentially it allowed the client (the browser) to query the server without the necessity to
reload the whole page. It achieved this feat by sending an asynchronous request to the server
via JavaScript. Although, strictly speaking, anything could be sent and received using the tech-
nology, XML was the initial technique used. Web applications could suddenly be event-driven,use drag-and-drop, perform autocompletion that integrates with server components, and do
all sorts of fancy things previously only seen in frameworks such as Swing. Applications such as
Gmail and Flickr even prompted users to stop using their desktop equivalents for mail and
photo organization, respectively.
      Since then, the word Ajax (Asynchronous JavaScript and XML) was coined and the web
has been abuzz with it ever since; Web 2.0 was born. The significance of this technology cannot
be underestimated. It has brought capabilities to web browsers thought only possible in desktop
environments. However, it has also increased the complexity, development time, and expertise
required to develop web applications.
      Luckily, with this influx of software engineering expertise into the client-side programming
world, JavaScript libraries have advanced at a staggering pace, adopting object-oriented tech-
niques to create simple reusable components. However, it is not just the client side that has
had to adapt; a much unwanted side effect of Ajax applications is the increased number of requests
that they produce. Ajax applications are for the most part loathed by network administrators
because of the load placed on the servers, but equally undesirable for developers because the
frameworks and tools we know and love are designed around a sequential request/response
model.
      Furthermore, existing Java frameworks have followed the traditional develop-compile-
deploy paradigm, a process that becomes slower as the number of requests increase and the
size of the project grows. Since Ajax applications inevitably end up being larger, in terms of
project size, than traditional web applications, this has huge implications on the compilation
and packaging time required to deploy a web application.
      To compound these already significant factors, testing rich application flows started to
become problematic. With much of the state held on the client, having to reload your browser
due to an application restart could set you several steps back in any given use case. The reality
was that the frameworks needed to adapt. Adapting is not the easiest thing to achieve in the
statically typed world of the Java Virtual Machine (JVM) where classes tend to be compiled
once. This is in complete contrast to dynamic languages that follow either an interpreted model
or automatically update resources for you at run time.
      The timing of the arrival of Ajax was perfect for the aforementioned dynamic-language-
based frameworks as they began offering solutions that wowed developers with support for devel-
oping Ajax applications and automatic reloading. Tight integration with JavaScript libraries such
as Prototype and Script.aculo.us allowed developers to easily perform asynchronous requests,
implement element observers, and perform interesting effects.
      In addition, features such as the iterative nature of development, no configuration or deploy-
ment cycle, and the convention-based approach meant that it was an extremely appealing
environment to develop with.
      Are the changing times a sign of not only a shift in the way we build applications, but also
the technologies we use to build them? Is this the end of Java as we know it? And is Java venturing
down the road to become the next COBOL? Many believe so; but the reality is quite different.

Unfortunately, however wonderful these dynamic frameworks are, they remain inaccessible to
thousands upon thousands of organizations for one simple reason: they do not integrate seam-
lessly with Java. Java integration itself goes far beyond simply executing within the context of
the JVM. It means API integration, architectural integration (security, profiling, debugging, etc.),object model integration, Java Enterprise Edition integration, and knowledge and mindshare
integration (yes company X already has dozens of Java developers if not more).
     Organizations across the world have a significant investment in Java technology as a plat-
form for their business. They’ve invested in application servers, support contracts, training
materials, employees, and hardware optimized for the JVM. All of this amounts to too much to
just walk away from to embrace the latest hot framework.
     The Java industry is a huge multibillion dollar behemoth that encompasses not only web
applications but server applications, desktop applications, smart cards, handheld devices,
mobile phones, set-top boxes—this list could go on forever. Conferences dedicated to Java are
some of the largest technology events in the world, proving to be the envy of other technology
industries.
     The size of the industry is sometimes difficult to fathom and it’s built on the strength of the
platform—a platform that has ensured the Java language has more open source libraries than
any other language on the planet.
     Need a library to programmatically create PDF documents? You have FOP or iText. Want a
choice of web frameworks that cover every potential use case? Java has dozens. Need a platform
to build service-oriented architecture (SOA) applications? The Java platform has the solution
for you.
     For many, Java and its sibling in the enterprise world, Java Enterprise Edition, have been
the platform of choice, having reached an unrivalled level of maturity and industry support.
Java application servers have become robust, scalable managed environments with advanced
deployment capabilities, security controls, and web services integration.
     Unfortunately, with all this power, Java web applications can be a pain to develop when
compared to their dynamic rivals from Ruby, Python, and PHP. Much of the time involved in
creating one of these beasts is spent on configuration, the build process, and deployment. Java
developers have strived to create build automation tools that make this process easier, including
tools that generate source code. This has improved even further with the advent of Java 5 anno-
tations support. But developing Java web applications for the most part remains quite a complex,
configuration-heavy experience.
     Nevertheless it would be simply unjust if the Java community were denied access to a
framework with the same capability as those available on dynamic language platforms.
     Since there are several dynamic languages that run happily on top of the JVM, such as
Jython, JRuby, and Groovy, it seems imminently possible. Luckily the Java community tends to
take the good ideas and make them better; enter Grails.

分享到:
评论

相关推荐

    Grails Grails Grails

    Grails 是一个基于 Groovy 语言的开源Web应用程序框架,它构建在Java平台之上,旨在简化开发过程并提高生产力。Grails 的设计深受Ruby on Rails的影响,提供了MVC(模型-视图-控制器)架构模式,允许开发者快速构建...

    grails-用户手册

    Grails的URL映射非常灵活,可以在`UrlMappings.groovy` 文件中定义,使URL更加语义化,便于SEO优化。 八、构建与部署 Grails使用Gradle作为构建工具,提供了`grails war` 命令生成可部署的WAR文件,方便在各种Java...

    Grails权威指南 Grails权威指南

    《Grails权威指南》是一本全面深入探讨Grails框架的专著,旨在帮助读者掌握这一强大的Web开发工具。Grails是一种基于Groovy语言的开源框架,它为构建现代、高效的应用程序提供了简洁高效的解决方案。本指南针对不同...

    第一个grails程序

    在"第一个grails程序"中,我们通常会看到一个典型的Grails项目结构,包括以下几个关键部分: 1. **src/main/groovy**:这个目录存放所有Groovy源代码,包括应用程序的主要业务逻辑和控制器。 2. **src/main/...

    Eclipse下搭建Grails项目

    Grails是一个基于Groovy语言的开源Web应用框架,它简化了开发过程,尤其适合快速构建动态网站。在Eclipse中搭建Grails项目可能相对复杂,但通过以下步骤,即使是初学者也能顺利进行。 1. **Grails环境安装** - ...

    grails中文入门简介

    Grails是一个基于Groovy语言的全栈框架,它遵循约定优于配置的原则,并且紧密集成Spring和Hibernate等流行的Java库,简化了开发流程。Grails在IT行业中尤其受到重视,因为它能够帮助开发者快速搭建并部署基于MVC模式...

    eclipse开发grails插件

    对于Grails开发,我们需要的是Eclipse中的Grails插件,它能够提供对Grails项目的创建、运行、调试等一系列功能。 **Grails**是基于Groovy语言的全栈式Web开发框架,它借鉴了Ruby on Rails的设计理念,提供了快速...

    grails快速开发web

    #### 一、Grails 概述 Grails 是一种基于 Groovy 的开源应用框架,用于简化 Web 应用程序的开发过程。它采用约定优于配置的原则,这使得开发者可以更快地创建功能丰富的 Web 应用程序。Grails 的设计灵感来源于 ...

    grails-2.4.4.zip

    Grails 2.4.4 是一个基于Java的开源Web应用框架,它利用Groovy语言的强大特性,为开发者提供了一种高效、灵活的开发环境。这个压缩包“grails-2.4.4.zip”包含了完整的Grails 2.4.4版本,使得开发者可以直接将其集成...

    Grails中文参考手册

    Grails 是一个基于 Groovy 语言的开源 web 应用程序框架,它构建在 Java 平台上,旨在提高开发效率,简化常见 Web 开发任务。Grails 遵循 Model-View-Controller (MVC) 架构模式,允许开发者快速构建动态、数据驱动...

    grails-core源码

    Grails,作为一个基于Groovy语言的全栈式Web应用框架,深受开发者喜爱。它以其简洁的语法、丰富的插件系统以及对Spring和Hibernate的无缝集成,为开发高效、灵活的Web应用提供了便利。本文将深入探讨Grails的核心...

    Groovy轻松入门——Grails实战基础篇

    本篇文章将详细介绍如何搭建Grails开发环境以及如何创建一个简单的Grails应用程序。 ### 一、搭建Grails环境 在开始搭建Grails环境之前,我们首先需要确保已经安装了Java环境。因为Grails是基于Groovy的,而Groovy...

    Grails1.1中文文档

    《Grails 1.1 中文文档》是一个非常宝贵的资源,尤其对于国内的开发者来说,由于Grails在中文社区中的资料相对较少,这份文档的价值不言而喻。Grails是一个基于Groovy语言的开源Web应用框架,它借鉴了Ruby on Rails...

    Groovy和Grails配置方法

    #### 一、Groovy与Grails简介 Groovy是一种强大的面向对象编程语言,它运行在Java平台上,并且能够直接与Java代码进行交互。Groovy支持函数式编程特性,拥有丰富的语法糖以及简洁的代码风格,这使得它非常适合用于...

    eclipse插件grails(groovy)

    Eclipse 插件 Grails(Groovy)是一个强大的开发工具,它使得在Eclipse环境中进行Groovy和Grails应用的开发变得更为便捷。Groovy是一种动态、面向对象的编程语言,而Grails则是一个基于Groovy的开源Web应用框架,...

    grails中文参考手册

    《Grails中文参考手册》是针对Groovy编程语言构建的Web应用框架——Grails的一份详尽学习资料。Grails以其高效、灵活和强大的特性,成为开发人员在Java平台上构建Web应用的热门选择。这份手册旨在帮助初学者快速上手...

    Grails标签

    Grails标签 主要介绍了grails的标签的一个帮助文档

    Grails入门指南 -- 针对grails1.0.4更新

    #### 一、Grails框架简介 - **背景**: Grails是一个基于Groovy语言的开源Web应用框架,适用于Java平台。它旨在简化开发过程,提高开发效率,尤其受到那些希望保留Java环境同时寻求更高效开发方式的开发者的欢迎。 ...

Global site tag (gtag.js) - Google Analytics