view _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
line wrap: on
line source

#!/usr/bin/perl
use strict;
use Carp;
use Time::HiRes qw(gettimeofday tv_interval);
use Scalar::Util qw(blessed refaddr);
use YAML::XS qw(Dump);

my $t = [gettimeofday];

use IMPL::require {
	Container => 'IMPL::Config::Container',
	Service => 'IMPL::Config::ServiceDescriptor',
	Reference => 'IMPL::Config::ReferenceDescriptor',
	Value => 'IMPL::Config::ValueDescriptor'
};

my $c1 = Container->new();

$c1->Register('db', Service->new(
    type => 'Foo::Data',
    norequire => 1,
    activation => 'container'
) );

$c1->Register(['sec', 'ldap'], Reference->new('db') );

$c1->Register('mixed', Value->new([
    Reference->new('db'),
    Reference->new('sec'),
    Reference->new('ldap')
]));

my $c2 = Container->new($c1);

my $data = [ $c1->Resolve('mixed')] ;

print "Activated: ",tv_interval($t,[gettimeofday]),"\n";

print Dump($data);


package Foo::Data;
use IMPL::declare {
	base => [
	   'IMPL::Object' => undef
	]
};

1;