mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-03 07:13:51 +00:00
feat[boot]: 支持spring boot的自动化配置
This commit is contained in:
1 parent
47be79785e
commit
44e4782641
37 files changed
+657
-219
No files matched your search
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The zfoo 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
|
||||
*
|
||||
* http://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 com.zfoo.boot;
|
||||
|
||||
import com.zfoo.event.EventContext;
|
||||
import com.zfoo.event.schema.EventRegisterProcessor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author jaysunxiao
|
||||
* @version 3.0
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class EventAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public EventRegisterProcessor eventRegisterProcessor() {
|
||||
return new EventRegisterProcessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public EventContext eventContext() {
|
||||
return new EventContext();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The zfoo 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
|
||||
*
|
||||
* http://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 com.zfoo.boot;
|
||||
|
||||
import com.zfoo.net.NetContext;
|
||||
import com.zfoo.net.config.manager.ConfigManager;
|
||||
import com.zfoo.net.config.model.NetConfig;
|
||||
import com.zfoo.net.consumer.service.Consumer;
|
||||
import com.zfoo.net.dispatcher.manager.PacketDispatcher;
|
||||
import com.zfoo.net.packet.service.PacketService;
|
||||
import com.zfoo.net.session.manager.SessionManager;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author jaysunxiao
|
||||
* @version 3.0
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnBean(NetConfig.class)
|
||||
public class NetAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(NetConfig.class)
|
||||
public ConfigManager configManager(NetConfig netConfig) {
|
||||
var configManager = new ConfigManager();
|
||||
configManager.setLocalConfig(netConfig);
|
||||
return configManager;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public PacketService packetService() {
|
||||
return new PacketService();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public PacketDispatcher packetDispatcher() {
|
||||
return new PacketDispatcher();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public Consumer consumer() {
|
||||
return new Consumer();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SessionManager sessionManager() {
|
||||
return new SessionManager();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public NetContext netContext() {
|
||||
return new NetContext();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The zfoo 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
|
||||
*
|
||||
* http://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 com.zfoo.boot;
|
||||
|
||||
import com.zfoo.orm.OrmContext;
|
||||
import com.zfoo.orm.manager.OrmManager;
|
||||
import com.zfoo.orm.model.accessor.MongodbAccessor;
|
||||
import com.zfoo.orm.model.config.OrmConfig;
|
||||
import com.zfoo.orm.model.query.MongodbQuery;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author jaysunxiao
|
||||
* @version 3.0
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnBean(OrmConfig.class)
|
||||
public class OrmAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(OrmConfig.class)
|
||||
public OrmManager ormManager(OrmConfig ormConfig) {
|
||||
var ormManager = new OrmManager();
|
||||
ormManager.setOrmConfig(ormConfig);
|
||||
return ormManager;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public MongodbAccessor mongodbAccessor() {
|
||||
return new MongodbAccessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public MongodbQuery mongodbQuery() {
|
||||
return new MongodbQuery();
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public OrmContext ormContext() {
|
||||
return new OrmContext();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The zfoo 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
|
||||
*
|
||||
* http://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 com.zfoo.boot;
|
||||
|
||||
import com.zfoo.scheduler.SchedulerContext;
|
||||
import com.zfoo.scheduler.schema.SchedulerRegisterProcessor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author jaysunxiao
|
||||
* @version 3.0
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class SchedulerAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SchedulerRegisterProcessor schedulerRegisterProcessor() {
|
||||
return new SchedulerRegisterProcessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SchedulerContext schedulerContext() {
|
||||
return new SchedulerContext();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The zfoo 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
|
||||
*
|
||||
* http://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 com.zfoo.boot;
|
||||
|
||||
import com.zfoo.storage.StorageContext;
|
||||
import com.zfoo.storage.interpreter.ExcelResourceReader;
|
||||
import com.zfoo.storage.manager.StorageManager;
|
||||
import com.zfoo.storage.model.config.StorageConfig;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author jaysunxiao
|
||||
* @version 3.0
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnBean(StorageConfig.class)
|
||||
public class StorageAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnBean(StorageConfig.class)
|
||||
public StorageManager storageManager(StorageConfig storageConfig) {
|
||||
var storageManager = new StorageManager();
|
||||
storageManager.setStorageConfig(storageConfig);
|
||||
return storageManager;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ExcelResourceReader excelResourceReader() {
|
||||
return new ExcelResourceReader();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public StorageContext storageContext() {
|
||||
return new StorageContext();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.zfoo.boot.EventAutoConfiguration,\
|
||||
com.zfoo.boot.SchedulerAutoConfiguration,\
|
||||
com.zfoo.boot.StorageAutoConfiguration,\
|
||||
com.zfoo.boot.OrmAutoConfiguration,\
|
||||
com.zfoo.boot.NetAutoConfiguration
|
||||
Reference in new issue
Block a user