Author: drobiazko
Date: Wed Jan 14 13:14:07 2009
New Revision: 734515

URL: http://svn.apache.org/viewvc?rev=734515&view=rev
Log:
Reverting the changes from r734292 because contributions are collected only 
inside a single module.

Removed:
    
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/Contribute.java
    
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ContributeViaAnnotationAmbiguousModule.java
    
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ContributeViaAnnotationCombindedWithBinderMethodModule.java
    
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ContributeViaAnnotationCombindedWithBuilderMethodModule.java
    
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ContributeViaAnnotationWithMarkerModule.java
    
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ContributeViaMethodAnnotationModule.java
Modified:
    
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImpl.java
    
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCMessages.java
    
tapestry/tapestry5/trunk/tapestry-ioc/src/main/resources/org/apache/tapestry5/ioc/internal/IOCStrings.properties
    tapestry/tapestry5/trunk/tapestry-ioc/src/site/apt/configuration.apt
    
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java

Modified: 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImpl.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImpl.java?rev=734515&r1=734514&r2=734515&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImpl.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImpl.java
 Wed Jan 14 13:14:07 2009
@@ -116,7 +116,6 @@
 
         grind(methods, modulePreventsServiceDecoration);
         bind(methods, modulePreventsServiceDecoration);
-        contribute(methods, modulePreventsServiceDecoration);
 
         if (methods.isEmpty()) return;
 
@@ -149,27 +148,6 @@
     {
         return serviceDefs.get(serviceId);
     }
-    
-    public List<ServiceDef> getServiceDef(Class interfaceClass, 
Collection<Class> markers)
-    {
-        List<ServiceDef> result = newList();
-        
-        for (String id : getServiceIds())
-        {
-            ServiceDef def = getServiceDef(id);
-            
-            Class serviceInterface = def.getServiceInterface();
-
-            if(serviceInterface.equals(interfaceClass))
-            {
-                
-                if(CollectionFactory.newSet(markers).equals(def.getMarkers())){
-                    result.add(def);
-                }
-            }
-        }
-        return result;
-    }
 
     private void grind(Set<Method> remainingMethods, boolean 
modulePreventsServiceDecoration)
     {
@@ -208,36 +186,20 @@
                 remainingMethods.remove(m);
                 continue;
             }
-            
-            // contribute methods are handled later, after autobuilding is 
finished
-        }
-    }
-    
-    private void contribute(Set<Method> remainingMethods, boolean 
modulePreventsServiceDecoration)
-    {
-        Method[] methods = moduleClass.getMethods();
-        
-        for (Method m : methods)
-        {
-            String name = m.getName();
 
-            if (m.isAnnotationPresent(Contribute.class) ||
-                    name.startsWith(CONTRIBUTE_METHOD_NAME_PREFIX))
+            if (name.startsWith(CONTRIBUTE_METHOD_NAME_PREFIX))
             {
- 
                 addContributionDef(m);
                 remainingMethods.remove(m);
                 continue;
             }
         }
-        
     }
 
     private void addContributionDef(Method method)
     {
-        
-        String serviceId = extractServiceId(method);
-        
+        String serviceId = stripMethodPrefix(method, 
CONTRIBUTE_METHOD_NAME_PREFIX);
+
         Class returnType = method.getReturnType();
         if (!returnType.equals(void.class)) 
logger.warn(IOCMessages.contributionWrongReturnType(method));
 
@@ -264,33 +226,6 @@
 
         contributionDefs.add(def);
     }
-    
-    private String extractServiceId(Method method)
-    {
-        Contribute annotation = method.getAnnotation(Contribute.class);
-        
-        if(annotation != null)
-        {
-            Class serviceClass = annotation.value();
-            Collection<Class> markers = extractMarkers(method);
-            
-            List<ServiceDef> defs = getServiceDef(serviceClass, markers);
-          
-           if(defs.isEmpty())
-           {
-               return serviceClass.getSimpleName();
-               
-           }
-           else if(defs.size() != 1)
-           {
-               throw new 
RuntimeException(IOCMessages.tooManyServicesForContributeMethod(method, 
serviceClass));
-              
-           }
-           return defs.get(0).getServiceId();
-        }
-        
-        return stripMethodPrefix(method, CONTRIBUTE_METHOD_NAME_PREFIX);
-    }
 
     private void addDecoratorDef(Method method)
     {

Modified: 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCMessages.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCMessages.java?rev=734515&r1=734514&r2=734515&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCMessages.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCMessages.java
 Wed Jan 14 13:14:07 2009
@@ -322,9 +322,4 @@
     {
         return MESSAGES.format("no-convention-service-implementation-found", 
clazz.getName(), clazz.getName());
     }
-    
-    static String tooManyServicesForContributeMethod(Method method, Class 
clazz)
-    {
-        return 
MESSAGES.format("too-many-services-for-annotated-contribute-method", 
asString(method), clazz.getName());
-    }
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/resources/org/apache/tapestry5/ioc/internal/IOCStrings.properties
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/resources/org/apache/tapestry5/ioc/internal/IOCStrings.properties?rev=734515&r1=734514&r2=734515&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/resources/org/apache/tapestry5/ioc/internal/IOCStrings.properties
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/resources/org/apache/tapestry5/ioc/internal/IOCStrings.properties
 Wed Jan 14 13:14:07 2009
@@ -81,4 +81,3 @@
 unexpected-service-proxy-provider=Unexpected service proxy provider when 
clearing the provider. This may indicate that you have multiple IoC Registries.
 no-proxy-provider=Service token for service '%s' can not be converted back 
into a proxy because no proxy provider has been registered. This may indicate 
that an IoC Registry has not been started yet.
 no-convention-service-implementation-found=No service implements the interface 
%s. Please provide the implementation %sImpl or bind the service interface to a 
service implementation.
-too-many-services-for-annotated-contribute-method=Contribute method %s (for 
service '%s') is marked by @Contribute annotation but several implementations 
of the service were found. You should provide a @Marker annotation or use a 
method that starts with 'contribute' to disambiguate the service the 
contribution is provided for. 

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/site/apt/configuration.apt
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/site/apt/configuration.apt?rev=734515&r1=734514&r2=734515&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/site/apt/configuration.apt 
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/site/apt/configuration.apt Wed 
Jan 14 13:14:07 2009
@@ -80,45 +80,6 @@
   other contributing modules (such as the one that contributes the Office file 
services) may be written at 
   a much later date. With no change to the FileServicerDispatcher service or 
its module class,
   the new services "plug into" the overall solution, simply by having their 
JAR's on runtime classpath. 
-
-Annotated Service Contributor Methods
-
-  As an alternative to the naming convention, you may mark a method as a 
contributor method by placing the 
-  
{{{../apidocs/org/apache/tapestry5/ioc/annotations/Contribute.html}Contribute}} 
annotation on it. 
-  Tapestry will invoke this method just as if it starts with 'contribute'. The 
value attribute of the annotation 
-  is the type of service to contribute into. Based on this type Tapestry will 
find the service id provided as described 
-  {{{service.html}here}}. 
-  
-+------+
-  @Contribute(Runnable.class)
-  public static void arbitraryNamedMethod(MappedConfiguration<String,String> 
configuration)
-  {
-    ...
-  }  
-+------+
-
-  If several implementations of a service interface are provided Tapestry will 
throw an exception. 
-  In this case you should disambiguate by providing marker annotations or by 
using the naming convention (method starts with 'contribute').
-
-+------+
-  public class MyModule
-  {
-    public static void bind(ServiceBinder binder)
-    {
-      binder.bind(Runnable.class, 
RunnableImpl.class).withId("Red").withMarker(RedMarker.class);
-      
-      binder.bind(Runnable.class, 
AnotherRunnableImpl.class).withId("BlueAndRed")
-            .withMarker(new Class[]{BlueMarker.class,RedMarker.class});
-    }
-  
-    @Contribute(Runnable.class)
-    @Marker({BlueMarker.class,RedMarker.class})
-    public static void arbitraryNamedMethod(MappedConfiguration<String,String> 
configuration)
-    {
-      ...
-    } 
-  } 
-+------+
   
 Configuration Types
 

Modified: 
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java?rev=734515&r1=734514&r2=734515&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java
 Wed Jan 14 13:14:07 2009
@@ -278,57 +278,6 @@
     {
         attemptConfigurationMethod(SimpleModule.class, "Barney", 
"contributeBarney(Configuration)");
     }
-    
-    @Test
-    public void contribution_by_annotated_method()
-    {
-        attemptConfigurationMethod(ContributeViaMethodAnnotationModule.class, 
"Runnable", 
-                "contributeMyService(MappedConfiguration)");
-    }
-    
-    @Test
-    public void 
contribution_by_annotated_method_when_service_id_provided_by_builder_method()
-    {
-        
attemptConfigurationMethod(ContributeViaAnnotationCombindedWithBuilderMethodModule.class,
 "RunnableBuilderMethod", 
-                "contributeMyService(MappedConfiguration)");
-    }
-    
-    @Test
-    public void 
contribution_by_annotated_method_when_service_id_provided_by_binder_method()
-    {
-        
-        
attemptConfigurationMethod(ContributeViaAnnotationCombindedWithBinderMethodModule.class,
 "RunnableBinderMethod", 
-            "contributeMyService(MappedConfiguration)");
-    }
-    
-    @Test
-    public void contribution_by_annotated_method_ambiguous()  throws Exception
-    {
-        Class moduleClass = ContributeViaAnnotationAmbiguousModule.class;
-        
-        Method m = moduleClass.getMethod("contributeMyService", 
MappedConfiguration.class);
-        
-        Logger logger = mockLogger();
-        
-        try
-        {
-            new DefaultModuleDefImpl(moduleClass, logger, classFactory);       
     
-            unreachable();
-        }
-        catch (RuntimeException ex)
-        {
-            assertEquals(ex.getMessage(), 
IOCMessages.tooManyServicesForContributeMethod(m, Runnable.class));
-        }
-
-    }
-     
-    @Test
-    public void contribution_by_annotated_method_with_marker()  throws 
Exception
-    {
-        
attemptConfigurationMethod(ContributeViaAnnotationWithMarkerModule.class, 
"BlueAndRed", 
-            "contributeMyService(MappedConfiguration)");
-
-    }
 
     @Test
     public void ordered_contribution_method()


Reply via email to