tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r1196754 - in /tapestry/tapestry5/trunk: tapestry-core/src/test/java/org/apache/tapestry5/internal/test/ tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ tapestry-ioc/src/tes...
Date Wed, 02 Nov 2011 18:43:31 GMT
Author: hlship
Date: Wed Nov  2 18:43:31 2011
New Revision: 1196754

URL: http://svn.apache.org/viewvc?rev=1196754&view=rev
Log:
TAP5-546: ObjectLocator.getService(Class) should be expanded to pass a varargs of marker annotation
types

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ObjectLocator.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ObjectLocatorImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryWrapper.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java?rev=1196754&r1=1196753&r2=1196754&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java
Wed Nov  2 18:43:31 2011
@@ -91,6 +91,12 @@ public class InternalBaseTestCase extend
         return registry.getObject(objectType, annotationProvider);
     }
 
+    public final <T> T getService(Class<T> serviceInterface)
+    {
+        return registry.getService(serviceInterface);
+    }
+
+
     public final <T> T getService(Class<T> serviceInterface, Class<? extends
Annotation>... markerTypes)
     {
         return registry.getService(serviceInterface);

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ObjectLocator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ObjectLocator.java?rev=1196754&r1=1196753&r2=1196754&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ObjectLocator.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ObjectLocator.java
Wed Nov  2 18:43:31 2011
@@ -50,14 +50,29 @@ public interface ObjectLocator
      * Locates a service given a service interface and (optionally) some marker annotation
types. A single service must implement the service
      * interface (which                                                   * can be hard to
guarantee) and by marked by all the marker types. The search takes into account inheritance
of the service interface
      * (not the service <em>implementation</em>), which may result in a failure
due to extra
+     * matches.
+     *
+     * @param serviceInterface the interface the service implements
+     * @return the service's proxy
+     * @throws RuntimeException if the service does not exist (this is considered programmer
error), or multiple
+     *                          services directly implement, or extend from, the service
interface
+     * @see org.apache.tapestry5.ioc.annotations.Marker
+     */
+    <T> T getService(Class<T> serviceInterface);
+
+    /**
+     * Locates a service given a service interface and (optionally) some marker annotation
types. A single service must implement the service
+     * interface (which                                                   * can be hard to
guarantee) and by marked by all the marker types. The search takes into account inheritance
of the service interface
+     * (not the service <em>implementation</em>), which may result in a failure
due to extra
      * matches.        The ability to specify marker annotation types was added in 5.3
      *
      * @param serviceInterface the interface the service implements
-     * @param markerTypes
+     * @param markerTypes      Markers used to select a specific service that implements
the interface
      * @return the service's proxy
      * @throws RuntimeException if the service does not exist (this is considered programmer
error), or multiple
      *                          services directly implement, or extend from, the service
interface
      * @see org.apache.tapestry5.ioc.annotations.Marker
+     * @since 5.3
      */
     <T> T getService(Class<T> serviceInterface, Class<? extends Annotation>...
markerTypes);
 

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ObjectLocatorImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ObjectLocatorImpl.java?rev=1196754&r1=1196753&r2=1196754&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ObjectLocatorImpl.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ObjectLocatorImpl.java
Wed Nov  2 18:43:31 2011
@@ -42,6 +42,11 @@ public class ObjectLocatorImpl implement
         return registry.getService(expandedServiceId, serviceInterface);
     }
 
+    public <T> T getService(Class<T> serviceInterface)
+    {
+        return registry.getService(serviceInterface);
+    }
+
     public <T> T getService(Class<T> serviceInterface, Class<? extends Annotation>...
markerTypes)
     {
         return registry.getService(serviceInterface, markerTypes);

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java?rev=1196754&r1=1196753&r2=1196754&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java
Wed Nov  2 18:43:31 2011
@@ -621,19 +621,21 @@ public class RegistryImpl implements Reg
         }
     }
 
-    public <T> T getService(Class<T> serviceInterface, Class<? extends Annotation>...
markerTypes)
+    public <T> T getService(Class<T> serviceInterface)
     {
         lock.check();
 
-        if (markerTypes.length == 0)
-        {
-            return findServiceByTypeAlone(serviceInterface);
-        }
+        return getServiceByTypeAndMarkers(serviceInterface);
+    }
 
-        return findServiceByTypeAndMarkers(serviceInterface, markerTypes);
+    public <T> T getService(Class<T> serviceInterface, Class<? extends Annotation>...
markerTypes)
+    {
+        lock.check();
+
+        return getServiceByTypeAndMarkers(serviceInterface, markerTypes);
     }
 
-    private <T> T findServiceByTypeAlone(Class<T> serviceInterface)
+    private <T> T getServiceByTypeAlone(Class<T> serviceInterface)
     {
         List<String> serviceIds = findServiceIdsForInterface(serviceInterface);
 
@@ -660,8 +662,13 @@ public class RegistryImpl implements Reg
         }
     }
 
-    private <T> T findServiceByTypeAndMarkers(Class<T> serviceInterface, Class<?
extends Annotation>... markerTypes)
+    private <T> T getServiceByTypeAndMarkers(Class<T> serviceInterface, Class<?
extends Annotation>... markerTypes)
     {
+        if (markerTypes.length == 0)
+        {
+            return getServiceByTypeAlone(serviceInterface);
+        }
+
         AnnotationProvider provider = createAnnotationProvider(markerTypes);
 
         Set<ServiceDef2> matches = CollectionFactory.newSet();

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryWrapper.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryWrapper.java?rev=1196754&r1=1196753&r2=1196754&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryWrapper.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryWrapper.java
Wed Nov  2 18:43:31 2011
@@ -55,6 +55,11 @@ public class RegistryWrapper implements 
         return registry.getService(expandedServiceId, serviceInterface);
     }
 
+    public <T> T getService(Class<T> serviceInterface)
+    {
+        return registry.getService(serviceInterface);
+    }
+
     public <T> T getService(Class<T> serviceInterface, Class<? extends Annotation>...
markerTypes)
     {
         return registry.getService(serviceInterface, markerTypes);

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java?rev=1196754&r1=1196753&r2=1196754&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java
Wed Nov  2 18:43:31 2011
@@ -53,14 +53,19 @@ public class IOCInternalTestCase extends
         return registry.getObject(objectType, annotationProvider);
     }
 
-    public final <T> T getService(Class<T> serviceInterface, Class<? extends
Annotation>... markerTypes)
+    public final <T> T getService(String serviceId, Class<T> serviceInterface)
     {
-        return registry.getService(serviceInterface, markerTypes);
+        return registry.getService(serviceId, serviceInterface);
     }
 
-    public final <T> T getService(String serviceId, Class<T> serviceInterface)
+    public final <T> T getService(Class<T> serviceInterface)
     {
-        return registry.getService(serviceId, serviceInterface);
+        return registry.getService(serviceInterface);
+    }
+
+    public final <T> T getService(Class<T> serviceInterface, Class<? extends
Annotation>... markerTypes)
+    {
+        return registry.getService(serviceInterface, markerTypes);
     }
 
     public final <T> T autobuild(Class<T> clazz)



Mime
View raw message