List of usage examples for org.aspectj.lang ProceedingJoinPoint proceed
public Object proceed() throws Throwable;
From source file:com.netsteadfast.greenstep.aspect.HessianServiceProxyAspect.java
License:Apache License
@Around(AspectConstants.LOGIC_SERVICE_PACKAGE) @Override/*from w ww . ja va2s.com*/ public Object logicServiceProcess(ProceedingJoinPoint pjp) throws AuthorityException, ServiceException, Throwable { if (!GreenStepHessianUtils.isEnableCallRemote()) { return pjp.proceed(); } return this.proxyProcess(pjp); }
From source file:com.netsteadfast.greenstep.aspect.HessianServiceProxyAspect.java
License:Apache License
@Around(AspectConstants.BASE_SERVICE_PACKAGE) @Override//from w ww. j av a 2 s .c o m public Object baseServiceProcess(ProceedingJoinPoint pjp) throws AuthorityException, ServiceException, Throwable { if (!GreenStepHessianUtils.isEnableCallRemote()) { return pjp.proceed(); } return this.proxyProcess(pjp); }
From source file:com.netsteadfast.greenstep.aspect.HessianServiceProxyAspect.java
License:Apache License
/** * no for DataAccessObject//from w ww . j a v a2 s .c o m */ @Override public Object dataAccessObjectProcess(ProceedingJoinPoint pjp) throws AuthorityException, ServiceException, Throwable { return pjp.proceed(); }
From source file:com.netsteadfast.greenstep.aspect.HessianServiceProxyAspect.java
License:Apache License
private Object proxyProcess(ProceedingJoinPoint pjp) throws AuthorityException, ServiceException, Throwable { MethodSignature signature = (MethodSignature) pjp.getSignature(); Annotation[] annotations = pjp.getTarget().getClass().getAnnotations(); String serviceId = AspectConstants.getServiceId(annotations); /**/*from w w w . j a va2 s . c om*/ * ???? service-bean */ if (!GreenStepHessianUtils.isProxyServiceId(serviceId)) { //logger.info( "reject proxy service: " + serviceId ); return pjp.proceed(); } String userId = StringUtils.defaultString((String) SecurityUtils.getSubject().getPrincipal()); if (GreenStepHessianUtils.getConfigHessianHeaderCheckValueModeEnable()) { /** * ???? service-bean */ if (StringUtils.isBlank(userId)) { logger.warn("no userId"); pjp.proceed(); } /** * ???? service-bean */ if (GreenStepHessianUtils.isProxyBlockedAccountId(userId)) { logger.warn("reject proxy service: " + serviceId + " , blocked userId: " + userId); return pjp.proceed(); } } String serviceInterfacesName = ""; Class<?> serviceInterfaces[] = pjp.getTarget().getClass().getInterfaces(); for (Class<?> clazz : serviceInterfaces) { if (clazz.getName().indexOf(".service.") > -1) { serviceInterfacesName = clazz.getName(); } } if (StringUtils.isBlank(serviceInterfacesName)) { logger.error("error no service interface: " + serviceId); throw new Exception("error no service interface: " + serviceId); } String url = GreenStepHessianUtils.getServiceUrl(serviceId); String theSystemPath = ApplicationSiteUtils.getHost(Constants.getSystem()) + "/" + ApplicationSiteUtils.getContextPath(Constants.getSystem()); /** * ?????, ? HessianServiceProxyAspect ? (server-remote???) * http://127.0.0.1:8080/ * hessian.enable=Y ???, ?url hessian.serverUrl=http://127.0.0.1:8080/ * */ if (url.indexOf(theSystemPath) > -1) { logger.error("cannot open same-server. now system contextPath = " + theSystemPath + " , but proxy url = " + url); throw new Exception("cannot open same-server. now system contextPath = " + theSystemPath + " , but proxy url = " + url); } logger.info("proxy url = " + url); HessianProxyFactory factory = null; Object proxyServiceObject = null; if (GreenStepHessianUtils.getConfigHessianHeaderCheckValueModeEnable()) { // ?checkValue? factory = new GreenStepHessianProxyFactory(); ((GreenStepHessianProxyFactory) factory) .setHeaderCheckValue(GreenStepHessianUtils.getEncAuthValue(userId)); proxyServiceObject = ((GreenStepHessianProxyFactory) factory) .createForHeaderMode(Class.forName(serviceInterfacesName), url); } else { // ?checkValue? factory = new HessianProxyFactory(); proxyServiceObject = factory.create(Class.forName(serviceInterfacesName), url); } Method[] proxyObjectMethods = proxyServiceObject.getClass().getMethods(); Method proxyObjectMethod = null; if (null == proxyObjectMethods) { logger.error("error no find proxy method: " + serviceId); throw new Exception("error no find proxy method: " + serviceId); } for (Method m : proxyObjectMethods) { if (m.getName().equals(signature.getMethod().getName()) && Arrays.equals(m.getParameterTypes(), signature.getMethod().getParameterTypes())) { proxyObjectMethod = m; } } if (null == proxyObjectMethod) { logger.error("error no execute proxy method: " + serviceId); throw new Exception("error no execute proxy method: " + serviceId); } Object resultObj = null; try { resultObj = proxyObjectMethod.invoke(proxyServiceObject, pjp.getArgs()); this.setReCalculateSizePageOfForPageFindGridResult(resultObj, pjp.getArgs()); } catch (InvocationTargetException e) { if (e.getMessage() != null) { throw new ServiceException(e.getMessage().toString()); } if (e.getTargetException().getMessage() != null) { throw new ServiceException(e.getTargetException().getMessage().toString()); } throw e; } catch (Exception e) { logger.error(e.getMessage().toString()); throw e; } logger.info("proxy success: " + serviceId + " method: " + proxyObjectMethod.getName()); return resultObj; }
From source file:com.netsteadfast.greenstep.aspect.ServiceAuthorityCheckAspect.java
License:Apache License
/** * no enable for scan DAO package/*from w w w. j a v a2s . c om*/ */ //@Around( AspectConstants.DATA_ACCESS_OBJECT_PACKAGE ) @Override public Object dataAccessObjectProcess(ProceedingJoinPoint pjp) throws AuthorityException, ServiceException, Throwable { /** * do something... */ return pjp.proceed(); }
From source file:com.netsteadfast.greenstep.aspect.ServiceAuthorityCheckAspect.java
License:Apache License
/** * no enable for scan Base service package *///from w w w.j a va2 s . c om //@Around( AspectConstants.BASE_SERVICE_PACKAGE ) @Override public Object baseServiceProcess(ProceedingJoinPoint pjp) throws AuthorityException, ServiceException, Throwable { /** * do something... */ return pjp.proceed(); }
From source file:com.netsteadfast.greenstep.aspect.ServiceAuthorityCheckAspect.java
License:Apache License
@Around(AspectConstants.LOGIC_SERVICE_PACKAGE) public Object logicServiceProcess(ProceedingJoinPoint pjp) throws AuthorityException, ServiceException, Throwable { MethodSignature signature = (MethodSignature) pjp.getSignature(); Annotation[] annotations = pjp.getTarget().getClass().getAnnotations(); String serviceId = AspectConstants.getServiceId(annotations); Subject subject = SecurityUtils.getSubject(); Method method = signature.getMethod(); if (subject.hasRole(Constants.SUPER_ROLE_ALL) || subject.hasRole(Constants.SUPER_ROLE_ADMIN)) { SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true); return pjp.proceed(); }// www . j a v a 2 s . c om if (StringUtils.isBlank(serviceId)) { // service id SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true); return pjp.proceed(); } if (!this.isServiceAuthorityCheck(annotations)) { // ServiceAuthority check=false ? SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true); return pjp.proceed(); } Annotation[] methodAnnotations = method.getAnnotations(); if (this.isServiceMethodAuthority(serviceId, methodAnnotations, subject)) { SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true); return pjp.proceed(); } logger.warn("[decline] user[" + subject.getPrincipal() + "] " + pjp.getTarget().getClass().getName() + " - " + signature.getMethod().getName()); SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), false); throw new AuthorityException(SysMessageUtil.get(GreenStepSysMsgConstants.NO_PERMISSION)); }
From source file:com.netsteadfast.greenstep.aspect.ServiceScriptExpressionProcessAspect.java
License:Apache License
@Around(AspectConstants.LOGIC_SERVICE_PACKAGE) public Object logicServiceProcess(ProceedingJoinPoint pjp) throws AuthorityException, ServiceException, Throwable { Annotation[] annotations = pjp.getTarget().getClass().getAnnotations(); MethodSignature signature = (MethodSignature) pjp.getSignature(); if (annotations == null || annotations.length < 1) { return pjp.proceed(); }// w w w. j a va 2 s . co m String beanId = AspectConstants.getServiceId(annotations); /** * Hession proxy ?, remote-server ?, client??, ???, remote-server, client */ if (GreenStepHessianUtils.isEnableCallRemote() && GreenStepHessianUtils.isProxyServiceId(beanId)) { return pjp.proceed(); } if (StringUtils.isBlank(beanId)) { return pjp.proceed(); } if (!ServiceScriptExpressionUtils.needProcess(beanId, signature.getMethod().getName(), Constants.getSystem())) { return pjp.proceed(); } Method method = signature.getMethod(); ServiceScriptExpressionUtils.processBefore(beanId, signature.getMethod(), Constants.getSystem(), pjp); Object obj = pjp.proceed(); ServiceScriptExpressionUtils.processAfter(beanId, method, Constants.getSystem(), obj, pjp); return obj; }
From source file:com.netsteadfast.greenstep.service.aspect.ServiceAuthorityCheckAspect.java
License:Apache License
@Around(ServiceAspectConstants.AROUND_VALUE) public Object aroundMethod(ProceedingJoinPoint pjp) throws AuthorityException, ServiceException, Throwable { MethodSignature signature = (MethodSignature) pjp.getSignature(); Annotation[] annotations = pjp.getTarget().getClass().getAnnotations(); String serviceId = this.getServiceId(annotations); Subject subject = SecurityUtils.getSubject(); Method method = signature.getMethod(); if (subject.hasRole(Constants.SUPER_ROLE_ALL) || subject.hasRole(Constants.SUPER_ROLE_ADMIN)) { SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true); return pjp.proceed(); }// www .j av a 2 s . c om if (StringUtils.isBlank(serviceId)) { // service id SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true); return pjp.proceed(); } if (!this.isServiceAuthorityCheck(annotations)) { // ServiceAuthority check=false ? SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true); return pjp.proceed(); } Annotation[] methodAnnotations = method.getAnnotations(); if (this.isServiceMethodAuthority(serviceId, methodAnnotations, subject)) { SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true); return pjp.proceed(); } logger.warn("[decline] user[" + subject.getPrincipal() + "] " + pjp.getTarget().getClass().getName() + " - " + signature.getMethod().getName()); SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), false); throw new AuthorityException(SysMessageUtil.get(GreenStepSysMsgConstants.NO_PERMISSION)); }
From source file:com.netsteadfast.greenstep.service.aspect.ServiceScriptExpressionProcessAspect.java
License:Apache License
@Around(ServiceAspectConstants.AROUND_VALUE) public Object aroundMethod(ProceedingJoinPoint pjp) throws AuthorityException, ServiceException, Throwable { Annotation[] annotations = pjp.getTarget().getClass().getAnnotations(); MethodSignature signature = (MethodSignature) pjp.getSignature(); if (annotations == null || annotations.length < 1) { return pjp.proceed(); }/*w w w .j a v a 2 s . c om*/ String beanId = ""; for (int i = 0; i < annotations.length; i++) { if (annotations[i] instanceof Service) { beanId = ((Service) annotations[i]).value(); } } if (StringUtils.isBlank(beanId)) { return pjp.proceed(); } if (!ServiceScriptExpressionUtils.needProcess(beanId, signature.getMethod().getName(), Constants.getSystem())) { return pjp.proceed(); } Method method = signature.getMethod(); ServiceScriptExpressionUtils.processBefore(beanId, signature.getMethod(), Constants.getSystem(), pjp); Object obj = pjp.proceed(); ServiceScriptExpressionUtils.processAfter(beanId, method, Constants.getSystem(), obj, pjp); return obj; }