Bulk-add copyright headers to .xtend files
[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
19 class ProxyFactory {
20
21     static def <T extends BrokerService> T createProxy(ServiceReference<T> serviceRef, T service) {
22         return createProxyImpl(serviceRef, service) as T;
23     }
24
25     private static def dispatch createProxyImpl(ServiceReference<?> ref, DataBrokerService service) {
26         new DataBrokerServiceProxy(ref as ServiceReference<DataBrokerService>, service);
27     }
28
29     private static def dispatch createProxyImpl(ServiceReference<?> ref, DataProviderService service) {
30         new DataProviderServiceProxy(ref as ServiceReference<DataProviderService>, service);
31     }
32     
33     private static def dispatch createProxyImpl(ServiceReference<?> ref, NotificationPublishService service) {
34         new NotificationPublishServiceProxy(ref as ServiceReference<NotificationPublishService>, service);
35     }
36     
37     private static def dispatch createProxyImpl(ServiceReference<?> ref, NotificationService service) {
38         new NotificationServiceProxy(ref as ServiceReference<NotificationService>, service);
39     }
40
41     private static def dispatch createProxyImpl(ServiceReference<?> ref, MountProvisionService service) {
42         new MountProviderServiceProxy(ref as ServiceReference<MountProvisionService>, service);
43     }
44
45
46     private static def dispatch createProxyImpl(ServiceReference<?> ref, SchemaService service) {
47         new SchemaServiceProxy(ref as ServiceReference<SchemaService>, service);
48     }
49
50     private static def dispatch createProxyImpl(ServiceReference<?> reference, BrokerService service) {
51         throw new IllegalArgumentException("Not supported class");
52     }
53
54 }