ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
1134
1134
EMPFEHLEN
-
27.02.08 14:00 #1
- Registriert seit
- Jun 2002
- Ort
- Saarbrücken (Saarland)
- Beiträge
- 9.886
- Blog-Einträge
- 29
Hallo,
hier mal ein kleines Beispiel wie einfach man mit Spring.NET einen Dynamic Proxy erzeugen kann:
Code csharp:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Spring.Aop.Framework; using Spring.Aop; using AopAlliance.Intercept; namespace De.Tutorials.Spring { public class SpringProxyGeneratorExample { public static void Main(string[] args) { ProxyFactory proxyFactory = new ProxyFactory(new BusinessService()); proxyFactory.AddInterface(typeof(IBusinessService)); proxyFactory.AddAdvice(new TracingInterceptor()); IBusinessService businessService = (IBusinessService)proxyFactory.GetProxy(); Console.WriteLine(businessService.businessOperation("Tom")); } } public interface IBusinessService{ string businessOperation(string args); } public class BusinessService : IBusinessService { #region IBusinessService Members public string businessOperation(string args) { return args + " " + args; } #endregion } public class TracingInterceptor : IMethodInterceptor { #region IMethodInterceptor Members public object Invoke(IMethodInvocation invocation) { object result = null; Console.WriteLine("Before: " + invocation); result = invocation.Proceed(); Console.WriteLine("After: " + invocation); return result; } #endregion } }
Ausgabe:
Code :1 2 3
Before: Invocation: method 'businessOperation', arguments Tom; target is of Type [De.Tutorials.Spring.BusinessService After: Invocation: method 'businessOperation', arguments Tom; target is of Type [De.Tutorials.Spring.BusinessService] Tom Tom
Gruß TomJava rocks!
How to become a good Java Programmer?
Does IT in Java and .Net
The only valid measurement of code quality: WTFs / minute
Blog
Xing
Twitter
Ähnliche Themen
-
Spring Security NTLM & Spring Framework 3.0
Von Thomas Darimont im Forum Enterprise Java (JEE, J2EE, Spring & Co.)Antworten: 2Letzter Beitrag: 26.01.10, 12:50 -
Unterschiede Spring und Spring RCP
Von Looky im Forum JavaAntworten: 8Letzter Beitrag: 26.01.09, 08:45 -
Planung Serversoftware mit Spring als Framework, wie Spring einsetzen?
Von DarthShader im Forum Enterprise Java (JEE, J2EE, Spring & Co.)Antworten: 8Letzter Beitrag: 26.09.08, 19:05 -
RMI mit Spring
Von Newcomer2007 im Forum Enterprise Java (JEE, J2EE, Spring & Co.)Antworten: 2Letzter Beitrag: 21.05.07, 15:41 -
Spring One Praesentation: Introduction to Data Access with Spring.NET
Von Thomas Darimont im Forum .NET DatenverwaltungAntworten: 2Letzter Beitrag: 21.06.06, 13:42






Zitieren
Login





