X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fdom%2Fbroker%2Fosgi%2FProxyFactory.java;h=f922882f7f0b8fd3528825ce8d0923de3c129d34;hp=ebb923c375a8ba4ddea8f53119912b295f39e6d3;hb=4ef15f7a7e3fb5bcaa6a3202d268a5c945e0aa71;hpb=d70f418d19fa09b1efc8fa4ce4ed35f0cf59b73b diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/ProxyFactory.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/ProxyFactory.java index ebb923c375..f922882f7f 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/ProxyFactory.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/ProxyFactory.java @@ -8,129 +8,57 @@ package org.opendaylight.controller.sal.dom.broker.osgi; import java.util.Arrays; - +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.controller.sal.core.api.BrokerService; -import org.osgi.framework.ServiceReference; -import org.opendaylight.controller.sal.core.api.data.DataBrokerService; -import org.opendaylight.controller.sal.core.api.data.DataProviderService; -import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService; -import org.opendaylight.controller.sal.core.api.notify.NotificationService; import org.opendaylight.controller.sal.core.api.model.SchemaService; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionService; -import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.osgi.framework.ServiceReference; @SuppressWarnings("unchecked") -public class ProxyFactory { - - public static T createProxy( - final ServiceReference serviceRef, final T service) { - - Object _createProxyImpl = ProxyFactory.createProxyImpl(serviceRef, - service); - return ((T) _createProxyImpl); - } - - @Deprecated - private static Object _createProxyImpl(final ServiceReference ref, - final DataBrokerService service) { +public final class ProxyFactory { - return new DataBrokerServiceProxy( - ((ServiceReference) ref), service); + private ProxyFactory() { } - @Deprecated - private static Object _createProxyImpl(final ServiceReference ref, - final DataProviderService service) { + public static T createProxy(final ServiceReference serviceRef, final T service) { - return new DataProviderServiceProxy( - ((ServiceReference) ref), service); + Object createProxyImpl = ProxyFactory.createProxyImpl(serviceRef, service); + return ((T) createProxyImpl); } - private static Object _createProxyImpl(final ServiceReference ref, - final NotificationPublishService service) { + private static Object createProxyImpl(final ServiceReference ref, final DOMMountPointService service) { - return new NotificationPublishServiceProxy( - ((ServiceReference) ref), service); + return new DOMMountPointServiceProxy(((ServiceReference) ref), service); } - private static Object _createProxyImpl(final ServiceReference ref, - final NotificationService service) { + private static Object createProxyImpl(final ServiceReference ref, final SchemaService service) { - return new NotificationServiceProxy( - ((ServiceReference) ref), service); + return new SchemaServiceProxy(((ServiceReference) ref), service); } - @Deprecated - private static Object _createProxyImpl(final ServiceReference ref, - final MountProvisionService service) { + private static DOMDataBrokerProxy createProxyImpl(final ServiceReference ref, final DOMDataBroker service) { - return new MountProviderServiceProxy( - ((ServiceReference) ref), service); + return new DOMDataBrokerProxy(((ServiceReference) ref), service); } - private static Object _createProxyImpl(final ServiceReference ref, - final DOMMountPointService service) { - - return new DOMMountPointServiceProxy( - ((ServiceReference) ref), service); - } - - private static Object _createProxyImpl(final ServiceReference ref, - final SchemaService service) { - - return new SchemaServiceProxy(((ServiceReference) ref), - service); - } - - private static Object _createProxyImpl(final ServiceReference ref, - final RpcProvisionRegistry service) { - - return new RpcProvisionRegistryProxy( - ((ServiceReference) ref), service); - } - - private static DOMDataBrokerProxy _createProxyImpl( - final ServiceReference ref, final DOMDataBroker service) { - - return new DOMDataBrokerProxy(((ServiceReference) ref), - service); - } - - private static Object _createProxyImpl(final ServiceReference reference, - final BrokerService service) { - - throw new IllegalArgumentException("Not supported class: " - + service.getClass().getName()); - } - - private static Object createProxyImpl(final ServiceReference ref, - final BrokerService service) { + private static Object createProxyImpl(final ServiceReference ref, final BrokerService service) { if (service instanceof DOMDataBroker) { - return _createProxyImpl(ref, (DOMDataBroker) service); - } else if (service instanceof RpcProvisionRegistry) { - return _createProxyImpl(ref, (RpcProvisionRegistry) service); - } else if (service instanceof DataProviderService) { - return _createProxyImpl(ref, (DataProviderService) service); - } else if (service instanceof MountProvisionService) { - return _createProxyImpl(ref, (MountProvisionService) service); - } else if (service instanceof NotificationPublishService) { - return _createProxyImpl(ref, (NotificationPublishService) service); - } else if (service instanceof DataBrokerService) { - return _createProxyImpl(ref, (DataBrokerService) service); + return createProxyImpl(ref, (DOMDataBroker) service); } else if (service instanceof SchemaService) { - return _createProxyImpl(ref, (SchemaService) service); - } else if (service instanceof NotificationService) { - return _createProxyImpl(ref, (NotificationService) service); + return createProxyImpl(ref, (SchemaService) service); } else if (service instanceof DOMMountPointService) { - return _createProxyImpl(ref, (DOMMountPointService) service); + return createProxyImpl(ref, (DOMMountPointService) service); } else if (service != null) { - return _createProxyImpl(ref, service); + return createProxyImplFallback(ref, service); } else { - throw new IllegalArgumentException("Unhandled parameter types: " - + Arrays. asList(ref, service).toString()); + throw new IllegalArgumentException( + "Unhandled parameter types: " + Arrays.asList(ref, service).toString()); } } + + private static Object createProxyImplFallback(final ServiceReference reference, final BrokerService service) { + + return service; + } } \ No newline at end of file