annotate Lib/IMPL/Config/ActivationContext.pm @ 405:cd6c6e61d442 ref20150831

Working on DI container
author cin
date Mon, 31 Aug 2015 10:23:42 +0300
parents 9ef75f2029be
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
404
cin
parents:
diff changeset
1 package IMPL::Config::ActivationContext;
cin
parents:
diff changeset
2
405
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
3 use IMPL::Const qw(:prop);
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
4 use IMPL::Exception();
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
5 use IMPL::declare {
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
6 require => {
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
7 PropertyBag => 'IMPL::Config::ServicesBag'
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
8 },
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
9 base => {
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
10 'IMPL::Object' => '@_'
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
11 },
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
12 props => {
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
13 _services => PROP_RW,
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
14 _cache => PROP_RW,
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
15 _stack => PROP_RW
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
16 }
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
17 };
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
18
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
19 sub GetService {
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
20 my ($this,$serviceId) = @_;
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
21
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
22 $this->_services->
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
23 }
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
24
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
25 sub EnterScope {
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
26 my ($this, $name, $localize) = @_;
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
27
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
28 my $info = { name => $name };
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
29
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
30 if ($localize) {
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
31 $info->{services} = $this->_services;
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
32
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
33 $this->_services(PropertyBag->new($this->_services));
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
34 }
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
35
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
36 $this->_stack->Push($info);
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
37 }
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
38
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
39 sub LeaveScope {
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
40 my ($this) = @_;
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
41
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
42 my $info = $this->_stack->Pop()
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
43 or die IMPL::InvalidOperationException();
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
44
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
45 if ($info->{services})
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
46 $this->_services($info->{services});
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
47 }
cd6c6e61d442 Working on DI container
cin
parents: 404
diff changeset
48
404
cin
parents:
diff changeset
49 1;
cin
parents:
diff changeset
50 __END__
cin
parents:
diff changeset
51
cin
parents:
diff changeset
52 =pod
cin
parents:
diff changeset
53
cin
parents:
diff changeset
54 =head1 NAME
cin
parents:
diff changeset
55
cin
parents:
diff changeset
56 C<IMPL::Config::ActivationContext> - an activation context for the service
cin
parents:
diff changeset
57
cin
parents:
diff changeset
58 =head1 SYNOPSIS
cin
parents:
diff changeset
59
cin
parents:
diff changeset
60 For the internal use only
cin
parents:
diff changeset
61
cin
parents:
diff changeset
62 =head1 MEMBERS
cin
parents:
diff changeset
63
cin
parents:
diff changeset
64 =head2 METHODS
cin
parents:
diff changeset
65
cin
parents:
diff changeset
66 =head3 GetService($serviceId)
cin
parents:
diff changeset
67
cin
parents:
diff changeset
68 =cut