[jboss-cvs] JBossAS SVN: r75829 - projects/microcontainer/trunk/guice-int/src/main/org/jboss/guice/spi.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jul 15 03:36:52 EDT 2008


Author: alesj
Date: 2008-07-15 03:36:52 -0400 (Tue, 15 Jul 2008)
New Revision: 75829

Modified:
   projects/microcontainer/trunk/guice-int/src/main/org/jboss/guice/spi/GuiceIntegration.java
   projects/microcontainer/trunk/guice-int/src/main/org/jboss/guice/spi/InjectableMicrocontainerProvider.java
   projects/microcontainer/trunk/guice-int/src/main/org/jboss/guice/spi/MicrocontainerProvider.java
Log:
Name should be Object.

Modified: projects/microcontainer/trunk/guice-int/src/main/org/jboss/guice/spi/GuiceIntegration.java
===================================================================
--- projects/microcontainer/trunk/guice-int/src/main/org/jboss/guice/spi/GuiceIntegration.java	2008-07-15 06:54:08 UTC (rev 75828)
+++ projects/microcontainer/trunk/guice-int/src/main/org/jboss/guice/spi/GuiceIntegration.java	2008-07-15 07:36:52 UTC (rev 75829)
@@ -90,12 +90,29 @@
     * @param name the bean name
     * @return Provider instance
     */
-   public static <T> Provider<T> fromMicrocontainer(Class<T> type, String name)
+   public static <T> Provider<T> fromMicrocontainer(Class<T> type, Object name)
    {
       return new InjectableMicrocontainerProvider<T>(type, name);
    }
 
    /**
+    * Creates a provider which looks up objects from Microcontainer using the given type.
+    * Expects a binding to {@link org.jboss.dependency.spi.Controller}. Example usage:
+    * <p/>
+    * <pre>
+    * bind(DataSource.class).toProvider(fromMicrocontainer(DataSource.class));
+    * </pre>
+    *
+    * @param <T> the class type
+    * @param type the class type
+    * @return Provider instance
+    */
+   public static <T> Provider<T> fromMicrocontainer(Class<T> type)
+   {
+      return fromMicrocontainer(type, type);
+   }
+
+   /**
     * Binds all Microcontainer beans from the given factory by name. For a MC bean
     * named "foo", this method creates a binding to the bean's type and
     * {@code @Named("foo")}.
@@ -140,7 +157,7 @@
     * @param binder     the binder
     * @param controller the controller
     * @param context    the context
-    */
+    */
    @SuppressWarnings("deprecation")
    protected static void bindContext(Binder binder, Controller controller, ControllerContext context)
    {

Modified: projects/microcontainer/trunk/guice-int/src/main/org/jboss/guice/spi/InjectableMicrocontainerProvider.java
===================================================================
--- projects/microcontainer/trunk/guice-int/src/main/org/jboss/guice/spi/InjectableMicrocontainerProvider.java	2008-07-15 06:54:08 UTC (rev 75828)
+++ projects/microcontainer/trunk/guice-int/src/main/org/jboss/guice/spi/InjectableMicrocontainerProvider.java	2008-07-15 07:36:52 UTC (rev 75829)
@@ -31,7 +31,7 @@
  */
 class InjectableMicrocontainerProvider<T> extends MicrocontainerProvider<T>
 {
-   public InjectableMicrocontainerProvider(Class<T> type, String name)
+   public InjectableMicrocontainerProvider(Class<T> type, Object name)
    {
       super(type, name);
    }

Modified: projects/microcontainer/trunk/guice-int/src/main/org/jboss/guice/spi/MicrocontainerProvider.java
===================================================================
--- projects/microcontainer/trunk/guice-int/src/main/org/jboss/guice/spi/MicrocontainerProvider.java	2008-07-15 06:54:08 UTC (rev 75828)
+++ projects/microcontainer/trunk/guice-int/src/main/org/jboss/guice/spi/MicrocontainerProvider.java	2008-07-15 07:36:52 UTC (rev 75829)
@@ -34,16 +34,17 @@
 class MicrocontainerProvider<T> implements Provider<T>
 {
    private Class<T> type;
-   private String name;
+   private Object name;
    private Controller controller;
 
-   protected MicrocontainerProvider(Class<T> type, String name)
+   protected MicrocontainerProvider(Class<T> type, Object name)
    {
       if (type == null)
          throw new IllegalArgumentException("Null type.");
-      this.type = type;
       if (name == null)
          throw new IllegalArgumentException("Null name.");
+
+      this.type = type;
       this.name = name;
    }
 




More information about the jboss-cvs-commits mailing list