You are previewing Programming Grails.
O'Reilly logo
Programming Grails

Book Description

Responding to the demand for more in-depth Grails coverage that goes beyond the typical use cases, this book helps experienced web developers learn Grails best practices for building and deployment, debugging and problem solving, creating and using Grails plugins, as well as testing, security, performance, scaling, tuning, and monitoring.

Table of Contents

  1. Special Upgrade Offer
  2. Preface
    1. Who This Book Is For
    2. Other Resources
    3. Conventions Used in This Book
    4. Using Code Examples
    5. Safari® Books Online
    6. How to Contact Us
    7. Acknowledgments
  3. 1. Introduction to Groovy
    1. Installing Groovy
      1. Groovy Console
    2. Optional Typing
    3. Collections and Maps
    4. Properties
      1. Using the AST Browser
      2. Decompiling with JD-GUI
      3. Decompiling with javap
    5. Closures
      1. Interface Coercion
      2. Programmatic Closures
      3. Owner, Delegate, and this
    6. Groovy’s Contributions in the War Against Verbosity
      1. Constructors
      2. Checked Exceptions
      3. Groovy Truth
      4. Semicolons
      5. Optional Return
      6. Scope
      7. Parentheses
      8. Default Imports
    7. Differences Between Java and Groovy
      1. Array Initialization
      2. in and def Keywords
      3. do/while Loops
      4. for Loops
      5. Annotations
      6. Groovy Equality
      7. Multimethod Dispatch
    8. Groovy Strings
    9. Static this
    10. The Groovy JDK (GDK)
      1. DefaultGroovyMethods and InvokerHelper
    11. Metaprogramming and the MOP
    12. Adding Methods
      1. Intercepting Method Calls
        1. getProperty and setProperty
        2. methodMissing and propertyMissing
    13. Operators
      1. Null-Safe Dereference
      2. Elvis
      3. Spread
      4. Spaceship
      5. Field Access
      6. as
      7. in
      8. Method Reference
    14. Overload Your Operators
      1. Being Too Groovy
    15. def Considered Harmful
    16. Closures Versus Methods
    17. TypeChecked, CompileStatic, and invokedynamic
  4. 2. Grails Internals
    1. Installing Grails
      1. Creating an Application
        1. A nte about the work directory
        2. Running the application
    2. The Grails Command Line
    3. IDE Support
    4. Plugins
      1. Optional Plugins
        1. The cache plugin
        2. The database-migration plugin
        3. The hibernate plugin
        4. The jquery plugin
        5. The resources plugin
        6. The tomcat plugin
        7. The webxml plugin
      2. Core Plugins
        1. The codecs plugin
        2. The controllers plugin
        3. The converters plugin
        4. The core plugin
        5. The dataSource plugin
        6. The domainClass plugin
        7. The filters plugin
        8. The groovyPages plugin
        9. The i18n plugin
        10. The logging plugin
        11. The mimeTypes plugin
        12. The scaffolding plugin
        13. The services plugin
        14. The servlets plugin
        15. The urlMappings plugin
        16. The validation plugin
    5. Conventions
      1. Controller and View Conventions
        1. Data binding conventions
        2. Layout conventions
        3. URI conventions
      2. Service Conventions
      3. Domain Class Conventions
    6. More Information
  5. 3. Persistence
    1. Data Mapping
      1. Nonpersistent Domain Classes
    2. Data Validation
      1. Custom Validation
      2. Extreme Custom Validation
      3. Validation Plugins
      4. Friendly Error Messages
      5. Blanks Versus Nulls
    3. Transients
    4. Mapping Collections
    5. Querying
    6. Saving, Updating, and Deleting
    7. NoSQL Support
  6. 4. Spring
    1. Inversion of Control and Dependency Injection
      1. Complex Dependency Configuration Using Spring SpEL
      2. Manually Injecting Dependencies at Runtime
    2. Bean Scopes
    3. Transactional Services
      1. @Transactional
      2. Transaction Proxies
        1. Unintentionally bypassing the bean proxy
      3. Transaction Utility Methods
    4. Bean Life Cycles and Interfaces
    5. Bean Postprocessors
      1. A Groovier Way
    6. Bean Aliases
    7. Internationalization
    8. Resources
      1. Resource Dependency Injection
      2. ResourceLocator
    9. Data Binding and Validation
      1. Data Binding
      2. Validation
    10. Database Persistence
      1. Thread-Local Holders
      2. JdbcTemplate
      3. Other Database Support
    11. Spring MVC
      1. Filters
      2. Using Spring MVC Controllers
    12. Remoting
      1. Client Access
    13. JMS
    14. EJBs
    15. JMX
    16. Email
    17. Cache Abstraction
  7. 5. Hibernate
    1. Mapping Domain Classes
    2. Dialects
      1. Dialect Autodetection
      2. Dialect Customization
    3. Hibernate Without GORM
      1. hibernate.cfg.xml
      2. HibernateUtil
      3. Author
      4. Book
      5. Experimenting with the APIs
    4. The Session
      1. withSession
      2. withNewSession
    5. Open Session in View
      1. Disabling OSIV
    6. Custom User Types
    7. Optimistic and Pessimistic Locking
    8. Accessing the Session’s Connection
    9. schema-export
    10. SQL Logging
    11. Proxies
      1. equals, hashCode, and compareTo
    12. Caching
      1. Examples
      2. Caching API
        1. evicting
        2. Accessing caches
      3. Query Caching Considered Harmful?
    13. HQL
      1. executeQuery
      2. Query Syntax
      3. Report Queries
        1. Single properties
        2. Multiple properties
        3. new list
      4. Aggregate Functions
      5. Expressions
      6. Collections
    14. Collections Performance
      1. The Solution
    15. Session.createFilter()
    16. Custom Configurations
    17. Mapping Views and Subselect Classes
      1. Subselect Domain Classes
      2. Selecting with a POGO
    18. get(), load(), and read()
      1. get()
      2. load()
      3. read()
    19. Performance
      1. Caching
      2. Lazy Loading
      3. Transactional Write-Behind
  8. 6. Integration
    1. JMS
      1. XA Support with the Atomikos Plugin
    2. Mail
      1. Sending Email
      2. Sending Email Asynchronously
      3. Sending Email from Log4j
      4. Testing
    3. SOAP Web Services
      1. The Server Application
      2. The Client Application
      3. TCPMon
    4. REST
      1. TCPMon
    5. JMX
  9. 7. Configuration
    1. External config Files
      1. Loading the Configuration
      2. Partitioning Config Files
    2. Splitting resources.groovy
    3. Modularizing Within resources.groovy
    4. Environment-Specific Spring Beans
      1. Beans Closures in Config.groovy
    5. Options for BuildConfig.groovy
    6. Adding Additional Source Folders
      1. Extra Folders Under grails-app
  10. 8. Plugins
    1. Creating a Plugin
      1. Initial Steps
    2. The Plugin Descriptor
      1. Metadata
      2. Life Cycle Callbacks
        1. doWithWebDescriptor
        2. doWithSpring
        3. doWithDynamicMethods
        4. doWithApplicationContext
        5. onChange
        6. onConfigChange
        7. onShutdown
    3. Splitting Applications into Plugins
      1. Inline Plugins
    4. Building and Releasing
      1. Automated Testing
        1. A mini DSL to describe versions
        2. Continuous integration
        3. Testing scripts
    5. Running the Tests
    6. Custom Plugin Repositories
    7. Plugin Documentation
    8. Custom Artifacts
    9. Some Notes on Plugin Development Workflow
  11. 9. Security
    1. OWASP
      1. A1: Injection
        1. Command injection
      2. A2: Cross-Site Scripting (XSS)
        1. Remedies
        2. Best practices
      3. A3: Broken Authentication and Session Management
      4. A4: Insecure Direct Object References
        1. Remedies
      5. A5: Cross-Site Request Forgery
        1. Remedies
      6. A6: Security Misconfiguration
        1. Remedies
      7. A7: Insecure Cryptographic Storage
        1. Best practices
      8. A8: Failure to Restrict URL Access
      9. A9: Insufficient Transport Layer Protection
      10. A10: Unvalidated Redirects and Forwards
    2. Security Plugins
      1. spring-security-core
        1. Getting started
        2. Access control
    3. Other Plugins and Libraries
      1. AntiSamy
      2. ESAPI
      3. HDIV
    4. General Best Practices
  12. 10. The Cloud
    1. Cost Savings
    2. What You Give Up
    3. Cloud Foundry
      1. Database Applications
        1. Creating an application
      2. Scaling
        1. HTTP sessions
      3. NoSQL, RabbitMQ, and Searchable
      4. Monitoring and the Cloud Foundry UI Plugin
        1. The cloud-foundry-ui Plugin
    4. Heroku
      1. Database Applications
        1. Creating an application
      2. Scaling
        1. HTTP sessions
      3. Build Packs
    5. Other Providers
    6. Other Uses for Cloud Services
  13. 11. AOP
    1. Grails Filters
    2. HTTP Filters
    3. Groovy AOP
      1. Registering Metaclass Interceptors
      2. Error Code URL Mappings
    4. Spring AOP
      1. Enabling Spring AOP
      2. Defining AspectJ-Annotated Aspects
      3. Compile-Time Weaving
  14. 12. Upgrading Applications and Plugins
    1. Why Doesn’t the Upgrade Script Do More?
    2. A General Approach to Upgrading
      1. Upgrading Petclinic: A Case Study
        1. Step 1: Determine the changes in the application
        2. Step 2: Make the first round of changes in a new application
        3. Step 3: Make the second round of changes
        4. Step 4: Finishing up
        5. Running the upgrade script instead
    3. A Short History of Grails
      1. Grails 1.2
      2. Grails 1.2.2
      3. Grails 1.2.4
      4. Grails 1.3
      5. Grails 1.3.1
      6. Grails 1.3.2
      7. Grails 1.3.4
      8. Grails 1.3.6
      9. Grails 1.3.7
      10. Grails 1.3.8
      11. Grails 1.3.9
      12. Grails 2.0
      13. Grails 2.0.2
      14. Grails 2.1.x
      15. Grails 2.2.x
    4. Notes on Upgrading
  15. Index
  16. About the Author
  17. Colophon
  18. Special Upgrade Offer
  19. Copyright