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