summaryrefslogtreecommitdiffstats
path: root/container-di/src/main/java/com/yahoo/container/di/componentgraph/Provider.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-di/src/main/java/com/yahoo/container/di/componentgraph/Provider.java')
-rw-r--r--container-di/src/main/java/com/yahoo/container/di/componentgraph/Provider.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/container-di/src/main/java/com/yahoo/container/di/componentgraph/Provider.java b/container-di/src/main/java/com/yahoo/container/di/componentgraph/Provider.java
new file mode 100644
index 00000000000..38482371455
--- /dev/null
+++ b/container-di/src/main/java/com/yahoo/container/di/componentgraph/Provider.java
@@ -0,0 +1,25 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.container.di.componentgraph;
+
+/**
+ * <p>Provides a component of the parameter type T.
+ * If (and only if) dependency injection does not have a component of type T,
+ * it will request one from the Provider providing type T.</p>
+ *
+ * <p>Providers are useful in these situations:</p>
+ * <ul>
+ * <li>Some code is needed to create the component instance in question.</li>
+ * <li>The component creates resources that must be deconstructed.</li>
+ * <li>A fallback component should be provided in case the application (or system)
+ * does not provide a component instance.</li>
+ * </ul>
+ *
+ * @author tonytv
+ * @author gjoranv
+ */
+public interface Provider<T> {
+
+ T get();
+ void deconstruct();
+
+}