annotate Lib/IMPL/Config/Reference.pm @ 245:7c517134c42f

Added Unsupported media type Web exception corrected resourceLocation setting in the resource Implemented localizable resources for text messages fixed TT view scopings, INIT block in controls now sets globals correctly.
author sergey
date Mon, 29 Oct 2012 03:15:22 +0400
parents 2ffe6f661605
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
196
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
1 package IMPL::Config::Reference;
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
2 use strict;
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
3
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
4 use IMPL::Exception;
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
5
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
6 sub restore {
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
7 my ($self,$data,$surrogate) = @_;
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
8
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
9 my @path;
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
10
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
11 my ($tagTarget,$target) = splice @$data, 0, 2;
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
12
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
13 die new IMPL::Exception('A traget tag must be the first tag in the reference specification') unless $tagTarget eq 'target';
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
14 while(my ($method,$args) = splice @$data, 0, 2 ) {
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 196
diff changeset
15 $target = $self->_InvokeMember($target,{ method => $method, args => $args});
196
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
16 }
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
17 return $target;
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
18 }
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
19
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
20 sub _InvokeMember {
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
21 my ($self,$object,$member) = @_;
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
22
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
23 my $method = $member->{method};
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 196
diff changeset
24 return
196
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
25 ref $object eq 'HASH' ?
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
26 $object->{$method}
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
27 :
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
28 $object->$method(
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
29 exists $member->{args} ?
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
30 _as_list($member->{args})
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
31 :
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
32 ()
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
33 )
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 196
diff changeset
34 ;
196
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
35 }
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
36
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
37 sub _as_list {
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
38 ref $_[0] ?
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
39 (ref $_[0] eq 'HASH' ?
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
40 %{$_[0]}
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
41 :
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
42 (ref $_[0] eq 'ARRAY'?
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
43 @{$_[0]}
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
44 :
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
45 $_[0]
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
46 )
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
47 )
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
48 :
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
49 ($_[0]);
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
50 }
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
51
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
52 1;
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
53
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
54 __END__
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
55
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
56 =pod
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
57
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
58 =head1 NAME
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
59
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
60 C<IMPL::Config::Reference> - ссылка на внешний объект, вычисляемый на этапе десериализации данных.
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
61
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
62 =head1 SYNOPSIS
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
63
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
64 =begin code xml
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
65
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
66 <Application>
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
67 <processingStack type="IMPL::Config::Reference">
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
68 <target>IMPL::Config</target>
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
69 <LoadXMLFile>stdprocessing.xml</LoadXMLFile>
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
70 </processingStack>
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
71 </Application>
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
72
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
73 =end code xml
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
74
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
75 =head1 DESCRIPTION
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
76
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
77 Позволяет на указвать ссылки на вычисляемые объекты, например, загружаемые из файлов. Ссылки такого рода
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
78 будут вычислены на этапе десериализации еще до того, как будет создан объект верхнего уровня, поэтому
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
79 следует избегать таких ссылок на сам (его свойства и методы) десериализуемый объект.
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
80
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
81 =head1 MEMBERS
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
82
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
83 =head2 C<restore($class,$data,$surrogate)>
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
84
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
85 Использует данные переданные в параметре дата C<$data> для вычисления свойства. Данный метод - стандартный
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
86 метод для десериализации объекта, а параметр C<$data> содержит пары значений C<(имя_узла,значение_узла)>,
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
87 первая пара обязательно является узлом C<target>, а его значение - целевой объект, который будет
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
88 использован для вычисления конечного значения.
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
89
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
90 =back
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
91
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
92 =cut