示例#1
0
        private static object LogIt(OperationJoinPoint jp)
        {
            String name = "";
            if (wlogInfoEnable)
            {
                name = jp.TargetOperation.DeclaringType.FullName + "::" + jp.TargetOperationName;
                wLOG.Info("Entering " + name);
            }

            object result = jp.Proceed();

            if (wlogInfoEnable)
                wLOG.Info("Leaving " + name);

            return result;
        }
        public static object ExecutionToLogInternal(OperationJoinPoint jp)
        {
            object result = null;
            StoreManager storeManager = null;
            try
            {

                if (jp == null)
                {
                    sLog.Error("Unable to log a null joinpoint");
                    return result;
                }

                storeManager = StoreManager.GetManager();

                Object[] tArgs = null;
                if (logParameter)
                {
                    // On log les paramètres d'appel, de retour et les exceptions
                    tArgs = jp.Arguments;
                }

                if (storeManager != null)
                {
                    storeManager.LogBeginOfMethod(jp, tArgs, groupName);
                }
                else
                {
                    //sLog.Error("executionToLogInternal Impossible de logger l'entrée de la methode");
                }
            }

            //Impossible de laisser remonter une erreur de NMonitoring vers l'appli !
            // TODO : Voir s'il ne faudrait pas courcircuiter l'appel a LogEndOfMethod
            //dans le cas ou on arrive pas à logger le debut
            catch (NMonitoringException e)
            {
                sLog.Error("NMonitoringException : Unable to log", e);
            }
            catch (Exception e)
            {
                sLog.Error("Unknown Exception : Unable to log", e);
            }

            try
            {
                //Execution du code à auditer
                result = jp.Proceed();

                //Fin normale (sans exception) du code audité
                try
                {
                    if (storeManager != null)
                    {
                        if (logParameter)
                        {
                            storeManager.LogEndOfMethodNormal(result);
                        }
                        else
                        {
                            storeManager.LogEndOfMethodNormal(null);
                        }
                    }
                    else
                    {
                        sLog.Error("executionToLogInternal Impossible de logger la sortie de la methode");
                    }
                }
                //Impossible de laisser remonter une erreur de NMonitoring vars l'appli !
                catch (NMonitoringException e)
                {
                    sLog.Error("NMonitoringException : Unable to log", e);
                }
                catch (Exception e)
                {
                    sLog.Error("Unknown Exception : Unable to log", e);
                }
            }
            //Une exception s'est produite dans l'application auditée
            catch (Exception externalException)
            {
                try
                {
                    //In log la fin de la methode en marquant l'exception
                    storeManager.LogEndOfMethodWithException(externalException);
                }
                //Impossible de laisser remonter une erreur de NMonitoring vars l'appli !
                catch (NMonitoringException internalException)
                {
                    sLog.Error("NMonitoringException : Unable to log execution Throwable", internalException);
                }
                catch (Exception e)
                {
                    sLog.Error("Unknown Exception : Unable to log", e);
                }

                //On propage l'exception issue de l'application auditée
                throw;
            }

            return result;
        }
示例#3
0
 public static object Interceptor(OperationJoinPoint jp)
 {
     object result = jp.Proceed();
     return result;
 }
示例#4
0
	public static object Intercept(OperationJoinPoint jp)
	{
		Console.WriteLine("--- before call : {0}", jp);
		return jp.Proceed();
	}
示例#5
0
 public static object AroundBodyFilter(OperationJoinPoint ojpOperationJoinPoint)
 {
     //Log("AroundBody:::" + ojpOperationJoinPoint.ToString());
     //Log(ojpOperationJoinPoint);
     try
     {
         object oReturnValue = ojpOperationJoinPoint.Proceed();
         Log(ojpOperationJoinPoint, oReturnValue);
         //if (oReturnValue != null)
         //    Log(ojpOperationJoinPoint.TargetOperationName + " returned:" + oReturnValue);
         return oReturnValue;
     }
     catch (Exception ex)
     {
         Log(ex, ojpOperationJoinPoint);
         return null;
     }
 }
示例#6
0
        public static object AroundCallFilter(OperationJoinPoint ojpOperationJoinPoint)
        {
            //System.Diagnostics.Debug.WriteLine("AroundCall:" + ojpOperationJoinPoint.ToString());
            //Log("AroundCall:" + ojpOperationJoinPoint.ToString());

            try
            {
                object oReturnValue = ojpOperationJoinPoint.Proceed();
                Log(ojpOperationJoinPoint, oReturnValue);
                //if (oReturnValue != null)
                //    Log(ojpOperationJoinPoint.TargetOperationName + " returned:" + oReturnValue);
                return oReturnValue;
            }
            catch (Exception ex)
            {
                Log(ex, ojpOperationJoinPoint);
                return null;
            }
        }