Merge changes I8c23739a,Ia0e70828
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / sal / dom / broker / osgi / ProxyFactory.xtend
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.sal.dom.broker.osgi
9
10 import org.opendaylight.controller.sal.core.api.BrokerService
11 import org.osgi.framework.ServiceReference
12 import org.opendaylight.controller.sal.core.api.data.DataBrokerService
13 import org.opendaylight.controller.sal.core.api.data.DataProviderService
14 import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService
15 import org.opendaylight.controller.sal.core.api.notify.NotificationService
16 import org.opendaylight.controller.sal.core.api.model.SchemaService
17 import org.opendaylight.controller.sal.core.api.mount.MountProvisionService
18 import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry
19
20 class ProxyFactory {
21
22     static def <T extends BrokerService> T createProxy(ServiceReference<T> serviceRef, T service) {
23         return createProxyImpl(serviceRef, service) as T;
24     }
25
26     private static def dispatch createProxyImpl(ServiceReference<?> ref, DataBrokerService service) {
27         new DataBrokerServiceProxy(ref as ServiceReference<DataBrokerService>, service);
28     }
29
30     private static def dispatch createProxyImpl(ServiceReference<?> ref, DataProviderService service) {
31         new DataProviderServiceProxy(ref as ServiceReference<DataProviderService>, service);
32     }
33     
34     private static def dispatch createProxyImpl(ServiceReference<?> ref, NotificationPublishService service) {
35         new NotificationPublishServiceProxy(ref as ServiceReference<NotificationPublishService>, service);
36     }
37     
38     private static def dispatch createProxyImpl(ServiceReference<?> ref, NotificationService service) {
39         new NotificationServiceProxy(ref as ServiceReference<NotificationService>, service);
40     }
41
42     private static def dispatch createProxyImpl(ServiceReference<?> ref, MountProvisionService service) {
43         new MountProviderServiceProxy(ref as ServiceReference<MountProvisionService>, service);
44     }
45
46
47     private static def dispatch createProxyImpl(ServiceReference<?> ref, SchemaService service) {
48         new SchemaServiceProxy(ref as ServiceReference<SchemaService>, service);
49     }
50
51     private static def dispatch createProxyImpl(ServiceReference<?> ref, RpcProvisionRegistry service) {
52         new RpcProvisionRegistryProxy(ref as ServiceReference<RpcProvisionRegistry>, service);
53     }
54
55     private static def dispatch createProxyImpl(ServiceReference<?> reference, BrokerService service) {
56         throw new IllegalArgumentException("Not supported class");
57     }
58
59 }