From 21e24151c50c5cd382826f98bbb8b689bf931696 Mon Sep 17 00:00:00 2001 From: erik Date: Wed, 28 Jul 2010 18:22:35 +0000 Subject: [PATCH] --- .../src/main/java/org/wamblee/inject/Injectable.java | 8 ++++---- ...njectorFactoryBuilder.java => InjectorBuilder.java} | 9 +++++++-- .../main/java/org/wamblee/inject/InjectorFactory.java | 2 +- .../main/java/org/wamblee/inject/SimpleInjector.java | 4 ++-- .../src/main/java/org/wamblee/inject/package-info.java | 9 ++++----- ...actoryBuilderTest.java => InjectorBuilderTest.java} | 10 +++++----- 6 files changed, 23 insertions(+), 19 deletions(-) rename support/inject/src/main/java/org/wamblee/inject/{InjectorFactoryBuilder.java => InjectorBuilder.java} (90%) rename support/inject/src/test/java/org/wamblee/inject/{InjectorFactoryBuilderTest.java => InjectorBuilderTest.java} (78%) diff --git a/support/inject/src/main/java/org/wamblee/inject/Injectable.java b/support/inject/src/main/java/org/wamblee/inject/Injectable.java index a87c236b..ccc408f7 100644 --- a/support/inject/src/main/java/org/wamblee/inject/Injectable.java +++ b/support/inject/src/main/java/org/wamblee/inject/Injectable.java @@ -22,15 +22,15 @@ package org.wamblee.inject; * initialize fields of derived classes to null as these will override the * initializations of this base class. * - * This class uses {@link InjectorFactoryBuilder} to obtain an implementation of + * This class uses {@link InjectorBuilder} to obtain an implementation of * a {@link InjectorFactory} to use. * * @author Erik Brakkee */ public abstract class Injectable { - private final SimpleInjector injector = - InjectorFactoryBuilder.getInjector(); + private final Injector injector = + InjectorBuilder.getInjector(); /** * Inheritance style constructor. @@ -53,7 +53,7 @@ public abstract class Injectable { * Gets the default injector. * @return Injector. */ - public SimpleInjector getInjector() { + public Injector getInjector() { return injector; } } diff --git a/support/inject/src/main/java/org/wamblee/inject/InjectorFactoryBuilder.java b/support/inject/src/main/java/org/wamblee/inject/InjectorBuilder.java similarity index 90% rename from support/inject/src/main/java/org/wamblee/inject/InjectorFactoryBuilder.java rename to support/inject/src/main/java/org/wamblee/inject/InjectorBuilder.java index 197311a8..fe6c2a93 100644 --- a/support/inject/src/main/java/org/wamblee/inject/InjectorFactoryBuilder.java +++ b/support/inject/src/main/java/org/wamblee/inject/InjectorBuilder.java @@ -30,7 +30,7 @@ import java.util.ServiceLoader; * * @author Erik Brakkee */ -public class InjectorFactoryBuilder { +public class InjectorBuilder { private static InjectorFactory FACTORY; @@ -59,7 +59,12 @@ public class InjectorFactoryBuilder { return FACTORY; } - public static SimpleInjector getInjector() { + /** + * Gets an injector that support injection into any type of object and + * performs caching of the injector obtained from the {@link InjectorFactory}. + * @return Injector. + */ + public static Injector getInjector() { getInjectorFactory(); return INJECTOR; } diff --git a/support/inject/src/main/java/org/wamblee/inject/InjectorFactory.java b/support/inject/src/main/java/org/wamblee/inject/InjectorFactory.java index 9f2dfe22..d36720de 100644 --- a/support/inject/src/main/java/org/wamblee/inject/InjectorFactory.java +++ b/support/inject/src/main/java/org/wamblee/inject/InjectorFactory.java @@ -22,7 +22,7 @@ package org.wamblee.inject; * testing. * * Implementations of this class must have a default no-arg constructor to be usable by - * {@link InjectorFactoryBuilder}. + * {@link InjectorBuilder}. * * @author Erik Brakkee */ diff --git a/support/inject/src/main/java/org/wamblee/inject/SimpleInjector.java b/support/inject/src/main/java/org/wamblee/inject/SimpleInjector.java index 9e83064c..b41eb4c3 100644 --- a/support/inject/src/main/java/org/wamblee/inject/SimpleInjector.java +++ b/support/inject/src/main/java/org/wamblee/inject/SimpleInjector.java @@ -53,11 +53,11 @@ package org.wamblee.inject; * * For more advanced cases, the injector factory can also be directly * constructed instead of being obtained through the - * {@link InjectorFactoryBuilder}. + * {@link InjectorBuilder}. * * @author Erik Brakkee */ -public class SimpleInjector { +public class SimpleInjector implements Injector { private InjectorCache cache; diff --git a/support/inject/src/main/java/org/wamblee/inject/package-info.java b/support/inject/src/main/java/org/wamblee/inject/package-info.java index c07c8ab8..2d07bb1f 100644 --- a/support/inject/src/main/java/org/wamblee/inject/package-info.java +++ b/support/inject/src/main/java/org/wamblee/inject/package-info.java @@ -23,12 +23,12 @@ * *

Users of this package will typically use:

* * *

Implementors of the package

@@ -38,7 +38,7 @@ *
  • Injector: The main interface to be implemented is the {@link Injector}, by which injection is done.
  • *
  • InjectorFactory: Injectors are created by an implementation of the {@link InjectorFactory} which * creates injectors based on the class.
  • - *
  • InjectorFactoryBuilder: Implementations must make their InjectorFactory + *
  • InjectorBuilder: Implementations must make their InjectorFactory * available through the ServiceLoader mechanism. *
  • * @@ -49,4 +49,3 @@ */ package org.wamblee.inject; - diff --git a/support/inject/src/test/java/org/wamblee/inject/InjectorFactoryBuilderTest.java b/support/inject/src/test/java/org/wamblee/inject/InjectorBuilderTest.java similarity index 78% rename from support/inject/src/test/java/org/wamblee/inject/InjectorFactoryBuilderTest.java rename to support/inject/src/test/java/org/wamblee/inject/InjectorBuilderTest.java index 6e20e32a..e1c10a80 100644 --- a/support/inject/src/test/java/org/wamblee/inject/InjectorFactoryBuilderTest.java +++ b/support/inject/src/test/java/org/wamblee/inject/InjectorBuilderTest.java @@ -21,16 +21,16 @@ import static junit.framework.TestCase.*; import static org.mockito.Mockito.*; -public class InjectorFactoryBuilderTest { +public class InjectorBuilderTest { @After public void tearDown() { - InjectorFactoryBuilder.setInjectorFactory(null); + InjectorBuilder.setInjectorFactory(null); } @Test public void testGetInjectorFactory() { - InjectorFactory factory = InjectorFactoryBuilder.getInjectorFactory(); + InjectorFactory factory = InjectorBuilder.getInjectorFactory(); assertTrue(factory instanceof TestInjectorFactory); } @@ -38,8 +38,8 @@ public class InjectorFactoryBuilderTest { public void testOVerrideInjectorFactory() { InjectorFactory factory = mock(InjectorFactory.class); - InjectorFactoryBuilder.setInjectorFactory(factory); - InjectorFactory factory2 = InjectorFactoryBuilder.getInjectorFactory(); + InjectorBuilder.setInjectorFactory(factory); + InjectorFactory factory2 = InjectorBuilder.getInjectorFactory(); assertSame(factory, factory2); } } -- 2.31.1