Question: Aspect Oriented Programming

  • Thread starter Thread starter Shawn B.
  • Start date Start date
S

Shawn B.

Greetings,

I was reading the latest MSDN magazine and in it is an insert (VOLUME I: Feb
2005 -- Patterns & Practices Digest) that discusses something relating to
the Avande ACA.NET framework (which I'll most likely never afford to
purchase and I'm not shopping, anyway)... but I have a question.

On page 12, it gives an example of using the ACA.NET aspects framework and
it seems to be more automatic than I thought you could achieve with .NET.
They give an example:

using Avanade.ACA.Aspects;

[AcaService]
[AsmxTransport]
[WseTransport]
public CalculatorService
{
[AcaServiceMethod]
[AspectContainer("CalcContainer", AspectContainerScope.SendersOnly)]
public int Add(int arg1, int arg1)
{
return arg1 + aqrg2;
}
}


My questions, since the class is not inheriting from ContextBoundObject or
derivitive, how it is possible to apply an attribute and then have that
attribute get fired when the method is executed?

My understanding, is that in .NET you must inherit your object at least from
ContextBoundObject, and your attributes from ContextBoundAttribute in order
to get the attribute to automatically fire when the "thing" that the
attribute is applied to is executed. Perhaps that isn't exactly all you
need to do to add aspects (and there example, although says it is, is
missing some serious details in order to market it)...?


Thanks,
Shawn
 
Shawn B. said:
Greetings,

I was reading the latest MSDN magazine and in it is an insert (VOLUME I:
Feb
2005 -- Patterns & Practices Digest) that discusses something relating to
the Avande ACA.NET framework (which I'll most likely never afford to
purchase and I'm not shopping, anyway)... but I have a question.

On page 12, it gives an example of using the ACA.NET aspects framework and
it seems to be more automatic than I thought you could achieve with .NET.
They give an example:

using Avanade.ACA.Aspects;

[AcaService]
[AsmxTransport]
[WseTransport]
public CalculatorService
{
[AcaServiceMethod]
[AspectContainer("CalcContainer", AspectContainerScope.SendersOnly)]
public int Add(int arg1, int arg1)
{
return arg1 + aqrg2;
}
}


My questions, since the class is not inheriting from ContextBoundObject or
derivitive, how it is possible to apply an attribute and then have that
attribute get fired when the method is executed?

Theoretically it's not. However, what they could be doing is generating a
proxy based on the attributes and reflection, and exposing that proxy to the
outside world. Some other alternatives include modifying the IL at compile
or JIT time.
 
Back
Top