|
| 1 | +/* |
| 2 | + * Copyright [2019] [恒宇少年 - 于起宇] |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + * |
| 16 | + */ |
| 17 | +package org.minbox.framework.api.boot.autoconfigure.resource; |
| 18 | + |
| 19 | +import org.minbox.framework.api.boot.plugin.resource.load.ApiBootResourceStoreDelegate; |
| 20 | +import org.minbox.framework.api.boot.plugin.resource.load.aop.advistor.ApiBootResourceLoadAdvisor; |
| 21 | +import org.minbox.framework.api.boot.plugin.resource.load.aop.interceptor.ApiBootResourceLoadMethodInterceptor; |
| 22 | +import org.springframework.beans.factory.ObjectProvider; |
| 23 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
| 24 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
| 25 | +import org.springframework.context.annotation.Bean; |
| 26 | +import org.springframework.context.annotation.Configuration; |
| 27 | + |
| 28 | +/** |
| 29 | + * ApiBoot Resource Load Auto Config |
| 30 | + * |
| 31 | + * @author:恒宇少年 - 于起宇 |
| 32 | + * <p> |
| 33 | + * DateTime:2019-04-12 13:30 |
| 34 | + * Blog:http://blog.yuqiyu.com |
| 35 | + * WebSite:http://www.jianshu.com/u/092df3f77bca |
| 36 | + * Gitee:https://gitee.com/hengboy |
| 37 | + * GitHub:https://github.com/hengboy |
| 38 | + */ |
| 39 | +@Configuration |
| 40 | +@ConditionalOnClass(ApiBootResourceStoreDelegate.class) |
| 41 | +public class ApiBootResourceLoadAutoConfiguration { |
| 42 | + /** |
| 43 | + * ApiBoot Resource Load Store Delegate |
| 44 | + */ |
| 45 | + private ApiBootResourceStoreDelegate resourceStoreDelegate; |
| 46 | + |
| 47 | + public ApiBootResourceLoadAutoConfiguration(ObjectProvider<ApiBootResourceStoreDelegate> resourceStoreDelegateObjectProvider) { |
| 48 | + this.resourceStoreDelegate = resourceStoreDelegateObjectProvider.getIfAvailable(); |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * ApiBoot Resource Load Pointcut Advisor |
| 53 | + * |
| 54 | + * @param resourceLoadMethodInterceptor ResourceLoad Annotation Method Interceptor |
| 55 | + * @return ApiBootResourceLoadAdvisor |
| 56 | + */ |
| 57 | + @Bean |
| 58 | + @ConditionalOnMissingBean |
| 59 | + ApiBootResourceLoadAdvisor resourceLoadAdvisor(ApiBootResourceLoadMethodInterceptor resourceLoadMethodInterceptor) { |
| 60 | + return new ApiBootResourceLoadAdvisor(resourceLoadMethodInterceptor); |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * ResourceLoad Annotation Method Interceptor |
| 65 | + * Implementing major business logic |
| 66 | + * |
| 67 | + * @return ApiBootResourceLoadMethodInterceptor |
| 68 | + */ |
| 69 | + @Bean |
| 70 | + @ConditionalOnMissingBean |
| 71 | + ApiBootResourceLoadMethodInterceptor resourceLoadMethodInterceptor() { |
| 72 | + return new ApiBootResourceLoadMethodInterceptor(resourceStoreDelegate); |
| 73 | + } |
| 74 | +} |
0 commit comments