From: Owen C. <oco...@ac...> - 2005-03-16 16:47:11
|
Here is my AspectJ HelloWorld thing, I need the equivalent stripped to = the barebones example in Aspect#, shouldn=92t be as difficult as a PHD dissertation, one would hope this represents less than an hour=92s work = (much less actually), although it took me several days to come up with it for AspectJ, I bought a book, but also got it instrumenting already built = jars, working within ant etc: The steps: C:\owen\HelloWorld>ajc com\howdy\*.java com\tracing\HelloAspect.aj C:\owen\HelloWorld>java com.howdy.HelloWorld 2005-03-15 10:54:58,084 [main] INFO trace - Entering [com.howdy.HelloWorld.main] 2005-03-15 10:54:58,124 [main] INFO trace - Entering [com.howdy.Object1.<init>] The classes that were instrumented: Obect1.java: package com.howdy; public class Object1 { public Object1() { int i; } } HelloWorld.java: package com.howdy; public class HelloWorld { public static void main(String[] args) { Object1 fred =3D new Object1(); } } The aspect HelloAspect.aj:=20 package com.tracing; import org.apache.log4j.*; import org.aspectj.lang.*; public aspect HelloAspect=20 { Logger logger =3D Logger.getLogger("trace"); =09 HelloAspect() { logger.setLevel(Level.ALL); } =09 pointcut traceMethods():(execution(* *.*(..)) || execution(*.new(..)))=20 && !within(HelloAspect); =09 before():traceMethods() { if (logger.isEnabledFor(Level.INFO)) { Signature sig =3D thisJoinPointStaticPart.getSignature(); logger.log(Level.INFO, "Entering [" + sig.getDeclaringType().getName() + "."=20 + sig.getName() + "]"); } }=09 } Log4j.properties: log4j.rootLogger=3DDEBUG, A1 log4j.appender.A1=3Dorg.apache.log4j.ConsoleAppender log4j.appender.A1.layout=3Dorg.apache.log4j.PatternLayout # Print the date in ISO 8601 format log4j.appender.A1.layout.ConversionPattern=3D%d [%t] %-5p %c - %m%n # Print only messages of level WARN or above in the package com.foo. log4j.logger.trace=3DINFO =20 Here is the C# equivalent I am starting with and want to add logging to = in similar fashion: File Hello.cs: using System; namespace HelloWorld { class Hello { static void Main(string[] args) { Object1 obj =3D new Object1(); System.Console.WriteLine("Hello"); } } } File Object1.cs: using System; namespace HelloWorld { public class Object1 { public Object1() { int i; } } } C:\owen\HelloWorld.net\HelloWorld>csc Hello.cs Object1.cs Microsoft (R) Visual C# .NET Compiler version 7.10.6001.4 for Microsoft (R) .NET Framework version 1.1.4322 Copyright (C) Microsoft Corporation 2001-2002. All rights reserved. Object1.cs(9,8): warning CS0168: The variable 'i' is declared but never = used C:\owen\HelloWorld.net\HelloWorld>hello Hello C:\owen\HelloWorld.net\HelloWorld> Thanks, =20 Owen Corpening Acorn Systems -----Original Message----- From: asp...@li... [mailto:asp...@li...] On Behalf Of = Henry Concei=E7=E3o Sent: Monday, March 14, 2005 8:27 PM To: asp...@li... Subject: Re: Fw: [Aspectsharp-users] examples, docs I'll create a simple example, but it won't be avaliable soon... sorry. The final beta release should came in the next 3 or 4 weeks. The http://aspectsharp.sourceforge.net/tutorial.html and the src/AspectSharpTests/InterceptorTests/InterceptorTestCase.cs has a overview of the example that should help you understand the AspectSharp. The testcases are very simple and should take only a few minutes to read it. On Mon, 14 Mar 2005 12:14:29 -0300, hammett <ha...@uo...> wrote: > Would somebody please answer this request? I need to put a web project > online today. >=20 > -- > Cheers, > hammett > http://www.castleproject.org/~hammett >=20 > ----- Original Message ----- > From: "Owen Corpening" <oco...@ac...> >=20 > > That is a relatively mammoth example to get started with - you can > > probably > > imagine that I have a day job and can't initially invest heavily in = an > > unkown quantity - is there more of a helloworld - type thing you = could > > cobble together for me? > > > > If Aspect# is truly simple and easy to use this request should take almost > > no time at all. Might want to add such an example to the src too. > > > > Even the tutorial is actually too much for evaluation purposes. > > > > Thanks, > > > > Owen Corpening > > Acorn Systems >=20 >=20 --=20 Cheers, Henry Concei=E7=E3o ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_ide95&alloc_id=14396&op=3Dick _______________________________________________ Aspectsharp-users mailing list Asp...@li... https://lists.sourceforge.net/lists/listinfo/aspectsharp-users |