X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.support.osgi%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fosgi%2Fdeploy%2FOsgiResourceSet.java;fp=runtime%2Forg.argeo.slc.support.osgi%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fosgi%2Fdeploy%2FOsgiResourceSet.java;h=0000000000000000000000000000000000000000;hb=7c2fed34c687a49693640e3b16231b2f1459559a;hp=823a0def44e93ced7ccf85ee5bfc445f1e8004de;hpb=805e3301575e708491482a2a00dd37bc2b41b851;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/deploy/OsgiResourceSet.java b/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/deploy/OsgiResourceSet.java deleted file mode 100644 index 823a0def4..000000000 --- a/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/deploy/OsgiResourceSet.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2007-2012 Argeo GmbH - * - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.osgi.deploy; - -import org.argeo.slc.core.deploy.DefaultResourceSet; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.springframework.core.io.ResourceLoader; -import org.springframework.osgi.context.BundleContextAware; -import org.springframework.osgi.io.OsgiBundleResourceLoader; -import org.springframework.osgi.io.OsgiBundleResourcePatternResolver; -import org.springframework.osgi.util.OsgiBundleUtils; - -/** - * Retrieves ressources from an OSGi bundle either the active one or another one - * referenced by its symbolic name. - */ -public class OsgiResourceSet extends DefaultResourceSet implements - BundleContextAware { - private BundleContext bundleContext; - private Bundle bundle = null; - private String bundleSymbolicName = null; - - private OsgiBundleResourceLoader osgiBundleResourceLoader = null; - - @Override - public void afterPropertiesSet() throws Exception { - osgiBundleResourceLoader = new OsgiBundleResourceLoader(getBundle()); - if (getResourcePatternResolver() == null) - setResourcePatternResolver(new OsgiBundleResourcePatternResolver( - osgiBundleResourceLoader)); - super.afterPropertiesSet(); - } - - public Bundle getBundle() { - if (bundle != null) - return bundle; - else if (bundleSymbolicName != null)// do not cache - return OsgiBundleUtils.findBundleBySymbolicName(bundleContext, - bundleSymbolicName); - else - // containing bundle - return bundleContext.getBundle(); - } - - public void setBundleContext(BundleContext bundleContext) { - this.bundleContext = bundleContext; - } - - @Override - public ResourceLoader getResourceLoaderToUse() { - return osgiBundleResourceLoader; - } - - public void setBundle(Bundle bundle) { - this.bundle = bundle; - } - - public void setBundleSymbolicName(String bundleSymbolicName) { - this.bundleSymbolicName = bundleSymbolicName; - } - -}