| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <!--NewPage--> |
| <HTML> |
| <HEAD> |
| <!-- Generated by javadoc (build 1.5.0_07) on Wed Sep 05 19:50:22 PDT 2007 --> |
| <TITLE> |
| Binder (Guice 1.0 API) |
| </TITLE> |
| |
| <META NAME="keywords" CONTENT="com.google.inject.Binder interface"> |
| |
| <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"> |
| |
| <SCRIPT type="text/javascript"> |
| function windowTitle() |
| { |
| parent.document.title="Binder (Guice 1.0 API)"; |
| } |
| </SCRIPT> |
| <NOSCRIPT> |
| </NOSCRIPT> |
| |
| </HEAD> |
| |
| <BODY BGCOLOR="white" onload="windowTitle();"> |
| |
| |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <A NAME="navbar_top"><!-- --></A> |
| <A HREF="#skip-navbar_top" title="Skip navigation links"></A> |
| <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> |
| <TR> |
| <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> |
| <A NAME="navbar_top_firstrow"><!-- --></A> |
| <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> |
| <TR ALIGN="center" VALIGN="top"> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> |
| <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> |
| </TR> |
| </TABLE> |
| </TD> |
| <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> |
| </EM> |
| </TD> |
| </TR> |
| |
| <TR> |
| <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
| <A HREF="../../../com/google/inject/AbstractModule.html" title="class in com.google.inject"><B>PREV CLASS</B></A> |
| <A HREF="../../../com/google/inject/Binding.html" title="interface in com.google.inject"><B>NEXT CLASS</B></A></FONT></TD> |
| <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
| <A HREF="../../../index.html?com/google/inject/Binder.html" target="_top"><B>FRAMES</B></A> |
| <A HREF="Binder.html" target="_top"><B>NO FRAMES</B></A> |
| <SCRIPT type="text/javascript"> |
| <!-- |
| if(window==top) { |
| document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); |
| } |
| //--> |
| </SCRIPT> |
| <NOSCRIPT> |
| <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A> |
| </NOSCRIPT> |
| |
| |
| </FONT></TD> |
| </TR> |
| <TR> |
| <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
| SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> |
| <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
| DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> |
| </TR> |
| </TABLE> |
| <A NAME="skip-navbar_top"></A> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| |
| <HR> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <H2> |
| <FONT SIZE="-1"> |
| com.google.inject</FONT> |
| <BR> |
| Interface Binder</H2> |
| <HR> |
| <DL> |
| <DT><PRE>public interface <B>Binder</B></DL> |
| </PRE> |
| |
| <P> |
| Collects configuration information (primarily <i>bindings</i>) which will be |
| used to create an <A HREF="../../../com/google/inject/Injector.html" title="interface in com.google.inject"><CODE>Injector</CODE></A>. Guice provides this object to your |
| application's <A HREF="../../../com/google/inject/Module.html" title="interface in com.google.inject"><CODE>Module</CODE></A> implementors so they may each contribute |
| their own bindings and other registrations. |
| |
| <h3>The Guice Binding EDSL</h3> |
| |
| Guice uses an <i>embedded domain-specific language</i>, or EDSL, to help you |
| create bindings simply and readably. This approach is great for overall |
| usability, but it does come with a small cost: <b>it is difficult to |
| learn how to use the Binding EDSL in the usual way -- by reading |
| method-level javadocs</b>. Instead, you should consult this series of |
| examples below. To save space, these examples omit the opening |
| <code>binder.</code>, just as you will if your module extends |
| <A HREF="../../../com/google/inject/AbstractModule.html" title="class in com.google.inject"><CODE>AbstractModule</CODE></A>. |
| |
| <pre> |
| bind(ServiceImpl.class);</pre> |
| |
| This statement does essentially nothing; it "binds the <code>ServiceImpl</code> |
| class to itself" and does not change Guice's default behavior. You may still |
| want to use this if you prefer your <A HREF="../../../com/google/inject/Module.html" title="interface in com.google.inject"><CODE>Module</CODE></A> class to serve as an |
| explicit <i>manifest</i> for the services it provides. Also, in rare cases, |
| Guice may be unable to validate a binding at injector creation time unless it |
| is given explicitly. |
| |
| <pre> |
| bind(Service.class).to(ServiceImpl.class);</pre> |
| |
| Specifies that a request for a <code>Service</code> instance with no binding |
| annotations should be treated as if it were a request for a |
| <code>ServiceImpl</code> instance. This <i>overrides</i> the function of any |
| <A HREF="../../../com/google/inject/ImplementedBy.html" title="annotation in com.google.inject"><CODE>@ImplementedBy</CODE></A> or <A HREF="../../../com/google/inject/ProvidedBy.html" title="annotation in com.google.inject"><CODE>@ProvidedBy</CODE></A> |
| annotations found on <code>Service</code>, since Guice will have already |
| "moved on" to <code>ServiceImpl</code> before it reaches the point when it starts |
| looking for these annotations. |
| |
| <pre> |
| bind(Service.class).toProvider(ServiceProvider.class);</pre> |
| |
| In this example, <code>ServiceProvider</code> must extend or implement |
| <code>Provider<Service></code>. This binding specifies that Guice should resolve |
| an unannotated injection request for <code>Service</code> by first resolving an |
| instance of <code>ServiceProvider</code> in the regular way, then calling |
| <A HREF="../../../com/google/inject/Provider.html#get()"><CODE>get()</CODE></A> on the resulting Provider instance to obtain the |
| <code>Service</code> instance. |
| |
| <p>The <A HREF="../../../com/google/inject/Provider.html" title="interface in com.google.inject"><CODE>Provider</CODE></A> you use here does not have to be a "factory"; that |
| is, a provider which always <i>creates</i> each instance it provides. |
| However, this is generally a good practice to follow. You can then use |
| Guice's concept of <A HREF="../../../com/google/inject/Scope.html" title="interface in com.google.inject"><CODE>scopes</CODE></A> to guide when creation should happen |
| -- "letting Guice work for you". |
| |
| <pre> |
| bind(Service.class).annotatedWith(Red.class).to(ServiceImpl.class);</pre> |
| |
| Like the previous example, but only applies to injection requests that use |
| the binding annotation <code>@Red</code>. If your module also includes bindings |
| for particular <i>values</i> of the <code>@Red</code> annotation (see below), |
| then this binding will serve as a "catch-all" for any values of <code>@Red</code> |
| that have no exact match in the bindings. |
| |
| <pre> |
| bind(ServiceImpl.class).in(Singleton.class); |
| // or, alternatively |
| bind(ServiceImpl.class).in(Scopes.SINGLETON);</pre> |
| |
| Either of these statements places the <code>ServiceImpl</code> class into |
| singleton scope. Guice will create only one instance of <code>ServiceImpl</code> |
| and will reuse it for all injection requests of this type. Note that it is |
| still possible to bind another instance of <code>ServiceImpl</code> if the second |
| binding is qualified by an annotation as in the previous example. Guice is |
| not overly concerned with <i>preventing</i> you from creating multiple |
| instances of your "singletons", only with <i>enabling</i> your application to |
| share only one instance if that's all you tell Guice you need. |
| |
| <p><b>Note:</b> a scope specified in this way <i>overrides</i> any scope that |
| was specified with an annotation on the <code>ServiceImpl</code> class. |
| |
| <p>Besides <A HREF="../../../com/google/inject/Singleton.html" title="annotation in com.google.inject"><CODE>Singleton</CODE></A>/<A HREF="../../../com/google/inject/Scopes.html#SINGLETON"><CODE>Scopes.SINGLETON</CODE></A>, there are |
| servlet-specific scopes available in |
| <code>com.google.inject.servlet.ServletScopes</code>, and your Modules can |
| contribute their own custom scopes for use here as well. |
| |
| <pre> |
| bind(new TypeLiteral<PaymentService<CreditCard>>() {}) |
| .to(CreditCardPaymentService.class);</pre> |
| |
| This admittedly odd construct is the way to bind a parameterized type. It |
| tells Guice how to honor an injection request for an element of type |
| <code>PaymentService<CreditCard></code>. The class |
| <code>CreditCardPaymentService</code> must implement the |
| <code>PaymentService<CreditCard></code> interface. Guice cannot currently bind or |
| inject a generic type, such as <code>Set<E></code>; all type parameters must be |
| fully specified. |
| |
| <pre> |
| bind(Service.class).toInstance(new ServiceImpl()); |
| // or, alternatively |
| bind(Service.class).toInstance(SomeLegacyRegistry.getService());</pre> |
| |
| In this example, your module itself, <i>not Guice</i>, takes responsibility |
| for obtaining a <code>ServiceImpl</code> instance, then asks Guice to always use |
| this single instance to fulfill all <code>Service</code> injection requests. When |
| the <A HREF="../../../com/google/inject/Injector.html" title="interface in com.google.inject"><CODE>Injector</CODE></A> is first created, it will automatically perform field |
| and method injection for this instance, but any injectable constructor on |
| <code>ServiceImpl</code> is simply ignored. Note that using this approach results |
| in "eager loading" behavior that you can't control. |
| |
| <pre> |
| bindConstant().annotatedWith(ServerHost.class).to(args[0]);</pre> |
| |
| Sets up a constant binding. Constant bindings are typeless in Guice; you |
| can provide the values in a variety of types and the values can be injected |
| in a variety of types; Guice performs the standard type conversions for you |
| behind the scenes. Because of this "typelessness", constant injections must |
| always be annotated. |
| |
| <pre> |
| @Color("red") Color red; // A member variable (field) |
| . . . |
| red = MyModule.class.getField("red").getAnnotation(Color.class); |
| bind(Service.class).annotatedWith(red).to(RedService.class);</pre> |
| |
| If your binding annotation has parameters you can apply different bindings to |
| different specific values of your annotation. Getting your hands on the |
| right instance of the annotation is a bit of a pain -- one approach, shown |
| above, is to apply a prototype annotation to a field in your module class, so |
| that you can read this annotation instance and give it to Guice. |
| |
| <pre> |
| bind(Service.class) |
| .annotatedWith(Names.named("blue")) |
| .to(BlueService.class);</pre> |
| |
| Differentiating by names is a common enough use case that we provided a |
| standard annotation, <A HREF="../../../com/google/inject/name/Named.html" title="annotation in com.google.inject.name"><CODE>@Named</CODE></A>. Because of |
| Guice's library support, binding by name is quite easier than in the |
| arbitrary binding annotation case we just saw. However, remember that these |
| names will live in a single flat namespace with all the other names used in |
| your application. |
| |
| <p>The above list of examples is far from exhaustive. If you can think of |
| how the concepts of one example might coexist with the concepts from another, |
| you can most likely weave the two together. If the two concepts make no |
| sense with each other, you most likely won't be able to do it. In a few |
| cases Guice will let something bogus slip by, and will then inform you of |
| the problems at runtime, as soon as you try to create your Injector. |
| |
| <p>The other methods of Binder such as <A HREF="../../../com/google/inject/Binder.html#bindScope(java.lang.Class, com.google.inject.Scope)"><CODE>bindScope(java.lang.Class<? extends java.lang.annotation.Annotation>, com.google.inject.Scope)</CODE></A>, |
| <A HREF="../../../com/google/inject/Binder.html#bindInterceptor(com.google.inject.matcher.Matcher, com.google.inject.matcher.Matcher, org.aopalliance.intercept.MethodInterceptor...)"><CODE>bindInterceptor(com.google.inject.matcher.Matcher<? super java.lang.Class<?>>, com.google.inject.matcher.Matcher<? super java.lang.reflect.Method>, org.aopalliance.intercept.MethodInterceptor...)</CODE></A>, <A HREF="../../../com/google/inject/Binder.html#install(com.google.inject.Module)"><CODE>install(com.google.inject.Module)</CODE></A>, <A HREF="../../../com/google/inject/Binder.html#requestStaticInjection(java.lang.Class...)"><CODE>requestStaticInjection(java.lang.Class<?>...)</CODE></A>, |
| <A HREF="../../../com/google/inject/Binder.html#addError(java.lang.String, java.lang.Object...)"><CODE>addError(java.lang.String, java.lang.Object...)</CODE></A> and <A HREF="../../../com/google/inject/Binder.html#currentStage()"><CODE>currentStage()</CODE></A> are not part of the Binding EDSL; |
| you can learn how to use these in the usual way, from the method |
| documentation. |
| <P> |
| |
| <P> |
| <HR> |
| |
| <P> |
| |
| <!-- ========== METHOD SUMMARY =========== --> |
| |
| <A NAME="method_summary"><!-- --></A> |
| <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> |
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> |
| <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> |
| <B>Method Summary</B></FONT></TH> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> void</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../com/google/inject/Binder.html#addError(java.lang.String, java.lang.Object...)">addError</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> message, |
| <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A>... arguments)</CODE> |
| |
| <BR> |
| Records an error message which will be presented to the user at a later |
| time.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> void</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../com/google/inject/Binder.html#addError(java.lang.Throwable)">addError</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Throwable.html" title="class or interface in java.lang">Throwable</A> t)</CODE> |
| |
| <BR> |
| Records an exception, the full details of which will be logged, and the |
| message of which will be presented to the user at a later |
| time.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> |
| <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> |
| <TR ALIGN="right" VALIGN=""> |
| <TD NOWRAP><FONT SIZE="-1"> |
| <CODE><T> <A HREF="../../../com/google/inject/binder/AnnotatedBindingBuilder.html" title="interface in com.google.inject.binder">AnnotatedBindingBuilder</A><T></CODE></FONT></TD> |
| </TR> |
| </TABLE> |
| </CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../com/google/inject/Binder.html#bind(java.lang.Class)">bind</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A><T> type)</CODE> |
| |
| <BR> |
| See the EDSL examples at <A HREF="../../../com/google/inject/Binder.html" title="interface in com.google.inject"><CODE>Binder</CODE></A>.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> |
| <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> |
| <TR ALIGN="right" VALIGN=""> |
| <TD NOWRAP><FONT SIZE="-1"> |
| <CODE><T> <A HREF="../../../com/google/inject/binder/LinkedBindingBuilder.html" title="interface in com.google.inject.binder">LinkedBindingBuilder</A><T></CODE></FONT></TD> |
| </TR> |
| </TABLE> |
| </CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../com/google/inject/Binder.html#bind(com.google.inject.Key)">bind</A></B>(<A HREF="../../../com/google/inject/Key.html" title="class in com.google.inject">Key</A><T> key)</CODE> |
| |
| <BR> |
| See the EDSL examples at <A HREF="../../../com/google/inject/Binder.html" title="interface in com.google.inject"><CODE>Binder</CODE></A>.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> |
| <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> |
| <TR ALIGN="right" VALIGN=""> |
| <TD NOWRAP><FONT SIZE="-1"> |
| <CODE><T> <A HREF="../../../com/google/inject/binder/AnnotatedBindingBuilder.html" title="interface in com.google.inject.binder">AnnotatedBindingBuilder</A><T></CODE></FONT></TD> |
| </TR> |
| </TABLE> |
| </CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../com/google/inject/Binder.html#bind(com.google.inject.TypeLiteral)">bind</A></B>(<A HREF="../../../com/google/inject/TypeLiteral.html" title="class in com.google.inject">TypeLiteral</A><T> typeLiteral)</CODE> |
| |
| <BR> |
| See the EDSL examples at <A HREF="../../../com/google/inject/Binder.html" title="interface in com.google.inject"><CODE>Binder</CODE></A>.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> <A HREF="../../../com/google/inject/binder/AnnotatedConstantBindingBuilder.html" title="interface in com.google.inject.binder">AnnotatedConstantBindingBuilder</A></CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../com/google/inject/Binder.html#bindConstant()">bindConstant</A></B>()</CODE> |
| |
| <BR> |
| See the EDSL examples at <A HREF="../../../com/google/inject/Binder.html" title="interface in com.google.inject"><CODE>Binder</CODE></A>.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> void</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../com/google/inject/Binder.html#bindInterceptor(com.google.inject.matcher.Matcher, com.google.inject.matcher.Matcher, org.aopalliance.intercept.MethodInterceptor...)">bindInterceptor</A></B>(<A HREF="../../../com/google/inject/matcher/Matcher.html" title="interface in com.google.inject.matcher">Matcher</A><? super <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A><?>> classMatcher, |
| <A HREF="../../../com/google/inject/matcher/Matcher.html" title="interface in com.google.inject.matcher">Matcher</A><? super <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/reflect/Method.html" title="class or interface in java.lang.reflect">Method</A>> methodMatcher, |
| <A HREF="http://aopalliance.sourceforge.net/doc/org/aopalliance/intercept/MethodInterceptor.html" title="class or interface in org.aopalliance.intercept">MethodInterceptor</A>... interceptors)</CODE> |
| |
| <BR> |
| Binds a method interceptor to methods matched by class and method |
| matchers.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> void</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../com/google/inject/Binder.html#bindScope(java.lang.Class, com.google.inject.Scope)">bindScope</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/annotation/Annotation.html" title="class or interface in java.lang.annotation">Annotation</A>> annotationType, |
| <A HREF="../../../com/google/inject/Scope.html" title="interface in com.google.inject">Scope</A> scope)</CODE> |
| |
| <BR> |
| Binds a scope to an annotation.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> <A HREF="../../../com/google/inject/Stage.html" title="enum in com.google.inject">Stage</A></CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../com/google/inject/Binder.html#currentStage()">currentStage</A></B>()</CODE> |
| |
| <BR> |
| Gets the current stage.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> |
| <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> |
| <TR ALIGN="right" VALIGN=""> |
| <TD NOWRAP><FONT SIZE="-1"> |
| <CODE><T> <A HREF="../../../com/google/inject/Provider.html" title="interface in com.google.inject">Provider</A><T></CODE></FONT></TD> |
| </TR> |
| </TABLE> |
| </CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../com/google/inject/Binder.html#getProvider(java.lang.Class)">getProvider</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A><T> type)</CODE> |
| |
| <BR> |
| Returns the provider used to obtain instances for the given injection type.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> |
| <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> |
| <TR ALIGN="right" VALIGN=""> |
| <TD NOWRAP><FONT SIZE="-1"> |
| <CODE><T> <A HREF="../../../com/google/inject/Provider.html" title="interface in com.google.inject">Provider</A><T></CODE></FONT></TD> |
| </TR> |
| </TABLE> |
| </CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../com/google/inject/Binder.html#getProvider(com.google.inject.Key)">getProvider</A></B>(<A HREF="../../../com/google/inject/Key.html" title="class in com.google.inject">Key</A><T> key)</CODE> |
| |
| <BR> |
| Returns the provider used to obtain instances for the given injection key.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> void</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../com/google/inject/Binder.html#install(com.google.inject.Module)">install</A></B>(<A HREF="../../../com/google/inject/Module.html" title="interface in com.google.inject">Module</A> module)</CODE> |
| |
| <BR> |
| Uses the given module to configure more bindings.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> void</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../com/google/inject/Binder.html#requestStaticInjection(java.lang.Class...)">requestStaticInjection</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A><?>... types)</CODE> |
| |
| <BR> |
| Upon successful creation, the <A HREF="../../../com/google/inject/Injector.html" title="interface in com.google.inject"><CODE>Injector</CODE></A> will inject static fields |
| and methods in the given classes.</TD> |
| </TR> |
| </TABLE> |
| |
| <P> |
| |
| <!-- ============ METHOD DETAIL ========== --> |
| |
| <A NAME="method_detail"><!-- --></A> |
| <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> |
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> |
| <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> |
| <B>Method Detail</B></FONT></TH> |
| </TR> |
| </TABLE> |
| |
| <A NAME="bindInterceptor(com.google.inject.matcher.Matcher, com.google.inject.matcher.Matcher, org.aopalliance.intercept.MethodInterceptor...)"><!-- --></A><H3> |
| bindInterceptor</H3> |
| <PRE> |
| void <B>bindInterceptor</B>(<A HREF="../../../com/google/inject/matcher/Matcher.html" title="interface in com.google.inject.matcher">Matcher</A><? super <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A><?>> classMatcher, |
| <A HREF="../../../com/google/inject/matcher/Matcher.html" title="interface in com.google.inject.matcher">Matcher</A><? super <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/reflect/Method.html" title="class or interface in java.lang.reflect">Method</A>> methodMatcher, |
| <A HREF="http://aopalliance.sourceforge.net/doc/org/aopalliance/intercept/MethodInterceptor.html" title="class or interface in org.aopalliance.intercept">MethodInterceptor</A>... interceptors)</PRE> |
| <DL> |
| <DD>Binds a method interceptor to methods matched by class and method |
| matchers. |
| <P> |
| <DD><DL> |
| <DT><B>Parameters:</B><DD><CODE>classMatcher</CODE> - matches classes the interceptor should apply to. For |
| example: <code>only(Runnable.class)</code>.<DD><CODE>methodMatcher</CODE> - matches methods the interceptor should apply to. For |
| example: <code>annotatedWith(Transactional.class)</code>.<DD><CODE>interceptors</CODE> - to bind</DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="bindScope(java.lang.Class, com.google.inject.Scope)"><!-- --></A><H3> |
| bindScope</H3> |
| <PRE> |
| void <B>bindScope</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/annotation/Annotation.html" title="class or interface in java.lang.annotation">Annotation</A>> annotationType, |
| <A HREF="../../../com/google/inject/Scope.html" title="interface in com.google.inject">Scope</A> scope)</PRE> |
| <DL> |
| <DD>Binds a scope to an annotation. |
| <P> |
| <DD><DL> |
| </DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="bind(com.google.inject.Key)"><!-- --></A><H3> |
| bind</H3> |
| <PRE> |
| <T> <A HREF="../../../com/google/inject/binder/LinkedBindingBuilder.html" title="interface in com.google.inject.binder">LinkedBindingBuilder</A><T> <B>bind</B>(<A HREF="../../../com/google/inject/Key.html" title="class in com.google.inject">Key</A><T> key)</PRE> |
| <DL> |
| <DD>See the EDSL examples at <A HREF="../../../com/google/inject/Binder.html" title="interface in com.google.inject"><CODE>Binder</CODE></A>. |
| <P> |
| <DD><DL> |
| </DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="bind(com.google.inject.TypeLiteral)"><!-- --></A><H3> |
| bind</H3> |
| <PRE> |
| <T> <A HREF="../../../com/google/inject/binder/AnnotatedBindingBuilder.html" title="interface in com.google.inject.binder">AnnotatedBindingBuilder</A><T> <B>bind</B>(<A HREF="../../../com/google/inject/TypeLiteral.html" title="class in com.google.inject">TypeLiteral</A><T> typeLiteral)</PRE> |
| <DL> |
| <DD>See the EDSL examples at <A HREF="../../../com/google/inject/Binder.html" title="interface in com.google.inject"><CODE>Binder</CODE></A>. |
| <P> |
| <DD><DL> |
| </DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="bind(java.lang.Class)"><!-- --></A><H3> |
| bind</H3> |
| <PRE> |
| <T> <A HREF="../../../com/google/inject/binder/AnnotatedBindingBuilder.html" title="interface in com.google.inject.binder">AnnotatedBindingBuilder</A><T> <B>bind</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A><T> type)</PRE> |
| <DL> |
| <DD>See the EDSL examples at <A HREF="../../../com/google/inject/Binder.html" title="interface in com.google.inject"><CODE>Binder</CODE></A>. |
| <P> |
| <DD><DL> |
| </DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="bindConstant()"><!-- --></A><H3> |
| bindConstant</H3> |
| <PRE> |
| <A HREF="../../../com/google/inject/binder/AnnotatedConstantBindingBuilder.html" title="interface in com.google.inject.binder">AnnotatedConstantBindingBuilder</A> <B>bindConstant</B>()</PRE> |
| <DL> |
| <DD>See the EDSL examples at <A HREF="../../../com/google/inject/Binder.html" title="interface in com.google.inject"><CODE>Binder</CODE></A>. |
| <P> |
| <DD><DL> |
| </DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="requestStaticInjection(java.lang.Class...)"><!-- --></A><H3> |
| requestStaticInjection</H3> |
| <PRE> |
| void <B>requestStaticInjection</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A><?>... types)</PRE> |
| <DL> |
| <DD>Upon successful creation, the <A HREF="../../../com/google/inject/Injector.html" title="interface in com.google.inject"><CODE>Injector</CODE></A> will inject static fields |
| and methods in the given classes. |
| <P> |
| <DD><DL> |
| <DT><B>Parameters:</B><DD><CODE>types</CODE> - for which static members will be injected</DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="install(com.google.inject.Module)"><!-- --></A><H3> |
| install</H3> |
| <PRE> |
| void <B>install</B>(<A HREF="../../../com/google/inject/Module.html" title="interface in com.google.inject">Module</A> module)</PRE> |
| <DL> |
| <DD>Uses the given module to configure more bindings. |
| <P> |
| <DD><DL> |
| </DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="currentStage()"><!-- --></A><H3> |
| currentStage</H3> |
| <PRE> |
| <A HREF="../../../com/google/inject/Stage.html" title="enum in com.google.inject">Stage</A> <B>currentStage</B>()</PRE> |
| <DL> |
| <DD>Gets the current stage. |
| <P> |
| <DD><DL> |
| </DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="addError(java.lang.String, java.lang.Object...)"><!-- --></A><H3> |
| addError</H3> |
| <PRE> |
| void <B>addError</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> message, |
| <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A>... arguments)</PRE> |
| <DL> |
| <DD>Records an error message which will be presented to the user at a later |
| time. Unlike throwing an exception, this enable us to continue |
| configuring the Injector and discover more errors. Uses <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html#format(java.lang.String, java.lang.Object...)" title="class or interface in java.lang"><CODE>String.format(String, Object[])</CODE></A> to insert the arguments into the |
| message. |
| <P> |
| <DD><DL> |
| </DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="addError(java.lang.Throwable)"><!-- --></A><H3> |
| addError</H3> |
| <PRE> |
| void <B>addError</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Throwable.html" title="class or interface in java.lang">Throwable</A> t)</PRE> |
| <DL> |
| <DD>Records an exception, the full details of which will be logged, and the |
| message of which will be presented to the user at a later |
| time. If your Module calls something that you worry may fail, you should |
| catch the exception and pass it into this. |
| <P> |
| <DD><DL> |
| </DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="getProvider(com.google.inject.Key)"><!-- --></A><H3> |
| getProvider</H3> |
| <PRE> |
| <T> <A HREF="../../../com/google/inject/Provider.html" title="interface in com.google.inject">Provider</A><T> <B>getProvider</B>(<A HREF="../../../com/google/inject/Key.html" title="class in com.google.inject">Key</A><T> key)</PRE> |
| <DL> |
| <DD>Returns the provider used to obtain instances for the given injection key. |
| The returned will not be valid until the <A HREF="../../../com/google/inject/Injector.html" title="interface in com.google.inject"><CODE>Injector</CODE></A> has been |
| created. The provider will throw an <code>IllegalStateException</code> if you |
| try to use it beforehand. |
| <P> |
| <DD><DL> |
| </DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="getProvider(java.lang.Class)"><!-- --></A><H3> |
| getProvider</H3> |
| <PRE> |
| <T> <A HREF="../../../com/google/inject/Provider.html" title="interface in com.google.inject">Provider</A><T> <B>getProvider</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A><T> type)</PRE> |
| <DL> |
| <DD>Returns the provider used to obtain instances for the given injection type. |
| The returned will not be valid until the <A HREF="../../../com/google/inject/Injector.html" title="interface in com.google.inject"><CODE>Injector</CODE></A> has been |
| created. The provider will throw an <code>IllegalStateException</code> if you |
| try to use it beforehand. |
| <P> |
| <DD><DL> |
| </DL> |
| </DD> |
| </DL> |
| <!-- ========= END OF CLASS DATA ========= --> |
| <HR> |
| |
| |
| <!-- ======= START OF BOTTOM NAVBAR ====== --> |
| <A NAME="navbar_bottom"><!-- --></A> |
| <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> |
| <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> |
| <TR> |
| <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> |
| <A NAME="navbar_bottom_firstrow"><!-- --></A> |
| <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> |
| <TR ALIGN="center" VALIGN="top"> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> |
| <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> |
| </TR> |
| </TABLE> |
| </TD> |
| <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> |
| </EM> |
| </TD> |
| </TR> |
| |
| <TR> |
| <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
| <A HREF="../../../com/google/inject/AbstractModule.html" title="class in com.google.inject"><B>PREV CLASS</B></A> |
| <A HREF="../../../com/google/inject/Binding.html" title="interface in com.google.inject"><B>NEXT CLASS</B></A></FONT></TD> |
| <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
| <A HREF="../../../index.html?com/google/inject/Binder.html" target="_top"><B>FRAMES</B></A> |
| <A HREF="Binder.html" target="_top"><B>NO FRAMES</B></A> |
| <SCRIPT type="text/javascript"> |
| <!-- |
| if(window==top) { |
| document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); |
| } |
| //--> |
| </SCRIPT> |
| <NOSCRIPT> |
| <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A> |
| </NOSCRIPT> |
| |
| |
| </FONT></TD> |
| </TR> |
| <TR> |
| <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
| SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> |
| <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
| DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> |
| </TR> |
| </TABLE> |
| <A NAME="skip-navbar_bottom"></A> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| |
| <HR> |
| |
| </BODY> |
| </HTML> |