org.zodiac.plugin.extension.ExtensionWebMvcFactory Maven / Gradle / Ivy
package org.zodiac.plugin.extension;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.springframework.context.ApplicationContext;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.zodiac.commons.util.Colls;
import org.zodiac.commons.util.spring.Springs;
import org.zodiac.sdk.toolkit.util.collection.CollUtil;
/**
* 静态的扩展工厂。
*/
public class ExtensionWebMvcFactory extends AbstractExtensionFactory {
private ExtensionWebMvcFactory() {}
@Override
@SuppressWarnings("rawtypes")
public List getPluginControllerProcessorExtend(ApplicationContext mainApplicationContext) {
List extendList = Springs.getBeanList(mainApplicationContext, PluginWebMvcControllerProcessorExtend.class);
if (CollUtil.isEmptyColl(extendList)) {
return Collections.emptyList();
}
List result = CollUtil.list();
for (PluginWebMvcControllerProcessorExtend extend : extendList) {
result.add(extend);
}
return result;
}
public static void addExtension(PluginExtension pluginExtension) {
getInstance().addPluginExtension(pluginExtension);
}
/**
* 得到PluginControllerProcessorExtend的实现
*
* @param mainApplicationContext
* 主程序的 ApplicationContext
* @return PluginWebMvcControllerProcessorExtend 的实现对象集合
*/
@SuppressWarnings("rawtypes")
public static List
pluginControllerProcessorExtendList(ApplicationContext mainApplicationContext) {
return getInstance().getPluginControllerProcessorExtend(mainApplicationContext);
}
static Map pluginExtensionMap() {
return getInstance().getPluginExtensions();
}
public static ExtensionWebMvcFactory getInstance() {
return ExtensionWebMvcFactoryHolder.INSTANCE;
}
private static class ExtensionWebMvcFactoryHolder {
private static ExtensionWebMvcFactory INSTANCE = new ExtensionWebMvcFactory();
}
}