]> git.argeo.org Git - gpl/argeo-slc.git/commitdiff
MOve project to PDE
authorMathieu Baudier <mbaudier@argeo.org>
Sun, 14 Feb 2010 22:06:30 +0000 (22:06 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sun, 14 Feb 2010 22:06:30 +0000 (22:06 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@3343 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

runtime/org.argeo.slc.support.osgi/.classpath
runtime/org.argeo.slc.support.osgi/.project
runtime/org.argeo.slc.support.osgi/pom.xml
runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/BundlesManager.java
runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/build/OsgiRuntimeModularDistribution.java
runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/deploy/OsgiResourceSet.java

index 3e386d407d84208e216c085e4f61d3f4267a7045..a0707243bdea6c3287ce031ea4bf98883b9b586d 100644 (file)
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-       <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+       <classpathentry kind="src" path="src/main/java"/>
        <classpathentry kind="src" path="src/main/resources"/>
        <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
        <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
-       <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
-       <classpathentry kind="output" path="target/classes"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="output" path="bin"/>
 </classpath>
index e0c27e6facf49fc34d18d2617a2c1ba09c30f08d..bd5f8a1ca7fa53805979f2a1d99e60e6c3759311 100644 (file)
                        </arguments>
                </buildCommand>
                <buildCommand>
-                       <name>org.maven.ide.eclipse.maven2Builder</name>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
                        <arguments>
                        </arguments>
                </buildCommand>
        </buildSpec>
        <natures>
-               <nature>org.maven.ide.eclipse.maven2Nature</nature>
                <nature>org.eclipse.jdt.core.javanature</nature>
+               <nature>org.eclipse.pde.PluginNature</nature>
        </natures>
 </projectDescription>
index 9f38f480cf9e9e07d63e9bfaa832c7dac364159b..3897000f2a9b15d87bbc3af5c543ceef8f817b37 100644 (file)
        <packaging>jar</packaging>
        <properties />
        <build>
+               <outputDirectory>bin</outputDirectory>
+               <resources>
+                       <resource>
+                               <directory>src/main/resources</directory>
+                       </resource>
+                       <resource>
+                               <directory>.</directory>
+                               <includes>
+                                       <include>META-INF/**</include>
+                               </includes>
+                       </resource>
+               </resources>
                <plugins>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-jar-plugin</artifactId>
+                               <configuration>
+                                       <archive>
+                                               <manifestFile>META-INF/MANIFEST.MF</manifestFile>
+                                       </archive>
+                               </configuration>
                        </plugin>
                        <plugin>
                                <groupId>org.apache.felix</groupId>
                                <artifactId>maven-bundle-plugin</artifactId>
                                <version>${version.maven-bundle-plugin}</version>
                                <configuration>
+                                       <manifestLocation>META-INF</manifestLocation>
                                        <instructions>
                                                <Export-Package>
                                                        org.argeo.slc.*
index f282f948301b8b9f4b1577fbd48f07a9c561b827..2f846ccb7a102663e5b10ba9986eaac2d0e7d130 100644 (file)
@@ -22,6 +22,7 @@ import org.springframework.osgi.context.event.OsgiBundleApplicationContextListen
 import org.springframework.osgi.context.event.OsgiBundleContextClosedEvent;
 import org.springframework.osgi.context.event.OsgiBundleContextFailedEvent;
 import org.springframework.osgi.context.event.OsgiBundleContextRefreshedEvent;
+import org.springframework.osgi.util.OsgiBundleUtils;
 import org.springframework.osgi.util.OsgiFilterUtils;
 import org.springframework.util.Assert;
 
@@ -302,7 +303,10 @@ public class BundlesManager implements BundleContextAware, FrameworkListener,
                                Assert.isTrue(osgiBundle.getVersion().equals(
                                                bundle.getHeaders().get(Constants.BUNDLE_VERSION)),
                                                "version consistent");
-               } else {
+               } else if (osgiBundle.getVersion() == null) {
+                       bundle = OsgiBundleUtils.findBundleBySymbolicName(bundleContext,
+                                       osgiBundle.getName());
+               } else {// scan all bundles
                        bundles: for (Bundle b : bundleContext.getBundles()) {
                                if (b.getSymbolicName() == null) {
                                        log.warn("Bundle " + b + " has no symbolic name defined.");
index 7f3b49a381867914c9b35b0f2b3bbab2b789d7a4..cb6353c35de812b8a9a2810737c818390dcf80b5 100644 (file)
@@ -13,6 +13,7 @@ import org.osgi.framework.Bundle;
 import org.springframework.context.ResourceLoaderAware;
 import org.springframework.core.io.Resource;
 import org.springframework.core.io.ResourceLoader;
+import org.springframework.osgi.util.OsgiBundleUtils;
 
 public class OsgiRuntimeModularDistribution extends
                AbstractOsgiModularDistribution implements ResourceLoaderAware {
@@ -25,14 +26,32 @@ public class OsgiRuntimeModularDistribution extends
                        SortedMap<NameVersion, Distribution> distributions)
                        throws Exception {
 
-               for (Bundle bundle : getBundleContext().getBundles()) {
+               String frameworkUrl = System.getProperty("osgi.framework");
+               String frameworkBaseUrl = null;
+               if (frameworkUrl != null)
+                       frameworkBaseUrl = frameworkUrl.substring(0, frameworkUrl
+                                       .lastIndexOf('/'));
+               bundles: for (Bundle bundle : getBundleContext().getBundles()) {
                        OsgiBundle osgiBundle = new OsgiBundle(bundle);
 
                        String originalLocation = bundle.getLocation();
+
+                       if (OsgiBundleUtils.isSystemBundle(bundle)) {
+                               continue bundles;
+                       }
+
                        String location = originalLocation;
                        if (originalLocation.startsWith("reference:file:"))
                                location = originalLocation.substring("reference:".length());
 
+                       if (frameworkBaseUrl != null
+                                       && originalLocation.startsWith("initial@reference:file:")) {
+                               location = frameworkBaseUrl
+                                               + '/'
+                                               + originalLocation.substring("initial@reference:file:"
+                                                               .length());
+                       }
+
                        try {
                                URL url = new URL(location);
                                Resource res = resourceLoader.getResource(url.toString());
index 13ba5fe19f6210c05952cb7f50ce747c02abeb76..48185da59b77f2767cbcfdc434878a575c3be3c7 100644 (file)
@@ -1,24 +1,57 @@
 package org.argeo.slc.osgi.deploy;
 
-import org.argeo.slc.core.deploy.RelativeResourceSet;
+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;
 
-public class OsgiResourceSet extends RelativeResourceSet implements
+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(
-                                       bundleContext.getBundle()));
+                                       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;
+       }
+
 }