5 use Catalyst::IOC::ConstructorInjection;
7 # FIXME - neither of these work:
8 use Sub::Exporter -setup => {
12 groups => { default => [qw/
16 #use Sub::Exporter -setup => [
19 # Bread::Board::container
20 # Bread::Board::depends_on
21 # Bread::Board::service
23 # Bread::Board::wire_names
24 # Bread::Board::include
25 # Bread::Board::typemap
29 # I'm probably doing it wrong.
30 # Anyway, I'll just use Moose::Exporter. Do I really have to use Sub::Exporter?
32 #Moose::Exporter->setup_import_methods(
33 # also => ['Bread::Board'],
37 my ($name, %args) = @_;
38 $args{dependencies} ||= {};
39 $args{dependencies}{application_name} = depends_on( '/application_name' );
41 # FIXME - check $args{type} here!
43 Catalyst::IOC::ConstructorInjection->new(
46 lifecycle => 'Singleton',
47 # XX FIXME - needs to become possible to intuit catalyst_component_name
48 # from dependencies (like config)
49 catalyst_component_name => 'TestAppCustomContainer::Model::Bar',
55 # FIXME - should the code example below be on this file or Catalyst::IOC::Container?
63 Catalyst::IOC - IOC for Catalyst, based on Bread::Board
67 package MyApp::Container;
73 container $self => as {
74 container model => as {
79 # model Bar needs model Foo to be built before
80 # and Bar's constructor gets Foo as a parameter
81 component Bar => ( dependencies => [
82 depends_on('/model/Foo'),
85 # Baz is rebuilt once per HTTP request
86 component Baz => ( lifecycle => 'Request' );
88 # built only once per application life time
89 component Quux => ( lifecycle => 'Singleton' );
91 # built once per app life time and uses an external model,
92 # outside the default directory
93 # no need for wrappers or Catalyst::Model::Adaptor
95 lifecycle => 'Singleton',
96 class => 'My::External::Class',
108 Catalyst Contributors, see Catalyst.pm
116 This library is free software. You can redistribute it and/or modify it under
117 the same terms as Perl itself.