annotate Lib/IMPL/Web/Application.pm @ 47:a9b70d836b28

Web::Application development (request controller) Security development
author Sergey
date Tue, 23 Feb 2010 22:57:16 +0300
parents 1b1fb9d54f55
children 16ada169ca75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
1 package IMPL::Web::Application;
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
2 use strict;
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
3 use warnings;
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
4
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
5 use base qw(IMPL::Object IMPL::Object::Singleton);
47
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
6 use IMPL::Class::Property;
45
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
7
47
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
8 BEGIN {
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
9 public property RequestFactory => prop_all;
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
10 public property ContextInitializers => prop_all;
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
11 }
45
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
12
47
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
13 # custom factory
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
14 sub new {
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
15 my ($self,$file) = @_;
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
16
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
17 return $self->LoadXMLFile($file);
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
18 }
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
19
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
20 sub Run {
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
21 my ($this) = @_;
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
22
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
23 while (my $request = $this->fetch_request()) {
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
24 my $context = $this->prepare_context($request);
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
25 $context->invoke($request);
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
26 }
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
27 }
45
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
28
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
29 1;
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
30
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
31 =pod
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
32
47
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
33 =head1 SYNOPSIS
45
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
34
47
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
35 require MyApp;
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
36 MyApp->instance('app.config')->Run();
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
37
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
38 =head1 DESCRIPTION
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
39
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
40 Зкземпляр приложения содержит в себе глобальные настройки, реализует контроллер запросов,
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
41
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
42 Получая запрос из источника запросов, создает контекст выполнения запроса
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
43 затем выполняет запрос в указанном контексте.
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
44
a9b70d836b28 Web::Application development (request controller)
Sergey
parents: 45
diff changeset
45 Контекст формируется сначала из запроса, а затем посредством набора инициализаторов
45
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
46
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
47 =cut