1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<!--NewPage-->
3<HTML>
4<HEAD>
5<!-- Generated by javadoc (build 1.5.0_16) on Mon Oct 12 16:11:19 PDT 2009 -->
6<TITLE>
7Provider
8</TITLE>
9
10<META NAME="keywords" CONTENT="javax.inject.Provider interface">
11
12<LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style">
13
14<SCRIPT type="text/javascript">
15function windowTitle()
16{
17    parent.document.title="Provider";
18}
19</SCRIPT>
20<NOSCRIPT>
21</NOSCRIPT>
22
23</HEAD>
24
25<BODY BGCOLOR="white" onload="windowTitle();">
26
27
28<!-- ========= START OF TOP NAVBAR ======= -->
29<A NAME="navbar_top"><!-- --></A>
30<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
31<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
32<TR>
33<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
34<A NAME="navbar_top_firstrow"><!-- --></A>
35<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
36  <TR ALIGN="center" VALIGN="top">
37  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../javax/inject/package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
38  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
39  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
40  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
41  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
42  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
43  </TR>
44</TABLE>
45</TD>
46<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
47</EM>
48</TD>
49</TR>
50
51<TR>
52<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
53&nbsp;<A HREF="../../javax/inject/Named.html" title="annotation in javax.inject"><B>PREV CLASS</B></A>&nbsp;
54&nbsp;<A HREF="../../javax/inject/Qualifier.html" title="annotation in javax.inject"><B>NEXT CLASS</B></A></FONT></TD>
55<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
56  <A HREF="../../index.html?javax/inject/Provider.html" target="_top"><B>FRAMES</B></A>  &nbsp;
57&nbsp;<A HREF="Provider.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
58&nbsp;<SCRIPT type="text/javascript">
59  <!--
60  if(window==top) {
61    document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
62  }
63  //-->
64</SCRIPT>
65<NOSCRIPT>
66  <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>
67</NOSCRIPT>
68
69
70</FONT></TD>
71</TR>
72<TR>
73<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
74  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
75<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
76DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
77</TR>
78</TABLE>
79<A NAME="skip-navbar_top"></A>
80<!-- ========= END OF TOP NAVBAR ========= -->
81
82<HR>
83<!-- ======== START OF CLASS DATA ======== -->
84<H2>
85<FONT SIZE="-1">
86javax.inject</FONT>
87<BR>
88Interface Provider&lt;T&gt;</H2>
89<HR>
90<DL>
91<DT><PRE>public interface <B>Provider&lt;T&gt;</B></DL>
92</PRE>
93
94<P>
95Provides instances of <code>T</code>. Typically implemented by an injector. For
96 any type <code>T</code> that can be injected, you can also inject
97 <code>Provider&lt;T&gt;</code>. Compared to injecting <code>T</code> directly, injecting
98 <code>Provider&lt;T&gt;</code> enables:
99
100 <ul>
101   <li>retrieving multiple instances.</li>
102   <li>lazy or optional retrieval of an instance.</li>
103   <li>breaking circular dependencies.</li>
104   <li>abstracting scope so you can look up an instance in a smaller scope
105      from an instance in a containing scope.</li>
106 </ul>
107
108 <p>For example:
109
110 <pre>
111   class Car {
112     &#064;Inject Car(Provider&lt;Seat> seatProvider) {
113       Seat driver = seatProvider.get();
114       Seat passenger = seatProvider.get();
115       ...
116     }
117   }</pre>
118<P>
119
120<P>
121<HR>
122
123<P>
124
125<!-- ========== METHOD SUMMARY =========== -->
126
127<A NAME="method_summary"><!-- --></A>
128<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
129<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
130<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
131<B>Method Summary</B></FONT></TH>
132</TR>
133<TR BGCOLOR="white" CLASS="TableRowColor">
134<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
135<CODE>&nbsp;<A HREF="../../javax/inject/Provider.html" title="type parameter in Provider">T</A></CODE></FONT></TD>
136<TD><CODE><B><A HREF="../../javax/inject/Provider.html#get()">get</A></B>()</CODE>
137
138<BR>
139&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Provides a fully-constructed and injected instance of <code>T</code>.</TD>
140</TR>
141</TABLE>
142&nbsp;
143<P>
144
145<!-- ============ METHOD DETAIL ========== -->
146
147<A NAME="method_detail"><!-- --></A>
148<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
149<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
150<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
151<B>Method Detail</B></FONT></TH>
152</TR>
153</TABLE>
154
155<A NAME="get()"><!-- --></A><H3>
156get</H3>
157<PRE>
158<A HREF="../../javax/inject/Provider.html" title="type parameter in Provider">T</A> <B>get</B>()</PRE>
159<DL>
160<DD>Provides a fully-constructed and injected instance of <code>T</code>.
161<P>
162<DD><DL>
163
164<DT><B>Throws:</B>
165<DD><CODE>java.lang.RuntimeException</CODE> - if the injector encounters an error while
166  providing an instance. For example, if an injectable member on
167  <code>T</code> throws an exception, the injector may wrap the exception
168  and throw it to the caller of <code>get()</code>. Callers should not try
169  to handle such exceptions as the behavior may vary across injector
170  implementations and even different configurations of the same injector.</DL>
171</DD>
172</DL>
173<!-- ========= END OF CLASS DATA ========= -->
174<HR>
175
176
177<!-- ======= START OF BOTTOM NAVBAR ====== -->
178<A NAME="navbar_bottom"><!-- --></A>
179<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
180<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
181<TR>
182<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
183<A NAME="navbar_bottom_firstrow"><!-- --></A>
184<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
185  <TR ALIGN="center" VALIGN="top">
186  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../javax/inject/package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
187  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
188  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
189  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
190  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
191  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
192  </TR>
193</TABLE>
194</TD>
195<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
196</EM>
197</TD>
198</TR>
199
200<TR>
201<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
202&nbsp;<A HREF="../../javax/inject/Named.html" title="annotation in javax.inject"><B>PREV CLASS</B></A>&nbsp;
203&nbsp;<A HREF="../../javax/inject/Qualifier.html" title="annotation in javax.inject"><B>NEXT CLASS</B></A></FONT></TD>
204<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
205  <A HREF="../../index.html?javax/inject/Provider.html" target="_top"><B>FRAMES</B></A>  &nbsp;
206&nbsp;<A HREF="Provider.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
207&nbsp;<SCRIPT type="text/javascript">
208  <!--
209  if(window==top) {
210    document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
211  }
212  //-->
213</SCRIPT>
214<NOSCRIPT>
215  <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>
216</NOSCRIPT>
217
218
219</FONT></TD>
220</TR>
221<TR>
222<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
223  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
224<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
225DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
226</TR>
227</TABLE>
228<A NAME="skip-navbar_bottom"></A>
229<!-- ======== END OF BOTTOM NAVBAR ======= -->
230
231<HR>
232<font size='-1'>Copyright (C) 2009 <a href='http://code.google.com/p/atinject/'>The JSR-330 Expert Group</a>. Licensed under the <a href='http://www.apache.org/licenses/LICENSE-2.0'>Apache License</a>, Version 2.0.</font>
233</BODY>
234</HTML>
235