|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ComponentAdapter.java | - | - | - | - |
|
1 |
/*****************************************************************************
|
|
2 |
* Copyright (C) PicoContainer Organization. All rights reserved. *
|
|
3 |
* ------------------------------------------------------------------------- *
|
|
4 |
* The software in this package is published under the terms of the BSD *
|
|
5 |
* style license a copy of which has been included with this distribution in *
|
|
6 |
* the LICENSE.txt file. *
|
|
7 |
*****************************************************************************/
|
|
8 |
package org.picocontainer;
|
|
9 |
|
|
10 |
/**
|
|
11 |
* A component adapter is responsible for providing a specific component instance. An instance of an implementation of
|
|
12 |
* this interface is used inside a {@link PicoContainer} for every registered component or instance. Each
|
|
13 |
* <code>ComponentAdapter</code> instance has to have a key which is unique within that container. The key itself is
|
|
14 |
* either a class type (normally an interface) or an identifier.
|
|
15 |
*
|
|
16 |
* @author Jon Tirsén
|
|
17 |
* @author Paul Hammant
|
|
18 |
* @author Aslak Hellesøy
|
|
19 |
* @version $Revision: 1.16 $
|
|
20 |
* @see MutablePicoContainer an extension of the PicoContainer interface which allows you to modify the contents of the
|
|
21 |
* container.
|
|
22 |
* @since 1.0
|
|
23 |
*/
|
|
24 |
public interface ComponentAdapter { |
|
25 |
/**
|
|
26 |
* Retrieve the key associated with the component.
|
|
27 |
*
|
|
28 |
* @return the component's key. Should either be a class type (normally an interface) or an identifier that is
|
|
29 |
* unique (within the scope of the current PicoContainer).
|
|
30 |
*/
|
|
31 |
Object getComponentKey(); |
|
32 |
|
|
33 |
/**
|
|
34 |
* Retrieve the class of the component.
|
|
35 |
*
|
|
36 |
* @return the component's implementation class. Should normally be a concrete class (ie, a class that can be
|
|
37 |
* instantiated).
|
|
38 |
*/
|
|
39 |
Class getComponentImplementation(); |
|
40 |
|
|
41 |
/**
|
|
42 |
* Retrieve the component instance. This method will usually create a new instance each time it is called, but that
|
|
43 |
* is not required. For example, {@link org.picocontainer.defaults.CachingComponentAdapter} will always return the
|
|
44 |
* same instance.
|
|
45 |
*
|
|
46 |
* @return the component instance.
|
|
47 |
* @throws PicoInitializationException if the component could not be instantiated.
|
|
48 |
* @throws PicoIntrospectionException if the component has dependencies which could not be resolved, or
|
|
49 |
* instantiation of the component lead to an ambigous situation within the
|
|
50 |
* container.
|
|
51 |
*/
|
|
52 |
Object getComponentInstance() throws PicoInitializationException, PicoIntrospectionException;
|
|
53 |
|
|
54 |
/**
|
|
55 |
* Retrieve the container in which the component is registered.
|
|
56 |
*
|
|
57 |
* @return the container in which the component is registered.
|
|
58 |
*/
|
|
59 |
PicoContainer getContainer(); |
|
60 |
|
|
61 |
/**
|
|
62 |
* Set the container in which this adapter is registered. This method will be called once by the container when the
|
|
63 |
* adapter is registered in that container. It should usually not be called directly.
|
|
64 |
*
|
|
65 |
* @param picoContainer the container in which this adapter is registered.
|
|
66 |
*/
|
|
67 |
void setContainer(PicoContainer picoContainer);
|
|
68 |
|
|
69 |
/**
|
|
70 |
* Verify that all dependencies for this adapter can be satisifed. Normally, the adapter should verify this by
|
|
71 |
* checking that the associated PicoContainer contains all the needed dependnecies.
|
|
72 |
*
|
|
73 |
* @throws PicoVerificationException if one or more dependencies cannot be resolved.
|
|
74 |
*/
|
|
75 |
void verify() throws PicoVerificationException; |
|
76 |
} |
|
77 |
|
|