Skip to content

Commit 0efef0c

Browse files
committed
Auto-Configure DynamicModules
* Use DynamicModulesAutoConfiguration instead of DynamicModulesGrailsPlugin.doWithSpring
1 parent 64f691f commit 0efef0c

File tree

4 files changed

+54
-10
lines changed

4 files changed

+54
-10
lines changed

src/main/groovy/org/rainboyan/plugins/DynamicModulesGrailsPlugin.groovy

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,4 @@ Grails Dynamic Modules Plugin offer new ways of creating modular and maintainabl
5555
// Online location of the plugin's browseable source code.
5656
def scm = [ url: "https://github.com/rainboyan/grails-plugin-dynamic-modules.git" ]
5757

58-
Closure doWithSpring() {
59-
{->
60-
def ctx = applicationContext
61-
moduleDescriptorFactory(DefaultModuleDescriptorFactory) {
62-
applicationContext = ctx
63-
}
64-
dynamicModulesManager(DefaultDynamicModulesManager)
65-
}
66-
}
67-
6858
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2022-2023 the original author or authors.
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+
* https://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+
package org.rainboyan.plugins.config;
17+
18+
import org.rainboyan.plugins.DefaultDynamicModulesManager;
19+
import org.rainboyan.plugins.DefaultModuleDescriptorFactory;
20+
import org.rainboyan.plugins.DynamicModulesManager;
21+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
22+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
23+
import org.springframework.context.annotation.Bean;
24+
import org.springframework.context.annotation.Configuration;
25+
26+
import grails.plugins.ModuleDescriptorFactory;
27+
28+
/**
29+
* {@link EnableAutoConfiguration Auto-configuration} Dynamic Modules
30+
*
31+
* @author Michael Yan
32+
* @since 1.0.0
33+
*/
34+
@Configuration(proxyBeanMethods = false)
35+
public class DynamicModulesAutoConfiguration {
36+
37+
@Bean
38+
@ConditionalOnMissingBean
39+
public ModuleDescriptorFactory moduleDescriptorFactory() {
40+
return new DefaultModuleDescriptorFactory();
41+
}
42+
43+
@Bean
44+
@ConditionalOnMissingBean
45+
public DynamicModulesManager dynamicModulesManager() {
46+
return new DefaultDynamicModulesManager();
47+
}
48+
49+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# Application Listener
22
org.springframework.context.ApplicationListener=\
33
org.rainboyan.plugins.DynamicModulesApplicationListener
4+
5+
# Auto Configure
6+
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
7+
org.rainboyan.plugins.config.DynamicModulesAutoConfiguration
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.rainboyan.plugins.config.DynamicModulesAutoConfiguration

0 commit comments

Comments
 (0)