当前位置: 首页>>代码示例>>Java>>正文


Java JoinPoint.getArgs方法代码示例

本文整理汇总了Java中org.aspectj.lang.JoinPoint.getArgs方法的典型用法代码示例。如果您正苦于以下问题:Java JoinPoint.getArgs方法的具体用法?Java JoinPoint.getArgs怎么用?Java JoinPoint.getArgs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.aspectj.lang.JoinPoint的用法示例。


在下文中一共展示了JoinPoint.getArgs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: afterReturn

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
 * @param joinPoint
 */
@AfterReturning("logAnnoAspect()")

public void afterReturn(JoinPoint joinPoint) {
    MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
    Method method = methodSignature.getMethod();
    LogModify logModifyAnno = method.getAnnotation(LogModify.class);
    if (null != logModifyAnno) {

        BaseEntity entity = (BaseEntity) joinPoint.getArgs()[0];
        Log log = new Log();
        log.setUserId(((User) SecurityUtils.getSubject().getSession().getAttribute("curUser")).getId());
        log.setAction(ACTION + logModifyAnno.resource());
        log.setResource(entity.getLogResource());
        log.setResourceId(entity.getId());
        logService.insert(log);
    }
}
 
开发者ID:melonlee,项目名称:PowerApi,代码行数:21,代码来源:LogModifyAdvice.java

示例2: deleteServiceCallCalls

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
 * 管理员删除操作日志(后置通知)
 * 
 */
@AfterReturning(value = "deleteServiceCall()", argNames = "rtv", returning = "rtv")
public void deleteServiceCallCalls(JoinPoint joinPoint, Object rtv)
		throws Throwable {
	// 获取方法名
	String methodName = joinPoint.getSignature().getName();
	StringBuffer rs = new StringBuffer();
	rs.append(methodName);
	String className = null;
	for (Object info : joinPoint.getArgs()) {
		// 获取对象类型
		className = info.getClass().getName();
		className = className.substring(className.lastIndexOf(".") + 1);
		rs.append("[参数1,类型:" + className + ",值:(id:"
				+ joinPoint.getArgs()[0] + ")");
	}
	// 创建日志对象
	LogInfoEntity log = new LogInfoEntity();
	log.setUserId(ShiroAuthenticationManager.getUserId());// 用户编号
	log.setAccountName(ShiroAuthenticationManager.getUserAccountName());
	log.setCreateTime(new Date(System.currentTimeMillis()));// 操作时间
	log.setContent(rs.toString());// 操作内容
	log.setOperation("delete");// 操作

	logService.log(log);// 添加日志
}
 
开发者ID:wjggwm,项目名称:webside,代码行数:30,代码来源:LogAspect.java

示例3: beforeServer

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
@Before("execution(* cn.org.once.cstack.ServerService.updateType(..))")
public void beforeServer(JoinPoint joinPoint) throws MonitorException, ServiceException {

	Server server = (Server) joinPoint.getArgs()[0];
	User user = getAuthentificatedUser();
	Message message = null;
	// String applicationName = server.getApplication().getName();
	String applicationDisplayName = server.getApplication().getDisplayName();

	switch (joinPoint.getSignature().getName().toUpperCase()) {
	case updateType:
		message = MessageUtils.writeBeforeApplicationMessage(user, applicationDisplayName, updateType);
		break;
	}
	logger.info(message.toString());
	messageService.create(message);

}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:19,代码来源:ServerAspect.java

示例4: beforeDeployment

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
@Before("execution(* cn.org.once.cstack.service.DeploymentService.create(..))")
public void beforeDeployment(JoinPoint joinPoint)
    throws MonitorException {
    try {
        User user = this.getAuthentificatedUser();
        Application application = (Application) joinPoint.getArgs()[0];
        Message message = null;
        switch (joinPoint.getSignature().getName().toUpperCase()) {
            case createType:
                message = MessageUtils.writeBeforeDeploymentMessage(user,
                    application, createType);
                break;
        }
        if (message != null) {
            logger.info(message.toString());
            messageService.create(message);
        }

    } catch (ServiceException e) {
        throw new MonitorException("Error afterReturningApplication", e);

    }
}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:24,代码来源:DeploymentAspect.java

示例5: resolveFromInternal

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
protected String resolveFromInternal(final JoinPoint joinPoint) {
    final Object arg1 = joinPoint.getArgs()[0];
    if (arg1 instanceof Credential) {
       return arg1.toString();
    } else if (arg1 instanceof String) {
        final Ticket ticket = this.ticketRegistry.getTicket((String) arg1);
        if (ticket instanceof ServiceTicket) {
            final ServiceTicket serviceTicket = (ServiceTicket) ticket;
            return serviceTicket.getGrantingTicket().getAuthentication().getPrincipal().getId();
        } else if (ticket instanceof TicketGrantingTicket) {
            final TicketGrantingTicket tgt = (TicketGrantingTicket) ticket;
            return tgt.getAuthentication().getPrincipal().getId();
        }
    } else {
        final SecurityContext securityContext = SecurityContextHolder.getContext();
        if (securityContext != null) {
            final Authentication authentication = securityContext.getAuthentication();

            if (authentication != null) {
                return ((UserDetails) authentication.getPrincipal()).getUsername();
            }
        }
    }
    return UNKNOWN_USER;
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:26,代码来源:TicketOrCredentialPrincipalResolver.java

示例6: before

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
@Before("apiPointcut()")
public void before(JoinPoint joinPoint) {
    Object obj[] = joinPoint.getArgs();
    if (obj.length > 0) {
        APIRequest request = (APIRequest) obj[0];
        Set set = request.getParams().entrySet();
        Map.Entry[] entries = (Map.Entry[]) set.toArray(new Map.Entry[set.size()]);
        for (Map.Entry entry : entries) {
            logger.info("[Params] " + entry.getKey() + ":" + entry.getValue());
        }
    } else {
        logger.info("[Params] null");
    }
}
 
开发者ID:bingozb,项目名称:DKJavaWebApiDemo,代码行数:15,代码来源:APILogger.java

示例7: findService

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
 * Find service.
 *
 * @param joinPoint the join point
 * @return the string[]
 */
private String[] findService(final JoinPoint joinPoint) {
    final JoinPoint j = AopUtils.unWrapJoinPoint(joinPoint);

    final Long id = (Long) j.getArgs()[0];

    if (id == null) {
        return new String[] {""};
    }

    return new String[] {"id=" + id};
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:ServiceManagementResourceResolver.java

示例8: resolveFromInternal

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
 * Resolve the principal from the join point given.
 *
 * @param joinPoint the join point
 * @return the principal id, or {@link PrincipalResolver#UNKNOWN_USER}
 */
protected String resolveFromInternal(final JoinPoint joinPoint) {
    final StringBuilder builder = new StringBuilder();

    final Object arg1 = joinPoint.getArgs()[0];
    if (arg1.getClass().isArray()) {
        final Object[] args1AsArray = (Object[]) arg1;
        resolveArguments(builder, args1AsArray);
    } else {
        builder.append(resolveArgument(arg1));
    }

    return builder.toString();

}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:21,代码来源:TicketOrCredentialPrincipalResolver.java

示例9: getControllerMethodDescription

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
 * 获取注解中对方法的描述信息 用于Controller层注解
 * @param joinPoint 切点
 * @return 方法描述
 * @throws Exception
 */
public static String getControllerMethodDescription(JoinPoint joinPoint) throws Exception{
    //获取目标类名
    String targetName = joinPoint.getTarget().getClass().getName();
    //获取方法名
    String methodName = joinPoint.getSignature().getName();
    //获取相关参数
    Object[] arguments = joinPoint.getArgs();
    //生成类对象
    Class targetClass = Class.forName(targetName);
    //获取该类中的方法
    Method[] methods = targetClass.getMethods();

    String description = "";

    for(Method method : methods) {
        if(!method.getName().equals(methodName)) {
            continue;
        }
        Class[] clazzs = method.getParameterTypes();
        if(clazzs.length != arguments.length) {//比较方法中参数个数与从切点中获取的参数个数是否相同,原因是方法可以重载哦
            continue;
        }
        description = method.getAnnotation(SystemControllerLog.class).description();
    }
    return description;
}
 
开发者ID:Exrick,项目名称:xmall,代码行数:33,代码来源:SystemLogAspect.java

示例10: logBefore

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
@Before("execution(public * com.numsg.system1.biz1.controller..*.*(..))")
public void logBefore(JoinPoint joinPoint) {
    String args = "";
    for (int i = 0; i < joinPoint.getArgs().length; i++) {
        args += joinPoint.getArgs()[i] + ",";
    }
    logger.info("The method " + joinPoint.getSignature().getName() + " begin, Args:" + args);
}
 
开发者ID:numsg,项目名称:spring-boot-seed,代码行数:9,代码来源:ControllerLogAspectJ.java

示例11: doAfterException

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
@AfterThrowing(pointcut = "errorPointCutMethod()", throwing = "throwable")
public void doAfterException(JoinPoint jp, Throwable throwable) {
    logger.error("invoke method: {}", jp.getSignature().getName());
    Object[] args = jp.getArgs();
    for (Object object : args) {
        if (object != null) {
            logger.error("parameter value: {},parameter type: {}", object, object.getClass().getName());
        } else {
            logger.error("arg is null");
        }
    }
    logger.error("Throwable", throwable);
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:14,代码来源:ThrowableInterceptor.java

示例12: insertServiceCallCalls

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
 * 管理员添加操作日志(后置通知)
 * 
 */
@AfterReturning(value = "insertServiceCall()", argNames = "rtv", returning = "rtv")
public void insertServiceCallCalls(JoinPoint joinPoint, Object rtv)
		throws Throwable {
	// 获取登录管理员id
	Long adminUserId = ShiroAuthenticationManager.getUserId();
	if (adminUserId == null) {// 没有管理员登录
		return;
	}
	// 判断参数
	if (joinPoint.getArgs() == null) {// 没有参数
		return;
	}
	// 获取方法名
	String methodName = joinPoint.getSignature().getName();
	// 获取操作内容
	String opContent = adminOptionContent(joinPoint.getArgs(), methodName);
	// 创建日志对象
	LogInfoEntity log = new LogInfoEntity();
	log.setUserId(adminUserId);// 设置管理员id
	log.setAccountName(ShiroAuthenticationManager.getUserAccountName());
	log.setCreateTime(new Date(System.currentTimeMillis()));// 操作时间
	log.setContent(opContent);// 操作内容
	log.setOperation("insert");// 操作

	logService.log(log);// 添加日志
}
 
开发者ID:wjggwm,项目名称:webside,代码行数:31,代码来源:LogAspect.java

示例13: getBaseRequest

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
public static BaseRequest getBaseRequest(JoinPoint joinPoint) throws Exception {
 BaseRequest returnRequest = null;
 Object[] arguments = joinPoint.getArgs();
 if(arguments != null && arguments.length > 0){
	 returnRequest = (BaseRequest) arguments[0];
 }
    return returnRequest;
}
 
开发者ID:crossoverJie,项目名称:SSM-REQUEST-CHECK,代码行数:9,代码来源:ReqNoDrcAspect.java

示例14: findService

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
private String[] findService(final JoinPoint joinPoint) {
    final JoinPoint j = AopUtils.unWrapJoinPoint(joinPoint);

    final Long id = (Long) j.getArgs()[0];

    if (id == null) {
        return new String[] {""};
    }

    return new String[] {"id=" + id};
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:12,代码来源:ServiceManagementResourceResolver.java

示例15: permissionServiceCallCalls

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
 * 管理员授权操作日志(后置通知)
 * 
 */
@AfterReturning(value = "permissionServiceCall()", argNames = "rtv", returning = "rtv")
public void permissionServiceCallCalls(JoinPoint joinPoint, Object rtv)
		throws Throwable {
	// 获取登录管理员id
	Long adminUserId = ShiroAuthenticationManager.getUserId();
	if (adminUserId == null) {// 没有管理员登录
		return;
	}
	// 判断参数
	if (joinPoint.getArgs() == null) {// 没有参数
		return;
	}
	// 获取方法名
	String methodName = joinPoint.getSignature().getName();
	// 获取操作内容
	String opContent = adminOptionContent(joinPoint.getArgs(), methodName);
	// 创建日志对象
	LogInfoEntity log = new LogInfoEntity();
	log.setUserId(adminUserId);// 设置管理员id
	log.setAccountName(ShiroAuthenticationManager.getUserAccountName());
	log.setCreateTime(new Date(System.currentTimeMillis()));// 操作时间
	log.setContent(opContent);// 操作内容
	log.setOperation("permission");// 操作

	logService.log(log);// 添加日志
}
 
开发者ID:wjggwm,项目名称:webside,代码行数:31,代码来源:LogAspect.java


注:本文中的org.aspectj.lang.JoinPoint.getArgs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。