2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
18 package org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles;
20 import java.io.IOException;
22 import java.util.Iterator;
23 import org.osgi.framework.Bundle;
24 import org.osgi.framework.FrameworkUtil;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27 import com.opensymphony.xwork2.util.ClassLoaderUtil;
29 public class ClassLoaderUtilExt {
31 final static Logger LOG = LoggerFactory.getLogger(ClassLoaderUtilExt.class);
33 public static URL getResource(String resourceName, Class<?> callingClass) {
35 Iterator<URL> urls = null;
38 urls = getResources(resourceName, callingClass, true);
39 } catch (IOException e) {
40 LOG.debug("No resource {}", resourceName);
43 while (urls.hasNext()) {
45 LOG.debug("found " + u.toString());
51 LOG.debug("res currently not found. try to find with bundle");
52 Bundle b = FrameworkUtil.getBundle(callingClass);
54 url = b.getEntry(resourceName);
56 ClassLoader loader = Thread.currentThread().getContextClassLoader();
57 url = loader.getResource(resourceName);
64 public static Iterator<URL> getResources(String resourceName, Class<?> callingClass, boolean aggregate)
66 return ClassLoaderUtil.getResources(resourceName, callingClass, aggregate);