List of usage examples for org.aspectj.lang JoinPoint getTarget
Object getTarget();
From source file:$.BizAspect.java
License:Open Source License
/** * . //www . j a va 2s. c om * * @param jionpoint * @param e */ @AfterThrowing(pointcut = "bizPointcut() && @annotation(aspectLogger)", throwing = "e") public void throwingAdvice(JoinPoint jionpoint, AspectLogger aspectLogger, Exception e) { /* * ???. */ String targetClassName = jionpoint.getTarget().getClass().getName(); /* * ???. */ String targetMethodName = jionpoint.getSignature().getName(); /* * ??. */ String desc = aspectLogger.value(); /* * ?. */ StringBuilder aspectMessage = new StringBuilder(); aspectMessage.append("[]:(").append(desc).append("),(").append(targetClassName) .append(".").append(targetMethodName).append(")").append(",?()"); /* * . */ logger.info(aspectMessage.toString()); }
From source file:$.CommonAspect.java
License:Open Source License
/** * ./*from w w w. j ava 2 s .co m*/ * * @param jionpoint * @param e */ @AfterThrowing(pointcut = "commonPointcut() && @annotation(aspectLogger)", throwing = "e") public void throwingAdvice(JoinPoint jionpoint, AspectLogger aspectLogger, Exception e) { /* * ???. */ String targetClassName = jionpoint.getTarget().getClass().getName(); /* * ???. */ String targetMethodName = jionpoint.getSignature().getName(); /* * ??. */ String desc = aspectLogger.value(); /* * ?. */ StringBuilder aspectMessage = new StringBuilder(); aspectMessage.append("[]:(").append(desc).append("),(").append(targetClassName) .append(".").append(targetMethodName).append(")").append(",?()"); /* * . */ logger.info(aspectMessage.toString()); }
From source file:$.CoreAspect.java
License:Open Source License
/** * ./*from ww w.j a v a 2 s .c o m*/ * * @param jionpoint * @param e */ @AfterThrowing(pointcut = "corePointcut() && @annotation(aspectLogger)", throwing = "e") public void throwingAdvice(JoinPoint jionpoint, AspectLogger aspectLogger, Exception e) { /* * ???. */ String targetClassName = jionpoint.getTarget().getClass().getName(); /* * ???. */ String targetMethodName = jionpoint.getSignature().getName(); /* * ??. */ String desc = aspectLogger.value(); /* * ?. */ StringBuilder aspectMessage = new StringBuilder(); aspectMessage.append("[]:(").append(desc).append("),(").append(targetClassName) .append(".").append(targetMethodName).append(")").append(",?()"); /* * . */ logger.info(aspectMessage.toString()); }
From source file:at.ac.tuwien.infosys.jcloudscale.datastore.aspects.DataSourceAspect.java
License:Apache License
@Before("get(@at.ac.tuwien.infosys.jcloudscale.datastore.annotations.DataSource * *.*)") public void injectDataSource(JoinPoint joinPoint) { try {/* w ww . j a v a2 s . c om*/ Field field = getFieldFromJoinPoint(joinPoint); DataSource dataSource = field.getAnnotation(DataSource.class); Datastore datastore = getDatastoreForDataSource(dataSource); setDatastoreOnField(joinPoint.getTarget(), field, datastore); } catch (NoSuchFieldException ne) { throw new DatastoreException("Error injecting datasource. Field not found. " + ne.getMessage()); } catch (IllegalAccessException ie) { throw new DatastoreException("Error injecting datasource. Illegal Access. " + ie.getMessage()); } }
From source file:at.ac.tuwien.infosys.jcloudscale.datastore.aspects.DatastoreLibAspect.java
License:Apache License
@Before("get(@at.ac.tuwien.infosys.jcloudscale.datastore.annotations.DatastoreLib * *.*)") public void injectDataSource(JoinPoint joinPoint) { try {/* www .j a v a 2 s. c om*/ Field field = getFieldFromJoinPoint(joinPoint); DatastoreLib datastoreLib = field.getAnnotation(DatastoreLib.class); Datastore datastore = getDatastoreForDatastoreLib(datastoreLib); LibWrapper libWrapper = getWrapperForDatastoreLib(datastoreLib, datastore); setLibWrapperField(joinPoint.getTarget(), field, libWrapper, datastore); } catch (NoSuchFieldException ne) { throw new DatastoreException("Error injecting datastore lib. Field not found. " + ne.getMessage()); } catch (IllegalAccessException ie) { throw new DatastoreException("Error injecting datastore lib. Illegal Access. " + ie.getMessage()); } }
From source file:cn.com.infcn.superspider.service.impl.CheckHandlerImpl.java
/** * DB?// w w w . j av a 2 s . c o m * * @author lihf * @date 2016420 ?6:28:01 * @param joinPoint * @throws Exception */ @SuppressWarnings("null") @Deprecated @Override public void checkDataBase(JoinPoint joinPoint) throws Exception { init(); Date expireDate = this.license.getExpireDate(); Date currentDay = new Date(); SimpleDateFormat dataFormat = new SimpleDateFormat("yyyy-MM-dd"); String currentDayStr = dataFormat.format(currentDay); Date toDay = dataFormat.parse(currentDayStr); boolean verifyFlag = toDay.after(expireDate); if (verifyFlag) { throw new Exception("??"); } logger.debug("??" + joinPoint.getTarget().getClass().getName() + " ??" + joinPoint.getSignature().getName()); logger.debug("-----------------DB?-------------------------------"); Object[] args = joinPoint.getArgs(); for (int i = 0; i < args.length; i++) { logger.debug(args[i]); if (args[i] instanceof DbConfig) { DbConfig dbConfig = (DbConfig) args[i]; // Map<String, Integer> map = licenseDb.getDbSupport(); Map<String, Integer> map = null; String dbType = dbConfig.getDsType(); Integer num = map.get(dbType); if (null == num) { throw new Exception("" + dbType + "??"); } Map<String, Object> params = new HashMap<String, Object>(); params.put("dsType", dbType); String hql = " select count(t.dsId) from DbSource t where t.dsType=:dsType "; long count = dbSourceDao.count(hql, params); if (count >= num.longValue()) { throw new Exception( "" + dbType + "??" + num.longValue() + "?"); } } } logger.debug("-----------------DB??-------------------------------"); }
From source file:cn.mypandora.log.MyLogAspect.java
License:Apache License
/** * ??/*from ww w . java 2 s . c o m*/ * * @param point * @throws Throwable */ @After("pointcut()") public void afterSuccessLog(JoinPoint point) throws Throwable { // MethodSignature joinMethodSignature = (MethodSignature) point.getSignature(); //?? Method method = joinMethodSignature.getMethod(); String methodName = method.getName(); Class<?>[] parameterTypes = method.getParameterTypes(); // Object target = point.getTarget(); method = target.getClass().getMethod(methodName, parameterTypes); if (method != null) { boolean hasAnnotation = method.isAnnotationPresent(MyMethodAnno.class); if (hasAnnotation) { MyMethodAnno anno = method.getAnnotation(MyMethodAnno.class); BaseLog log = new BaseLog(); log.setCreateTime(new Timestamp(System.currentTimeMillis())); log.setName("???"); log.setIp("???"); log.setDescription(anno.description()); service.addLog(log); } } }
From source file:com.agiletec.plugins.jpblog.apsadmin.content.IntroNewContentActionAspect.java
License:Open Source License
@After("execution(* com.agiletec.plugins.jacms.apsadmin.content.IntroNewContentAction.createNew())") public void presetBlogAttributes(JoinPoint joinPoint) { try {/*from www . ja va 2 s . com*/ IntroNewContentAction action = (IntroNewContentAction) joinPoint.getTarget(); Content content = action.getContent(); HttpServletRequest request = ServletActionContext.getRequest(); UserDetails currentUser = (UserDetails) request.getSession() .getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER); AttributeInterface authorAttribute = content .getAttributeByRole(JpblogSystemConstants.ATTRIBUTE_ROLE_AUTHOR); if (null != authorAttribute) { ((MonoTextAttribute) authorAttribute).setText(currentUser.getUsername()); } TimestampAttribute timeAttribute = (TimestampAttribute) content .getAttributeByRole(JpblogSystemConstants.ATTRIBUTE_ROLE_DATE); if (null != timeAttribute) { Date now = new Date(); ((TimestampAttribute) timeAttribute).setDate(now); } } catch (Throwable t) { _logger.error("Error presetting Blog Attributes", t); throw new RuntimeException("Error presetting Blog Attributes", t); } }
From source file:com.agiletec.plugins.jpcontentworkflow.apsadmin.content.IntroNewContentActionAspect.java
License:Open Source License
@After("execution(* com.agiletec.plugins.jacms.apsadmin.content.IntroNewContentAction.createNewVoid())") public void checkCreateNewContent(JoinPoint joinPoint) { try {/* w w w . j av a 2 s . c om*/ IntroNewContentAction action = (IntroNewContentAction) joinPoint.getTarget(); List<SmallContentType> allowedContentTypes = this.getAllowedContentTypes(); boolean check = false; for (int i = 0; i < allowedContentTypes.size(); i++) { SmallContentType contentType = allowedContentTypes.get(i); if (contentType.getCode().equals(action.getContentTypeCode())) { check = true; break; } } if (!check) { SmallContentType contentType = (SmallContentType) this.getContentManager().getSmallContentTypesMap() .get(action.getContentTypeCode()); String typeDescr = contentType != null ? contentType.getCode() : action.getContentTypeCode(); action.addFieldError("contentTypeCode", action.getText("error.content.contentType.userNotAllowed", typeDescr)); } } catch (Throwable t) { ApsSystemUtils.logThrowable(t, this, "getAllowedContentTypes", "Error checking content type authorization"); throw new RuntimeException("Error extracting allowed content types", t); } }
From source file:com.arcbees.test.CurrentScenarioAspect.java
License:Apache License
@Before("(call(public * cucumber.runtime.model.CucumberScenario.run(..))) " + "|| (call(public * cucumber.runtime.model.CucumberTagStatement.run(..)) " + "&& target(cucumber.runtime.model.CucumberScenario))") public void beforeRunningScenario(JoinPoint thisJoinPoint) throws InterruptedException { scenario.set((CucumberScenario) thisJoinPoint.getTarget()); lock.lock();//www .ja v a2s .co m registerSteps(scenario.get()); }