@AfterReturning(
      pointcut =
          "execution(public String at.ac.tuwien.infosys.jcloudscale.server.JCloudScaleServer.createNewCloudObject(..))",
      returning = "ret")
  public void matchObjectCreated(JoinPoint jp, String ret) throws JCloudScaleException {

    try {
      ObjectCreatedEvent event = new ObjectCreatedEvent();
      initializeBaseEventProperties(event);
      UUID objectId = UUID.fromString(ret);
      event.setObjectId(objectId);
      JCloudScaleServer server = (JCloudScaleServer) jp.getThis();
      // XXX AbstractJCloudScaleServerRunner
      // UUID serverId = JCloudScaleServerRunner.getInstance().getId();
      UUID serverId = AbstractJCloudScaleServerRunner.getInstance().getId();
      event.setHostId(serverId);
      ClassLoader cl = server.getCloudObjectClassLoader(objectId);
      Class<?> theClazz = Class.forName((String) (jp.getArgs()[0]), true, cl);
      event.setObjectType(theClazz);
      getMqHelper().sendEvent(event);
      log.finer("Sent object created for object " + objectId.toString());
    } catch (Exception e) {
      e.printStackTrace();
      log.severe("Error while triggering ObjectCreatedEvent: " + e.getMessage());
    }
  }
 @Before("execution(* *.*(..))")
 public void logJoinPoint(JoinPoint joinPoint) {
   log.info("Join point kind : " + joinPoint.getKind());
   log.info("Signature declaring type : " + joinPoint.getSignature().getDeclaringTypeName());
   log.info("Signature name : " + joinPoint.getSignature().getName());
   log.info("Arguments : " + Arrays.toString(joinPoint.getArgs()));
   log.info("Target class : " + joinPoint.getTarget().getClass().getName());
   log.info("This class : " + joinPoint.getThis().getClass().getName());
 }
Exemplo n.º 3
0
  /**
   * 记录一条日志【登陆,逻辑,异常】
   *
   * @param logText
   * @param classStr
   * @param exceptions
   * @author 朱启亮
   * @date 2008-1-31
   */
  public void saveLog(JoinPoint jp, String logText, String classStr, Exception... exceptions) {
    Object obj = jp.getThis();
    String ip = "unknow";
    if (obj instanceof AbstractAction) {
      AbstractAction action = (AbstractAction) obj;
      HttpServletRequest request = action.getRequest();
      ip = this.getIpAddr(request);
    }

    HttpSession session = (HttpSession) UserSession.get(Constants.THREADLOCAL_CURRENT_SESSION);
    Serializable personid = (Serializable) session.getAttribute(Constants.SESSION_CURRENT_PERSONID);
    Person person = null;
    // 区分游客,root用户,普通用户
    if (personid == null) {
      person = new Person();
      person.setUserName(Constants.GUEST_NAME);
      person.setId(Constants.GUEST_ID);
      person.setUserLoginName(Constants.GUEST_NAME);
    } else if (personid.equals(Constants.ADMINISTRATOR_ID)) {
      person = new Person();
      person.setUserName(Constants.ADMINISTRATOR_NAME);
      person.setId(Constants.ADMINISTRATOR_ID);
      person.setUserLoginName(Constants.ADMINISTRATOR_ACCOUNT);
    } else {
      PersonManager personManager = this.getPersonManager();
      person = personManager.get(personid);
    }
    StringUtil.isoToUTF8(logText);
    Log log = new Log();
    log.setIp(ip);
    log.setLog(logText);
    log.setDt(new Date());
    // 记录日志的类型
    if (exceptions.length == 0) {
      //			if(classStr.equals(Constants.LOGINACTION)){
      //				log.setType(Log.LOG_TYPE_LOGIN);
      //			}else{
      log.setType(Log.LOG_TYPE_LOGIC);
      //			}
    } else {
      log.setType(Log.LOG_TYPE_EXCEPTION);
    }
    log.setPersonName(person.getUserName());
    if (person.getUserName().equals(Constants.GUEST_NAME)
        || person.getUserName().equals(Constants.ADMINISTRATOR_NAME)) {
      log.setPersonLoginName(person.getUserLoginName());
    } else {
      log.setPersonLoginName(person.getUserLoginName());
    }
    logManager.save(log);
  }
Exemplo n.º 4
0
  private void writeMethodCall(String message, JoinPoint point) {
    if (!active || writer == null) return;

    AutState state = detectAutState();
    if (lastState == null || lastState != state) {
      writeAnnouncement("%s is the current AUT mode", state);
      lastState = state;
    }

    write(
        "%s %s %s - %s\n  %s: %s\n",
        message,
        point.getSignature(),
        point.getSourceLocation(),
        new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS").format(new Date()),
        formatObject(point.getThis()),
        formatArgs(point.getArgs()));
  }