本文整理匯總了Java中org.aspectj.lang.ProceedingJoinPoint.proceed方法的典型用法代碼示例。如果您正苦於以下問題:Java ProceedingJoinPoint.proceed方法的具體用法?Java ProceedingJoinPoint.proceed怎麽用?Java ProceedingJoinPoint.proceed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.aspectj.lang.ProceedingJoinPoint
的用法示例。
在下文中一共展示了ProceedingJoinPoint.proceed方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: aroundAdvise
import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
public int aroundAdvise(ProceedingJoinPoint joinPoint) {
long start_time=System.currentTimeMillis();
logger.info("around advise before "+joinPoint.getSignature()
+" B.L.method getting invoked");
Integer o=null;
try {
o=(Integer)joinPoint.proceed();
logger.info("number of rows affected:-"+o);
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
logger.info("around advise after "+joinPoint.getSignature()+
" B.L.method getting invoked");
long end_time=System.currentTimeMillis();
logger.info(joinPoint.getSignature()+" took " +
(end_time-start_time)+" to complete");
return o.intValue();
}
示例2: executeWithoutPostProcessor
import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
private Object executeWithoutPostProcessor(
ProceedingJoinPoint call, ArgumentDiscover argumentDiscover) throws Throwable {
final Object[] args = call.getArgs();
final Message message = argumentDiscover.message;
final String exchange = argumentDiscover.exchangeOfSender;
final String routingKey = argumentDiscover.routingKey;
before(message, exchange, routingKey);
try {
Object result = call.proceed(args);
spanManager.afterSend(null);
return result;
} catch (Exception e) {
spanManager.afterSend(e);
throw e;
}
}
示例3: constructorAnnotatedTrace
import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
@Around("methodAnnotatedWithTrace() || constructorAnnotatedTrace()")
public Object traceMethod(final ProceedingJoinPoint joinPoint) throws Throwable {
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Trace trace = methodSignature.getMethod().getAnnotation(Trace.class);
if (trace!=null && !trace.enable()) {
return joinPoint.proceed();
}
String className = methodSignature.getDeclaringType().getSimpleName();
String methodName = methodSignature.getName();
final StopWatch stopWatch = new StopWatch();
stopWatch.start();
Object result = joinPoint.proceed();
stopWatch.stop();
if (Preconditions.isBlank(className)) {
className = "Anonymous class";
}
L.i(className, buildLogMessage(methodName, stopWatch.getElapsedTime()));
return result;
}
示例4: returnValueHandle
import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
@Around( "execution(org.springframework.http.ResponseEntity com.aidijing.*.controller.*Controller.*(..)) )" )
public Object returnValueHandle ( ProceedingJoinPoint joinPoint ) throws Throwable {
Object returnValue = joinPoint.proceed();
ResponseEntity responseEntity = ( ResponseEntity ) returnValue;
// 用戶權限或者用戶自定義處理
final RolePermissionResource currentRequestRolePermissionResource = ContextUtils.getCurrentRequestRolePermissionResource();
if ( Objects.isNull( currentRequestRolePermissionResource ) ) {
return returnValue;
}
if ( ResponseEntityPro.WILDCARD_ALL.equals( currentRequestRolePermissionResource.getResourceApiUriShowFields() ) ) {
ContextUtils.removeCurrentRequestRolePermissionResource();
return returnValue;
}
final String resourceApiUriShowFields = currentRequestRolePermissionResource.getResourceApiUriShowFields();
final String filterAfterJsonBody = toFilterJson( responseEntity.getBody() , resourceApiUriShowFields );
final Object filterAfterBody = jsonToType( filterAfterJsonBody , responseEntity.getBody().getClass() );
ContextUtils.removeCurrentRequestRolePermissionResource();
return new ResponseEntity<>( filterAfterBody ,
responseEntity.getHeaders() ,
responseEntity.getStatusCode() );
}
示例5: aroundJoinPoint
import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
@Around("methodAnnotated()")//在連接點進行方法替換
public Object aroundJoinPoint(ProceedingJoinPoint joinPoint) throws Throwable {
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
String methodName = methodSignature.getName();
MemoryCacheManager mMemoryCacheManager = MemoryCacheManager.getInstance();
StringBuilder keyBuilder = new StringBuilder();
keyBuilder.append(methodName);
for (Object obj : joinPoint.getArgs()) {
if (obj instanceof String) keyBuilder.append((String) obj);
else if (obj instanceof Class) keyBuilder.append(((Class) obj).getSimpleName());
}
String key = keyBuilder.toString();
Object result = mMemoryCacheManager.get(key);//key規則 : 方法名+參數1+參數2+...
LogUtils.showLog("MemoryCache", "key:" + key + "--->" + (result != null ? "not null" : "null"));
if (result != null) return result;//緩存已有,直接返回
result = joinPoint.proceed();//執行原方法
if (result instanceof List && result != null && ((List) result).size() > 0 //列表不為空
|| result instanceof String && !TextUtils.isEmpty((String) result)//字符不為空
|| result instanceof Object && result != null)//對象不為空
mMemoryCacheManager.add(key, result);//存入緩存
LogUtils.showLog("MemoryCache", "key:" + key + "--->" + "save");
return result;
}
示例6: execution
import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
@Around("@annotation(com.nibado.example.springaop.aspects.Timed) && execution(public * *(..))")
public Object time(final ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
long start = System.currentTimeMillis();
Object value;
try {
value = proceedingJoinPoint.proceed();
} catch (Throwable throwable) {
throw throwable;
} finally {
long duration = System.currentTimeMillis() - start;
log.info(
"{}.{} took {} ms",
proceedingJoinPoint.getSignature().getDeclaringType().getSimpleName(),
proceedingJoinPoint.getSignature().getName(),
duration);
}
return value;
}
示例7: monitorElapsedTime
import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
/**
* Monitor the elapsed time of method on controller layer, in
* order to detect performance problems as soon as possible.
* If elapsed time > 1 s, log it as an error. Otherwise, log it
* as an info.
*/
@Around("controllerLayer()")
public Object monitorElapsedTime(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
// Timing the method in controller layer
StopWatch stopWatch = new StopWatch();
stopWatch.start();
Object result = proceedingJoinPoint.proceed();
stopWatch.stop();
// Log the elapsed time
double elapsedTime = stopWatch.getTime() / 1000.0;
Signature signature = proceedingJoinPoint.getSignature();
String infoString = "[" + signature.toShortString() + "][Elapsed time: " + elapsedTime + " s]";
if (elapsedTime > 1) {
log.error(infoString + "[Note that it's time consuming!]");
} else {
log.info(infoString);
}
// Return the result
return result;
}
示例8: handler
import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
/**
* 處理補償內嵌的遠程方法的時候,不提交,隻調用
*
* @param point point 切點
* @param info 信息
* @return Object
* @throws Throwable 異常
*/
@Override
public Object handler(ProceedingJoinPoint point, TxTransactionInfo info) throws Throwable {
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus transactionStatus = platformTransactionManager.getTransaction(def);
try {
return point.proceed();
} finally {
platformTransactionManager.rollback(transactionStatus);
}
}
示例9: setUserVisibleHintProcess
import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
@Around("setUserVisibleHint()")
public Object setUserVisibleHintProcess(ProceedingJoinPoint joinPoint) throws Throwable {
Object result = joinPoint.proceed();
Object puppet = joinPoint.getTarget();
//Only inject the class that marked by Puppet annotation.
Object[] args = joinPoint.getArgs();
Method onDestroy = getRiggerMethod("setUserVisibleHint", Object.class, boolean.class);
onDestroy.invoke(getRiggerInstance(), puppet, args[0]);
return result;
}
示例10: handlerControllerMethod
import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
@Around("controllerMethod()")
public Object handlerControllerMethod(ProceedingJoinPoint pjp) {
long startTime = System.currentTimeMillis();
ResultBean<?> result;
try {
result = (ResultBean<?>) pjp.proceed();
logger.info(pjp.getSignature() + "use time:" + (System.currentTimeMillis() - startTime));
} catch (Throwable e) {
result = handlerException(pjp, e);
}
return result;
}
示例11: around
import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
@Around("execution(* io.renren.common.cache.RedisCache.*(..))")
public Object around(ProceedingJoinPoint point) throws Throwable {
Object result = null;
if (open) {
try {
result = point.proceed();
} catch (Exception e) {
log.error("redis error", e);
throw new RRException("Redis服務異常");
}
}
return result;
}
示例12: doBefore
import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
/**
* 前置通知 用於攔截Controller層是否有某種權限操作
* @param joinPoint 切點
* @throws InterruptedException
* @throws IOException
*/
/*
@Before("controllerAspect()")
public void doBefore(JoinPoint joinPoint) throws InterruptedException, IOException{
//讀取session中的用戶
HttpSession session = request.getSession();
User user = (User) session.getAttribute("userInfo");
if(user != null){
String permissionInfo = getControllerMethodPemissionInfo(joinPoint);
Subject currentUser = SecurityUtils.getSubject();
try{
currentUser.checkPermission(permissionInfo);
}catch (Exception e) {
System.out.println("沒有"+permissionInfo+"權限");
//throw new UnauthorizedException(permissionInfo);
}
}
}*/
@Around("controllerAspect()")
public Object doAround(ProceedingJoinPoint pjp) throws Throwable{
String permissionInfo = getControllerMethodPemissionInfo(pjp);
Subject currentUser = SecurityUtils.getSubject();
try{
if(currentUser!=null){
currentUser.checkPermission(permissionInfo);
SystemContext.setAuthStatus(3); //-- 享有授權
}
}catch (Exception e) {
System.out.println("沒有"+permissionInfo+"權限");
SystemContext.setAuthStatus(2); //-- 無授權
return "{message:unauthorized}"; //-- 這種寫法相當於給MV.setViewName(); 如何寫成"redirect:/exception/unauthorized"相當於調用Controller
}
return pjp.proceed();
}
示例13: executeAroundConvertAndSendThreeArgsWithPostProcessor
import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
@Around(
"execution(* org.springframework.amqp.core.AmqpTemplate.convertAndSend(String,String,Object,org.springframework.amqp.core.MessagePostProcessor))")
public void executeAroundConvertAndSendThreeArgsWithPostProcessor(ProceedingJoinPoint call)
throws Throwable {
final ArgumentDiscover discoverArguments = ArgumentDiscover.from(call);
final MessagePostProcessor argPostProcessor = discoverArguments.messagePostProcessor;
final boolean byPass = argPostProcessor instanceof SpanManagerMessagePostProcessor;
if (byPass) {
call.proceed(call.getArgs());
} else {
executeConvertAndSendWithoutPostProcessor(call, discoverArguments);
}
}
示例14: handleAdminPage
import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
/**
* 處理admin下麵的頁麵
*
* @param individuation 個性化名稱
* @param joinPoint
* @return
* @throws Throwable
*/
private Object handleAdminPage(String individuation, ProceedingJoinPoint joinPoint) throws Throwable {
MMSnsCommonUserEntity loginUser = (MMSnsCommonUserEntity) request.getSession().getAttribute(MMSnsCommonUserEntity.MMSNS_COMMON_USER);
if (individuation == null) {
return "redirect:/profile/" + loginUser.getIndividuation() + "/home";
}
if (!individuation.equals(loginUser.getIndividuation())) {
return "redirect:/profile/" + loginUser.getIndividuation() + "/home";
}
return joinPoint.proceed();
}
示例15: byId
import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
@Around("execution(* byId(..))")
public ProductInformation byIdQueryLogging(ProceedingJoinPoint jp) throws Throwable {
log.info("byId query is about to run");
ProductInformation pi = (ProductInformation) jp.proceed(jp.getArgs());
log.info("byId query was executed");
return pi;
}