-
Notifications
You must be signed in to change notification settings - Fork 0
/
manager.asp
162 lines (136 loc) · 4.37 KB
/
manager.asp
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<%
' File: manager.asp
'
' Evolved Classic ASP Plugins Framework manager definition.
'
' Versioning System:
'
' Semantic Versioning 2.0.0 which is, in practice, given a version number MAJOR.MINOR.PATCH:
'
' - A MAJOR increment requires a change in your program (API Change),
' - A MINOR increment should not break your app, but make additional functionality available,
' - A PATCH increment fixes a bug, so just replace in place with the latest version.
'
' More details at <http://semver.org/>.
'
' License:
'
' This file is part of Evolved Classic ASP Plugins Framework.
' Copyright (C) 2013 Fabio Zendhi Nagao
'
' Evolved Classic ASP Plugins Framework is free software: you can redistribute it and/or modify
' it under the terms of the GNU Lesser General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' Evolved Classic ASP Plugins Framework is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU Lesser General Public License for more details.
'
' You should have received a copy of the GNU Lesser General Public License
' along with Evolved Classic ASP Plugins Framework. If not, see <http://www.gnu.org/licenses/>.
' Class: PluginManager
'
' The central piece of Evolved Classic ASP Plugins Framework. This class loads
' and configure plugins from a json file which manifests the desires of the
' plugin to extend the functionality of a process.
'
' About:
'
' - Written by Fabio Zendhi Nagao <http://zend.lojcomm.com.br> @ Jun 2013
'
class PluginManager
' --[ Public section ]----------------------------------------------------------
public default function [new](byVal name, byVal path)
Me.name = name
if isEmpty( Application(Me.name) ) then
Application(Me.name) = loadTextFile(path)
end if
set [new] = Me
end function
public name
public Listeners
' Property: classType
'
' Class type.
'
' Contains:
'
' (string) - type
'
public property get classType
classType = typename(Me)
end property
' Property: classVersion
'
' Class version.
'
' Contains:
'
' (string) - version
'
public property get classVersion
classVersion = "1.0.0"
end property
public sub [set](byVal controller, byVal method)
dim Plugins, Plugin, i
[Ξ].unshift( []( "{0}_{1}", array(controller, method) ) )
set Plugins = JSON.parse( Application(Me.name) )
for each i in Plugins.enumerate()
set Plugin = Plugins.get(i)
if not isEmpty( Plugin.extends.get( controller ) ) then
if isEmpty( Application( []( "Plugins.{0}", Plugin.id ) ) ) then _
Application( []( "Plugins.{0}", Plugin.id ) ) = mid( loadTextFile( Server.mapPath( []( "{0}/plugin.asp", Plugin.path ) ) ), 3 )
if not Listeners.hasOwnProperty(Plugin.id) then
executeGlobal Application( []( "Plugins.{0}", Plugin.id ) )
execute []( "Listeners.set ""{0}"", new {0}", Plugin.id )
end if
end if
set Plugin = nothing
next
set Plugins = nothing
end sub
public sub unset(byVal controller, byVal method)
[Ξ].shift( []( "{0}_{1}", array(controller, method) ) )
end sub
public sub define(byRef Actors)
dim context_id, key
context_id = [Ξ].get(0)
for each key in Listeners.enumerate()
Listeners.get(key).define context_id, Actors
next
end sub
public sub bind(byRef Actors)
dim context_id, key
context_id = [Ξ].get(0)
for each key in Listeners.enumerate()
Listeners.get(key).bind context_id, Actors
next
end sub
public sub beforeAction(byRef Context)
dim context_id, key
context_id = [Ξ].get(0)
for each key in Listeners.enumerate()
Listeners.get(key).beforeAction context_id, Context
next
end sub
public sub afterAction(byRef Context)
dim context_id, key
context_id = [Ξ].get(0)
for each key in Listeners.enumerate()
Listeners.get(key).afterAction context_id, Context
next
end sub
' --[ Private section ]---------------------------------------------------------
private [Ξ]
private sub Class_initialize()
set Listeners = [!]("{}")
set [Ξ] = [!]("[]")
end sub
private sub Class_terminate()
set [Ξ] = nothing
set Listeners = nothing
end sub
end class
%>