Mercurial > pub > Impl
annotate Lib/IMPL/Web/Application.pm @ 59:0f3e369553bd
Rewritten property implementation (probably become slower but more flexible)
Configuration infrastructure in progress (in the aspect of the lazy activation)
Initial concept for the code generator
author | wizard |
---|---|
date | Tue, 09 Mar 2010 02:50:45 +0300 |
parents | a35b60b16a99 |
children | b0c068da93ac |
rev | line source |
---|---|
49 | 1 package IMPL::Web::Application; |
2 use strict; | |
3 use warnings; | |
4 | |
5 use base qw(IMPL::Object IMPL::Object::Singleton); | |
58 | 6 |
7 require IMPL::Web::Application::Action; | |
8 require IMPL::Web::Application::Response; | |
9 | |
49 | 10 use IMPL::Class::Property; |
57 | 11 use CGI; |
49 | 12 |
13 BEGIN { | |
52 | 14 public property handlerError => prop_all; |
57 | 15 public property factoryAction => prop_all; |
59
0f3e369553bd
Rewritten property implementation (probably become slower but more flexible)
wizard
parents:
58
diff
changeset
|
16 public property handlersQuery => prop_all | prop_list; |
49 | 17 } |
18 | |
19 # custom factory | |
20 sub new { | |
21 my ($self,$file) = @_; | |
22 | |
23 return $self->LoadXMLFile($file); | |
24 } | |
25 | |
26 sub Run { | |
27 my ($this) = @_; | |
28 | |
58 | 29 while (my $query = $this->FetchRequest()) { |
30 my $response = new IMPL::Web::Application::Response(request => $query); | |
31 | |
32 my $action = new IMPL::Web::Application::Action( | |
33 request => $query, | |
34 response => $response, | |
35 application => $this, | |
36 ); | |
37 | |
38 $action->ChainHandler($_) foreach $this->handlersQuery; | |
39 | |
40 $action->Invoke(); | |
49 | 41 } |
42 } | |
43 | |
57 | 44 { |
45 my $hasFetched = 0; | |
46 | |
47 sub FetchRequest { | |
48 return undef if $hasFetched; | |
49 $hasFetched = 1; | |
50 return CGI->new(); | |
51 } | |
52 } | |
53 | |
49 | 54 1; |
55 | |
52 | 56 __END__ |
57 | |
49 | 58 =pod |
59 | |
60 =head1 SYNOPSIS | |
61 | |
62 require MyApp; | |
59
0f3e369553bd
Rewritten property implementation (probably become slower but more flexible)
wizard
parents:
58
diff
changeset
|
63 MyApp->spawn('app.config')->Run(); |
49 | 64 |
65 =head1 DESCRIPTION | |
66 | |
67 Зкземпляр приложения содержит в себе глобальные настройки, реализует контроллер запросов, | |
52 | 68 в качестве источника запросов используется CGI или иной совместимый модуль. |
49 | 69 |
52 | 70 Процесс обработки запроса состоит из следующих частей |
49 | 71 |
52 | 72 1. Получение cgi запроса |
73 2. Вызов модуля для инициализации объекта действия | |
74 3. Инициализация контекста выполнения | |
75 4. Выполнение запроса | |
76 5. Преобразование полученных данных в тело ответа | |
77 | |
78 | |
79 | |
49 | 80 |
81 =cut |