geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1229075 - in /geronimo/server/trunk: framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/util/osgi/ framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ plugins/jasper/ger...
Date Mon, 09 Jan 2012 09:37:00 GMT
Author: xuhaihong
Date: Mon Jan  9 09:36:59 2012
New Revision: 1229075

URL: http://svn.apache.org/viewvc?rev=1229075&view=rev
Log:
GERONIMO-6251 More changes to use OsgiMetaDataProvider, update the interface a bit.
GERONIMO-6254 Shared library does not work in the deployment process

Modified:
    geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/util/osgi/OSGiBuildContext.java
    geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/util/osgi/OSGiMetaDataBuilder.java
    geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/DependencyManager.java
    geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/OsgiMetaDataProvider.java
    geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/internal/TldRegistryImpl.java
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigRegistryImpl.java
    geronimo/server/trunk/plugins/sharedlib/geronimo-sharedlib/src/main/java/org/apache/geronimo/system/sharedlib/SharedLib.java
    geronimo/server/trunk/plugins/sharedlib/geronimo-sharedlib/src/main/java/org/apache/geronimo/system/sharedlib/SharedLibExtender.java

Modified: geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/util/osgi/OSGiBuildContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/util/osgi/OSGiBuildContext.java?rev=1229075&r1=1229074&r2=1229075&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/util/osgi/OSGiBuildContext.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/util/osgi/OSGiBuildContext.java
Mon Jan  9 09:36:59 2012
@@ -129,7 +129,7 @@ public class OSGiBuildContext {
         if (clientModule) {
             return getFullClientDependentBundleIds(bundle.getBundleId());
         }
-        return osgiMetaDataProvider.getFullDependentBundleIds(bundle);
+        return osgiMetaDataProvider.getFullDependentBundleIds(bundle.getBundleId());
     }
 
     private Set<Long> getFullClientDependentBundleIds(long bundleId) {

Modified: geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/util/osgi/OSGiMetaDataBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/util/osgi/OSGiMetaDataBuilder.java?rev=1229075&r1=1229074&r2=1229075&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/util/osgi/OSGiMetaDataBuilder.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/util/osgi/OSGiMetaDataBuilder.java
Mon Jan  9 09:36:59 2012
@@ -29,7 +29,6 @@ import org.apache.geronimo.kernel.Intern
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.repository.ArtifactResolver;
 import org.apache.geronimo.kernel.repository.Environment;
-import org.apache.geronimo.system.configuration.DependencyManager;
 import org.apache.geronimo.system.configuration.OsgiMetaDataProvider;
 import org.apache.xbean.osgi.bundle.util.BundleDescription.ExportPackage;
 import org.apache.xbean.osgi.bundle.util.HeaderParser;

Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/DependencyManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/DependencyManager.java?rev=1229075&r1=1229074&r2=1229075&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/DependencyManager.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/DependencyManager.java
Mon Jan  9 09:36:59 2012
@@ -261,7 +261,7 @@ public class DependencyManager implement
     }
 
     @Override
-    public Set<ExportPackage> getExportedPackages(Long bundleId) {
+    public Set<ExportPackage> getExportedPackages(long bundleId) {
         synchronized (bundleExportPackagesMap) {
             Set<ExportPackage> exportPackages = bundleExportPackagesMap.get(bundleId);
             if (exportPackages == null) {
@@ -296,7 +296,7 @@ public class DependencyManager implement
         return getFullDependentBundles(bundle.getBundleId());
     }
 
-    public Set<Bundle> getFullDependentBundles(Long bundleId) {
+    public Set<Bundle> getFullDependentBundles(long bundleId) {
         Set<Long> fullDependentBundleIds = getFullDependentBundleIds(bundleId);
         if (fullDependentBundleIds.size() == 0) {
             return Collections.<Bundle> emptySet();
@@ -310,13 +310,13 @@ public class DependencyManager implement
         }
         return dependentBundles;
     }
-
-    @Override
+    
     public Set<Long> getFullDependentBundleIds(Bundle bundle) {
         return getFullDependentBundleIds(bundle.getBundleId());
     }
 
-    public Set<Long> getFullDependentBundleIds(Long bundleId) {
+    @Override
+    public Set<Long> getFullDependentBundleIds(long bundleId) {
         Set<Long> fullDependentBundleIds = fullDependentBundleIdsMap.get(bundleId);
         return fullDependentBundleIds == null ? Collections.<Long> emptySet() : new
HashSet<Long>(fullDependentBundleIds);
     }
@@ -448,10 +448,9 @@ public class DependencyManager implement
     }
 
     private void removeArtifactBundleEntry(Bundle bundle) {
-        Artifact artifact = toArtifact(bundle.getLocation());
+        Artifact artifact = bundleIdArtifactMap.remove(bundle.getBundleId());
         if (artifact != null) {
             artifactBundleMap.remove(artifact);
-            bundleIdArtifactMap.remove(bundle.getBundleId());
         }
     }
 

Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/OsgiMetaDataProvider.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/OsgiMetaDataProvider.java?rev=1229075&r1=1229074&r2=1229075&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/OsgiMetaDataProvider.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/OsgiMetaDataProvider.java
Mon Jan  9 09:36:59 2012
@@ -33,9 +33,11 @@ import org.osgi.framework.Bundle;
 public interface OsgiMetaDataProvider {
     Set<BundleDescription.ExportPackage> getExportedPackages(Bundle bundle);
 
-    Set<BundleDescription.ExportPackage> getExportedPackages(Long bundleId);
+    Set<BundleDescription.ExportPackage> getExportedPackages(long bundleId);
 
-    Set<Long> getFullDependentBundleIds(Bundle bundle);
+    Set<Long> getFullDependentBundleIds(long bundleId);
+    
+    Set<Bundle> getFullDependentBundles(long bundleId);
 
     Bundle getBundle(Artifact artifact);
 

Modified: geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/internal/TldRegistryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/internal/TldRegistryImpl.java?rev=1229075&r1=1229074&r2=1229075&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/internal/TldRegistryImpl.java
(original)
+++ geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/internal/TldRegistryImpl.java
Mon Jan  9 09:36:59 2012
@@ -31,9 +31,10 @@ import java.util.zip.ZipEntry;
 import org.apache.geronimo.jasper.TldProvider;
 import org.apache.geronimo.jasper.TldRegistry;
 import org.apache.geronimo.system.configuration.DependencyManager;
+import org.apache.geronimo.system.configuration.OsgiMetaDataProvider;
 import org.apache.xbean.osgi.bundle.util.BundleResourceFinder;
-import org.apache.xbean.osgi.bundle.util.BundleUtils;
 import org.apache.xbean.osgi.bundle.util.BundleResourceFinder.ResourceFinderCallback;
+import org.apache.xbean.osgi.bundle.util.BundleUtils;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
@@ -72,11 +73,11 @@ public class TldRegistryImpl implements 
         Set<Bundle> dependentBundles = new HashSet<Bundle>();
         
         // add in bundles from dependency manager
-        ServiceReference serviceReference = bundleContext.getServiceReference(DependencyManager.class.getName());
+        ServiceReference serviceReference = bundleContext.getServiceReference(OsgiMetaDataProvider.class.getName());
         if (serviceReference != null) {
-            DependencyManager dependencyManager = (DependencyManager) bundleContext.getService(serviceReference);
+            OsgiMetaDataProvider osgiMetaDataProvider = (OsgiMetaDataProvider) bundleContext.getService(serviceReference);
             try {
-                dependentBundles.addAll(dependencyManager.getFullDependentBundles(bundle.getBundleId()));
+                dependentBundles.addAll(osgiMetaDataProvider.getFullDependentBundles(bundle.getBundleId()));
             } finally {
                 bundleContext.ungetService(serviceReference);
             }

Modified: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigRegistryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigRegistryImpl.java?rev=1229075&r1=1229074&r2=1229075&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigRegistryImpl.java
(original)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigRegistryImpl.java
Mon Jan  9 09:36:59 2012
@@ -33,6 +33,7 @@ import org.apache.geronimo.kernel.util.I
 import org.apache.geronimo.myfaces.FacesConfigDigester;
 import org.apache.geronimo.myfaces.config.resource.osgi.api.ConfigRegistry;
 import org.apache.geronimo.system.configuration.DependencyManager;
+import org.apache.geronimo.system.configuration.OsgiMetaDataProvider;
 import org.apache.myfaces.config.element.FacesConfig;
 import org.apache.xbean.osgi.bundle.util.BundleUtils;
 import org.osgi.framework.Bundle;
@@ -128,9 +129,9 @@ public class ConfigRegistryImpl implemen
         Set<Bundle> dependentBundles = new HashSet<Bundle>();
         
         // add in bundles from dependency manager
-        ServiceReference serviceReference = bundleContext.getServiceReference(DependencyManager.class.getName());
+        ServiceReference serviceReference = bundleContext.getServiceReference(OsgiMetaDataProvider.class.getName());
         if (serviceReference != null) {
-            DependencyManager dependencyManager = (DependencyManager) bundleContext.getService(serviceReference);
+            OsgiMetaDataProvider dependencyManager = (DependencyManager) bundleContext.getService(serviceReference);
             try {
                 dependentBundles.addAll(dependencyManager.getFullDependentBundles(bundleId));
             } finally {

Modified: geronimo/server/trunk/plugins/sharedlib/geronimo-sharedlib/src/main/java/org/apache/geronimo/system/sharedlib/SharedLib.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/sharedlib/geronimo-sharedlib/src/main/java/org/apache/geronimo/system/sharedlib/SharedLib.java?rev=1229075&r1=1229074&r2=1229075&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/sharedlib/geronimo-sharedlib/src/main/java/org/apache/geronimo/system/sharedlib/SharedLib.java
(original)
+++ geronimo/server/trunk/plugins/sharedlib/geronimo-sharedlib/src/main/java/org/apache/geronimo/system/sharedlib/SharedLib.java
Mon Jan  9 09:36:59 2012
@@ -20,7 +20,6 @@ package org.apache.geronimo.system.share
 import java.io.File;
 import java.io.FileWriter;
 import java.io.PrintWriter;
-import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
@@ -131,12 +130,6 @@ public class SharedLib implements GBeanL
         String dynamicImportPackages = (String)bundleContext.getBundle().getHeaders().get(Constants.DYNAMICIMPORT_PACKAGE);
         if (dynamicImportPackages != null) {
             List<HeaderElement> headerElements = HeaderParser.parseHeader(dynamicImportPackages);
-            //From shared library perspective, dynamic * should not be used
-            for (Iterator<HeaderElement> it = headerElements.iterator(); it.hasNext();)
{
-                if (it.next().getName().equals("*")) {
-                    it.remove();
-                }
-            }
             if (headerElements.size() > 0) {
                 manifest.addConfiguredAttribute(new Manifest.Attribute(Manifest.Attribute.Separator.COMMA,
Constants.DYNAMICIMPORT_PACKAGE, HeaderBuilder.build(headerElements)));
             }
@@ -161,7 +154,7 @@ public class SharedLib implements GBeanL
             BundleUtils.resolve(sharedLibBundle);
         }
         //5. register the shared library bundle to the shared library bundle extender
-        ServiceReference sharedLibExtenderReference = null;
+        ServiceReference<?> sharedLibExtenderReference = null;
         try {
             sharedLibExtenderReference = bundleContext.getServiceReference(SharedLibExtender.class.getName());
             if (sharedLibExtenderReference != null) {
@@ -244,7 +237,7 @@ public class SharedLib implements GBeanL
             delegatingBundle.removeBundle(sharedLibBundle);
         }
         //2. unregister the share lib bundle to the share lib bundle extender
-        ServiceReference sharedLibExtenderReference = null;
+        ServiceReference<?> sharedLibExtenderReference = null;
         try {
             sharedLibExtenderReference = bundleContext.getServiceReference(SharedLibExtender.class.getName());
             if (sharedLibExtenderReference != null) {

Modified: geronimo/server/trunk/plugins/sharedlib/geronimo-sharedlib/src/main/java/org/apache/geronimo/system/sharedlib/SharedLibExtender.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/sharedlib/geronimo-sharedlib/src/main/java/org/apache/geronimo/system/sharedlib/SharedLibExtender.java?rev=1229075&r1=1229074&r2=1229075&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/sharedlib/geronimo-sharedlib/src/main/java/org/apache/geronimo/system/sharedlib/SharedLibExtender.java
(original)
+++ geronimo/server/trunk/plugins/sharedlib/geronimo-sharedlib/src/main/java/org/apache/geronimo/system/sharedlib/SharedLibExtender.java
Mon Jan  9 09:36:59 2012
@@ -21,6 +21,7 @@ import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.locks.ReentrantLock;
 
@@ -32,9 +33,9 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Service;
 import org.apache.geronimo.hook.BundleHelper;
 import org.apache.geronimo.hook.SharedLibraryRegistry;
-import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.config.ConfigurationManager;
 import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.system.configuration.OsgiMetaDataProvider;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
@@ -54,7 +55,7 @@ public class SharedLibExtender implement
     private BundleContext bundleContext;
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    private ConfigurationManager configurationManager;
+    private OsgiMetaDataProvider osgiMetaDataProvider;
 
     private Map<Artifact, List<Bundle>> configruationSharedLibBundlesMap = new
ConcurrentHashMap<Artifact, List<Bundle>>();
 
@@ -62,23 +63,23 @@ public class SharedLibExtender implement
 
     private final ReentrantLock registerLock = new ReentrantLock();
 
-//    public SharedLibExtender(@ParamSpecial(type = SpecialAttributeType.bundleContext) BundleContext
bundleContext,
-//            @ParamReference(name = "DependencyManager") DependencyManager dependencyManager,
-//            @ParamReference(name = "ConfigurationManager", namingType = "ConfigurationManager")
ConfigurationManager configurationManager) {
-//        this.bundleContext = bundleContext;
-//        this.configurationManager = configurationManager;
-//    }
-    
-    public void setConfigurationManager(ConfigurationManager configurationManager) {
-        this.configurationManager = configurationManager;
-    }
-
-    public void unsetConfigurationManager(ConfigurationManager configurationManager) {
-        if (this.configurationManager == configurationManager) {
-            this.configurationManager = null;
+    //    public SharedLibExtender(@ParamSpecial(type = SpecialAttributeType.bundleContext)
BundleContext bundleContext,
+    //            @ParamReference(name = "DependencyManager") DependencyManager dependencyManager,
+    //            @ParamReference(name = "ConfigurationManager", namingType = "ConfigurationManager")
ConfigurationManager configurationManager) {
+    //        this.bundleContext = bundleContext;
+    //        this.configurationManager = configurationManager;
+    //    }
+
+    public void setOsgiMetaDataProvider(OsgiMetaDataProvider osgiMetaDataProvider) {
+        this.osgiMetaDataProvider = osgiMetaDataProvider;
+    }
+
+    public void unsetOsgiMetaDataProvider(OsgiMetaDataProvider osgiMetaDataProvider) {
+        if (this.osgiMetaDataProvider == osgiMetaDataProvider) {
+            this.osgiMetaDataProvider = null;
         }
     }
-    
+
     @Activate
     public void activate(BundleContext bundleContext) throws Exception {
         this.bundleContext = bundleContext;
@@ -121,13 +122,18 @@ public class SharedLibExtender implement
     }
 
     private void installSharedLibs(Bundle appBundle) {
-        Configuration configuration = configurationManager.getConfiguration(appBundle.getBundleId());
-        if (configuration == null) {
+        if (osgiMetaDataProvider == null) {
+            logger.warn("No OsgiMetaDataProvider service found, shared libs will not be installed
for the application bundle {}", appBundle.getSymbolicName());
             return;
         }
+        Set<Long> dependentBundleIds = osgiMetaDataProvider.getFullDependentBundleIds(appBundle.getBundleId());
         List<Bundle> dependentSharedLibBundles = new ArrayList<Bundle>();
-        for (Artifact parentArtifact : configuration.getDependencyNode().getParents()) {
-            List<Bundle> sharedLibBundles = configruationSharedLibBundlesMap.get(parentArtifact);
+        for (long dependentBundleId : dependentBundleIds) {
+            Artifact currArtifact = osgiMetaDataProvider.getArtifact(dependentBundleId);
+            if (currArtifact == null) {
+                continue;
+            }
+            List<Bundle> sharedLibBundles = configruationSharedLibBundlesMap.get(currArtifact);
             if (sharedLibBundles != null) {
                 dependentSharedLibBundles.addAll(sharedLibBundles);
             }



Mime
View raw message