forked from mt830813/MVCWebServer
/
typeRegist.go
55 lines (40 loc) · 1.71 KB
/
typeRegist.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"github.com/mt830813/MVCWebServer/Command"
"github.com/mt830813/MVCWebServer/Common"
"github.com/mt830813/MVCWebServer/Server"
"github.com/mt830813/MVCWebServer/Server/Handler"
"github.com/mt830813/MVCWebServer/Web/Test/Controller"
"reflect"
)
type typeRegist struct {
}
func (this *typeRegist) Regist() {
test()
registCommand()
registHandler()
registController()
}
func test() {
}
func registHandler() {
factory := Common.GetIOCFactory()
iHandlerType := reflect.TypeOf((*Server.IHandler)(nil)).Elem()
factory.RegistByName("normalhandler", iHandlerType, reflect.TypeOf(new(Handler.NormalHandler)), Common.InstanceType_Normal)
}
func registCommand() {
iCmd := reflect.TypeOf((*Command.ICommand)(nil)).Elem()
factory := Common.GetIOCFactory()
factory.RegistByName("stop", iCmd, reflect.TypeOf(new(Command.Stop)), Common.InstanceType_Singleton)
factory.RegistByName("echo", iCmd, reflect.TypeOf(new(Command.Echo)), Common.InstanceType_Singleton)
factory.RegistByName("start", iCmd, reflect.TypeOf(new(Command.Start)), Common.InstanceType_Singleton)
factory.RegistByName("list", iCmd, reflect.TypeOf(new(Command.List)), Common.InstanceType_Singleton)
factory.RegistByName("exit", iCmd, reflect.TypeOf(new(Command.Exit)), Common.InstanceType_Singleton)
factory.RegistByName("quit", iCmd, reflect.TypeOf(new(Command.Exit)), Common.InstanceType_Singleton)
factory.RegistByName("restart", iCmd, reflect.TypeOf(new(Command.ServerReload)), Common.InstanceType_Singleton)
}
func registController() {
i := reflect.TypeOf((*Server.IController)(nil)).Elem()
factory := Common.GetIOCFactory()
factory.RegistByName("test", i, reflect.TypeOf(new(Controller.TestController)), Common.InstanceType_Normal)
}