210
|
1 #!/usr/bin/perl
|
|
2 use strict;
|
412
|
3 use Carp;
|
|
4 use Time::HiRes qw(gettimeofday tv_interval);
|
415
|
5 use Scalar::Util qw(blessed refaddr);
|
|
6 use YAML::XS qw(Dump);
|
407
|
7
|
417
|
8 my $t = [gettimeofday];
|
|
9
|
|
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
|
415
|
46 ]
|
|
47 };
|
417
|
48
|
407
|
49 1;
|