Skip to content

Commit

Permalink
Auto-Configure DynamicModules
Browse files Browse the repository at this point in the history
* Use DynamicModulesAutoConfiguration instead of DynamicModulesGrailsPlugin.doWithSpring
  • Loading branch information
rainboyan committed Sep 22, 2023
1 parent 64f691f commit 0efef0c
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,4 @@ Grails Dynamic Modules Plugin offer new ways of creating modular and maintainabl
// Online location of the plugin's browseable source code.
def scm = [ url: "https://github.com/rainboyan/grails-plugin-dynamic-modules.git" ]

Closure doWithSpring() {
{->
def ctx = applicationContext
moduleDescriptorFactory(DefaultModuleDescriptorFactory) {
applicationContext = ctx
}
dynamicModulesManager(DefaultDynamicModulesManager)
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright 2022-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.rainboyan.plugins.config;

import org.rainboyan.plugins.DefaultDynamicModulesManager;
import org.rainboyan.plugins.DefaultModuleDescriptorFactory;
import org.rainboyan.plugins.DynamicModulesManager;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import grails.plugins.ModuleDescriptorFactory;

/**
* {@link EnableAutoConfiguration Auto-configuration} Dynamic Modules
*
* @author Michael Yan
* @since 1.0.0
*/
@Configuration(proxyBeanMethods = false)
public class DynamicModulesAutoConfiguration {

@Bean
@ConditionalOnMissingBean
public ModuleDescriptorFactory moduleDescriptorFactory() {
return new DefaultModuleDescriptorFactory();
}

@Bean
@ConditionalOnMissingBean
public DynamicModulesManager dynamicModulesManager() {
return new DefaultDynamicModulesManager();
}

}
4 changes: 4 additions & 0 deletions src/main/resources/META-INF/spring.factories
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Application Listener
org.springframework.context.ApplicationListener=\
org.rainboyan.plugins.DynamicModulesApplicationListener

# Auto Configure
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.rainboyan.plugins.config.DynamicModulesAutoConfiguration
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.rainboyan.plugins.config.DynamicModulesAutoConfiguration

0 comments on commit 0efef0c

Please sign in to comment.