业务中Spring使用
不管是MVC框架还是DAO框架,在业务场景中能够通用的个人觉得AOP是一个重点,看是不是可以合理使用,其他的框架都是基础框架
==================================
第一个AOP学习,对其类进行增强。
import java.util.Map;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.yyb.service.IAuthService;
import com.yyb.ws.SecurityMannager;
@Component
@Aspect
public class AuthServiceImpl implements IAuthService {
@Autowired
private SecurityMannager securityMannager;
//@After(value="pointRegister(map)",argNames="map")
@After(value="execution(* com.yyb.service.impl.UserServiceImpl.register(..)) && args(map)",argNames="map")
public void authOther(Map<String,String> map) {
System.out.println("AuthServiceImpl.authOther(map=" + map + ") in authOther ");
}
@Pointcut(value="execution(* com.yyb.service.impl.UserServiceImpl.login(..)) && args(cfg,other)",argNames="cfg,other")
public void pointAuth(String cfg,String other){}
//@Before(value="pointAuth(cfg,other)",argNames="cfg,other")
@Before(value="execution(* com.yyb.service.impl.UserServiceImpl.login(..)) && args(cfg,other)",argNames="cfg,other")
@Override
public void auth(String cfg,String other) {
securityMannager.doCheck(cfg + "-" + other );
System.out.println("AuthServiceImpl.auth(cfg=" + cfg + ",other=" + other + ") in auth ");
}
}
import java.util.Map;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import com.yyb.service.IUserService;
@Component
public class UserServiceImpl implements IUserService {
@Override
public void login(String name,String pass) {
System.out.println("UserServiceImpl.login() in login......");
}
@Override
public void register(Map<String,String> map) {
System.out.println("UserServiceImpl.register() in register......");
}
@Override
public void findUserByParams(String params) {
}
}
业务中Spring使用的更多相关文章
- Spring事件,ApplicationEvent在业务中的应用
前言 关于事件驱动模型,百度百科在有明确的解释.在JDK的Util包里抽象了事件驱动,有兴趣的朋友可以自行去看下相关类的定义.Spring事件模型ApplicationEvent是基于JDK里的事件模 ...
- redis整合Spring集群搭建及业务中的使用
1.redis安装 Redis是c语言开发的. 安装redis需要c语言的编译环境.如果没有gcc需要在线安装.yum install gcc-c++ 安装步骤: 第一步:redis的源码包上传到li ...
- Maven项目中Spring整合Mybatis
Maven项目中Spring整合Mybatis 添加jar包依赖 spring需要的jar包依赖 <dependency> <groupId>org.springframewo ...
- 初识quartz 并分析 项目中spring整合quartz的配置【原创+转载】
初识quartz 并分析 项目中spring整合quartz的配置[原创+转载]2018年01月29日 12:08:07 守望dfdfdf 阅读数:114 标签: quartz 更多个人分类: 工具 ...
- SpringPlugin-Core在业务中的应用
前言 一直负责部门的订单模块,从php转到Java也是如此,换了一种语言来实现订单相关功能.那么Spring里有很多已经搭建好基础模块的设计模式来帮助我们解耦实际业务中的逻辑,用起来非常的方便!就比如 ...
- log4j中Spring控制台输出Debug级信息过多解决方法
log4j中Spring控制台输出Debug级信息过多解决方法 >>>>>>>>>>>>>>>>> ...
- 区块链Fabric技术在托管业务中的运用初探
区块链Fabric技术在托管业务中的运用初探 什么是Fabric技术 HyperLedger是IBM.Intel等多家公司正开展的一个区块链项目,包含了Fabric.Iroha等多项技术,其中最为活跃 ...
- ideal中spring的xml文件没有提示的问题
ideal中spring的xml文件没有提示的问题 今天第一次用ideal来练习spring,发现和视频中老师不一样,我的没有提示.老师的视频里,他写了个<mvc:a 就会有一系列的提示,然 ...
- springboot中spring.profiles.include
springboot中spring.profiles.include的妙用. 我们有这样的一个springboot项目.项目分为开发.测试.生产三个不同阶段(环境),每个阶段都会有db.ftp.red ...
随机推荐
- SELECT INTO 和 INSERT INTO SELECT 两种表复制语句.txt
Insert是T-sql中常用语句,Insert INTO table(field1,field2,...) values(value1,value2,...)这种形式的在应用程序开发中必不可少.但我 ...
- MySQL【Update误操作】回滚(转)
前言: 继上一篇MySQL[Delete误操作]回滚之后,现在介绍下Update回滚,操作数据库时候难免会因为“大意”而误操作,需要快速恢复的话通过备份来恢复是不太可能的,因为需要还原和bi ...
- Ruby Exception
begin #可能发生异常的地方 rescue #如何处理异常 end rescue,哈哈,太有爱的一个单词了... begin #可能发生异常的地方 rescue => exception # ...
- wcf stream 不知道长度的情况下,读取stream
http://bbs.csdn.net/topics/360163784 string filepath = @"http://ww4.sinaimg.cn/thumbnail/6741e0 ...
- TX Textcontrol 使用总结六——常用属性设置
1.字体设置 Tx textcontrol字体设置以版本22为例,直接设置FontSize =int,字体大小将小于正常其他控件字体设置.应做如下处理(仅供参考) this.textControl1. ...
- erlang的escript脚本
参考霸爷的博客 测试例子 #!/usr/bin/env escript %%! -smp enable -sname mmcshadow -mnesia debug verbose[/color] m ...
- android如何播放资源文件夹raw中的视频
转自这里 videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/&qu ...
- 什么是编解码器codec
编解码器(英语:codec)指的是一个能够对一个信号或者一个数据流进行编解码操作的设备或者程序.这里指的变换既包括将信号或者数据流进行编码(通常是为了传输.存储或者加密)或者提获取到一个编码流的操作, ...
- [Vue]学习中遇到的疑点
computed:计算属性,官方api上说计算属性的结果会被缓存,除非依赖的响应式属性变化才会重新计算.但是经过测试并没有缓存.案例: computed: { now: function () { c ...
- Spark MLlib知识点学习整理
MLlib的设计原理:把数据以RDD的形式表示,然后在分布式数据集上调用各种算法.MLlib就是RDD上一系列可供调用的函数的集合. 操作步骤: 1.用字符串RDD来表示信息. 2.运行MLlib中的 ...