-- cgit v1.2.3 From 89db028e66ac03773d75c440fdaac667e2f63b83 Mon Sep 17 00:00:00 2001 From: Bob Lee Date: Sat, 4 Apr 2009 21:29:59 +0000 Subject: Initial checkin. git-svn-id: https://atinject.googlecode.com/svn/trunk@2 3bc8319c-20ab-11de-9edc-3f40a397ab60 --- atinject.iml | 12 ++ atinject.ipr | 243 ++++++++++++++++++++++ javadoc/allclasses-frame.html | 40 ++++ javadoc/allclasses-noframe.html | 40 ++++ javadoc/constant-values.html | 138 +++++++++++++ javadoc/deprecated-list.html | 138 +++++++++++++ javadoc/help-doc.html | 205 ++++++++++++++++++ javadoc/index-files/index-1.html | 137 ++++++++++++ javadoc/index-files/index-2.html | 134 ++++++++++++ javadoc/index-files/index-3.html | 134 ++++++++++++ javadoc/index-files/index-4.html | 134 ++++++++++++ javadoc/index-files/index-5.html | 134 ++++++++++++ javadoc/index-files/index-6.html | 134 ++++++++++++ javadoc/index-files/index-7.html | 134 ++++++++++++ javadoc/index.html | 36 ++++ javadoc/org/atinject/Inject.html | 332 ++++++++++++++++++++++++++++++ javadoc/org/atinject/Named.html | 209 +++++++++++++++++++ javadoc/org/atinject/Provider.html | 226 ++++++++++++++++++++ javadoc/org/atinject/Qualifier.html | 210 +++++++++++++++++++ javadoc/org/atinject/Scope.html | 215 +++++++++++++++++++ javadoc/org/atinject/Singleton.html | 169 +++++++++++++++ javadoc/org/atinject/package-frame.html | 51 +++++ javadoc/org/atinject/package-summary.html | 206 ++++++++++++++++++ javadoc/org/atinject/package-tree.html | 150 ++++++++++++++ javadoc/overview-tree.html | 152 ++++++++++++++ javadoc/package-list | 1 + javadoc/resources/inherit.gif | Bin 0 -> 57 bytes javadoc/stylesheet.css | 29 +++ src/org/atinject/Inject.java | 157 ++++++++++++++ src/org/atinject/Named.java | 17 ++ src/org/atinject/Provider.java | 36 ++++ src/org/atinject/Qualifier.java | 58 ++++++ src/org/atinject/Scope.java | 63 ++++++ src/org/atinject/Singleton.java | 15 ++ src/org/atinject/package-info.java | 17 ++ 35 files changed, 4106 insertions(+) create mode 100644 atinject.iml create mode 100644 atinject.ipr create mode 100644 javadoc/allclasses-frame.html create mode 100644 javadoc/allclasses-noframe.html create mode 100644 javadoc/constant-values.html create mode 100644 javadoc/deprecated-list.html create mode 100644 javadoc/help-doc.html create mode 100644 javadoc/index-files/index-1.html create mode 100644 javadoc/index-files/index-2.html create mode 100644 javadoc/index-files/index-3.html create mode 100644 javadoc/index-files/index-4.html create mode 100644 javadoc/index-files/index-5.html create mode 100644 javadoc/index-files/index-6.html create mode 100644 javadoc/index-files/index-7.html create mode 100644 javadoc/index.html create mode 100644 javadoc/org/atinject/Inject.html create mode 100644 javadoc/org/atinject/Named.html create mode 100644 javadoc/org/atinject/Provider.html create mode 100644 javadoc/org/atinject/Qualifier.html create mode 100644 javadoc/org/atinject/Scope.html create mode 100644 javadoc/org/atinject/Singleton.html create mode 100644 javadoc/org/atinject/package-frame.html create mode 100644 javadoc/org/atinject/package-summary.html create mode 100644 javadoc/org/atinject/package-tree.html create mode 100644 javadoc/overview-tree.html create mode 100644 javadoc/package-list create mode 100644 javadoc/resources/inherit.gif create mode 100644 javadoc/stylesheet.css create mode 100644 src/org/atinject/Inject.java create mode 100644 src/org/atinject/Named.java create mode 100644 src/org/atinject/Provider.java create mode 100644 src/org/atinject/Qualifier.java create mode 100644 src/org/atinject/Scope.java create mode 100644 src/org/atinject/Singleton.java create mode 100644 src/org/atinject/package-info.java diff --git a/atinject.iml b/atinject.iml new file mode 100644 index 0000000..c053808 --- /dev/null +++ b/atinject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/atinject.ipr b/atinject.ipr new file mode 100644 index 0000000..133b6ff --- /dev/null +++ b/atinject.ipr @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/javadoc/allclasses-frame.html b/javadoc/allclasses-frame.html new file mode 100644 index 0000000..525618b --- /dev/null +++ b/javadoc/allclasses-frame.html @@ -0,0 +1,40 @@ + + + + + + +All Classes + + + + + + + + + + +All Classes +
+ + + + + +
Inject +
+Named +
+Provider +
+Qualifier +
+Scope +
+Singleton +
+
+ + + diff --git a/javadoc/allclasses-noframe.html b/javadoc/allclasses-noframe.html new file mode 100644 index 0000000..d5e2351 --- /dev/null +++ b/javadoc/allclasses-noframe.html @@ -0,0 +1,40 @@ + + + + + + +All Classes + + + + + + + + + + +All Classes +
+ + + + + +
Inject +
+Named +
+Provider +
+Qualifier +
+Scope +
+Singleton +
+
+ + + diff --git a/javadoc/constant-values.html b/javadoc/constant-values.html new file mode 100644 index 0000000..68854e8 --- /dev/null +++ b/javadoc/constant-values.html @@ -0,0 +1,138 @@ + + + + + + +Constant Field Values + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Constant Field Values

+
+
+Contents + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/javadoc/deprecated-list.html b/javadoc/deprecated-list.html new file mode 100644 index 0000000..89b7711 --- /dev/null +++ b/javadoc/deprecated-list.html @@ -0,0 +1,138 @@ + + + + + + +Deprecated List + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Deprecated API

+
+
+Contents + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/javadoc/help-doc.html b/javadoc/help-doc.html new file mode 100644 index 0000000..e9c13ce --- /dev/null +++ b/javadoc/help-doc.html @@ -0,0 +1,205 @@ + + + + + + +API Help + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+How This API Document Is Organized

+
+This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

+Package

+
+ +

+Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

+
+

+Class/Interface

+
+ +

+Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+ +

+Annotation Type

+
+ +

+Each annotation type has its own separate page with the following sections:

+
+ +

+Enum

+
+ +

+Each enum has its own separate page with the following sections:

+
+

+Tree (Class Hierarchy)

+
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object. +
+

+Deprecated API

+
+The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+

+Index

+
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+

+Prev/Next

+These links take you to the next or previous class, interface, package, or related page.

+Frames/No Frames

+These links show and hide the HTML frames. All pages are available with or without frames. +

+

+Serialized Form

+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. +

+

+Constant Field Values

+The Constant Field Values page lists the static final fields and their values. +

+ + +This help file applies to API documentation generated using the standard doclet. + +
+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/javadoc/index-files/index-1.html b/javadoc/index-files/index-1.html new file mode 100644 index 0000000..e7eeffc --- /dev/null +++ b/javadoc/index-files/index-1.html @@ -0,0 +1,137 @@ + + + + + + +G-Index + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +G I N O P Q S
+

+G

+
+
get() - +Method in interface org.atinject.Provider +
Provides an instance of T. +
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +G I N O P Q S
+ + + diff --git a/javadoc/index-files/index-2.html b/javadoc/index-files/index-2.html new file mode 100644 index 0000000..2f15616 --- /dev/null +++ b/javadoc/index-files/index-2.html @@ -0,0 +1,134 @@ + + + + + + +I-Index + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +G I N O P Q S
+

+I

+
+
Inject - Annotation Type in org.atinject
Identifies injectable constructors, methods, and fields.
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +G I N O P Q S
+ + + diff --git a/javadoc/index-files/index-3.html b/javadoc/index-files/index-3.html new file mode 100644 index 0000000..016f5dc --- /dev/null +++ b/javadoc/index-files/index-3.html @@ -0,0 +1,134 @@ + + + + + + +N-Index + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +G I N O P Q S
+

+N

+
+
Named - Annotation Type in org.atinject
String-based qualifier.
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +G I N O P Q S
+ + + diff --git a/javadoc/index-files/index-4.html b/javadoc/index-files/index-4.html new file mode 100644 index 0000000..3459703 --- /dev/null +++ b/javadoc/index-files/index-4.html @@ -0,0 +1,134 @@ + + + + + + +O-Index + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +G I N O P Q S
+

+O

+
+
org.atinject - package org.atinject
Provides annotations for dependency injection.
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +G I N O P Q S
+ + + diff --git a/javadoc/index-files/index-5.html b/javadoc/index-files/index-5.html new file mode 100644 index 0000000..a7254a7 --- /dev/null +++ b/javadoc/index-files/index-5.html @@ -0,0 +1,134 @@ + + + + + + +P-Index + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +G I N O P Q S
+

+P

+
+
Provider<T> - Interface in org.atinject
Provides instances of T.
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +G I N O P Q S
+ + + diff --git a/javadoc/index-files/index-6.html b/javadoc/index-files/index-6.html new file mode 100644 index 0000000..20ab32f --- /dev/null +++ b/javadoc/index-files/index-6.html @@ -0,0 +1,134 @@ + + + + + + +Q-Index + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +G I N O P Q S
+

+Q

+
+
Qualifier - Annotation Type in org.atinject
Identifies qualifier annotations.
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +G I N O P Q S
+ + + diff --git a/javadoc/index-files/index-7.html b/javadoc/index-files/index-7.html new file mode 100644 index 0000000..f355ced --- /dev/null +++ b/javadoc/index-files/index-7.html @@ -0,0 +1,134 @@ + + + + + + +S-Index + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +G I N O P Q S
+

+S

+
+
Scope - Annotation Type in org.atinject
Identifies scope annotations.
Singleton - Annotation Type in org.atinject
Identifies a type that the injector only instantiates once.
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +G I N O P Q S
+ + + diff --git a/javadoc/index.html b/javadoc/index.html new file mode 100644 index 0000000..ddbba08 --- /dev/null +++ b/javadoc/index.html @@ -0,0 +1,36 @@ + + + + + + +Generated Documentation (Untitled) + + + + + + + + +<H2> +Frame Alert</H2> + +<P> +This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. +<BR> +Link to<A HREF="org/atinject/package-summary.html">Non-frame version.</A> + + + diff --git a/javadoc/org/atinject/Inject.html b/javadoc/org/atinject/Inject.html new file mode 100644 index 0000000..b356f03 --- /dev/null +++ b/javadoc/org/atinject/Inject.html @@ -0,0 +1,332 @@ + + + + + + +Inject + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +org.atinject +
+Annotation Type Inject

+
+
+
@Target(value={METHOD,CONSTRUCTOR,FIELD})
+@Retention(value=RUNTIME)
+@Documented
+public @interface Inject
+ + +

+Identifies injectable constructors, methods, and fields. Applies 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. + Which values are injected depends upon the injector implementation and its + configuration. + +

Injectable constructors are annotated with @Inject and accept + zero or more dependencies as arguments. @Inject can apply to at most + one constructor per class. + +

@Inject + ConstructorModifiersopt + SimpleTypeName(FormalParameterListopt) + Throwsopt + ConstructorBody
+ +

@Inject is optional for public, no-argument constructors when no + other constructors are present. This enables injectors to invoke default + constructors. + +

+ @Injectopt + Annotationsopt + public + SimpleTypeName() + Throwsopt + ConstructorBody
+ +

Injectable fields: +

+ +

@Inject + FieldModifiersopt + Type + VariableDeclarators;
+ +

Injectable methods: +

+ +

@Inject + MethodModifiersopt + void + Identifier(FormalParameterListopt) + Throwsopt + MethodBody
+ +

For example: + +

+   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) { ... }
+   }
+ +

A method annotated with @Inject that overrides another method + annotated with @Inject will only be injected once per injection + request per instance. A method with no @Inject annotation + that overrides a method annotated with @Inject will not be + injected. + +

Injection of members annotated with @Inject is required by + default. This behavior can be overridden by setting optional equal to true. + +

Detecting and resolving circular dependencies is left as an exercize 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: + +

+   class A {
+     @Inject B b;
+   }
+   class B {
+     @Inject A a;
+   }
+ +

When constructing an instance of A, a naive injector + implementation might go into an infinite loop constructing an instance of + B to set on A, a second instance of A to set on + B, a second instance of B to set on the second instance of + A, and so on. + +

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 Provider<A> or Provider<B> instead of A or B respectively. Calling get() 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 singleton scope, for + example) may also enable a valid circular relationship. +

+ +

+

+
See Also:
@Qualifier, +Provider
+
+ +

+ + + + + + + + + + + +
+Optional Element Summary
+ booleanoptional + +
+          Whether or not injection is optional.
+  +

+

+optional

+
+public abstract boolean optional
+
+
Whether or not injection is optional. If true, the injector's + behavior varies depending on the type of injection point: + +

    +
  • Constructors: Not allowed
  • +
  • Fields: If a dependency matching the field can't + be found, the injector will not set the field.
  • +
  • Methods: If a dependency matching a method parameter can't + be found, the injector will skip invoking the method entirely, even + if other arguments could be provided.
  • +
+ +

If an applicable dependency has been configured but the injector + encounters an error while resolving the dependency (a transitive + dependency could be missing, for example), the injector should generate + an error, not skip the injection. For example: + +

+   @Inject(optional=true) Gps gps;
+ +

If a Gps isn't available at all, the injector will simply not set the + gps field. If a Gps is available but an algorithm it depends + upon can't be found, the injector will generate an error. +

+

+
+
+
+
+
+
Default:
false
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/javadoc/org/atinject/Named.html b/javadoc/org/atinject/Named.html new file mode 100644 index 0000000..18fbee0 --- /dev/null +++ b/javadoc/org/atinject/Named.html @@ -0,0 +1,209 @@ + + + + + + +Named + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +org.atinject +
+Annotation Type Named

+
+
+
@Qualifier
+@Documented
+@Retention(value=RUNTIME)
+public @interface Named
+ + +

+String-based qualifier. +

+ +

+


+ +

+ + + + + + + + + + + +
+Required Element Summary
+ java.lang.Stringvalue + +
+          The name.
+  +

+ + + + + + + + +
+Element Detail
+ +

+value

+
+public abstract java.lang.String value
+
+
The name. +

+

+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/javadoc/org/atinject/Provider.html b/javadoc/org/atinject/Provider.html new file mode 100644 index 0000000..e766235 --- /dev/null +++ b/javadoc/org/atinject/Provider.html @@ -0,0 +1,226 @@ + + + + + + +Provider + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +org.atinject +
+Interface Provider<T>

+
+
+
public interface Provider<T>
+ + +

+Provides instances of T. For any type T that can be + injected, you can also inject Provider<T>. Compared to injecting + T directly, injecting Provider<T> enables: + +

+ +

For example: + +

+   class Car {
+     @Inject Car(Provider<Seat> seatProvider) {
+       Seat driver = seatProvider.get();
+       Seat passenger = seatProvider.get();
+       ...
+     }
+   }
+

+ +

+


+ +

+ + + + + + + + + + + + +
+Method Summary
+ Tget() + +
+          Provides an instance of T.
+  +

+ + + + + + + + +
+Method Detail
+ +

+get

+
+T get()
+
+
Provides an instance of T. +

+

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/javadoc/org/atinject/Qualifier.html b/javadoc/org/atinject/Qualifier.html new file mode 100644 index 0000000..2e7a7c8 --- /dev/null +++ b/javadoc/org/atinject/Qualifier.html @@ -0,0 +1,210 @@ + + + + + + +Qualifier + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +org.atinject +
+Annotation Type Qualifier

+
+
+
@Target(value=ANNOTATION_TYPE)
+@Retention(value=RUNTIME)
+@Documented
+public @interface Qualifier
+ + +

+Identifies qualifier annotations. A qualifier annotates an injectable field + or parameter and, combined with the type, identifies the implementation to + inject. Qualifiers are optional and no more than one should annotate a + single field or parameter. The qualifiers are bold in the following + example: + +

+   public class Car {
+     @Inject private @Leather Provider<Seat> seatProvider;
+
+     @Inject void install(@Tinted Windshield windshield,
+         @Big Trunk trunk) { ... }
+   }
+ +

If one injectable method overrides another, the overriding method's + parameters do not automatically inherit qualifiers from the overridden + method's parameters. + +

Anyone can define a new qualifier. A qualifier annotation: +

+ +

For example: + +

+   @org.atinject.Qualifier
+   @java.lang.annotation.Documented
+   @java.lang.annotation.Retention(RUNTIME)
+   public @interface Leather {
+     Color color() default Color.TAN;
+     public enum Color { RED, BLACK, TAN }
+   }
+

+ +

+

+
See Also:
@Named
+ +

+ +

+ +


+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/javadoc/org/atinject/Scope.html b/javadoc/org/atinject/Scope.html new file mode 100644 index 0000000..cc3dcb3 --- /dev/null +++ b/javadoc/org/atinject/Scope.html @@ -0,0 +1,215 @@ + + + + + + +Scope + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +org.atinject +
+Annotation Type Scope

+
+
+
@Target(value=ANNOTATION_TYPE)
+@Retention(value=RUNTIME)
+@Documented
+public @interface Scope
+ + +

+Identifies scope annotations. A scope annotation applies to a class + containing an injectable constructor and governs how the injector reuses + instances of the type. By default, if no scope annotation is present, the + injector creates an instance (by injecting the type's constructor), uses + the instance for one injection, and then forgets it. If a scope annotation + is present, the injector may retain the instance for possible reuse in a + later injection. If multiple threads can access a scoped instance, its + implementation should be thread safe. The implementation of the scope + itself is left up to the injector. + +

In the following example, the scope annotation @Singleton ensures + that we only have one Log instance: + +

+   @Singleton
+   class Log {
+     void log(String message) { ... }
+   }
+ +

The injector generates an error if it encounters more than one scope + annotation on the same class or a scope annotation it doesn't support. + +

A scope annotation: +

+ +

For example: + +

+   @Scope
+   @Documented
+   @Retention(RUNTIME)
+   public @interface RequestScoped {}
+ +

Annotating scope annotations with @Scope helps the injector + detect the case where a programmer used the scope annotation on a class but + forgot to configure the scope in the injector. A conservative injector + would generate an error rather than not apply a scope. +

+ +

+

+
See Also:
@Singleton
+ +

+ +

+ +


+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/javadoc/org/atinject/Singleton.html b/javadoc/org/atinject/Singleton.html new file mode 100644 index 0000000..3015304 --- /dev/null +++ b/javadoc/org/atinject/Singleton.html @@ -0,0 +1,169 @@ + + + + + + +Singleton + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +org.atinject +
+Annotation Type Singleton

+
+
+
@Scope
+@Documented
+@Retention(value=RUNTIME)
+public @interface Singleton
+ + +

+Identifies a type that the injector only instantiates once. Not inherited. +

+ +

+

+
See Also:
@Scope
+ +

+ +

+ +


+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/javadoc/org/atinject/package-frame.html b/javadoc/org/atinject/package-frame.html new file mode 100644 index 0000000..8f375bd --- /dev/null +++ b/javadoc/org/atinject/package-frame.html @@ -0,0 +1,51 @@ + + + + + + +org.atinject + + + + + + + + + + + +org.atinject + + + + +
+Interfaces  + +
+Provider
+ + + + + + +
+Annotation Types  + +
+Inject +
+Named +
+Qualifier +
+Scope +
+Singleton
+ + + + diff --git a/javadoc/org/atinject/package-summary.html b/javadoc/org/atinject/package-summary.html new file mode 100644 index 0000000..5d79f12 --- /dev/null +++ b/javadoc/org/atinject/package-summary.html @@ -0,0 +1,206 @@ + + + + + + +org.atinject + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package org.atinject +

+Provides annotations for dependency injection. +

+See: +
+          Description +

+ + + + + + + + + +
+Interface Summary
Provider<T>Provides instances of T.
+  + +

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+Annotation Types Summary
InjectIdentifies injectable constructors, methods, and fields.
NamedString-based qualifier.
QualifierIdentifies qualifier annotations.
ScopeIdentifies scope annotations.
SingletonIdentifies a type that the injector only instantiates once.
+  + +

+

+Package org.atinject Description +

+ +

+Provides annotations for dependency injection. Enables portable objects but + leaves external dependency configuration up to the injector + implementation. For the purposes of this specification, the injector is + anything that injects objects. Injector implementations can take many + forms. An injector could rely on code generation or reflection. An injector + could configure itself using XML, annotations, a DSL (domain-specific + language), or even plain Java code. A "container", for some definition, can + be an injector, but this specification aims to minimize restrictions on + injector implementations. For example, an injector that uses compile time + code generation may not even have its own run time representation. Other + injectors may not be able to generate code at all, neither at compile nor + run time. +

+ +

+

+
See Also:
@Inject
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/javadoc/org/atinject/package-tree.html b/javadoc/org/atinject/package-tree.html new file mode 100644 index 0000000..2d69936 --- /dev/null +++ b/javadoc/org/atinject/package-tree.html @@ -0,0 +1,150 @@ + + + + + + +org.atinject Class Hierarchy + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package org.atinject +

+
+

+Interface Hierarchy +

+ +

+Annotation Type Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/javadoc/overview-tree.html b/javadoc/overview-tree.html new file mode 100644 index 0000000..9e51b15 --- /dev/null +++ b/javadoc/overview-tree.html @@ -0,0 +1,152 @@ + + + + + + +Class Hierarchy + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For All Packages

+
+
+
Package Hierarchies:
org.atinject
+
+

+Interface Hierarchy +

+ +

+Annotation Type Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/javadoc/package-list b/javadoc/package-list new file mode 100644 index 0000000..87091fc --- /dev/null +++ b/javadoc/package-list @@ -0,0 +1 @@ +org.atinject diff --git a/javadoc/resources/inherit.gif b/javadoc/resources/inherit.gif new file mode 100644 index 0000000..c814867 Binary files /dev/null and b/javadoc/resources/inherit.gif differ diff --git a/javadoc/stylesheet.css b/javadoc/stylesheet.css new file mode 100644 index 0000000..6d31fdb --- /dev/null +++ b/javadoc/stylesheet.css @@ -0,0 +1,29 @@ +/* Javadoc style sheet */ + +/* Define colors, fonts and other style attributes here to override the defaults */ + +/* Page background color */ +body { background-color: #FFFFFF } + +/* Headings */ +h1 { font-size: 145% } + +/* Table colors */ +.TableHeadingColor { background: #CCCCFF } /* Dark mauve */ +.TableSubHeadingColor { background: #EEEEFF } /* Light mauve */ +.TableRowColor { background: #FFFFFF } /* White */ + +/* Font used in left-hand frame lists */ +.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif } +.FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif } +.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif } + +/* Navigation bar fonts and colors */ +.NavBarCell1 { background-color:#EEEEFF;} /* Light mauve */ +.NavBarCell1Rev { background-color:#00008B;} /* Dark Blue */ +.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} +.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} + +.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} +.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} + diff --git a/src/org/atinject/Inject.java b/src/org/atinject/Inject.java new file mode 100644 index 0000000..74f1193 --- /dev/null +++ b/src/org/atinject/Inject.java @@ -0,0 +1,157 @@ +package org.atinject; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.Documented; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.CONSTRUCTOR; +import static java.lang.annotation.ElementType.FIELD; + +/** + * Identifies injectable constructors, methods, and fields. Applies 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. + * Which values are injected depends upon the injector implementation and its + * configuration. + * + *

Injectable constructors are annotated with {@code @Inject} and accept + * zero or more dependencies as arguments. {@code @Inject} can apply to at most + * one constructor per class. + * + *

@Inject + * ConstructorModifiersopt + * SimpleTypeName(FormalParameterListopt) + * Throwsopt + * ConstructorBody
+ * + *

{@code @Inject} is optional for public, no-argument constructors when no + * other constructors are present. This enables injectors to invoke default + * constructors. + * + *

+ * {@literal @}Injectopt + * Annotationsopt + * public + * SimpleTypeName() + * Throwsopt + * ConstructorBody
+ * + *

Injectable fields: + *

+ * + *

@Inject + * FieldModifiersopt + * Type + * VariableDeclarators;
+ * + *

Injectable methods: + *

+ * + *

@Inject + * MethodModifiersopt + * void + * Identifier(FormalParameterListopt) + * Throwsopt + * MethodBody
+ * + *

For example: + * + *

+ *   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) { ... }
+ *   }
+ * + *

A method annotated with {@code @Inject} that overrides another method + * annotated with {@code @Inject} will only be injected once per injection + * request per instance. A method with no {@code @Inject} annotation + * that overrides a method annotated with {@code @Inject} will not be + * injected. + * + *

Injection of members annotated with {@code @Inject} is required by + * default. This behavior can be overridden by setting {@link #optional() + * optional} equal to {@code true}. + * + *

Detecting and resolving circular dependencies is left as an exercize 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: + * + *

+ *   class A {
+ *     @Inject B b;
+ *   }
+ *   class B {
+ *     @Inject A a;
+ *   }
+ * + *

When constructing an instance of {@code A}, a naive injector + * implementation might go into an infinite loop constructing an instance of + * {@code B} to set on {@code A}, a second instance of {@code A} to set on + * {@code B}, a second instance of {@code B} to set on the second instance of + * {@code A}, and so on. + * + *

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 {@link Provider Provider<A>} or {@code + * Provider} instead of {@code A} or {@code B} respectively. Calling {@link + * Provider#get() get()} 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 {@linkplain Singleton singleton scope}, for + * example) may also enable a valid circular relationship. + * + * @see org.atinject.Qualifier @Qualifier + * @see org.atinject.Provider + */ +@Target({ METHOD, CONSTRUCTOR, FIELD }) +@Retention(RUNTIME) +@Documented +public @interface Inject { + + /** + * Whether or not injection is optional. If {@code true}, the injector's + * behavior varies depending on the type of injection point: + * + *

+ * + *

If an applicable dependency has been configured but the injector + * encounters an error while resolving the dependency (a transitive + * dependency could be missing, for example), the injector should generate + * an error, not skip the injection. For example: + * + *

+     *   @Inject(optional=true) Gps gps;
+ * + *

If a Gps isn't available at all, the injector will simply not set the + * {@code gps} field. If a Gps is available but an algorithm it depends + * upon can't be found, the injector will generate an error. + */ + boolean optional() default false; +} diff --git a/src/org/atinject/Named.java b/src/org/atinject/Named.java new file mode 100644 index 0000000..4dc62d6 --- /dev/null +++ b/src/org/atinject/Named.java @@ -0,0 +1,17 @@ +package org.atinject; + +import java.lang.annotation.Retention; +import java.lang.annotation.Documented; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * String-based {@linkplain Qualifier qualifier}. + */ +@Qualifier +@Documented +@Retention(RUNTIME) +public @interface Named { + + /** The name. */ + String value(); +} diff --git a/src/org/atinject/Provider.java b/src/org/atinject/Provider.java new file mode 100644 index 0000000..4de598e --- /dev/null +++ b/src/org/atinject/Provider.java @@ -0,0 +1,36 @@ +package org.atinject; + +/** + * Provides instances of {@code T}. For any type {@code T} that can be + * injected, you can also inject {@code Provider}. Compared to injecting + * {@code T} directly, injecting {@code Provider} enables: + * + *

+ * + *

For example: + * + *

+ *   class Car {
+ *     @Inject Car(Provider<Seat> seatProvider) {
+ *       Seat driver = seatProvider.get();
+ *       Seat passenger = seatProvider.get();
+ *       ...
+ *     }
+ *   }
+ */ +public interface Provider { + + // TODO: Specify OutOfScopeException (or IllegalStateException) and + // ProvisionException? + + /** + * Provides an instance of {@code T}. + */ + T get(); +} diff --git a/src/org/atinject/Qualifier.java b/src/org/atinject/Qualifier.java new file mode 100644 index 0000000..235e3b4 --- /dev/null +++ b/src/org/atinject/Qualifier.java @@ -0,0 +1,58 @@ +package org.atinject; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.Documented; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; + +/** + * Identifies qualifier annotations. A qualifier annotates an injectable field + * or parameter and, combined with the type, identifies the implementation to + * inject. Qualifiers are optional and no more than one should annotate a + * single field or parameter. The qualifiers are bold in the following + * example: + * + *
+ *   public class Car {
+ *     @Inject private @Leather Provider<Seat> seatProvider;
+ *
+ *     @Inject void install(@Tinted Windshield windshield,
+ *         @Big Trunk trunk) { ... }
+ *   }
+ * + *

If one injectable method overrides another, the overriding method's + * parameters do not automatically inherit qualifiers from the overridden + * method's parameters. + * + *

Anyone can define a new qualifier. A qualifier annotation: + *

    + *
  • is annotated with {@code @Qualifier}, {@code @Retention(RUNTIME)}, + * and typically {@code @Documented}.
  • + *
  • can have attributes.
  • + *
  • is not annotated with {@code @Target}. While this + * specification only covers applying qualifiers to fields and parameters, + * some injector configurations might use qualifier annotations in other + * places (on methods or classes for example).
  • + *
  • may be part of the public API, much like the dependency type, but + * unlike implementation types which needn't be part of the public + * API.
  • + *
+ * + *

For example: + * + *

+ *   @org.atinject.Qualifier
+ *   @java.lang.annotation.Documented
+ *   @java.lang.annotation.Retention(RUNTIME)
+ *   public @interface Leather {
+ *     Color color() default Color.TAN;
+ *     public enum Color { RED, BLACK, TAN }
+ *   }
+ * + * @see org.atinject.Named @Named + */ +@Target(ANNOTATION_TYPE) +@Retention(RUNTIME) +@Documented +public @interface Qualifier {} diff --git a/src/org/atinject/Scope.java b/src/org/atinject/Scope.java new file mode 100644 index 0000000..c5f5b8f --- /dev/null +++ b/src/org/atinject/Scope.java @@ -0,0 +1,63 @@ +package org.atinject; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.Documented; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; + +/** + * Identifies scope annotations. A scope annotation applies to a class + * containing an injectable constructor and governs how the injector reuses + * instances of the type. By default, if no scope annotation is present, the + * injector creates an instance (by injecting the type's constructor), uses + * the instance for one injection, and then forgets it. If a scope annotation + * is present, the injector may retain the instance for possible reuse in a + * later injection. If multiple threads can access a scoped instance, its + * implementation should be thread safe. The implementation of the scope + * itself is left up to the injector. + * + *

In the following example, the scope annotation {@code @Singleton} ensures + * that we only have one Log instance: + * + *

+ *   @Singleton
+ *   class Log {
+ *     void log(String message) { ... }
+ *   }
+ * + *

The injector generates an error if it encounters more than one scope + * annotation on the same class or a scope annotation it doesn't support. + * + *

A scope annotation: + *

    + *
  • is annotated with {@code @Scope}, {@code @Retention(RUNTIME)}, + * and typically {@code @Documented}.
  • + *
  • should not have attributes.
  • + *
  • is typically not {@code @Inherited}, so scoping is orthogonal to + * implementation inheritance.
  • + *
  • is not annotated with {@code @Target}. While this + * specification only covers applying scopes to classes, some injector + * configurations might use scopes in other places (on factory + * method results for example).
  • + *
+ * + *

For example: + * + *

+ *   @Scope
+ *   @Documented
+ *   @Retention(RUNTIME)
+ *   public @interface RequestScoped {}
+ * + *

Annotating scope annotations with {@code @Scope} helps the injector + * detect the case where a programmer used the scope annotation on a class but + * forgot to configure the scope in the injector. A conservative injector + * would generate an error rather than not apply a scope. + * + * @see org.atinject.Singleton @Singleton + */ +@Target(ANNOTATION_TYPE) +@Retention(RUNTIME) +@Documented +public @interface Scope {} diff --git a/src/org/atinject/Singleton.java b/src/org/atinject/Singleton.java new file mode 100644 index 0000000..624a20c --- /dev/null +++ b/src/org/atinject/Singleton.java @@ -0,0 +1,15 @@ +package org.atinject; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * Identifies a type that the injector only instantiates once. Not inherited. + * + * @see org.atinject.Scope @Scope + */ +@Scope +@Documented +@Retention(RUNTIME) +public @interface Singleton {} diff --git a/src/org/atinject/package-info.java b/src/org/atinject/package-info.java new file mode 100644 index 0000000..a1b2b26 --- /dev/null +++ b/src/org/atinject/package-info.java @@ -0,0 +1,17 @@ +/** + * Provides annotations for dependency injection. Enables portable objects but + * leaves external dependency configuration up to the injector + * implementation. For the purposes of this specification, the injector is + * anything that injects objects. Injector implementations can take many + * forms. An injector could rely on code generation or reflection. An injector + * could configure itself using XML, annotations, a DSL (domain-specific + * language), or even plain Java code. A "container", for some definition, can + * be an injector, but this specification aims to minimize restrictions on + * injector implementations. For example, an injector that uses compile time + * code generation may not even have its own run time representation. Other + * injectors may not be able to generate code at all, neither at compile nor + * run time. + * + * @see org.atinject.Inject @Inject + */ +package org.atinject; -- cgit v1.2.3 From c92d8c3ee7684193bd85e3a3bc6c42273f2305ec Mon Sep 17 00:00:00 2001 From: Bob Lee Date: Wed, 29 Apr 2009 00:39:35 +0000 Subject: Repackaged as javax.inject. git-svn-id: https://atinject.googlecode.com/svn/trunk@3 3bc8319c-20ab-11de-9edc-3f40a397ab60 --- atinject.ipr | 5 +- javadoc/allclasses-frame.html | 14 +- javadoc/allclasses-noframe.html | 14 +- javadoc/constant-values.html | 14 +- javadoc/deprecated-list.html | 14 +- javadoc/help-doc.html | 14 +- javadoc/index-files/index-1.html | 22 +- javadoc/index-files/index-2.html | 20 +- javadoc/index-files/index-3.html | 28 +-- javadoc/index-files/index-4.html | 28 +-- javadoc/index-files/index-5.html | 20 +- javadoc/index-files/index-6.html | 20 +- javadoc/index-files/index-7.html | 20 +- javadoc/index.html | 6 +- javadoc/javax/inject/Inject.html | 332 ++++++++++++++++++++++++++++++ javadoc/javax/inject/Named.html | 209 +++++++++++++++++++ javadoc/javax/inject/Provider.html | 226 ++++++++++++++++++++ javadoc/javax/inject/Qualifier.html | 210 +++++++++++++++++++ javadoc/javax/inject/Scope.html | 215 +++++++++++++++++++ javadoc/javax/inject/Singleton.html | 169 +++++++++++++++ javadoc/javax/inject/package-frame.html | 51 +++++ javadoc/javax/inject/package-summary.html | 209 +++++++++++++++++++ javadoc/javax/inject/package-tree.html | 150 ++++++++++++++ javadoc/org/atinject/Inject.html | 332 ------------------------------ javadoc/org/atinject/Named.html | 209 ------------------- javadoc/org/atinject/Provider.html | 226 -------------------- javadoc/org/atinject/Qualifier.html | 210 ------------------- javadoc/org/atinject/Scope.html | 215 ------------------- javadoc/org/atinject/Singleton.html | 169 --------------- javadoc/org/atinject/package-frame.html | 51 ----- javadoc/org/atinject/package-summary.html | 206 ------------------ javadoc/org/atinject/package-tree.html | 150 -------------- javadoc/overview-tree.html | 24 +-- javadoc/package-list | 2 +- src/javax/inject/Inject.java | 157 ++++++++++++++ src/javax/inject/Named.java | 17 ++ src/javax/inject/Provider.java | 36 ++++ src/javax/inject/Qualifier.java | 58 ++++++ src/javax/inject/Scope.java | 63 ++++++ src/javax/inject/Singleton.java | 15 ++ src/javax/inject/package-info.java | 23 +++ src/org/atinject/Inject.java | 157 -------------- src/org/atinject/Named.java | 17 -- src/org/atinject/Provider.java | 36 ---- src/org/atinject/Qualifier.java | 58 ------ src/org/atinject/Scope.java | 63 ------ src/org/atinject/Singleton.java | 15 -- src/org/atinject/package-info.java | 17 -- 48 files changed, 2274 insertions(+), 2262 deletions(-) create mode 100644 javadoc/javax/inject/Inject.html create mode 100644 javadoc/javax/inject/Named.html create mode 100644 javadoc/javax/inject/Provider.html create mode 100644 javadoc/javax/inject/Qualifier.html create mode 100644 javadoc/javax/inject/Scope.html create mode 100644 javadoc/javax/inject/Singleton.html create mode 100644 javadoc/javax/inject/package-frame.html create mode 100644 javadoc/javax/inject/package-summary.html create mode 100644 javadoc/javax/inject/package-tree.html delete mode 100644 javadoc/org/atinject/Inject.html delete mode 100644 javadoc/org/atinject/Named.html delete mode 100644 javadoc/org/atinject/Provider.html delete mode 100644 javadoc/org/atinject/Qualifier.html delete mode 100644 javadoc/org/atinject/Scope.html delete mode 100644 javadoc/org/atinject/Singleton.html delete mode 100644 javadoc/org/atinject/package-frame.html delete mode 100644 javadoc/org/atinject/package-summary.html delete mode 100644 javadoc/org/atinject/package-tree.html create mode 100644 src/javax/inject/Inject.java create mode 100644 src/javax/inject/Named.java create mode 100644 src/javax/inject/Provider.java create mode 100644 src/javax/inject/Qualifier.java create mode 100644 src/javax/inject/Scope.java create mode 100644 src/javax/inject/Singleton.java create mode 100644 src/javax/inject/package-info.java delete mode 100644 src/org/atinject/Inject.java delete mode 100644 src/org/atinject/Named.java delete mode 100644 src/org/atinject/Provider.java delete mode 100644 src/org/atinject/Qualifier.java delete mode 100644 src/org/atinject/Scope.java delete mode 100644 src/org/atinject/Singleton.java delete mode 100644 src/org/atinject/package-info.java diff --git a/atinject.ipr b/atinject.ipr index 133b6ff..a1aa219 100644 --- a/atinject.ipr +++ b/atinject.ipr @@ -73,7 +73,7 @@


+G I J N P Q S

G

-
get() - -Method in interface org.atinject.Provider +
get() - +Method in interface javax.inject.Provider
Provides an instance of T.

@@ -92,9 +92,9 @@ Method in interface org.atinject. - + - + @@ -102,7 +102,7 @@ Method in interface org.atinject. - +This is a DRAFT specification. @@ -131,7 +131,7 @@ Method in interface org.atinject. -GINOPQS
+GIJNPQS
diff --git a/javadoc/index-files/index-2.html b/javadoc/index-files/index-2.html index 2f15616..cd0368b 100644 --- a/javadoc/index-files/index-2.html +++ b/javadoc/index-files/index-2.html @@ -2,7 +2,7 @@ - + I-Index @@ -33,9 +33,9 @@ function windowTitle()
- + - + @@ -43,7 +43,7 @@ function windowTitle()
- +This is a DRAFT specification. @@ -72,11 +72,11 @@ function windowTitle() -G I N O P Q S
+G I J N P Q S

I

-
Inject - Annotation Type in org.atinject
Identifies injectable constructors, methods, and fields.
+
Inject - Annotation Type in javax.inject
Identifies injectable constructors, methods, and fields.
@@ -89,9 +89,9 @@ function windowTitle() - + - + @@ -99,7 +99,7 @@ function windowTitle()
- +This is a DRAFT specification. @@ -128,7 +128,7 @@ function windowTitle() -G I N O P Q S
+G I J N P Q S
diff --git a/javadoc/index-files/index-3.html b/javadoc/index-files/index-3.html index 016f5dc..fe9bfc8 100644 --- a/javadoc/index-files/index-3.html +++ b/javadoc/index-files/index-3.html @@ -2,9 +2,9 @@ - + -N-Index +J-Index @@ -13,7 +13,7 @@ N-Index