spring源码-aop源码-5.1
一、aop的源码部分还是有点复杂的,但是为了更好的理解,我这里会省去很多不必要的逻辑实现过程。主要方向还是更好的理解整体代码的实现过程。
二、说明重点:aop的过程主要过程有两点:第一点,发现正确和适配的过程。第二点就是动态代理
三、源码部分
1)可能开始有点奇怪哈,从哪里下手呢?spring所有的东西还是基于配置来实现的,虽然后面修改了很多方式比如注解。但是我们这里还是从注解出发。
<aop:aspectj-autoproxy/>
说明:这个注解也算是spring的自定义注解吧,通过spring源码-自定义标签-4的解读我们可以知道解析是从NamespaceHandlerSupport的实现类开始的。
2)通过需要我们可以发现aop的NamespaceHandlerSupport的实现类为AopNamespaceHandler
public class AopNamespaceHandler extends NamespaceHandlerSupport {
public AopNamespaceHandler() {
} public void init() {
this.registerBeanDefinitionParser("config", new ConfigBeanDefinitionParser());
//这里就是自动解析过程
this.registerBeanDefinitionParser("aspectj-autoproxy", new AspectJAutoProxyBeanDefinitionParser());
this.registerBeanDefinitionDecorator("scoped-proxy", new ScopedProxyBeanDefinitionDecorator());
this.registerBeanDefinitionParser("spring-configured", new SpringConfiguredBeanDefinitionParser());
}
}
说明:<aop:aspectj-autoproxy/>的解析过程就是在AspectJAutoProxyBeanDefinitionParser下面进行解析的。
3)AspectJAutoProxyBeanDefinitionParser
class AspectJAutoProxyBeanDefinitionParser implements BeanDefinitionParser {
AspectJAutoProxyBeanDefinitionParser() {
} //解析过程,不多解释。不懂可以开自定义标签的解析方式
public BeanDefinition parse(Element element, ParserContext parserContext) {
//这里就是整个代理的过程了
AopNamespaceUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(parserContext, element);
//这里不做太多讲解,也没有写出来
this.extendBeanDefinition(element, parserContext);
return null;
}
......
}
4)registerAspectJAnnotationAutoProxyCreatorIfNecessary
public static void registerAspectJAnnotationAutoProxyCreatorIfNecessary(ParserContext parserContext, Element sourceElement) {
//注册过程:名为org.springframework.aop.config.internalAutoProxyCreator
BeanDefinition beanDefinition = AopConfigUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(parserContext.getRegistry(), parserContext.extractSource(sourceElement));
//解析proxy-target-class(设置代理模式默认false, true为cglib),expose-proxy(处理内部增强,可以自己百度)
useClassProxyingIfNecessary(parserContext.getRegistry(), sourceElement);
registerComponentIfNecessary(beanDefinition, parserContext);
}
5)registerAspectJAnnotationAutoProxyCreatorIfNecessary
public static BeanDefinition registerAspectJAnnotationAutoProxyCreatorIfNecessary(BeanDefinitionRegistry registry, Object source) {
return registerOrEscalateApcAsRequired(AnnotationAwareAspectJAutoProxyCreator.class, registry, source);
} private static BeanDefinition registerOrEscalateApcAsRequired(Class cls, BeanDefinitionRegistry registry, Object source) {
Assert.notNull(registry, "BeanDefinitionRegistry must not be null");
//如果存在org.springframework.aop.config.internalAutoProxyCreator直接使用
if (registry.containsBeanDefinition("org.springframework.aop.config.internalAutoProxyCreator")) {
BeanDefinition apcDefinition = registry.getBeanDefinition("org.springframework.aop.config.internalAutoProxyCreator");
if (!cls.getName().equals(apcDefinition.getBeanClassName())) {
int currentPriority = findPriorityForClass(apcDefinition.getBeanClassName());
int requiredPriority = findPriorityForClass(cls);
if (currentPriority < requiredPriority) {
apcDefinition.setBeanClassName(cls.getName());
}
} return null;
} else {
//没有就自己注册
RootBeanDefinition beanDefinition = new RootBeanDefinition(cls);
beanDefinition.setSource(source);
beanDefinition.getPropertyValues().add("order", -2147483648);
beanDefinition.setRole(2);
registry.registerBeanDefinition("org.springframework.aop.config.internalAutoProxyCreator", beanDefinition);
return beanDefinition;
}
}
6)注册到容器的过程就结束了,接下来就是看AnnotationAwareAspectJAutoProxyCreator.class有什么不一样了
通过上面我们可以知道,bean的后置操作。肯定是做了什么!
7)BeanPostProcessor的后置操作(不明白可以参考:spring源码-BeanPostProcessor-3.3)
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean != null) {
//通过自己封装的key获取(beanClassName_beanName)
Object cacheKey = this.getCacheKey(bean.getClass(), beanName);
//缓存中不包含
if (!this.earlyProxyReferences.contains(cacheKey)) {
//解析过程
return this.wrapIfNecessary(bean, beanName, cacheKey);
}
}
return bean;
}
8)wrapIfNecessary
protected Object wrapIfNecessary(Object bean, String beanName, Object cacheKey) {
if (this.targetSourcedBeans.contains(beanName)) {
return bean;
} else if (this.nonAdvisedBeans.contains(cacheKey)) {
return bean;
} else if (!this.isInfrastructureClass(bean.getClass()) && !this.shouldSkip(bean.getClass(), beanName)) {
//获取增强器
Object[] specificInterceptors = this.getAdvicesAndAdvisorsForBean(bean.getClass(), beanName, (TargetSource)null);
if (specificInterceptors != DO_NOT_PROXY) {
this.advisedBeans.add(cacheKey);
//创建代理
Object proxy = this.createProxy(bean.getClass(), beanName, specificInterceptors, new SingletonTargetSource(bean));
this.proxyTypes.put(cacheKey, proxy.getClass());
//返回代理过后的bean,加入容器
return proxy;
} else {
this.nonAdvisedBeans.add(cacheKey);
return bean;
}
} else {
this.nonAdvisedBeans.add(cacheKey);
return bean;
}
}
说明:增强器可以理解成对需要代理的类的增强,代理过程就是对需要的代理类进行相关处理,后续我会在动态代理讲解。
9)getAdvicesAndAdvisorsForBean
protected Object[] getAdvicesAndAdvisorsForBean(Class beanClass, String beanName, TargetSource targetSource) {
//发现合适的增强器
List advisors = this.findEligibleAdvisors(beanClass, beanName);
return advisors.isEmpty() ? DO_NOT_PROXY : advisors.toArray();
} protected List<Advisor> findEligibleAdvisors(Class beanClass, String beanName) {
//查找所有增强器
List<Advisor> candidateAdvisors = this.findCandidateAdvisors();
//发现合适的增强器
List<Advisor> eligibleAdvisors = this.findAdvisorsThatCanApply(candidateAdvisors, beanClass, beanName);
this.extendAdvisors(eligibleAdvisors);
if (!eligibleAdvisors.isEmpty()) {
eligibleAdvisors = this.sortAdvisors(eligibleAdvisors);
} return eligibleAdvisors;
}
9.1)findCandidateAdvisors
protected List<Advisor> findCandidateAdvisors() {
//发现父类是否存在
List<Advisor> advisors = super.findCandidateAdvisors();
//添加新发现的
advisors.addAll(this.aspectJAdvisorsBuilder.buildAspectJAdvisors());
return advisors;
} public List<Advisor> buildAspectJAdvisors() {
List<String> aspectNames = null;
synchronized(this) {
aspectNames = this.aspectBeanNames;
if (aspectNames == null) {
List<Advisor> advisors = new LinkedList();
List<String> aspectNames = new LinkedList();
//获取所有beanNames
String[] beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this.beanFactory, Object.class, true, false);
String[] var8 = beanNames;
int var7 = beanNames.length; for(int var18 = 0; var18 < var7; ++var18) {
String beanName = var8[var18];
if (this.isEligibleBean(beanName)) {
Class beanType = this.beanFactory.getType(beanName);
//判断是否是Aspect类型(不做讲解了,就是注解的判断过程)
if (beanType != null && this.advisorFactory.isAspect(beanType)) {
aspectNames.add(beanName);
AspectMetadata amd = new AspectMetadata(beanType, beanName);
//单例
if (amd.getAjType().getPerClause().getKind() == PerClauseKind.SINGLETON) {
MetadataAwareAspectInstanceFactory factory = new BeanFactoryAspectInstanceFactory(this.beanFactory, beanName);
//获取增强器
List<Advisor> classAdvisors = this.advisorFactory.getAdvisors(factory);
if (this.beanFactory.isSingleton(beanName)) {
this.advisorsCache.put(beanName, classAdvisors);
} else {
this.aspectFactoryCache.put(beanName, factory);
}
//加入list返回
advisors.addAll(classAdvisors);
} else {
if (this.beanFactory.isSingleton(beanName)) {
throw new IllegalArgumentException("Bean with name '" + beanName + "' is a singleton, but aspect instantiation model is not singleton");
} MetadataAwareAspectInstanceFactory factory = new PrototypeAspectInstanceFactory(this.beanFactory, beanName);
this.aspectFactoryCache.put(beanName, factory);
advisors.addAll(this.advisorFactory.getAdvisors(factory));
}
}
}
} //缓存名称
this.aspectBeanNames = aspectNames;
return advisors;
}
} if (aspectNames.isEmpty()) {
return Collections.EMPTY_LIST;
} else {
List<Advisor> advisors = new LinkedList();
Iterator var4 = aspectNames.iterator(); while(var4.hasNext()) {
String aspectName = (String)var4.next();
List<Advisor> cachedAdvisors = (List)this.advisorsCache.get(aspectName);
if (cachedAdvisors != null) {
advisors.addAll(cachedAdvisors);
} else {
MetadataAwareAspectInstanceFactory factory = (MetadataAwareAspectInstanceFactory)this.aspectFactoryCache.get(aspectName);
advisors.addAll(this.advisorFactory.getAdvisors(factory));
}
} return advisors;
}
}
9.2)getAdvisors
public List<Advisor> getAdvisors(MetadataAwareAspectInstanceFactory maaif) {
Class<?> aspectClass = maaif.getAspectMetadata().getAspectClass();
final String aspectName = maaif.getAspectMetadata().getAspectName();
this.validate(aspectClass);
final MetadataAwareAspectInstanceFactory lazySingletonAspectInstanceFactory = new LazySingletonAspectInstanceFactoryDecorator(maaif);
final List<Advisor> advisors = new LinkedList();
ReflectionUtils.doWithMethods(aspectClass, new ReflectionUtils.MethodCallback() {
public void doWith(Method method) throws IllegalArgumentException {
if (AnnotationUtils.getAnnotation(method, Pointcut.class) == null) {
//循环获取增强器
Advisor advisor = ReflectiveAspectJAdvisorFactory.this.getAdvisor(method, lazySingletonAspectInstanceFactory, advisors.size(), aspectName);
if (advisor != null) {
advisors.add(advisor);
}
} }
});
if (!advisors.isEmpty() && lazySingletonAspectInstanceFactory.getAspectMetadata().isLazilyInstantiated()) {
Advisor instantiationAdvisor = new ReflectiveAspectJAdvisorFactory.SyntheticInstantiationAdvisor(lazySingletonAspectInstanceFactory);
advisors.add(0, instantiationAdvisor);
} Field[] var9;
int var8 = (var9 = aspectClass.getDeclaredFields()).length; for(int var7 = 0; var7 < var8; ++var7) {
Field field = var9[var7];
Advisor advisor = this.getDeclareParentsAdvisor(field);
if (advisor != null) {
advisors.add(advisor);
}
} return advisors;
} public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aif, int declarationOrderInAspect, String aspectName) {
this.validate(aif.getAspectMetadata().getAspectClass());
//获取切点
AspectJExpressionPointcut ajexp = this.getPointcut(candidateAdviceMethod, aif.getAspectMetadata().getAspectClass());
//是计划增强器
return ajexp == null ? null : new InstantiationModelAwarePointcutAdvisorImpl(this, ajexp, aif, candidateAdviceMethod, declarationOrderInAspect, aspectName);
}
9.3)getPointcut、InstantiationModelAwarePointcutAdvisorImpl
private AspectJExpressionPointcut getPointcut(Method candidateAdviceMethod, Class<?> candidateAspectClass) {
//发现注解的过程
AbstractAspectJAdvisorFactory.AspectJAnnotation<?> aspectJAnnotation = AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(candidateAdviceMethod);
if (aspectJAnnotation == null) {
return null;
} else {
//处理表达式(不讲解了)
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(candidateAspectClass, new String[0], new Class[0]);
ajexp.setExpression(aspectJAnnotation.getPointcutExpression());
return ajexp;
}
} protected static AbstractAspectJAdvisorFactory.AspectJAnnotation findAspectJAnnotationOnMethod(Method method) {
//默认的集中注解
Class[] classesToLookFor = new Class[]{Before.class, Around.class, After.class, AfterReturning.class, AfterThrowing.class, Pointcut.class};
Class[] var5 = classesToLookFor;
int var4 = classesToLookFor.length; for(int var3 = 0; var3 < var4; ++var3) {
Class<? extends Annotation> c = var5[var3];
//寻找过程(通过方法的注解判断,有兴趣自己看一下)
AbstractAspectJAdvisorFactory.AspectJAnnotation foundAnnotation = findAnnotation(method, c);
if (foundAnnotation != null) {
return foundAnnotation;
}
} return null;
}
public InstantiationModelAwarePointcutAdvisorImpl(AspectJAdvisorFactory af, AspectJExpressionPointcut ajexp, MetadataAwareAspectInstanceFactory aif, Method method, int declarationOrderInAspect, String aspectName) {
this.declaredPointcut = ajexp;
this.method = method;
this.atAspectJAdvisorFactory = af;
this.aspectInstanceFactory = aif;
this.declarationOrder = declarationOrderInAspect;
this.aspectName = aspectName;
//判断是否是lazy
if (aif.getAspectMetadata().isLazilyInstantiated()) {
Pointcut preInstantiationPointcut = Pointcuts.union(aif.getAspectMetadata().getPerClausePointcut(), this.declaredPointcut);
this.pointcut = new InstantiationModelAwarePointcutAdvisorImpl.PerTargetInstantiationModelPointcut(this.declaredPointcut, preInstantiationPointcut, aif, (InstantiationModelAwarePointcutAdvisorImpl.PerTargetInstantiationModelPointcut)null);
this.lazy = true;
} else {
//根据默认类型获取增强器
this.instantiatedAdvice = this.instantiateAdvice(this.declaredPointcut);
this.pointcut = this.declaredPointcut;
this.lazy = false;
}
} private Advice instantiateAdvice(AspectJExpressionPointcut pcut) {
//获取增强器(具体表达式的应用)
return this.atAspectJAdvisorFactory.getAdvice(this.method, pcut, this.aspectInstanceFactory, this.declarationOrder, this.aspectName);
} public Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut ajexp, MetadataAwareAspectInstanceFactory aif, int declarationOrderInAspect, String aspectName) {
Class<?> candidateAspectClass = aif.getAspectMetadata().getAspectClass();
this.validate(candidateAspectClass);
AbstractAspectJAdvisorFactory.AspectJAnnotation<?> aspectJAnnotation = AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(candidateAdviceMethod);
if (aspectJAnnotation == null) {
return null;
} else if (!this.isAspect(candidateAspectClass)) {
throw new AopConfigException("Advice must be declared inside an aspect type: Offending method '" + candidateAdviceMethod + "' in class [" + candidateAspectClass.getName() + "]");
} else {
if (this.logger.isDebugEnabled()) {
this.logger.debug("Found AspectJ method: " + candidateAdviceMethod);
} Object springAdvice;
switch($SWITCH_TABLE$org$springframework$aop$aspectj$annotation$AbstractAspectJAdvisorFactory$AspectJAnnotationType()[aspectJAnnotation.getAnnotationType().ordinal()]) {
case 1:
if (this.logger.isDebugEnabled()) {
this.logger.debug("Processing pointcut '" + candidateAdviceMethod.getName() + "'");
} return null;
case 2:
//前置
springAdvice = new AspectJMethodBeforeAdvice(candidateAdviceMethod, ajexp, aif);
break;
case 3:
//后置
springAdvice = new AspectJAfterAdvice(candidateAdviceMethod, ajexp, aif);
break;
case 4:
//return
springAdvice = new AspectJAfterReturningAdvice(candidateAdviceMethod, ajexp, aif);
AfterReturning afterReturningAnnotation = (AfterReturning)aspectJAnnotation.getAnnotation();
if (StringUtils.hasText(afterReturningAnnotation.returning())) {
((AbstractAspectJAdvice)springAdvice).setReturningName(afterReturningAnnotation.returning());
}
break;
case 5:
//异常
springAdvice = new AspectJAfterThrowingAdvice(candidateAdviceMethod, ajexp, aif);
AfterThrowing afterThrowingAnnotation = (AfterThrowing)aspectJAnnotation.getAnnotation();
if (StringUtils.hasText(afterThrowingAnnotation.throwing())) {
((AbstractAspectJAdvice)springAdvice).setThrowingName(afterThrowingAnnotation.throwing());
}
break;
case 6:
//环绕
springAdvice = new AspectJAroundAdvice(candidateAdviceMethod, ajexp, aif);
break;
default:
throw new UnsupportedOperationException("Unsupported advice type on method " + candidateAdviceMethod);
} ((AbstractAspectJAdvice)springAdvice).setAspectName(aspectName);
((AbstractAspectJAdvice)springAdvice).setDeclarationOrder(declarationOrderInAspect);
String[] argNames = this.parameterNameDiscoverer.getParameterNames(candidateAdviceMethod);
if (argNames != null) {
((AbstractAspectJAdvice)springAdvice).setArgumentNamesFromStringArray(argNames);
} ((AbstractAspectJAdvice)springAdvice).calculateArgumentBindings();
return (Advice)springAdvice;
}
}
备注:这就是整个发现增强器的过程,过程有点多。但是基本流程就是这样子的了。增强器后续会单独讲解
说明:匹配过程就不讲解了,主要是通过表达式进行匹配
10)createProxy
protected Object createProxy(Class<?> beanClass, String beanName, Object[] specificInterceptors, TargetSource targetSource) {
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.copyFrom(this);
int var8;
int var9;
if (!this.shouldProxyTargetClass(beanClass, beanName)) {
Class[] targetInterfaces = ClassUtils.getAllInterfacesForClass(beanClass, this.proxyClassLoader);
Class[] var10 = targetInterfaces;
var9 = targetInterfaces.length; for(var8 = 0; var8 < var9; ++var8) {
Class<?> targetInterface = var10[var8];
proxyFactory.addInterface(targetInterface);
}
} //家里增强器
Advisor[] advisors = this.buildAdvisors(beanName, specificInterceptors);
Advisor[] var11 = advisors;
var9 = advisors.length; for(var8 = 0; var8 < var9; ++var8) {
Advisor advisor = var11[var8];
proxyFactory.addAdvisor(advisor);
} proxyFactory.setTargetSource(targetSource);
this.customizeProxyFactory(proxyFactory);
proxyFactory.setFrozen(this.freezeProxy);
if (this.advisorsPreFiltered()) {
proxyFactory.setPreFiltered(true);
} //创建代理
return proxyFactory.getProxy(this.proxyClassLoader);
} public Object getProxy(ClassLoader classLoader) {
return this.createAopProxy().getProxy(classLoader);
} protected final synchronized AopProxy createAopProxy() {
if (!this.active) {
this.activate();
} return this.getAopProxyFactory().createAopProxy(this);
} public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException {
if (!config.isOptimize() && !config.isProxyTargetClass() && !this.hasNoUserSuppliedProxyInterfaces(config)) {
//默认JDK动态代理
return new JdkDynamicAopProxy(config);
} else {
Class targetClass = config.getTargetClass();
if (targetClass == null) {
throw new AopConfigException("TargetSource cannot determine target class: Either an interface or a target is required for proxy creation.");
} else if (targetClass.isInterface()) {
return new JdkDynamicAopProxy(config);
} else if (!cglibAvailable) {
throw new AopConfigException("Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.");
} else {
//cglib
return DefaultAopProxyFactory.CglibProxyFactory.createCglibProxy(config);
}
}
}
说明:代理过程就是讲具体的增强加入到代理中去。这里动态代理后续会讲,不详细介绍。
11)springaop的源码过程却是有些复杂。但是思路已经有了哦
发现增强-->匹配增强器-->创建代理
spring源码-aop源码-5.1的更多相关文章
- Spring框架之AOP源码完全解析
Spring框架之AOP源码完全解析 Spring可以说是Java企业开发里最重要的技术.Spring两大核心IOC(Inversion of Control控制反转)和AOP(Aspect Orie ...
- Spring基础系列-AOP源码分析
原创作品,可以转载,但是请标注出处地址:https://www.cnblogs.com/V1haoge/p/9560803.html 一.概述 Spring的两大特性:IOC和AOP. AOP是面向切 ...
- Spring框架之jms源码完全解析
Spring框架之jms源码完全解析 我们在前两篇文章中介绍了Spring两大核心IOC(Inversion of Control控制反转)和AOP(Aspect Oriented Programmi ...
- Spring框架之spring-webmvc源码完全解析
Spring框架之spring-webmvc源码完全解析 Spring框架提供了构建Web应用程序的全功能MVC模块.Spring MVC分离了控制器.模型对象.分派器以及处理程序对象的角色,支持多种 ...
- Spring框架之jdbc源码完全解析
Spring框架之jdbc源码完全解析 Spring JDBC抽象框架所带来的价值将在以下几个方面得以体现: 1.指定数据库连接参数 2.打开数据库连接 3.声明SQL语句 4.预编译并执行SQL语句 ...
- Spring框架之websocket源码完全解析
Spring框架之websocket源码完全解析 Spring框架从4.0版开始支持WebSocket,先简单介绍WebSocket协议(详细介绍参见"WebSocket协议中文版" ...
- Spring框架之事务源码完全解析
Spring框架之事务源码完全解析 事务的定义及特性: 事务是并发控制的单元,是用户定义的一个操作序列.这些操作要么都做,要么都不做,是一个不可分割的工作单位.通过事务将逻辑相关的一组操作绑定在一 ...
- Spring基础系列--AOP织入逻辑跟踪
原创作品,可以转载,但是请标注出处地址:https://www.cnblogs.com/V1haoge/p/9619910.html 其实在之前的源码解读里面,关于织入的部分并没有说清楚,那些前置.后 ...
- Spring核心框架 - AOP的原理及源码解析
一.AOP的体系结构 如下图所示:(引自AOP联盟) 层次3语言和开发环境:基础是指待增加对象或者目标对象:切面通常包括对于基础的增加应用:配置是指AOP体系中提供的配置环境或者编织配置,通过该配置A ...
随机推荐
- C#获取路径问题
由于在写控制台的时候,不能获取到绝对的路径.(下面为学习内容) System.IO.Path类中有一些获取路径的方法,可以在控制台程序或者WinForm中根据相对路径来获取绝对路径 获取web物理路径 ...
- jquery mobile header title左对齐 button右对齐
<div data-theme="b" data-role="header" data-position="fixed"> &l ...
- jQuery on()方法绑定动态元素的点击事件实例代码浅析
之前就一直受这个问题的困扰,在jQuery1.7版本之后添加了on方法,之前就了解过,其优越性高于live(),bind(),delegate()等方法,在此之前项目中想用这个来测试结果发现,居然动态 ...
- VC++ UDP网络控制台程序
采用的是VC2008,控制台应用程序,使用UDP编写. 1.服务端代码 //UDPServer.cpp #include <WinSock2.h> #include <stdio. ...
- nginx 反向代理 proxy_pass 及对比nginx与haproxy反向代理服务器功能、性能的优劣
1.使用 proxy 去请求另一个域名下的资源,如果跨域资源也部署在同一台机器上,我们甚至可以 proxy 到 127.0.0.1,比如: location /api { proxy_pass htt ...
- C#中Array类
Array类是C#中所有数组的基类,它是在System命名空间中定义的,Array类提供了各种用于数组的属性和方法
- 大话Linux内核中锁机制之原子操作、自旋锁
转至:http://blog.sina.com.cn/s/blog_6d7fa49b01014q7p.html 很多人会问这样的问题,Linux内核中提供了各式各样的同步锁机制到底有何作用?追根到底其 ...
- RunLoop 之初探
你好2019!一起努力呀! 1.什么是runloop runloop是通过内部维护的事件循环对事件/消息进行管理的一个对象. 事件循环(Event loop):通俗的解释:没有消息处理的时候,休眠以避 ...
- [iOS]被忽略的main函数
如同任何基于C的应用程序,程序启动的主入口点为iOS应用程序的main函数.在iOS应用程序,main函数的作用是很少的.它的主要工作是控制UIKit framework.因此,你在Xcode中创建任 ...
- angular的生命周期
什么是生命周期 生命周期函数通俗的讲就是组件创建.组件更新.组件销毁的时候会触发的一系列的方法. 当 Angular 使用构造函数新建一个组件或指令后,就会按下面的顺序在特定时刻调用这些 生命周期钩子 ...