Spring Python - Reference Documentation
Total Page:16
File Type:pdf, Size:1020Kb
Spring Python - Reference Documentation Version 1.0.1.BUILD-20101109171136 Copyright © 2006-2009 Greg Turnquist Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically. Table of Contents Preface................................................................................................................................................ 1.Overview........................................................................................................................................ 1.1.KeyFeatures.........................................................................................................................1 1.2.WhatSpringPythonisNOT .................................................................................................. 2 1.3.Support.................................................................................................................................2 1.3.1.ForumsandEmail ......................................................................................................2 1.3.2.IRC ...........................................................................................................................2 1.4.Downloads/SourceCode ......................................................................................................2 1.5.Licensing..............................................................................................................................3 1.6.SpringPython'steam .............................................................................................................3 1.6.1. How to become a team member ................................................................................... 3 1.7.DeprecatedCode ...................................................................................................................4 2.TheIoCcontainer .......................................................................................................................... 2.1.Container..............................................................................................................................6 2.1.1.ObjectContainervs.ApplicationContext ......................................................................7 2.1.2. Scope of Objects / Lazy Initialization ........................................................................... 7 2.2.Configuration........................................................................................................................7 2.2.1. XMLConfig - Spring Python's native XML format ....................................................... 8 2.2.2. PythonConfig and @Object - decorator-driven configuration ........................................ 14 2.2.3. PyContainerConfig - Spring Python's original XML format ........................................... 15 2.2.4.SpringJavaConfig.......................................................................................................15 2.2.5.MixingConfigurationModes ......................................................................................17 2.3.ObjectFactories ....................................................................................................................18 2.4.TestableCode .......................................................................................................................18 3.AspectOrientedProgramming ...................................................................................................... 3.1.Interceptors...........................................................................................................................20 3.2.ProxyFactoryObjects ...........................................................................................................22 3.3.Pointcuts...............................................................................................................................22 3.4.InterceptorChain ..................................................................................................................23 3.5.CodingAOPwithPurePython ............................................................................................... 23 4.DataAccess .................................................................................................................................... 4.1.DatabaseTemplate.................................................................................................................25 4.1.1.TraditionalDatabaseQuery .........................................................................................25 4.1.2.DatabaseTemplate .....................................................................................................25 4.1.3.WhatisaConnectionFactory? .................................................................................... 26 4.1.4. Creating/altering tables, databases, and other DDL ....................................................... 26 4.1.5.SQLInjectionAttacks ................................................................................................26 4.1.6. Have you used Spring Framework's JdbcTemplate? ...................................................... 26 5.TransactionManagement .............................................................................................................. 5.1.Solutionsrequiringtransactions..............................................................................................28 5.2.TransactionTemplate .............................................................................................................29 5.3.@transactional ......................................................................................................................29 5.3.1.@transactional(["PROPAGATION_REQUIRED"])... ..................................................31 6.Security.......................................................................................................................................... 6.1.SharedObjects ......................................................................................................................33 6.2.Authentication ......................................................................................................................33 6.2.1.AuthenticationProviders..............................................................................................33 6.2.2.AuthenticationManager...............................................................................................35 Spring Python ii Spring Python - Reference Documentation 6.3.Authorization........................................................................................................................35 7.Remoting........................................................................................................................................ 7.1. Remoting with PYRO (Python Remote Objects) ..................................................................... 39 7.1.1. Decoupling a simple service, to setup for remoting ....................................................... 39 7.1.2. Exporting a Spring Service Using Inversion Of Control ................................................ 40 7.1.3. Do I have to use XML? ............................................................................................... 41 7.1.4. Splitting up the client and the server ............................................................................ 42 7.2.RemotingwithHessian ..........................................................................................................44 7.3.High-Availability/ClusteringSolutions ...................................................................................44 8.SpringPython'spluginsystem ....................................................................................................... 8.1.Introduction ..........................................................................................................................46 8.2. Coily - Spring Python's command-line tool ............................................................................. 46 8.2.1.Commands.................................................................................................................46 8.3.OfficiallySupportedPlugins ..................................................................................................47 8.3.1.gen-cherrypy-app .......................................................................................................48 8.4.Writingyourownplugin ........................................................................................................48 8.4.1.Architectureofaplugin ..............................................................................................48 8.4.2.CaseStudy-gen-cherrypy-appplugin ......................................................................... 49 9.Samples.......................................................................................................................................... 9.1.PetClinic...............................................................................................................................52 9.1.1.Howtorun.................................................................................................................52 9.2.SpringWiki ..........................................................................................................................53