From 67414f17e30d04ad278fe7ab73c0bed8c44c0523 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 16 Mar 2018 13:58:47 -0400 Subject: Add test cases for sli Added test cases for sli in sli/core Change-Id: Ic8614f199ae843a46ec3441f0ae247f065b33322 Issue-ID: CCSDK-213 Signed-off-by: Timoney, Dan (dt5972) --- .../core/sli/provider/SvcLogicAdaptorFactory.java | 46 +++++++--------------- 1 file changed, 14 insertions(+), 32 deletions(-) (limited to 'sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java') diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java index 7316db57..ecfe6b69 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java @@ -8,9 +8,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,7 +35,7 @@ public class SvcLogicAdaptorFactory { private static final Logger LOG = LoggerFactory .getLogger(SvcLogicAdaptorFactory.class); - private static HashMap adaptorMap = new HashMap(); + private static HashMap adaptorMap = new HashMap<>(); public static void registerAdaptor(SvcLogicAdaptor adaptor) { String name = adaptor.getClass().getName(); @@ -51,36 +51,18 @@ public class SvcLogicAdaptorFactory { } } - public static SvcLogicAdaptor getInstance(String name) { - if (adaptorMap.containsKey(name)) { - return (adaptorMap.get(name)); - } else { - BundleContext bctx = null; - try - { - bctx = FrameworkUtil.getBundle(SvcLogicAdaptorFactory.class) - .getBundleContext(); - } - catch (Exception e) - { - LOG.debug("Caught exception trying to locate device adaptor "+name, e); - return(null); - } - - ServiceReference sref = bctx.getServiceReference(name); + public static SvcLogicAdaptor getInstance(String name) { + if (adaptorMap.containsKey(name)) { + return adaptorMap.get(name); + } else { - if (sref != null) { - SvcLogicAdaptor adaptor = (SvcLogicAdaptor) bctx - .getService(sref); + SvcLogicAdaptor adaptor = (SvcLogicAdaptor) SvcLogicClassResolver.resolve(name); - if (adaptor != null) { - registerAdaptor(adaptor); + if (adaptor != null) { + registerAdaptor(adaptor); + } - return (adaptor); - } - return (null); - } - } - return(null); - } + return adaptor; + } + } } -- cgit 1.2.3-korg