line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2001-2006 The Apache Software Foundation |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
4
|
|
|
|
|
|
|
# you may not use this file except in compliance with the License. |
5
|
|
|
|
|
|
|
# You may obtain a copy of the License at |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software |
10
|
|
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
11
|
|
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12
|
|
|
|
|
|
|
# See the License for the specific language governing permissions and |
13
|
|
|
|
|
|
|
# limitations under the License. |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package AxKit2; |
17
|
|
|
|
|
|
|
|
18
|
9
|
|
|
9
|
|
53
|
use strict; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
385
|
|
19
|
9
|
|
|
9
|
|
49
|
use warnings; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
349
|
|
20
|
9
|
|
|
9
|
|
42
|
no warnings 'deprecated'; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
328
|
|
21
|
9
|
|
|
9
|
|
9709
|
use Danga::Socket; |
|
9
|
|
|
|
|
271168
|
|
|
9
|
|
|
|
|
330
|
|
22
|
9
|
|
|
9
|
|
6182
|
use AxKit2::Client; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use AxKit2::Server; |
24
|
|
|
|
|
|
|
use AxKit2::Config; |
25
|
|
|
|
|
|
|
use AxKit2::Console; |
26
|
|
|
|
|
|
|
use AxKit2::Constants qw(LOGINFO); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use constant AIO_AVAILABLE => eval { require IO::AIO }; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $VERSION = '1.1'; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub run { |
33
|
|
|
|
|
|
|
my $class = shift; |
34
|
|
|
|
|
|
|
my $configfile = shift; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $config = AxKit2::Config->new($configfile); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
local $SIG{'PIPE'} = "IGNORE"; # handled manually |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# config server |
41
|
|
|
|
|
|
|
AxKit2::Console->create(AxKit2::Config->global); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# setup server |
44
|
|
|
|
|
|
|
for my $server ($config->servers) { |
45
|
|
|
|
|
|
|
AxKit2::Server->create($server); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
if (AIO_AVAILABLE) { |
49
|
|
|
|
|
|
|
AxKit2::Client->log(LOGINFO, "Adding AIO support"); |
50
|
|
|
|
|
|
|
Danga::Socket->AddOtherFds (IO::AIO::poll_fileno() => |
51
|
|
|
|
|
|
|
\&IO::AIO::poll_cb); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# print $_, "\n" for sort keys %INC; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Danga::Socket->EventLoop(); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
AxKit2 - XML Application Server |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SYNOPSIS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Just start the server: |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$ cp etc/axkit.conf.sample etc/axkit.conf |
70
|
|
|
|
|
|
|
$ ./axkit |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
To do anything more than run the demo files you'll need to read the |
73
|
|
|
|
|
|
|
documentation and start writing plugins. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 DESCRIPTION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
AxKit2 is the second generation XML Application Server following in the |
78
|
|
|
|
|
|
|
footsteps of AxKit-1 (ONE). AxKit makes content generation easy by providing |
79
|
|
|
|
|
|
|
powerful tools to push XML through stylesheets. This helps ensure your web |
80
|
|
|
|
|
|
|
applications don't suffer from XSS bugs, and provides standardised templating |
81
|
|
|
|
|
|
|
tools so that your template authors don't need to learn new Perl templating |
82
|
|
|
|
|
|
|
tools. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
In doing all this AxKit harnesses the power of XML. Feel the power. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 PLUGINS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Everything AxKit2 does is controlled by a plugin, and thus a lot of the |
89
|
|
|
|
|
|
|
documentation for things that AxKit2 does is held within the provided plugins. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
To get started writing plugins see L. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 CORE PLUGINS |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
The following are the core plugins which ship with AxKit2: |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=over 4 |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item * B - A cache plugin that gives every plugin access to a |
100
|
|
|
|
|
|
|
cache. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
See L. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * B - Provides XML for a directory request. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
See L. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item * B - When an exception/error occurs this plugin generates |
109
|
|
|
|
|
|
|
XML (with an optional stacktrace) for what happened, and allows you to apply |
110
|
|
|
|
|
|
|
XSLT to that XML to display it in the browser. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
See L. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * B - Maps files to a MIME type for output in the |
115
|
|
|
|
|
|
|
F header using the file extension only. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
See L. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * B - Maps files to a MIME type using F. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
See L. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * B - Logs requests in the Apache combined log format. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
See L. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item * B - Runs CGI scripts. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
See L. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item * B - Serves plain files. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
See L. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item * B - Provides access statistics for the console. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
See L. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item * B - Maps URLs to filenames. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
See L. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item * B - Logging output to STDERR via warn(). |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
See L. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=back |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 CONSOLE |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
AxKit2 has a console which you can log into to view current and trend activity |
152
|
|
|
|
|
|
|
on your server. To setup the console add the following config: |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
ConsolePort 18000 |
155
|
|
|
|
|
|
|
Plugin stats |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This creates the console on C, and loads the stats plugin to |
158
|
|
|
|
|
|
|
provide trend statistics on your server. To use the console just telnet to |
159
|
|
|
|
|
|
|
port 18000. There is online help there and it should be obvious what each |
160
|
|
|
|
|
|
|
function does. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
To provide additional stats, modify the stats plugin or write your own. Whatever |
163
|
|
|
|
|
|
|
C returns will be output in the console when asked for statistics. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 API DOCUMENTATION |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
TODO - fill in as I write more docs for each module. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 Why 2.0? |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
In creating AxKit2 the following goals were aimed for: |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=over 4 |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item * Make it easier to setup and get started with than before. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item * Make it faster. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item * Make building complex web applications easier. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item * Make easy to extend and hack on. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item * Make complex pipelines and caching schemes easier. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=back |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Many people wanted a straight port to Apache2/mod_perl2, so that they could |
188
|
|
|
|
|
|
|
get their AxKit code migrated off the Apache1.x platform. This would have been |
189
|
|
|
|
|
|
|
one route to go down, a route which we looked at very seriously. However already |
190
|
|
|
|
|
|
|
taking up the mantle of an Apache2 version of AxKit is Tom Schindl's |
191
|
|
|
|
|
|
|
Apache2::TomKit distribution. Please check that out if you absolutely need |
192
|
|
|
|
|
|
|
mod_perl2 integration. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 LICENSE |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
AxKit2 is licensed under the Apache License, Version 2.0. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=cut |