Zurück tutorials.de > Programming > .NET > .NET Application und Service Design

 
 
Hallo und herzlich willkommen! Tutorials.de ist eine Hilfe-Community mit dem Motto User helfen Usern. Als Gast verfügst Du über Schreibrechte in unseren Foren und Blogs. Du kannst dich aber gerne auch kostenlos registrieren und Teil unserer Gemeinschaft werden! Viel Spaß & Erfolg bei der Vermehrung deines Wissens :-)

Themen: 242.975 | Beiträge: 1.352.293 | Mitglieder: 169.418 (Stand 28.01.10) | Fragen zur Nutzung von Tutorials.de? Nutzungsregeln | Kontaktformular | Impressum

Jubiläums-Countdown 23.02 23.03 23.04 23.05 23.06 23.07 23.08 23.09


4 kostenlose Bücher bei unserer Buch-Verschenkaktion 03/2010
  AntwortAntworten (über Gastzugang)    
  AntwortAntworten (über Gastzugang)    
 
Themen-Optionen Ansicht
Alt 27.02.08, 14:00   #1 (permalink)
 
Benutzerbild von Thomas Darimont tutorials.de Administrator 
 
Registriert seit: Jun 2002
Ort: Saarbrücken (Saarland)
Beiträge: 9.164
Renommee-Modifikator: 61
Thomas Darimont hat eine strahlende ZukunftThomas Darimont hat eine strahlende ZukunftThomas Darimont hat eine strahlende ZukunftThomas Darimont hat eine strahlende ZukunftThomas Darimont hat eine strahlende ZukunftThomas Darimont hat eine strahlende ZukunftThomas Darimont hat eine strahlende ZukunftThomas Darimont hat eine strahlende Zukunft

DynamicProxy mit Spring.Aop aus Spring.NET

Hallo,

hier mal ein kleines Beispiel wie einfach man mit Spring.NET einen Dynamic Proxy erzeugen kann:
csharp Code:
  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:
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ß Tom
__________________
Java 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
  Thomas Darimont ist offline  
 
 
 
Lesezeichen:


Themen-Optionen
Ansicht
Ähnliche Themen
 
Thema Autor Forum Antworten Letzter Beitrag
Spring Problem: AOP configuration seems to be invalid manusch Enterprise Java (JEE, J2EE, Spring & Co.) 2 10.09.07 13:23
Beispiel zu Unit Testing mit NUnit, Spring.Net und ADO .Net Konstantin Denerz .NET Café 1 12.07.07 16:31
RMI mit Spring Newcomer2007 Enterprise Java (JEE, J2EE, Spring & Co.) 2 21.05.07 15:41
HibernateTemplate().save() aus dem Spring-Framework funktioniert nicht.. mahosand Enterprise Java (JEE, J2EE, Spring & Co.) 4 28.12.06 16:00
Spring One Praesentation: Introduction to Data Access with Spring.NET Thomas Darimont .NET Datenverwaltung 2 21.06.06 13:42
» Tools
 
tutorials.de-Tools tutorial.de-Suchfeld tutorial.de-Widget tutorial.de-RSS-Feed tutorial.de-Banner
» Neue Links
 
Hits: 137
»
JHT's Planetary...
(Cinema 4D-Objekte)
Hits: 264
»
Tageslicht ohne GI
(Cinema 4D-Tutorials)
Hits: 152
»
Puzzle
(Cinema 4D-Tutorials)
Hits: 103
»
Lacreme
(Cinema 4D-Tutorials)
Hits: 194
»
Liquid Light
(Cinema 4D-Tutorials)
» Aktuelle Umfrage
 
Bist du mit der Geschwindigkeit der Tutorials.de-Website zufrieden?
Ja, es putzt mir glatt den Staub vom Bildschirm! - 80,31%
155 Stimmen
Nein, ich denke da muss noch nachgebessert werden... - 19,69%
38 Stimmen
Stimmen gesamt: 193
Du darfst bei dieser Umfrage nicht abstimmen.

 

Alle Zeitangaben in WEZ +1. Es ist jetzt 21:40 Uhr.


Powered by vBulletin® Version 3.8.5 (Deutsch) & vBadvanced CMPS v.3.2.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.5.0 RC2 ©2010, Crawlability, Inc.
Alle Rechte vorbehalten ©2000 - 2010 tutorials.de
Design by Mark, CSS by Maik & Sven Mintel
Seite generiert in 0,21149 Sekunden mit 26 queries