[SDC-29] Amdocs OnBoard 1707 initial commit.
[sdc.git] / openecomp-be / lib / openecomp-logging-lib / openecomp-sdc-logging-core / src / main / java / org / openecomp / sdc / logging / aspects / DebugAspect.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.logging.aspects;
22
23 import org.aspectj.lang.JoinPoint;
24 import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
25 import org.slf4j.Marker;
26 import org.slf4j.MarkerFactory;
27
28 import java.lang.reflect.Method;
29
30
31 /**
32  * Created by TALIO on 12/26/2016.
33  */
34 public class DebugAspect {
35
36   private static final String MESSAGE_TEMPLATE = "'{}' '{}' with '{}'";
37   private static final Marker DEBUG = MarkerFactory.getMarker("DEBUG");
38   private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
39
40 //  @Autowired
41 //  private ParameterNameDiscoverer parameterNameDiscoverer;
42
43   public void debugEnterMethod(final JoinPoint joinPoint){
44
45     Class type = joinPoint.getSignature().getDeclaringType();
46     Method currentMethod = null;
47     for(Method method : type.getMethods()){
48       if(method.getName().equals(joinPoint.getSignature().getName())){
49         currentMethod = method;
50         break;
51       }
52     }
53
54 //    String[] parameterNames = parameterNameDiscoverer.getParameterNames(currentMethod);
55 //    Object[] args = joinPoint.getArgs();
56 //    Parameter[] parameters = currentMethod.getParameters();
57 //    StringBuilder str = new StringBuilder(joinPoint.getSignature().getName() + " with parameters:" +
58 //        " ");
59 //    if(args.length == parameters.length) {
60 //      for (int i = 0; i < args.length; i++) {
61 //        str.append(parameters[i].getName()).append('=').append(args[i]);
62 //      }
63 //    }
64     mdcDataDebugMessage.debugEntryMessage(null, null);
65   }
66
67   public void debugExitMethod(final JoinPoint joinPoint){
68     mdcDataDebugMessage.debugExitMessage(null, null);
69   }
70 }