要使用JITA,必须重写两个基类ServicedComponent的方法:Activate和Deactive.当对象生成后Activate方法会被运行时自动调用.当对象终止前Deactive方法会被自动调用 ConstructionEnabled(Default = @"C:\Temp\")] [EventTrackingEnabled] public class CoursesComponent : ServicedComponent
如果对象创建消耗更多的资源,可以考虑对象池 [Transaction(TransactionOption.Supported)]//是否需要支持事务特性 public class Cacu : ServicedComponent
指定哪些类的哪些方法需要事务处理,不管你是dao还是service,通通可以自由地在这儿指定,根本不会侵入你所写的类,如果是Com+的话,会强迫你去实现Com+的ServicedComponent。
Transaction(TransactionOption.Required)] public class BusinessComponent : ServicedComponent
事务 namespace ClassTran { [Transaction(TransactionOption.Required)] public class OrderData2 : ServicedComponent
test.obj.Method1(); t1.Join(); } } 所有服务组件的基类都是在System.EnterpriseService命名空间下的ServicedComponent
一种是在需要事务的对象中显式的调用事务处理, 还有一种是使用Enterprise Service的声明式的方法.这种方法:使用事务的对象需要继承ServicedComponent;即使不涉及多资源的分布式事务而仅仅是涉及到了多个对象的简单事务
a, int b); string SayHello(string msg); } public class Opeate:System.EnterpriseServices.ServicedComponent
如果确实需要这一功能,简单的解决方案是在 .NET 企业服务的服务器应用程序中部署一个从 System.EnterpriseServices.ServicedComponent 派生的类(更多信息,请参见
In COM+, your business class must inherit the ServicedComponent class.
System.EnterpriseServices.Transaction(TransactionOption.Required)]//始终需要事务处理域 public class Test2 : ServicedComponent