Merge "Unified implementations of BrokerService Proxies which are provided to Consume...
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / sal / dom / broker / osgi / ProxyFactory.xtend
1 package org.opendaylight.controller.sal.dom.broker.osgi
2
3 import org.opendaylight.controller.sal.core.api.BrokerService
4 import org.osgi.framework.ServiceReference
5 import org.opendaylight.controller.sal.core.api.data.DataBrokerService
6 import org.opendaylight.controller.sal.core.api.data.DataProviderService
7 import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService
8 import org.opendaylight.controller.sal.core.api.notify.NotificationService
9 import org.opendaylight.controller.sal.core.api.model.SchemaService
10
11 class ProxyFactory {
12
13     static def <T extends BrokerService> T createProxy(ServiceReference<T> serviceRef, T service) {
14         return createProxyImpl(serviceRef, service) as T;
15     }
16
17     private static def dispatch createProxyImpl(ServiceReference<?> ref, DataBrokerService service) {
18         new DataBrokerServiceProxy(ref as ServiceReference<DataBrokerService>, service);
19     }
20
21     private static def dispatch createProxyImpl(ServiceReference<?> ref, DataProviderService service) {
22         new DataProviderServiceProxy(ref as ServiceReference<DataProviderService>, service);
23     }
24     
25     private static def dispatch createProxyImpl(ServiceReference<?> ref, NotificationPublishService service) {
26         new NotificationPublishServiceProxy(ref as ServiceReference<NotificationPublishService>, service);
27     }
28     
29     private static def dispatch createProxyImpl(ServiceReference<?> ref, NotificationService service) {
30         new NotificationServiceProxy(ref as ServiceReference<NotificationService>, service);
31     }
32
33     private static def dispatch createProxyImpl(ServiceReference<?> ref, SchemaService service) {
34         new SchemaServiceProxy(ref as ServiceReference<SchemaService>, service);
35     }
36
37     private static def dispatch createProxyImpl(ServiceReference<?> reference, BrokerService service) {
38         throw new IllegalArgumentException("Not supported class");
39     }
40
41 }