X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.core%2Fsrc%2Forg%2Fargeo%2Fslc%2Fosgi%2Fbuild%2FBundleModularDistribution.java;fp=org.argeo.slc.core%2Fsrc%2Forg%2Fargeo%2Fslc%2Fosgi%2Fbuild%2FBundleModularDistribution.java;h=0000000000000000000000000000000000000000;hb=e14154d2baba78852915304d51cbb56bed1d3d3e;hp=db7c7e8a13bed34dad86572b99fe62516af79ba8;hpb=aba0f1135009d9014c42368ecea338088e6d2be1;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.core/src/org/argeo/slc/osgi/build/BundleModularDistribution.java b/org.argeo.slc.core/src/org/argeo/slc/osgi/build/BundleModularDistribution.java deleted file mode 100644 index db7c7e8a1..000000000 --- a/org.argeo.slc.core/src/org/argeo/slc/osgi/build/BundleModularDistribution.java +++ /dev/null @@ -1,96 +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.build; - -import java.net.URL; -import java.util.Enumeration; -import java.util.SortedMap; -import java.util.StringTokenizer; -import java.util.jar.JarInputStream; -import java.util.jar.Manifest; - -import org.apache.commons.io.IOUtils; -import org.argeo.slc.DefaultNameVersion; -import org.argeo.slc.NameVersion; -import org.argeo.slc.build.Distribution; -import org.argeo.slc.core.build.VersionedResourceDistribution; -import org.osgi.framework.Constants; -import org.springframework.context.ResourceLoaderAware; -import org.springframework.core.io.ResourceLoader; - -public class BundleModularDistribution extends AbstractOsgiModularDistribution - implements ResourceLoaderAware { - private ResourceLoader resourceLoader; - - private String libDirectory = "/lib"; - - protected void fillDistributions( - SortedMap distributions) - throws Exception { - Enumeration urls = (Enumeration) getBundleContext() - .getBundle().findEntries(libDirectory, "*.jar", false); - while (urls.hasMoreElements()) { - URL url = urls.nextElement(); - JarInputStream in = null; - try { - in = new JarInputStream(url.openStream()); - Manifest mf = in.getManifest(); - String name = mf.getMainAttributes().getValue( - Constants.BUNDLE_SYMBOLICNAME); - // Skip additional specs such as - // ; singleton:=true - if (name.indexOf(';') > -1) { - name = new StringTokenizer(name, " ;").nextToken(); - } - - String version = mf.getMainAttributes().getValue( - Constants.BUNDLE_VERSION); - DefaultNameVersion nameVersion = new DefaultNameVersion(name, - version); - distributions.put(nameVersion, - new VersionedResourceDistribution(name, version, - resourceLoader.getResource(url.toString()))); - } finally { - IOUtils.closeQuietly(in); - } - } - } - - public void setLibDirectory(String libDirectory) { - this.libDirectory = libDirectory; - } - - public void setResourceLoader(ResourceLoader resourceLoader) { - this.resourceLoader = resourceLoader; - } - - /* - * @SuppressWarnings(value = { "unchecked" }) protected URL - * findModule(String moduleName, String version) { Enumeration urls = - * (Enumeration) bundleContext.getBundle() .findEntries(libDirectory, - * moduleName + "*", false); - * - * if (!urls.hasMoreElements()) throw new SlcException("Cannot find module " - * + moduleName); - * - * URL url = urls.nextElement(); - * - * // TODO: check version as well if (urls.hasMoreElements()) throw new - * SlcException("More than one module with name " + moduleName); return url; - * } - */ - -}