comparison _test/temp.pl @ 417:3ed0c58e9da3 ref20150831

working on di container, tests
author cin
date Mon, 02 Nov 2015 01:56:53 +0300
parents 3d24b10dd0d5
children 3f38dabaf5cc
comparison
equal deleted inserted replaced
416:cc2cf8c0edc2 417:3ed0c58e9da3
3 use Carp; 3 use Carp;
4 use Time::HiRes qw(gettimeofday tv_interval); 4 use Time::HiRes qw(gettimeofday tv_interval);
5 use Scalar::Util qw(blessed refaddr); 5 use Scalar::Util qw(blessed refaddr);
6 use YAML::XS qw(Dump); 6 use YAML::XS qw(Dump);
7 7
8 print Dump { 8 my $t = [gettimeofday];
9 services => [ 9
10 { role => 'db', type => 'My::Data::Context', params => { '-ref' => 'some-role' } } 10 use IMPL::require {
11 Container => 'IMPL::Config::Container',
12 Service => 'IMPL::Config::ServiceDescriptor',
13 Reference => 'IMPL::Config::ReferenceDescriptor',
14 Value => 'IMPL::Config::ValueDescriptor'
15 };
16
17 my $c1 = Container->new();
18
19 $c1->Register('db', Service->new(
20 type => 'Foo::Data',
21 norequire => 1,
22 activation => 'container'
23 ) );
24
25 $c1->Register(['sec', 'ldap'], Reference->new('db') );
26
27 $c1->Register('mixed', Value->new([
28 Reference->new('db'),
29 Reference->new('sec'),
30 Reference->new('ldap')
31 ]));
32
33 my $c2 = Container->new($c1);
34
35 my $data = [ $c1->Resolve('mixed')] ;
36
37 print "Activated: ",tv_interval($t,[gettimeofday]),"\n";
38
39 print Dump($data);
40
41
42 package Foo::Data;
43 use IMPL::declare {
44 base => [
45 'IMPL::Object' => undef
11 ] 46 ]
12 }; 47 };
48
13 1; 49 1;