line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CatalystX::ASP::Application; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
4893
|
use namespace::autoclean; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
74
|
|
4
|
9
|
|
|
9
|
|
626
|
use Moose; |
|
9
|
|
|
|
|
12
|
|
|
9
|
|
|
|
|
50
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has 'asp' => ( |
7
|
|
|
|
|
|
|
is => 'ro', |
8
|
|
|
|
|
|
|
isa => 'CatalystX::ASP', |
9
|
|
|
|
|
|
|
required => 1, |
10
|
|
|
|
|
|
|
weak_ref => 1, |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
CatalystX::ASP::Application - $Application Object |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use CatalystX::ASP::Application; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $application = CatalystX::ASP::Application->new(asp => $asp); |
22
|
|
|
|
|
|
|
$application->{foo} = $bar; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Like the C<$Session> object, you may use the C<$Application> object to store |
27
|
|
|
|
|
|
|
data across the entire life of the application. Every page in the ASP |
28
|
|
|
|
|
|
|
application always has access to this object. So if you wanted to keep track of |
29
|
|
|
|
|
|
|
how many visitors there where to the application during its lifetime, you might |
30
|
|
|
|
|
|
|
have a line like this: |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$Application->{num_users}++ |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
The Lock and Unlock methods are used to prevent simultaneous access to the |
35
|
|
|
|
|
|
|
C<$Application> object. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 METHODS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=over |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item $Application->Lock() |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Not implemented. This is a no-op. This is unnecessary given the implementation |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# TODO: will not implement |
48
|
|
|
|
|
|
|
sub Lock { |
49
|
1
|
|
|
1
|
1
|
6
|
my ( $self ) = @_; |
50
|
1
|
|
|
|
|
24
|
$self->asp->c->log->warn( "\$Application->Lock has not been implemented!" ); |
51
|
1
|
|
|
|
|
993
|
return; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item $Application->UnLock() |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Not implemented. This is a no-op. This is unnecessary given the implementation |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# TODO: will not implement |
61
|
|
|
|
|
|
|
sub UnLock { |
62
|
1
|
|
|
1
|
1
|
2
|
my ( $self ) = @_; |
63
|
1
|
|
|
|
|
31
|
$self->asp->c->log->warn( "\$Application->UnLock has not been implemented!" ); |
64
|
1
|
|
|
|
|
9
|
return; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item $Application->GetSession($sess_id) |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This NON-PORTABLE API extension returns a user C<$Session> given a session id. |
70
|
|
|
|
|
|
|
This allows one to easily write a session manager if session ids are stored in |
71
|
|
|
|
|
|
|
C<$Application> during C<Session_OnStart>, with full access to these sessions |
72
|
|
|
|
|
|
|
for administrative purposes. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Be careful not to expose full session ids over the net, as they could be used |
75
|
|
|
|
|
|
|
by a hacker to impersonate another user. So when creating a session manager, for |
76
|
|
|
|
|
|
|
example, you could create some other id to reference the SessionID internally, |
77
|
|
|
|
|
|
|
which would allow you to control the sessions. This kind of application would |
78
|
|
|
|
|
|
|
best be served under a secure web server. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub GetSession { |
83
|
1
|
|
|
1
|
1
|
14
|
my ( $self, $sess_id ) = @_; |
84
|
1
|
|
|
|
|
24
|
my $c = $self->asp->c; |
85
|
1
|
|
|
|
|
22
|
my $session_class = ref $self->asp->Session; |
86
|
1
|
50
|
|
|
|
17
|
if ( $c->can( 'get_session_data' ) ) { |
|
|
50
|
|
|
|
|
|
87
|
0
|
|
|
|
|
0
|
my $session = $c->get_session_data( $sess_id ); |
88
|
0
|
|
|
|
|
0
|
return bless $session, $session_class |
89
|
|
|
|
|
|
|
} elsif ( $c->can( 'session_cache' ) ) { |
90
|
0
|
|
|
|
|
0
|
my $session = $c->session_cache->get( $sess_id, existing_session_only => 1 ); |
91
|
0
|
|
|
|
|
0
|
return bless $session, $session_class |
92
|
|
|
|
|
|
|
} else { |
93
|
1
|
|
|
|
|
45
|
return $self->asp->Session; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item $Application->SessionCount() |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This NON-PORTABLE method returns the current number of active sessions in the |
100
|
|
|
|
|
|
|
application, and is enabled by the C<SessionCount> configuration setting. This |
101
|
|
|
|
|
|
|
method is not implemented as part of the original ASP object model, but is |
102
|
|
|
|
|
|
|
implemented here because it is useful. In particular, when accessing databases |
103
|
|
|
|
|
|
|
with license requirements, one can monitor usage effectively through accessing |
104
|
|
|
|
|
|
|
this value. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# TODO: will not implement |
109
|
|
|
|
|
|
|
sub SessionCount { |
110
|
1
|
|
|
1
|
1
|
2
|
my ( $self ) = @_; |
111
|
1
|
|
|
|
|
29
|
$self->asp->c->log->warn( "\$Application->SessionCount has not been implemented!" ); |
112
|
1
|
|
|
|
|
7
|
return; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub DEMOLISH { |
116
|
0
|
|
|
0
|
0
|
|
my ( $self ) = @_; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# It's okay if it fails... |
119
|
0
|
|
|
|
|
|
eval { $self->asp->GlobalASA->Application_OnEnd }; |
|
0
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=back |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 SEE ALSO |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=over |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item * L<CatalystX::ASP::Session> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item * L<CatalystX::ASP::Request> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item * L<CatalystX::ASP::Response> |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item * L<CatalystX::ASP::Server> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=back |