/usr/share/doc/libatinject-jsr330-api-java/api/javax/inject/Inject.html is in libatinject-jsr330-api-java-doc 1.0+ds1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html>
<head>
<title>Inject (JSR 330: Dependency Injection for Java)</title>
<meta name="date" content="2017-11-17">
<link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Inject (JSR 330: Dependency Injection for Java)";
}
}
catch(err) {
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../index-all.html">Index</a></li>
<li><a href="../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev Class</li>
<li><a href="../../javax/inject/Named.html" title="annotation in javax.inject"><span class="typeNameLink">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../index.html?javax/inject/Inject.html" target="_top">Frames</a></li>
<li><a href="Inject.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Field | </li>
<li>Required | </li>
<li>Optional</li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Element</li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">javax.inject</div>
<h2 title="Annotation Type Inject" class="title">Annotation Type Inject</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>@Target(value={METHOD,CONSTRUCTOR,FIELD})
@Retention(value=RUNTIME)
@Documented
public @interface <span class="memberNameLabel">Inject</span></pre>
<div class="block">Identifies injectable constructors, methods, and fields. May apply to static
as well as instance members. An injectable member may have any access
modifier (private, package-private, protected, public). Constructors are
injected first, followed by fields, and then methods. Fields and methods
in superclasses are injected before those in subclasses. Ordering of
injection among fields and among methods in the same class is not specified.
<p>Injectable constructors are annotated with <code>@Inject</code> and accept
zero or more dependencies as arguments. <code>@Inject</code> can apply to at most
one constructor per class.
<p><tt><blockquote style="padding-left: 2em; text-indent: -2em;">@Inject
<i>ConstructorModifiers<sub>opt</sub></i>
<i>SimpleTypeName</i>(<i>FormalParameterList<sub>opt</sub></i>)
<i>Throws<sub>opt</sub></i>
<i>ConstructorBody</i></blockquote></tt>
<p><code>@Inject</code> is optional for public, no-argument constructors when no
other constructors are present. This enables injectors to invoke default
constructors.
<p><tt><blockquote style="padding-left: 2em; text-indent: -2em;">
@Inject<sub><i>opt</i></sub>
<i>Annotations<sub>opt</sub></i>
public
<i>SimpleTypeName</i>()
<i>Throws<sub>opt</sub></i>
<i>ConstructorBody</i></blockquote></tt>
<p>Injectable fields:
<ul>
<li>are annotated with <code>@Inject</code>.
<li>are not final.
<li>may have any otherwise valid name.</li></ul>
<p><tt><blockquote style="padding-left: 2em; text-indent: -2em;">@Inject
<i>FieldModifiers<sub>opt</sub></i>
<i>Type</i>
<i>VariableDeclarators</i>;</blockquote></tt>
<p>Injectable methods:
<ul>
<li>are annotated with <code>@Inject</code>.</li>
<li>are not abstract.</li>
<li>do not declare type parameters of their own.</li>
<li>may return a result</li>
<li>may have any otherwise valid name.</li>
<li>accept zero or more dependencies as arguments.</li></ul>
<p><tt><blockquote style="padding-left: 2em; text-indent: -2em;">@Inject
<i>MethodModifiers<sub>opt</sub></i>
<i>ResultType</i>
<i>Identifier</i>(<i>FormalParameterList<sub>opt</sub></i>)
<i>Throws<sub>opt</sub></i>
<i>MethodBody</i></blockquote></tt>
<p>The injector ignores the result of an injected method, but
non-<code>void</code> return types are allowed to support use of the method in
other contexts (builder-style method chaining, for example).
<p>Examples:
<pre>
public class Car {
// Injectable constructor
@Inject public Car(Engine engine) { ... }
// Injectable field
@Inject private Provider<Seat> seatProvider;
// Injectable package-private method
@Inject void install(Windshield windshield, Trunk trunk) { ... }
}</pre>
<p>A method annotated with <code>@Inject</code> that overrides another method
annotated with <code>@Inject</code> will only be injected once per injection
request per instance. A method with <i>no</i> <code>@Inject</code> annotation
that overrides a method annotated with <code>@Inject</code> will not be
injected.
<p>Injection of members annotated with <code>@Inject</code> is required. While an
injectable member may use any accessibility modifier (including
<tt>private</tt>), platform or injector limitations (like security
restrictions or lack of reflection support) might preclude injection
of non-public members.
<h3>Qualifiers</h3>
<p>A <a href="../../javax/inject/Qualifier.html" title="annotation in javax.inject">qualifier</a> may annotate an injectable field
or parameter and, combined with the type, identify the implementation to
inject. Qualifiers are optional, and when used with <code>@Inject</code> in
injector-independent classes, no more than one qualifier should annotate a
single field or parameter. The qualifiers are bold in the following example:
<pre>
public class Car {
@Inject private <b>@Leather</b> Provider<Seat> seatProvider;
@Inject void install(<b>@Tinted</b> Windshield windshield,
<b>@Big</b> Trunk trunk) { ... }
}</pre>
<p>If one injectable method overrides another, the overriding method's
parameters do not automatically inherit qualifiers from the overridden
method's parameters.
<h3>Injectable Values</h3>
<p>For a given type T and optional qualifier, an injector must be able to
inject a user-specified class that:
<ol type="a">
<li>is assignment compatible with T and</li>
<li>has an injectable constructor.</li>
</ol>
<p>For example, the user might use external configuration to pick an
implementation of T. Beyond that, which values are injected depend upon the
injector implementation and its configuration.
<h3>Circular Dependencies</h3>
<p>Detecting and resolving circular dependencies is left as an exercise for
the injector implementation. Circular dependencies between two constructors
is an obvious problem, but you can also have a circular dependency between
injectable fields or methods:
<pre>
class A {
@Inject B b;
}
class B {
@Inject A a;
}</pre>
<p>When constructing an instance of <code>A</code>, a naive injector
implementation might go into an infinite loop constructing an instance of
<code>B</code> to set on <code>A</code>, a second instance of <code>A</code> to set on
<code>B</code>, a second instance of <code>B</code> to set on the second instance of
<code>A</code>, and so on.
<p>A conservative injector might detect the circular dependency at build
time and generate an error, at which point the programmer could break the
circular dependency by injecting <a href="../../javax/inject/Provider.html" title="interface in javax.inject"><code>Provider<A></code></a> or <code>Provider<B></code> instead of <code>A</code> or <code>B</code> respectively. Calling <a href="../../javax/inject/Provider.html#get--"><code>get()</code></a> on the provider directly from the constructor or
method it was injected into defeats the provider's ability to break up
circular dependencies. In the case of method or field injection, scoping
one of the dependencies (using <a href="../../javax/inject/Singleton.html" title="annotation in javax.inject">singleton scope</a>, for
example) may also enable a valid circular relationship.</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../javax/inject/Qualifier.html" title="annotation in javax.inject"><code>@Qualifier</code></a>,
<a href="../../javax/inject/Provider.html" title="interface in javax.inject"><code>Provider</code></a></dd>
</dl>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../index-all.html">Index</a></li>
<li><a href="../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev Class</li>
<li><a href="../../javax/inject/Named.html" title="annotation in javax.inject"><span class="typeNameLink">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../index.html?javax/inject/Inject.html" target="_top">Frames</a></li>
<li><a href="Inject.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Field | </li>
<li>Required | </li>
<li>Optional</li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Element</li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>
|