Author: reto
Date: Sat Apr  9 14:59:50 2011
New Revision: 1090603

URL: http://svn.apache.org/viewvc?rev=1090603&view=rev
Log:
CLEREZZA-492: overloaded doWith functions supporting up to 3 arguments

Modified:
    
incubator/clerezza/trunk/parent/osgi.services/src/main/scala/org/apache/clerezza/osgi/services/ServicesDsl.scala

Modified: 
incubator/clerezza/trunk/parent/osgi.services/src/main/scala/org/apache/clerezza/osgi/services/ServicesDsl.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/osgi.services/src/main/scala/org/apache/clerezza/osgi/services/ServicesDsl.scala?rev=1090603&r1=1090602&r2=1090603&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/osgi.services/src/main/scala/org/apache/clerezza/osgi/services/ServicesDsl.scala
 (original)
+++ 
incubator/clerezza/trunk/parent/osgi.services/src/main/scala/org/apache/clerezza/osgi/services/ServicesDsl.scala
 Sat Apr  9 14:59:50 2011
@@ -61,4 +61,37 @@ class ServicesDsl(bundleContext: BundleC
                                                                                
         "("+Constants.OBJECTCLASS+"="+clazz.getName+")")
                }
        }
+
+       def doWith[T,U](action: (T,U) => Unit)(implicit mt: Manifest[T], mu: 
Manifest[U]) {
+               doWith[T] {
+                       t: T => {
+                               val clazz = mt.erasure.asInstanceOf[Class[U]]
+                               val service = getService(clazz)
+                               if (service != null) {
+                                       action(t, service)
+                               } else {
+                                       doWith[U,T] {
+                                               (u: U, t: T) => action(t,u)
+                                       }
+                                       }
+                       }
+               }
+       }
+
+       def doWith[T,U,V](action: (T,U,V) => Unit)(implicit mt: Manifest[T],
+                                                                               
                mu: Manifest[U], mv: Manifest[V]) {
+               doWith[T,U] {
+                       (t: T, u: U) => {
+                               val clazz = mv.erasure.asInstanceOf[Class[V]]
+                               val service = getService(clazz)
+                               if (service != null) {
+                                       action(t, u, service)
+                               } else {
+                                       doWith[U,V,T] {
+                                               (u: U, v: V, t: T) => 
action(t,u,v)
+                                       }
+                               }
+                       }
+               }
+       }
 }


Reply via email to