List of usage examples for org.springframework.aop MethodBeforeAdvice MethodBeforeAdvice
MethodBeforeAdvice
From source file:net.shopxx.service.impl.ConfigServiceImpl.java
public void init() { try {//from w ww . j av a 2s .com Setting setting = SystemUtils.getSetting(); setting.setSmtpPassword(null); setting.setKuaidi100Key(null); setting.setCnzzPassword(null); setting.setSmsKey(null); ProxyFactory proxyFactory = new ProxyFactory(setting); proxyFactory.setProxyTargetClass(true); proxyFactory.addAdvice(new MethodBeforeAdvice() { public void before(Method method, Object[] args, Object target) throws Throwable { if (StringUtils.startsWith(method.getName(), "set")) { throw new UnsupportedOperationException("Operation not supported"); } } }); Configuration configuration = freeMarkerConfigurer.getConfiguration(); configuration.setSharedVariable("setting", proxyFactory.getProxy()); configuration.setSharedVariable("locale", setting.getLocale()); configuration.setSharedVariable("theme", setting.getTheme()); if (setting.getIsDevelopmentEnabled()) { configuration.setSetting("template_update_delay", "0"); reloadableResourceBundleMessageSource.setCacheSeconds(0); } else { configuration.setSetting("template_update_delay", templateUpdateDelay); reloadableResourceBundleMessageSource.setCacheSeconds(messageCacheSeconds); } fixedLocaleResolver.setDefaultLocale(LocaleUtils.toLocale(setting.getLocale().toString())); } catch (TemplateModelException e) { throw new RuntimeException(e.getMessage(), e); } catch (TemplateException e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:org.springframework.aop.aspectj.autoproxy.AspectJAutoProxyCreatorTests.java
public TestBeanAdvisor() { setAdvice(new MethodBeforeAdvice() { @Override/* w w w.j a va2 s. c om*/ public void before(Method method, Object[] args, @Nullable Object target) throws Throwable { ++count; } }); }