标签: aop

找不到类型的序列化程序

我已经构建了一个方面,它使用我自己的库中的一个类来工作。为了有用,该类需要可序列化,但是当让 PostSharp 做它的事情时,我收到了这个错误:

PostSharp 3.0 [3.0.35.0, 64 bit, CLR 4.5, Release] - Copyright (c) SharpCrafters
 s.r.o., 2004-2012.

POSTSHARP : error LA0001: Cannot serialize the aspects: Cannot find a serializer
 for type 'NextGen.Framework.Managers.LogMgr.NxLogMgr'..
POSTSHARP : message PS0122: Details of the previous error or warning:\nPostSharp
.Serialization.PortableSerializationException: Cannot find a serializer for type
 'NextGen.Framework.Managers.LogMgr.NxLogMgr'.
POSTSHARP : message PS0122:    at PostSharp.Serialization.SerializationWriter.Ge
tObjectInfo(Object obj)
POSTSHARP : message PS0122:    at PostSharp.Serialization.SerializationWriter.Wr
iteObjectReference(Object value, Boolean writeInitializationDataInline)
POSTSHARP : message PS0122:    at PostSharp.Serialization.SerializationWriter.Wr
iteValue(Object value, SerializationIntrinsicType intrinsicType, Boolean …
Run Code Online (Sandbox Code Playgroud)

.net vb.net aop postsharp

0
推荐指数
1
解决办法
821
查看次数

Java - Spring AOP - 使用 before 建议停止执行方法?

如何在 Spring AOP 中使用 before 建议作为安全措施。

例如,我有这个之前的建议(带有伪代码):

@Before("trigger()")
public void beforeMethod(JoinPoint point){
    Method[] a = point.getSignature().getClass().getDeclaredMethods();
    for(int i=0; i < a.length; i++){
            //if method has such arguments then
        if(a[i] 'has args String name, String role, Int Money'){ 
               //And if these arguments meets such requirements
                if(a[i].argument(Int.class) > 1000 or a[i].argument(String role).equals("normal"))
                    //Stop executing this method
                    a[i].stop
                }
    }
}   
Run Code Online (Sandbox Code Playgroud)

我知道这只是伪代码,所以它看起来可能不正确,但我希望您能有所了解。如果满足或不满足某些要求,是否有一些 JoinPoint 方法可以停止扫描方法?

java aop spring

0
推荐指数
1
解决办法
4203
查看次数

带有 Autofac 和 DynamicProxy2 异常处理的 AOP

我正在尝试集中管理某个方法的异常处理,但我似乎无法到达那里。

public class ExceptionInterceptor : IInterceptor
{
    private readonly Logger _logger;

    public ExceptionInterceptor(Logger logger)
    {
        _logger = logger;
        Measure.Configure(new StatsdConfig());
    }

    public void Intercept(IInvocation invocation)
    {
        try
        {
            invocation.Proceed();
            //if ((Task<System.Threading.Tasks.VoidTaskReturn>) invocation.ReturnValue.Status == "Failed")
            //{
            //    throw new Exception(invocation.ReturnValue.Exception[0]);
            //}
        }
        catch (Exception e)
        {
            var errorMessage =
                String.Format(
                    "An error occurred while retrieving fund data. Error Message: {0} Inner Exception: {1}",
                    e.Message, e.InnerException != null ? e.InnerException.Message : "<None>");

            _logger.Log(errorMessage);
            Measure.Counter("Exception", 1);
            Measure.Event("Exception", errorMessage);
            throw;
        }

    }
Run Code Online (Sandbox Code Playgroud)

我将它连接到一个模块中,如下所示:

builder.RegisterType<DataConsumer>(). …
Run Code Online (Sandbox Code Playgroud)

c# aop autofac

0
推荐指数
1
解决办法
1777
查看次数

如何监控第三方库的方法执行?

我有任务以某种方式监视 logback 库中的方法调用。我开始用 spring aop 做这件事。因此,例如,我应该在 ch.qos.logback.classic.Logger 类中捕获所有方法的执行。这是我的方面:

@Aspect
@Configuration
public class LogbackAspect {

    @Before(value = "execution(* ch.qos.logback.classic.Logger.*(..))")
    public void getInfo(JoinPoint joinPoint) {
         System.out.println("+++++AOP " + joinPoint.getSignature().getName());
}
}
Run Code Online (Sandbox Code Playgroud)

但是暂时不行,那么,有没有可能用spring aop拦截方法执行呢?或者有一些更好的方法来做到这一点?

java aop spring spring-aop

0
推荐指数
1
解决办法
496
查看次数

Facade设计模式有哪些缺点?

\xe2\x80\xa6 我们如何使用面向方面的编程来克服它们?

\n

aop design-patterns facade aspects

-3
推荐指数
1
解决办法
4070
查看次数

标签 统计

aop ×5

java ×2

spring ×2

.net ×1

aspects ×1

autofac ×1

c# ×1

design-patterns ×1

facade ×1

postsharp ×1

spring-aop ×1

vb.net ×1