Debian Codegraph @

debian/additionalSrc/picocontainer1/container/src/java/org/picocontainer/defaults/package.html

raw
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 </head>
5 <body>
6 <p>This package contains the default implementation of the {@link org.picocontainer.PicoContainer}
7 API. The main class in this package is {@link org.picocontainer.defaults.DefaultPicoContainer},
8 which satisfies both the {@link org.picocontainer.PicoContainer} and
9 {@link org.picocontainer.MutablePicoContainer} contracts. In addition, it allows passing in of a
10 {@link org.picocontainer.defaults.ComponentAdapterFactory}, which can be used to customize the type
11 of {@link org.picocontainer.ComponentAdapter} that is used for components that are added to the
12 container for which no component adapter is specified explicitly.</p>
13
14 <p>This page contains a brief low-level overview of the default picocontainer implementation
15 package. Much more documentation is available on the
16 <a href="http://www.picocontainer.org/">PicoContainer website</a>.</p>
17
18 <h3>Buzzwords</h3>
19
20 <p>The implementation provided in this package is very extensible, embeddable and lightweight, to
21 get a few buzzwords out of the way.</p>
22
23 <ul>
24 <li><strong>extensible</strong>. A popular way to extend the container is to not really extend
25 it at all, but rather to feed the <code>DefaultPicoContainer</code> a custom-written component
26 adapter factory, for example one that creates adapters that support a different kind of IoC. For
27 really advanced applications you may wish to subclass <code>DefaultPicoContainer</code>.</li>
28 <li><strong>embeddable</strong>. This implementation has no external dependencies aside from the
29 java class libraries, is written in 100% pure java, and requires next to no set up to use. Good
30 examples of how the default picocontainer package can be embedded in an application can be found
31 in the <a href="http://www.nanocontainer.org/">nanocontainer project</a>.</li>
32 <li><strong>lightweight</strong>. The base PicoContainer package supports various ways to do
33 <a href="http://www.martinfowler.com/articles/injection.html">dependency injection</a> (including
34 {@link org.picocontainer.defaults.ConstructorInjectionComponentAdapterFactory constructor
35 injection},
36 which is used by default, and
37 {@link org.picocontainer.defaults.SetterInjectionComponentAdapterFactory setter
38 injection}), nothing more. With about 3 dozen classes, the picocontainer jar file (including the
39 PicoContainer API) is under a 100kb in size, small enough to use in just about any project.</li>
40 </ul>
41
42 <h3>Notes on Exceptions</h3>
43
44 <p>Almost all exceptions thrown in this package are subclasses of
45 {@link org.picocontainer.PicoException}, which is a subclass of {@link java.lang.RuntimeException}.
46 Furthermore, those exceptions are usually be subclasses of the basic pico exception types specified
47 in the API. As an example, {@link org.picocontainer.defaults.CyclicDependencyException} is a
48 specialization of {@link org.picocontainer.PicoInitializationException}.</p>
49
50 <p>It is not recommended that you catch the specific exceptions thrown in this package (except
51 perhaps if you're developing your own container based on this package). Rather catch the broader
52 exception classes defined as part of the core PicoContainer API, and minimize the ties your
53 application has to the implementation package.</p>
54
55 <h3>Notes on ComponentAdapters and ComponentAdapterFactories</h3>
56
57 <p>Most of the {@link org.picocontainer.ComponentAdapter} implementations in this package are
58 subclasses of either {@link org.picocontainer.defaults.AbstractComponentAdapter} or
59 {@link org.picocontainer.defaults.DecoratingComponentAdapter}. Subclasses of the former can
60 generally be used on their own, whereas subclasses of the latter wrap another ComponentAdapter,
61 providing slightly different behaviour or additional functionality. For example,
62 {@link org.picocontainer.defaults.CachingComponentAdapter} extends
63 <code>DecoratingComponentAdapter</code>. It can wrap any other adapter to
64 provide a singleton-like behaviour (where a single component instance is kept per container).
65 Contrast this with {@link org.picocontainer.defaults.ConstructorInjectionComponentAdapter} (a
66 subclass of <code>AbstractComponentAdapter</code>), which actually creates instances (using, in
67 this case, constructor dependency injection).</p>
68
69 <p>All component adapters in this package include a matching <code>ComponentAdapterFactory</code>.
70 The classnames of those factories can always be found simply by appending "Factory" to the name of
71 the component adapter class. One adapter factory deserves special mention: {@link
72 org.picocontainer.defaults.DefaultComponentAdapterFactory} is the factory that is used by
73 {@link org.picocontainer.defaults.DefaultPicoContainer} if none is explicitly specified.</p>
74
75 <p>It is recommended that you follow similar patterns if you write your own component adapters.
76 If you are not sure what type of adapter you need, it is often a good idea to start with a
77 decorating component adapter, so that you can mix and match functionality from the existing
78 adapters with your own. Also, always try to include a <code>ComponentAdapterFactory</code> for your
79 custom adapter.</p>
80
81 <h3>Notes on Parameters</h3>
82
83 <p>Advanced PicoContainer users may need to have full control over what parameters are fed to
84 components on instantiation, and the PicoContainer API provides this control via the
85 {@link org.picocontainer.Parameter} class. The default implementation provides two commonly used
86 parameter implementations: {@link org.picocontainer.defaults.ConstantParameter} for passing
87 "constants" (like primitive types and strings) to components and
88 {@link org.picocontainer.defaults.ConstantParameter} for passing a specific argument to the
89 component by specifying the key that should be used in retrieving that argument from the
90 container.</p>
91
92 </body>
93 </html>