diff --git a/doc/reference/src/misc.xml b/doc/reference/src/misc.xml index 77546dca..264c6b0c 100644 --- a/doc/reference/src/misc.xml +++ b/doc/reference/src/misc.xml @@ -1,182 +1,154 @@ - - - - Spring.NET miscellanea - - Introduction - - This chapter contains miscellanea information on features, goodies, caveats - that does not belong to any paricular area. - - - - PathMatcher - - Note, Spring.Util.PathMatcher is - currently only available in CVS, not the RC3 release. If you want to use these feature - please get the code from CVS - (instructions) - or from the download section of the - Spring.NET website that contains an .zip with the full CVS tree. - - - - Spring.Util.PathMatcher provides Ant/NAnt-like path name matching - features. - - To do the match, you use the method: - static bool Match(string pattern, string path) - - If you want to decide if case is important or not use the method: - static bool Match(string pattern, string path, bool ignoreCase) - - - General rules - - To build your pattern, you use the *, ? - and ** building blocks: - - - *: matches any number of non slash - characters; - - - - ?: matches exactly 1 (one) non slash/dot - character; - - - - **: matches any subdirectory, without - taking care of the depth; - - - - - - - - Matching filenames - - A file name can be matched using the following - notation: - foo?bar.* - matches: - fooAbar.txt -foo1bar.txt -foo_bar.txt -foo-bar.txt - does not match: - foo.bar.txt -foo/bar.txt -foo\bar.txt - - - The classical all files pattern: - *.* - matches: - foo.db -.db -foo -foo.bar.db -foo.db.db -db.db.db - does not match: - c:/ -c:/foo.db -c:/foo -c:/.db -c:/foo.foo.db -//server/foo - - - - - Matching subdirectories - - A directory name can be matched at any depth level using the following - notation: - **/db/** - That pattern matches the following paths: - /db -//server/db -c:/db -c:/spring/app/db/foo.db -//Program Files/App/spaced dir/db/foo.db -/home/spring/spaced dir/db/v1/foo.db - but does not match these: - c:/spring/app/db-v1/foo.db -/home/spring/spaced dir/db-v1/foo.db - - - You can compose subdirectories to match like this: - **/bin/**/tmp/** - That pattern matches the following paths: - c:/spring/foo/bin/bar/tmp/a -c:/spring/foo/bin/tmp/a/b.c - but does not match these: - c:/spring/foo/bin/bar/temp/a -c:/tmp/foo/bin/bar/a/b.c - - - You can use more advanced patterns: - **/.spring-assemblies*/** - matches: - c:/.spring-assemblies -c:/.spring-assembliesabcd73xs -c:/app/.spring-assembliesabcd73xs -c:/app/.spring-assembliesabcd73xs/foo.dll -//server/app/.spring-assembliesabcd73xs - does not match: - c:/app/.spring-assemblie - - - - - Case does matter, slashes don't - - .NET is expected to be a cross-platform development ... platform. So, - PathMatcher will match taking care of the case of the pattern - and the case of the path. For example: - **/db/**/*.DB - matches: - c:/spring/service/deploy/app/db/foo.DB - but does not match: - c:/spring/service/deploy/app/DB/foo.DB -c:spring/service/deploy/app/spaced dir/DB/foo.DB -//server/share/service/deploy/app/DB/backup/foo.db - - If you do not matter about case, you should explicitly tell the - Pathmatcher. - - Back and forward slashes, in the very same cross-platform spirit, are - not important: - spring/foo.bar - matches all the following paths: - c:\spring\foo.bar -c:/spring\foo.bar -c:/spring/foo.bar -/spring/foo.bar -\spring\foo.bar - - - - - - + + + + Spring.NET miscellanea + +
+ Introduction + + This chapter contains miscellanea information on features, goodies, + caveats that does not belong to any paricular area. +
+ +
+ PathMatcher + + Note, Spring.Util.PathMatcher is currently only available + in CVS, not the RC3 release. If you want to use these feature please get + the code from CVS (instructions) + or from the download section of the Spring.NET website that contains an + .zip with the full CVS tree. + + Spring.Util.PathMatcher provides + Ant/NAnt-like path name matching features. + + To do the match, you use the method: static bool Match(string pattern, string path) + + If you want to decide if case is important or not use the method: + static bool Match(string pattern, string path, bool ignoreCase) + +
+ General rules + + To build your pattern, you use the *, + ? and ** building blocks: + + + *: matches any number of non slash + characters; + + + + ?: matches exactly 1 (one) non slash/dot + character; + + + + **: matches any subdirectory, without + taking care of the depth; + + +
+ +
+ Matching filenames + + A file name can be matched using the following notation: + foo?bar.* matches: fooAbar.txt +foo1bar.txt +foo_bar.txt +foo-bar.txt does not match: foo.bar.txt +foo/bar.txt +foo\bar.txt + + The classical all files pattern: *.* + matches: foo.db +.db +foo +foo.bar.db +foo.db.db +db.db.db does not match: c:/ +c:/foo.db +c:/foo +c:/.db +c:/foo.foo.db +//server/foo +
+ +
+ Matching subdirectories + + A directory name can be matched at any depth level using the + following notation: **/db/** That + pattern matches the following paths: /db +//server/db +c:/db +c:/spring/app/db/foo.db +//Program Files/App/spaced dir/db/foo.db +/home/spring/spaced dir/db/v1/foo.db but does not match + these: c:/spring/app/db-v1/foo.db +/home/spring/spaced dir/db-v1/foo.db + + You can compose subdirectories to match like this: + **/bin/**/tmp/** That pattern matches + the following paths: c:/spring/foo/bin/bar/tmp/a +c:/spring/foo/bin/tmp/a/b.c but does not match these: + c:/spring/foo/bin/bar/temp/a +c:/tmp/foo/bin/bar/a/b.c + + You can use more advanced patterns: **/.spring-assemblies*/** + matches: c:/.spring-assemblies +c:/.spring-assembliesabcd73xs +c:/app/.spring-assembliesabcd73xs +c:/app/.spring-assembliesabcd73xs/foo.dll +//server/app/.spring-assembliesabcd73xs does not match: + c:/app/.spring-assemblie +
+ +
+ Case does matter, slashes don't + + .NET is expected to be a cross-platform development ... platform. + So, PathMatcher will match taking care of the case of + the pattern and the case of the path. For example: **/db/**/*.DB + matches: c:/spring/service/deploy/app/db/foo.DB + but does not match: c:/spring/service/deploy/app/DB/foo.DB +c:spring/service/deploy/app/spaced dir/DB/foo.DB +//server/share/service/deploy/app/DB/backup/foo.db + + If you do not matter about case, you should explicitly tell the + Pathmatcher. + + Back and forward slashes, in the very same cross-platform spirit, + are not important: spring/foo.bar + matches all the following paths: c:\spring\foo.bar +c:/spring\foo.bar +c:/spring/foo.bar +/spring/foo.bar +\spring\foo.bar +
+
+
diff --git a/doc/reference/src/objects.xml b/doc/reference/src/objects.xml index 0cfaa101..0abbb381 100644 --- a/doc/reference/src/objects.xml +++ b/doc/reference/src/objects.xml @@ -2111,6 +2111,163 @@ public class MixedIocObject + + Declarative Event Listener Registration + + In C# events are built right into the language thanks to the + event keyword. Under the scenes, events are + essentially a shorthand notation for delegates with some additional + guidelines as to what the parameters to an event handler method should + be (i.e. a sender System.Object and an + System.EventArgs object). + + public class EventSource +public event EventHandler Click; + + In use, .NET events are combined with one or more event handler + methods. Each handler method is programmatically added, or removed, from + the event and corresponds to an object's method that should be invoked + when a particular event occurs. When more than one handler method is + added to an event, then each of the registered methods will be invoked + in turn when an event occurs. + + TestObject source = new TestObject(); +TestEventHandler eventListener1 = new TestEventHandler(); +TestEventHandler eventListener2 = new TestEventHandler(); + +source.Click += eventListener1.HandleEvent; // Adding the first event handler method to the event +source.Click += eventListener2.HandleEvent; // Adding a second event handler method to the event + +source.OnClick(); // First eventListener1.HandleEvent is invoked, then eventListener2.HandleEvent + + When OnClick() is invoked, the event is fired. + + public void OnClick() +{ + if (Click != null) + { + Click(this, EventArgs.Empty); // Fire the event off to the registered handler methods + } +} + + One of the not so nice things about using events is that, without + employing late binding, you declare the objects that are registered with + a particular event programmatically. Spring .NET offers a way to + declaratively register your handler methods with particular events using + the <listener> element inside your + <object> elements. + + + Declarative event handlers + + Rather than having to specifically declare in your code that you + are adding a method to be invoked on an event, using the + <listener> element you can register a plain + object's methods with the corresponding event declaratively in your + application configuration. + + Using the listener element you can: + + + Configure a + method to be invoked when an event is fired. + + + + Register a + collection of handler methods based on a regular + expression. + + + + Register + a handler method against an event name that contains a regular + expression. + + + + + + Configuring a method to be invoked when an event is + fired + + The same event registration in the example above can be achieved + using configuration using the <listener> + element. + + <object id="eventListener1" type="SpringdotNETEventsExample.TestEventHandler, SpringdotNETEventsExample"> + <!-- wired up to an event exposed on an instance --> + <listener event="Click" method="HandleEvent"> + <ref object="source"/> + </listener> +</object> + +<object id="eventListener2" type="SpringdotNETEventsExample.TestEventHandler, SpringdotNETEventsExample"> + <!-- wired up to an event exposed on an instance --> + <listener event="Click" method="HandleEvent"> + <ref object="source"/> + </listener> +</object> + + In this case the two different objects will have their + HandleEvent method invoked, as indicated explicitly + using the method attribute, when a + Click event, as specified by the + event attribute, is triggered on the object + referred to by the ref element. + + + + Registering a collection of handler methods based on a regular + expression + + Regular expressions can be employed to wire up more than one + handler method to an object that contains one or more events. + + <object id="eventListener" type="SpringdotNETEventsExample.TestEventHandler, SpringdotNETEventsExample"> + <listener method="Handle.+"> + <ref object="source"/> + </listener> +</object> + + Here all the eventListener's handler methods + that begin with 'Handle', and that have the corresponding two + parameters of a System.Object and a + System.EventArgs, will be registered against all + events exposed by the source object. + + You can also use the name of the event in regular expression to + filter your handler methods based on the type of event + triggered. + + <object id="eventListener" type="SpringdotNETEventsExample.TestEventHandler, SpringdotNETEventsExample"> + <!-- For the Click event, the HandleClick handler method will be invoked. --> + <listener method="Handle${event}"> + <ref object="source"/> + </listener> +</object> + + + + Registering a handler method against an event name that + contains a regular expression + + Finally, you can register an object's handler methods against a + selection of events, filtering based on their name using a regular + expression. + + <object id="eventListener" type="SpringdotNETEventsExample.TestEventHandler, SpringdotNETEventsExample"> + <listener method="HandleEvent" event="Cl.+"> + <ref object="source"/> + </listener> +</object> + + In this example the eventListener's + HandleEvent handler method will be invoked for any + event that begins with 'Cl'. + + + Using <literal>depends-on</literal> diff --git a/doc/reference/src/transaction.xml b/doc/reference/src/transaction.xml index b9b1d1c9..7fedb346 100644 --- a/doc/reference/src/transaction.xml +++ b/doc/reference/src/transaction.xml @@ -16,7 +16,13 @@ * limitations under the License. */ --> - + Transaction management @@ -40,7 +46,8 @@ Provides a simple API for programmatic transaction management + linkend="transaction-programmatic">programmatic transaction + management @@ -76,9 +83,10 @@ - The fourth section, entitled Programmatic - transaction management, covers support for programmatic - transaction management. + The fourth section, entitled Programmatic transaction + management, covers support for programmatic transaction + management. @@ -215,16 +223,16 @@ This is primarily a 'SPI' (Service Provider Interface), although it can be used Programatically. Note that in keeping with the Spring - Framework's philosophy, IPlatformTransactionManager - is an interface, and can thus be easily mocked or stubbed as necessary. - IPlatformTransactionManager implementations - are defined like any other object in the IoC container. The following - implementations are provided + Framework's philosophy, IPlatformTransactionManager is + an interface, and can thus be easily mocked or stubbed as necessary. + IPlatformTransactionManager implementations are defined + like any other object in the IoC container. The following implementations + are provided - AdoPlatformTransactionManager - local - ADO.NET based transactions + AdoPlatformTransactionManager - local ADO.NET + based transactions @@ -238,8 +246,8 @@ - HibernatePlatformTransactionManager - - local transaction manager for use with NHibernate or mixed + HibernatePlatformTransactionManager - local + transaction manager for use with NHibernate or mixed ADO.NET/NHibernate data access operations. @@ -261,11 +269,10 @@ The GetTransaction(..) method returns a ITransactionStatus object, depending on a ITransactionDefinition parameters. The returned - ITransactionStatus might represent a new or - existing transaction (if there was a matching transaction in the current - call stack - with the implication being that a - ITransactionStatus is associated with a logical - thread of execution. + ITransactionStatus might represent a new or existing + transaction (if there was a matching transaction in the current call stack + - with the implication being that a ITransactionStatus + is associated with a logical thread of execution. The ITransactionDefinition interface specified @@ -305,28 +312,25 @@ concepts is essential to using the Spring Framework or indeed any other transaction management solution. - The ITransactionStatus interface - provides a simple way for transactional code to control transaction - execution and query transaction status. + The ITransactionStatus interface provides a + simple way for transactional code to control transaction execution and + query transaction status. Regardless of whether you opt for declarative or programmatic transaction management in Spring, defining the correct - IPlatformTransactionManager implementation - is absolutely essential. In good Spring fashion, this important definition + IPlatformTransactionManager implementation is + absolutely essential. In good Spring fashion, this important definition typically is made using via Dependency Injection. - IPlatformTransactionManager - implementations normally require knowledge of the environment in which - they work, ADO.NET, NHibernate, etc. The following example shows how a - standard ADO.NET based - IPlatformTransactionManager can be - defined. + IPlatformTransactionManager implementations + normally require knowledge of the environment in which they work, ADO.NET, + NHibernate, etc. The following example shows how a standard ADO.NET based + IPlatformTransactionManager can be defined. - We must define a Spring IDbProvider - and then use Spring's - AdoPlatformTransactionManager, giving it a - reference to the IDbProvider. For more information - on the IDbProvider abstraction refer to the next + We must define a Spring IDbProvider and then use + Spring's AdoPlatformTransactionManager, giving it a + reference to the IDbProvider. For more information on + the IDbProvider abstraction refer to the next chapter. <objects xmlns='http://www.springframework.net' @@ -463,9 +467,9 @@ specify which exceptions should cause automatic roll back. We specify this declaratively, in configuration, not in code. So, while we can still set RollbackOnly on the - ITransactionStatus object to roll the - current transaction back Programatically, most often we can specify a rule - that MyApplicationException must always result in rollback. This has the + ITransactionStatus object to roll the current + transaction back Programatically, most often we can specify a rule that + MyApplicationException must always result in rollback. This has the significant advantage that business objects don't need to depend on the transaction infrastructure. For example, they typically don't need to import any Spring APIs, transaction or other. If you would like to @@ -481,8 +485,8 @@ - Understanding - Spring's declarative transaction implementation + Understanding Spring's declarative transaction + implementation The aim of this section is to dispel the mystique that is sometimes associated with the use of declarative transactions. It is all @@ -522,7 +526,7 @@ - + @@ -534,9 +538,9 @@ - ProxyFactoryObject. The common - properties to set are the reference to the object to proxy (the - target object) and a reference to the transaction advice. See ProxyFactoryObject. The common properties + to set are the reference to the object to proxy (the target object) + and a reference to the transaction advice. See for more details. @@ -555,10 +559,10 @@ - DefaultAdvisorAutoProxyCreator - which specifies one or more "advisors" i.e an object - representing an aspect, including both an advice and a pointcut - targeting it to specific joinpoints. See DefaultAdvisorAutoProxyCreator which + specifies one or more "advisors" i.e an object representing an + aspect, including both an advice and a pointcut targeting it to + specific joinpoints. See @@ -567,8 +571,8 @@ There is also a convenience subclass of ProxyFactoryObject, namely - TransactionProxyFactoryObject, that sets some - common default values for the specific case of applying transactional + TransactionProxyFactoryObject, that sets some common + default values for the specific case of applying transactional advice. The DefaultAdvisorAutoProxyCreator is very @@ -610,11 +614,11 @@ Consider the following interface. The intent is to convey the concepts to you so you can concentrate on the transaction usage and not have to worry about domain specific details. The - ITestObjectManager is a poor-mans - business service layer - the implementation of which will make two DAO - calls. Clearly this example is overly simplistic from the service layer - perspective as there isn't any business logic at all!. The 'service' - interface is shown below. + ITestObjectManager is a poor-mans business service + layer - the implementation of which will make two DAO calls. Clearly + this example is overly simplistic from the service layer perspective as + there isn't any business logic at all!. The 'service' interface is shown + below. public interface ITestObjectManager { @@ -623,8 +627,8 @@ void DeleteTwoTestObjects(string name1, string name2); } - The implementation of - ITestObjectManager is shown below + The implementation of ITestObjectManager is + shown below public class TestObjectManager : ITestObjectManager { @@ -669,8 +673,8 @@ } The Create and Delete method implementation is shown below. Note - that this uses the AdoTemplate class discussed in - the following chapter. Refer to for + that this uses the AdoTemplate class discussed in the + following chapter. Refer to for information on the interaction between Spring's high level persistence integration APIs and transaction management features. @@ -691,15 +695,14 @@ } } - The TestObjectManager is configured with - the DAO objects by standard dependency injection techniques. The client + The TestObjectManager is configured with the + DAO objects by standard dependency injection techniques. The client code, which in this case directly asks the Spring IoC container for an - instance of ITestObjectManager, will - receive a transaction proxy with transaction options based on the - attribute metadata. Note that typically the - ITestObjectManager would be set on yet - another higher level object via dependency injection, for example a web - service. + instance of ITestObjectManager, will receive a + transaction proxy with transaction options based on the attribute + metadata. Note that typically the ITestObjectManager + would be set on yet another higher level object via dependency + injection, for example a web service. The client calling code is shown below @@ -807,26 +810,26 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); - TransactionInterceptor is the AOP - advice responsible for performing transaction management + TransactionInterceptor is the AOP advice + responsible for performing transaction management functionality. - TransactionAttributeSourceAdvisor is an - AOP Advisor that holds the TransactionInterceptor, which is the - advice, and a pointcut (where to apply the advice), in the form of a + TransactionAttributeSourceAdvisor is an AOP + Advisor that holds the TransactionInterceptor, which is the advice, + and a pointcut (where to apply the advice), in the form of a TransactionAttributeSource. - AttributesTransactionAttributeSource is - an implementation of the - ITransactionAttributeSource interface that - defines where to get the transaction metadata defining the - transaction semantics (isolation level, propagation behavior, etc) - that should be applied to specific methods of specific classes. The - transaction metadata is specified via implementations of the + AttributesTransactionAttributeSource is an + implementation of the ITransactionAttributeSource + interface that defines where to get the transaction metadata + defining the transaction semantics (isolation level, propagation + behavior, etc) that should be applied to specific methods of + specific classes. The transaction metadata is specified via + implementations of the ITransactionAttributeSource interface. This example shows the use of the implementation Spring.Transaction.Interceptor.AttributesTransactionAttributeSource @@ -848,8 +851,8 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); - AttributesTransactionAttributeSource - : Use a standard. .NET attributes to specify the transactional + AttributesTransactionAttributeSource : + Use a standard. .NET attributes to specify the transactional information. See TransactionAttribute class for more information. @@ -877,8 +880,8 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); - MethodMapTransactionAttributeSource - : Similar to NameMatchTransactionAttributeSource but specifies + MethodMapTransactionAttributeSource : + Similar to NameMatchTransactionAttributeSource but specifies that only fully qualified method names (i.e. type.method, assembly) and wildcards can be used at the start or end of the method name for matching multiple methods. @@ -887,8 +890,8 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); - DefaultAdvisorAutoProxyCreator: looks - for Advisors in the context, and automatically creates proxy objects + DefaultAdvisorAutoProxyCreator: looks for + Advisors in the context, and automatically creates proxy objects which are the transactional wrappers @@ -944,7 +947,7 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); xmlns:db="http://www.springframework.net/database" xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/schema/objects/spring-objects.xsd http://www.springframework.net/schema/tx http://www.springframework.net/schema/tx/spring-tx-1.1.xsd" - http://www.springframework.net/schema/tx http://www.springframework.net/schema/tx/spring-database.xsd"> + http://www.springframework.net/schema/db http://www.springframework.net/schema/db/spring-database.xsd"> <db:provider id="DbProvider" provider="SqlServer-1.1" @@ -980,13 +983,12 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); You can actually omit the 'transaction-manager' attribute in the <tx:attribute-driven/> tag if the object - name of the - IPlatformTransactionManager that you + name of the IPlatformTransactionManager that you want to wire in has the name 'transactionManager'. If the - PlatformTransactionManager object - that you want to dependency inject has any other name, then you have - to be explicit and use the 'transaction-manager' + PlatformTransactionManager object that you want + to dependency inject has any other name, then you have to be + explicit and use the 'transaction-manager' attribute as in the example above. The various optional elements of the <tx:attribute-driven/> tag are summarised in the following @@ -1011,57 +1013,68 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); - transaction-manager + + transaction-manager + No transactionManager - The name of transaction manager to use. Only - required if the name of the transaction manager is not - transactionManager, as in the example - above. + + The name of transaction manager to use. Only required + if the name of the transaction manager is not + transactionManager, as in the example + above. + - proxy-target-type + + proxy-target-type + No - + - Controls what type of transactional proxies are - created for classes annotated with the - [Transaction] attribute. If - "proxy-target-type" attribute is set to - "true", then class-based proxies will be - created (proxy inherits from target class, however calls are - still delegated to target object via composition. This allows - for casting to base class. If - "proxy-target-type" is - "false" or if the attribute is omitted, - then a pure composition based proxy is created and you can - only cast the proxy to implemented interfaces. (See the - section entitled for a - detailed examination of the different proxy - types.) + + Controls what type of transactional proxies are + created for classes annotated with the + [Transaction] attribute. If + "proxy-target-type" attribute is set to + "true", then class-based proxies will be + created (proxy inherits from target class, however calls are + still delegated to target object via composition. This + allows for casting to base class. If + "proxy-target-type" is + "false" or if the attribute is omitted, + then a pure composition based proxy is created and you can + only cast the proxy to implemented interfaces. (See the + section entitled for + a detailed examination of the different proxy types.) + - order + + order + No - + - Defines the order of the transaction advice that - will be applied to objects annotated with - [Transaction]. More on the rules related to - ordering of AOP advice can be found in the AOP chapter (see - section ). Note - that not specifying any ordering will leave the decision as to - what order advice is run in to the AOP - subsystem. + + Defines the order of the transaction advice that will + be applied to objects annotated with + [Transaction]. More on the rules related to + ordering of AOP advice can be found in the AOP chapter (see + section ). + Note that not specifying any ordering will leave the + decision as to what order advice is run in to the AOP + subsystem. + @@ -1214,23 +1227,29 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); - name + + name + Yes - + - The method name(s) with which the transaction - attributes are to be associated. The wildcard (*) character - can be used to associate the same transaction attribute - settings with a number of methods; for example, - 'Get*', - 'Handle*', 'On*Event', - and so forth. + + The method name(s) with which the transaction + attributes are to be associated. The wildcard (*) character + can be used to associate the same transaction attribute + settings with a number of methods; for example, + 'Get*', + 'Handle*', 'On*Event', + and so forth. + - propagation + + propagation + No @@ -1240,7 +1259,9 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); - isolation + + isolation + No @@ -1250,7 +1271,9 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); - timeout + + timeout + No @@ -1260,7 +1283,9 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); - read-only + + read-only + No @@ -1270,7 +1295,9 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); - EnterpriseServicesInteropOption + + EnterpriseServicesInteropOption + No @@ -1281,28 +1308,36 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); - rollback-for + + rollback-for + No - + - The Exception(s) that will - trigger rollback; comma-delimited. For example, - 'MyProduct.MyBusinessException,ValidationException' + + The Exception(s) that will trigger + rollback; comma-delimited. For example, + 'MyProduct.MyBusinessException,ValidationException' + - no-rollback-for + + no-rollback-for + No - + - The Exception(s) that will - not trigger rollback; comma-delimited. - For example, - 'MyProduct.MyBusinessException,ValidationException' + + The Exception(s) that will + not trigger rollback; comma-delimited. + For example, + 'MyProduct.MyBusinessException,ValidationException' + @@ -1365,14 +1400,17 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); - Property + + Property + - Type + + Type + - Description + + Description + @@ -1388,7 +1426,9 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); Isolation - System.Data.IsolationLevel + + System.Data.IsolationLevel + optional isolation level @@ -1496,9 +1536,8 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); first example. The use of Spring's autoproxy functionality defines criteria to select a collection of objects to create a transactional AOP proxy. There are two AutoProxy - classes that you can use, - ObjectNameAutoProxyCreator and - DefaultAdvisorAutoProxyCreator. If you are using + classes that you can use, ObjectNameAutoProxyCreator + and DefaultAdvisorAutoProxyCreator. If you are using the new transaction namespace support you do not need to configure these objects as a DefaultAdvisorAutoProxyCreator is created 'under the covers' while parsing the transaction namespace elements @@ -1759,8 +1798,7 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); - Using a - IPlatformTransactionManager + Using a IPlatformTransactionManager implementation directly @@ -1775,16 +1813,16 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); The TransactionTemplate adopts the same approach as other Spring templates such as AdoTemplate and - HibernateTemplate. It uses a callback approach, - to free application code from having to do the boilerplate acquisition - and release of resources, and results in code that is intention driven, - in that the code that is written focuses solely on what the developer - wants to do. Granted that the using construct of System.Transaction - alleviates much of this. One key difference with the approach taken with - the TransactionTemplate is that a commit is assumed - throwing an - exception triggers a rollback instead of using the TransactionScope API - to commit or rollback. This also allows for the use of rollback rules, - that is a commit can still occur for exceptions of certain types. + HibernateTemplate. It uses a callback approach, to + free application code from having to do the boilerplate acquisition and + release of resources, and results in code that is intention driven, in + that the code that is written focuses solely on what the developer wants + to do. Granted that the using construct of System.Transaction alleviates + much of this. One key difference with the approach taken with the + TransactionTemplate is that a commit is assumed - throwing an exception + triggers a rollback instead of using the TransactionScope API to commit + or rollback. This also allows for the use of rollback rules, that is a + commit can still occur for exceptions of certain types. As you will immediately see in the examples that follow, using the TransactionTemplate absolutely couples you to Spring's transaction infrastructure and APIs. Whether or not @@ -1799,8 +1837,8 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); execute in the context of a transaction. You will then pass an instance of your custom ITransactionCallback to the Execute(..) method exposed on the TransactionTemplate. Note that the - ITransactionCallback can be used to - return a value: + ITransactionCallback can be used to return a + value: public class SimpleService : IService { @@ -1826,11 +1864,10 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); delegates, which provides a particularly elegant means to invoke a callback function as local variables can be referred to inside the delegate, i.e. userId. In this case the - ITransactionStatus was not exposed in the - delegate (delegate can infer the signature to use), but one could also - obtain a reference to the - ITransactionStatus instance and set the - RollbackOnly property to trigger a rollback - or + ITransactionStatus was not exposed in the delegate + (delegate can infer the signature to use), but one could also obtain a + reference to the ITransactionStatus instance and set + the RollbackOnly property to trigger a rollback - or alternatively throw an exception. This is shown below tt.Execute(delegate(ITransactionStatus status) @@ -1846,8 +1883,8 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); If you are using .NET 1.1 then you should provide a normal delegate reference or an instance of a class that implements the - ITransactionCallback interface. This is - shown below + ITransactionCallback interface. This is shown + below tt.Execute(new TransactionRollbackTxCallback(amount)); @@ -1872,9 +1909,9 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); Application classes wishing to use the TransactionTemplate must have access to a - IPlatformTransactionManager (which will - typically be supplied to the class via dependency injection). It is easy - to unit test such classes with a mock or stub + IPlatformTransactionManager (which will typically be + supplied to the class via dependency injection). It is easy to unit test + such classes with a mock or stub IPlatformTransactionManager. @@ -1882,11 +1919,11 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); Transaction settings such as the propagation mode, the isolation level, the timeout, and so forth can be set on the - TransactionTemplate either programmatically or - in configuration. TransactionTemplate instances - by default have the default transactional settings. Find below an - example of programmatically customizing the transactional settings for - a specific TransactionTemplate. + TransactionTemplate either programmatically or in + configuration. TransactionTemplate instances by + default have the default transactional settings. Find below an example + of programmatically customizing the transactional settings for a + specific TransactionTemplate. public class SimpleService : IService { @@ -1912,8 +1949,8 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); Find below an example of defining a - TransactionTemplate with some custom - transactional settings, using Spring XML configuration. The + TransactionTemplate with some custom transactional + settings, using Spring XML configuration. The 'sharedTransactionTemplate' can then be injected into as many services as are required. @@ -1923,15 +1960,14 @@ mgr.DeleteTwoTestObjects("Jack", "Jill"); <property name="TransactionTimeout" value="30"/> </object> - Finally, instances of the - TransactionTemplate class are threadsafe, in - that instances do not maintain any conversational state. - TransactionTemplate instances do however - maintain configuration state, so while a number of classes may choose - to share a single instance of a + Finally, instances of the TransactionTemplate + class are threadsafe, in that instances do not maintain any + conversational state. TransactionTemplate instances + do however maintain configuration state, so while a number of classes + may choose to share a single instance of a TransactionTemplate, if a class needed to use a - TransactionTemplate with different settings - (for example, a different isolation level), then two distinct + TransactionTemplate with different settings (for + example, a different isolation level), then two distinct TransactionTemplate instances would need to be created and used. @@ -1991,10 +2027,10 @@ transactionManager.Commit(status); Typical application code should not need to rely on using this class but in some cases it is convenient to receive events around the lifecycle of the transaction, i.e. before committing, after committing. - TransactionSynchronizationManager provides a method - to register a callback object that is informed on all significant stages - in the transaction lifecycle. Note that you can register for lifecycle - call back information for any of the transaction managers you use, be it + TransactionSynchronizationManager provides a method to + register a callback object that is informed on all significant stages in + the transaction lifecycle. Note that you can register for lifecycle call + back information for any of the transaction managers you use, be it NHibernate or local ADO.NET transactions. The method to register a callback with the @@ -2023,7 +2059,7 @@ transactionManager.Commit(status); void AfterCompletion( TransactionSynchronizationStatus status ); } - The TransactionSynchronizationStatus is an - enum with the values Committed, Rolledback, and Unknown. + The TransactionSynchronizationStatus is an enum + with the values Committed, Rolledback, and Unknown. - \ No newline at end of file +