本文整理匯總了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);// 添加日誌
}