407
|
1 package IMPL::Config::Descriptor;
|
413
|
2 use strict;
|
|
3 use IMPL::Exception();
|
415
|
4 use Scalar::Util qw(looks_like_number);
|
|
5
|
|
6 sub ACTIVATE_SINGLETON() { 1 }
|
|
7 sub ACTIVATE_CONTAINER() { 2 }
|
|
8 sub ACTIVATE_CONTEXT() { 3 }
|
|
9 sub ACTIVATE_CALL() { 4 }
|
|
10
|
|
11 my %activateNames = (
|
|
12 singleton => ACTIVATE_SINGLETON,
|
|
13 container => ACTIVATE_CONTAINER,
|
|
14 context => ACTIVATE_CONTEXT,
|
|
15 call => ACTIVATE_CALL
|
|
16 );
|
|
17
|
|
18 my %activateNamesLookup = map { $activateNames{$_}, $_ } keys %activateNames;
|
407
|
19
|
413
|
20 sub Activate {
|
415
|
21 my ( $this, $context ) = @_;
|
413
|
22 die IMPL::NotImplementedException->new();
|
|
23 }
|
407
|
24
|
415
|
25 sub ParseActivation {
|
|
26 my $val = pop @_;
|
|
27
|
|
28 return ACTIVATE_CALL unless $val;
|
|
29
|
|
30 return grep $_ == $val,
|
|
31 ACTIVATE_SINGLETON,
|
|
32 ACTIVATE_CONTAINER,
|
|
33 ACTIVATE_CONTEXT, ACTIVATE_CALL ? $val : ACTIVATE_CALL
|
|
34 if looks_like_number($val);
|
|
35
|
|
36 return $activateNames{ lc($val) } || ACTIVATE_CALL;
|
|
37 }
|
|
38
|
|
39 sub ActivationToString {
|
|
40 my $val = pop @_;
|
|
41
|
|
42 return ( $val && $activateNamesLookup{$val} ) || '';
|
|
43 }
|
407
|
44
|
|
45 1;
|
|
46
|
|
47 __END__
|
|
48
|
|
49 =pod
|
|
50
|
|
51 =head1 NAME
|
|
52
|
|
53 C<IMPL::Config::Descriptor> - the abstract base types for the service descriptors
|
|
54
|
|
55 =head1 SYNOPSIS
|
|
56
|
|
57 =begin code
|
|
58
|
|
59 package MyDescriptor;
|
|
60
|
|
61 use IMPL::declare {
|
|
62 base => {
|
|
63 'IMPL::Config::Descriptor' => '@_'
|
|
64 }
|
|
65 };
|
|
66
|
|
67 sub Activate {
|
|
68 my ($this,$context) = @_;
|
|
69
|
|
70 my $service = $context->GetService('service');
|
|
71 my
|
|
72
|
|
73 }
|
|
74
|
|
75 =end code
|
|
76
|
|
77 =head1 MEMBERS
|
|
78
|
|
79 =head1 SEE ALSO
|
|
80
|
|
81 =over
|
|
82
|
|
83 =item * L<ReferenceDescriptor> - describes a reference to the service
|
|
84
|
|
85 =item * L<ServiceDescriptor> - descibes a service factory
|
|
86
|
|
87 =item * L<ValueDescriptor> - describes a value
|
|
88
|
|
89 =back
|
|
90
|
415
|
91 =cut
|