本文整理汇总了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);
}
}
示例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);// 添加日志
}
示例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);
}
示例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);
}
}
示例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;
}
示例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");
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);// 添加日志
}
示例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;
}
示例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};
}
示例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);// 添加日志
}