|
| 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 | + |
| 18 | +package org.minbox.framework.api.boot.autoconfigure.resource; |
| 19 | + |
| 20 | +import org.minbox.framework.api.boot.plugin.resource.load.ApiBootResourceStoreDelegate; |
| 21 | +import org.minbox.framework.api.boot.plugin.resource.load.pusher.support.ApiBootRedisResourcePusher; |
| 22 | +import org.springframework.beans.factory.ObjectProvider; |
| 23 | +import org.springframework.boot.autoconfigure.AutoConfigureAfter; |
| 24 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
| 25 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
| 26 | +import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; |
| 27 | +import org.springframework.context.annotation.Bean; |
| 28 | +import org.springframework.context.annotation.Configuration; |
| 29 | +import org.springframework.data.redis.core.RedisTemplate; |
| 30 | + |
| 31 | +/** |
| 32 | + * @author:恒宇少年 - 于起宇 |
| 33 | + * <p> |
| 34 | + * DateTime:2019-04-19 10:46 |
| 35 | + * Blog:http://blog.yuqiyu.com |
| 36 | + * WebSite:http://www.jianshu.com/u/092df3f77bca |
| 37 | + * Gitee:https://gitee.com/hengboy |
| 38 | + * GitHub:https://github.com/hengboy |
| 39 | + */ |
| 40 | +@Configuration |
| 41 | +@ConditionalOnClass(RedisTemplate.class) |
| 42 | +@AutoConfigureAfter(RedisAutoConfiguration.class) |
| 43 | +public class ApiBootResourceRedisLoadAutoConfiguration { |
| 44 | + /** |
| 45 | + * ApiBoot Resource Load Store Delegate |
| 46 | + */ |
| 47 | + private ApiBootResourceStoreDelegate resourceStoreDelegate; |
| 48 | + |
| 49 | + public ApiBootResourceRedisLoadAutoConfiguration(ObjectProvider<ApiBootResourceStoreDelegate> resourceStoreDelegateObjectProvider) { |
| 50 | + this.resourceStoreDelegate = resourceStoreDelegateObjectProvider.getIfAvailable(); |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * ApiBoot Redis Resource Pusher |
| 55 | + * |
| 56 | + * @param redisTemplate Redis Template |
| 57 | + * @return ApiBootRedisResourcePusher |
| 58 | + */ |
| 59 | + @Bean |
| 60 | + @ConditionalOnMissingBean |
| 61 | + ApiBootRedisResourcePusher apiBootRedisResourcePusher(RedisTemplate redisTemplate) { |
| 62 | + return new ApiBootRedisResourcePusher(resourceStoreDelegate, redisTemplate); |
| 63 | + } |
| 64 | +} |
0 commit comments