d0afc3f47dbb325b2e9b95fb715b3f8a611a82d9
[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 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker
20
21 class ProxyFactory {
22
23     static def <T extends BrokerService> T createProxy(ServiceReference<T> serviceRef, T service) {
24         return createProxyImpl(serviceRef, service) as T;
25     }
26
27
28     private static def dispatch createProxyImpl(ServiceReference<?> ref, DataBrokerService service) {
29         new DataBrokerServiceProxy(ref as ServiceReference<DataBrokerService>, service);
30     }
31
32     private static def dispatch createProxyImpl(ServiceReference<?> ref, DataProviderService service) {
33         new DataProviderServiceProxy(ref as ServiceReference<DataProviderService>, service);
34     }
35     
36     private static def dispatch createProxyImpl(ServiceReference<?> ref, NotificationPublishService service) {
37         new NotificationPublishServiceProxy(ref as ServiceReference<NotificationPublishService>, service);
38     }
39     
40     private static def dispatch createProxyImpl(ServiceReference<?> ref, NotificationService service) {
41         new NotificationServiceProxy(ref as ServiceReference<NotificationService>, service);
42     }
43
44     private static def dispatch createProxyImpl(ServiceReference<?> ref, MountProvisionService service) {
45         new MountProviderServiceProxy(ref as ServiceReference<MountProvisionService>, service);
46     }
47
48
49     private static def dispatch createProxyImpl(ServiceReference<?> ref, SchemaService service) {
50         new SchemaServiceProxy(ref as ServiceReference<SchemaService>, service);
51     }
52
53     private static def dispatch createProxyImpl(ServiceReference<?> ref, RpcProvisionRegistry service) {
54         new RpcProvisionRegistryProxy(ref as ServiceReference<RpcProvisionRegistry>, service);
55     }
56     
57     private static def dispatch createProxyImpl(ServiceReference<?> ref, DOMDataBroker service) {
58         new DOMDataBrokerProxy(ref as ServiceReference<DOMDataBroker>, service)
59     }
60     
61
62     private static def dispatch createProxyImpl(ServiceReference<?> reference, BrokerService service) {
63         throw new IllegalArgumentException("Not supported class");
64     }
65
66 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.