InheritanceBasedAopConfigurer using runtime constructor arguments

I have a (prototype) class belonging to Spring.NET content created using AutoProxy with runtime constructor arguments. It is created in this way.

var context = ContextRegistry.GetContext();
var myClass = context.GetObject("myclass", new object[]{ myRuntimeConstructorArgument }) as MyClass;

This class has some internal logic in which it captures an event that is processed by a class method, for example:

// MyClass owned by Spring.NET context
public class MyClass {

  // InnerObject not owned by Spring context
  private InnerObject innerobject;

  // argument object not owned by Spring context
  public MyClass(ObjectNotOwnedBySpring myRuntimeConstructorArgument) {
     ...
     this.innerobject = new InnerObject();
     this.innerobject.SomeEvent += this.handleSomeEvent;
  }

  // I would like to intercept this event handler
  public virtual void handleMyEvent (object sender, EventArgs args)
  {
    // do stuff
  }
}

I am trying to use AOP to remove an abstraction leak (caused by an error in an external component) by intercepting the handleMyEvent method. Because Spring.Aop uses a proxy approach to intercept method calls, internal method calls are not intercepted. I get this part.

, , InheritanceBasedAopConfigurer, 'true' . :

.

, !

, InheritanceBasedAopConfigurer runtime:

Spring.Objects.Factory.ObjectCreationException: 'myclass' > , ' [ spring -aop-config.xml] 36': .

InheritanceBasedAopConfigurer? InheritanceBasedAopConfigurer?

+2

Source: https://habr.com/ru/post/1706093/


All Articles