geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1099364 - in /geronimo/server/trunk: framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ plugins/j2ee/geronimo-j2ee-b...
Date Wed, 04 May 2011 08:18:51 GMT
Author: xuhaihong
Date: Wed May  4 08:18:50 2011
New Revision: 1099364

URL: http://svn.apache.org/viewvc?rev=1099364&view=rev
Log:
GERONIMO-5938 Load JSF taglib xml files from bundles

Modified:
    geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
    geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/DependencyManager.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/BundleDeploymentContext.java
    geronimo/server/trunk/plugins/openwebbeans/openwebbeans-deployer/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/wab/geronimo-web-extender/src/main/java/org/apache/geronimo/osgi/web/extender/WebApplication.java

Modified: geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java?rev=1099364&r1=1099363&r2=1099364&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
Wed May  4 08:18:50 2011
@@ -214,6 +214,18 @@ public class DeploymentContext {
     }
 
     private void createPluginMetadata() throws IOException, JAXBException, XMLStreamException
{
+        PluginType pluginType = getPluginMetadata();
+        File metaInf = new File(getConfigurationDir(), "META-INF");
+        metaInf.mkdirs();
+        OutputStream out = new FileOutputStream(new File(metaInf, "geronimo-plugin.xml"));
+        try {
+            PluginXmlUtil.writePluginMetadata(pluginType, out);
+        } finally {
+            out.close();
+        }
+    }
+
+    public PluginType getPluginMetadata() {
         PluginType pluginType = new PluginType();
         pluginType.setName("Temporary Plugin metadata for deployment");
         PluginArtifactType instance = new PluginArtifactType();
@@ -223,14 +235,7 @@ public class DeploymentContext {
             dependenciees.add(DependencyType.newDependencyType(dependency));
         }
         pluginType.getPluginArtifact().add(instance);
-        File metaInf = new File(getConfigurationDir(), "META-INF");
-        metaInf.mkdirs();
-        OutputStream out = new FileOutputStream(new File(metaInf, "geronimo-plugin.xml"));
-        try {
-            PluginXmlUtil.writePluginMetadata(pluginType, out);
-        } finally {
-            out.close();
-        }
+        return pluginType;
     }
 
     private void createTempManifest() throws DeploymentException, IOException {

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=1099364&r1=1099363&r2=1099364&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
Wed May  4 08:18:50 2011
@@ -20,6 +20,7 @@
 package org.apache.geronimo.system.configuration;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
@@ -229,6 +230,57 @@ public class DependencyManager implement
         return null;
     }
 
+    public void updatePluginMetadata(Bundle bundle) {
+        Long bundleId = bundle.getBundleId();
+        dependentBundleIdsMap.remove(bundleId);
+        fullDependentBundleIdsMap.remove(bundleId);
+        pluginMap.remove(bundleId);
+        PluginArtifactType pluginArtifactType = getCachedPluginMetadata(bundle);
+        if (pluginArtifactType != null) {
+            List<DependencyType> dependencies = pluginArtifactType.getDependency();
+            Set<Long> dependentBundleIds = new HashSet<Long>();
+            Set<Long> fullDependentBundleIds = new HashSet<Long>();
+            try {
+                for (DependencyType dependencyType : dependencies) {
+                    Artifact artifact = dependencyType.toArtifact();
+                    Bundle dependentBundle = getBundle(artifact);
+                    if(dependentBundle == null) {
+                        log.warn("Dependent artifact " + artifact + " could not be resolved,
it will be ignored");
+                        continue;
+                    }
+                    Long dependentBundleId = dependentBundle.getBundleId();
+                    dependentBundleIds.add(dependentBundleId);
+                    if (fullDependentBundleIds.add(dependentBundleId)) {
+                        Set<Long> parentDependentBundleIds = fullDependentBundleIdsMap.get(dependentBundleId);
+                        if (parentDependentBundleIds != null) {
+                            fullDependentBundleIds.addAll(parentDependentBundleIds);
+                        }
+                    }
+                }
+                fullDependentBundleIdsMap.put(bundle.getBundleId(), fullDependentBundleIds);
+                dependentBundleIdsMap.put(bundle.getBundleId(), dependentBundleIds);
+            } catch (Exception e) {
+                log.error("Could not update bundle dependecy", e);
+            }
+        }
+    }
+
+    public static void updatePluginMetadata(BundleContext bundleContext, Bundle bundle) {
+        ServiceReference serviceReference = null;
+        try {
+            serviceReference = bundleContext.getServiceReference(DependencyManager.class.getName());
+            DependencyManager dependencyManager = null;
+            if (serviceReference != null) {
+                dependencyManager = (DependencyManager) bundleContext.getService(serviceReference);
+                dependencyManager.updatePluginMetadata(bundle);
+            }
+        } finally {
+            if (serviceReference != null) {
+                bundleContext.ungetService(serviceReference);
+            }
+        }
+    }
+
     private void addArtifactBundleEntry(Bundle bundle) {
         Artifact artifact = toArtifact(bundle.getLocation());
         if (artifact != null) {
@@ -278,25 +330,32 @@ public class DependencyManager implement
 
     private PluginArtifactType getPluginMetadata(Bundle bundle) {
         PluginArtifactType pluginArtifactType = null;
-        URL info = bundle.getEntry("META-INF/geronimo-plugin.xml");
-        if (info != null) {
-            if (log.isDebugEnabled()) {
-                log.debug("found geronimo-plugin.xml for bundle " + bundle);
-            }
-            InputStream in = null;
-            try {
+        InputStream in = null;
+        try {
+            URL info = bundle.getEntry("META-INF/geronimo-plugin.xml");
+            if (info != null) {
+                if (log.isDebugEnabled()) {
+                    log.debug("found geronimo-plugin.xml for bundle " + bundle);
+                }
                 in = info.openStream();
+            } else if (bundle.getBundleContext() != null) {
+                File pluginMetadataFile = bundle.getBundleContext().getDataFile("geronimo-plugin.xml");
+                if (pluginMetadataFile.exists()) {
+                    in = new FileInputStream(pluginMetadataFile);
+                }
+            }
+            if (in != null) {
                 PluginType pluginType = PluginXmlUtil.loadPluginMetadata(in);
                 pluginArtifactType = pluginType.getPluginArtifact().get(0);
-            } catch (Throwable e) {
-                log.warn("Could not read geronimo metadata for bundle: " + bundle, e);
-            } finally {
-                IOUtils.close(in);
-            }
-        } else {
-            if (log.isDebugEnabled()) {
-                log.debug("did not find geronimo-plugin.xml for bundle " + bundle);
+            } else {
+                if (log.isDebugEnabled()) {
+                    log.debug("did not find geronimo-plugin.xml for bundle " + bundle);
+                }
             }
+        } catch (Throwable e) {
+            log.warn("Could not read geronimo metadata for bundle: " + bundle, e);
+        } finally {
+            IOUtils.close(in);
         }
         return pluginArtifactType;
     }
@@ -389,6 +448,13 @@ public class DependencyManager implement
         if (pluginArtifactType != null) {
             List<Bundle> bundles = new ArrayList<Bundle>();
             List<DependencyType> dependencies = pluginArtifactType.getDependency();
+            boolean dependencyHierarchyBuildingRequired = !dependentBundleIdsMap.containsKey(bundle.getBundleId());
+            Set<Long> dependentBundleIds = null;
+            Set<Long> fullDependentBundleIds = null;
+            if (dependencyHierarchyBuildingRequired) {
+                dependentBundleIds = new HashSet<Long>();
+                fullDependentBundleIds = new HashSet<Long>();
+            }
             try {
                 for (DependencyType dependencyType : dependencies) {
                     if (log.isDebugEnabled()) {
@@ -400,6 +466,16 @@ public class DependencyManager implement
                     }
                     String location = locateBundle(artifact);
                     Bundle b = bundleContext.installBundle(location);
+                    if (dependencyHierarchyBuildingRequired) {
+                        long startingBundleId = b.getBundleId();
+                        dependentBundleIds.add(startingBundleId);
+                        if (fullDependentBundleIds.add(startingBundleId)) {
+                            Set<Long> parentDependentBundleIds = fullDependentBundleIdsMap.get(startingBundleId);
+                            if (parentDependentBundleIds != null) {
+                                fullDependentBundleIds.addAll(parentDependentBundleIds);
+                            }
+                        }
+                    }
                     if (b.getState() != Bundle.ACTIVE ) {
                         bundles.add(b);
                     }
@@ -414,6 +490,11 @@ public class DependencyManager implement
                         }
                     }
                 }
+
+                if (dependencyHierarchyBuildingRequired) {
+                    fullDependentBundleIdsMap.put(bundle.getBundleId(), fullDependentBundleIds);
+                    dependentBundleIdsMap.put(bundle.getBundleId(), dependentBundleIds);
+                }
             } catch (Exception e) {
                 log.error("Could not install bundle dependecy", e);
             }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/BundleDeploymentContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/BundleDeploymentContext.java?rev=1099364&r1=1099363&r2=1099364&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/BundleDeploymentContext.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/BundleDeploymentContext.java
Wed May  4 08:18:50 2011
@@ -16,10 +16,16 @@
  */
 package org.apache.geronimo.j2ee.deployment;
 
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.net.URI;
 import java.util.Collection;
 import java.util.Map;
 
+import javax.xml.bind.JAXBException;
+import javax.xml.stream.XMLStreamException;
+
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.BundleResourceContext;
 import org.apache.geronimo.deployment.Deployable;
@@ -30,16 +36,21 @@ import org.apache.geronimo.kernel.config
 import org.apache.geronimo.kernel.config.ConfigurationManager;
 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.util.IOUtils;
+import org.apache.geronimo.system.configuration.DependencyManager;
+import org.apache.geronimo.system.plugin.model.PluginType;
+import org.apache.geronimo.system.plugin.model.PluginXmlUtil;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
 
 /**
  * @version $Rev:386276 $ $Date$
  */
 public class BundleDeploymentContext extends EARContext {
-      
+
     private Bundle bundle;
-    
+
     public BundleDeploymentContext(Environment environment,
                                    ConfigurationModuleType moduleType,
                                    Naming naming,
@@ -52,31 +63,44 @@ public class BundleDeploymentContext ext
                                    AbstractNameQuery corbaGBeanObjectName,
                                    Map messageDestinations,
                                    Bundle bundle) throws DeploymentException {
-        super(null, null, 
+        super(null, null,
               environment, moduleType, naming, configurationManager, new BundleResourceContext(bundle),
bundleContext,
-              serverName, baseName, transactionManagerObjectName, connectionTrackerObjectName,

+              serverName, baseName, transactionManagerObjectName, connectionTrackerObjectName,
               corbaGBeanObjectName, messageDestinations);
         this.bundle = bundle;
     }
-   
+
     @Override
     public void initializeConfiguration() throws DeploymentException {
         try {
             ConfigurationData configurationData = new ConfigurationData(moduleType, null,
childConfigurationDatas, environment, baseDir, inPlaceConfigurationDir, naming);
             configurationData.setBundleContext(bundle.getBundleContext());
+            createTempPluginMetadata(bundle);
+            DependencyManager.updatePluginMetadata(bundle.getBundleContext(), bundle);
             configurationManager.loadConfiguration(configurationData);
             this.configuration = configurationManager.getConfiguration(environment.getConfigId());
         } catch (Exception e) {
             throw new DeploymentException("Unable to create configuration for deployment",
e);
         }
     }
-    
+
     @Override
-    public void getCompleteManifestClassPath(Deployable deployable, 
-                                             URI moduleBaseUri, 
-                                             URI resolutionUri, 
-                                             Collection<String> classpath, 
+    public void getCompleteManifestClassPath(Deployable deployable,
+                                             URI moduleBaseUri,
+                                             URI resolutionUri,
+                                             Collection<String> classpath,
                                              Collection<String> exclusions) throws
DeploymentException {
     }
-    
+
+    private void createTempPluginMetadata(Bundle bundle) throws FileNotFoundException, XMLStreamException,
JAXBException {
+        File geronimoPlugin = bundle.getBundleContext().getDataFile("geronimo-plugin.xml");
+        FileOutputStream geronimoPluginOut = null;
+        try {
+            geronimoPluginOut = new FileOutputStream(geronimoPlugin);
+            PluginType pluginMetadata = getPluginMetadata();
+            PluginXmlUtil.writePluginMetadata(pluginMetadata, geronimoPluginOut);
+        } finally {
+            IOUtils.close(geronimoPluginOut);
+        }
+    }
 }

Modified: geronimo/server/trunk/plugins/openwebbeans/openwebbeans-deployer/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openwebbeans/openwebbeans-deployer/src/main/plan/plan.xml?rev=1099364&r1=1099363&r2=1099364&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openwebbeans/openwebbeans-deployer/src/main/plan/plan.xml
(original)
+++ geronimo/server/trunk/plugins/openwebbeans/openwebbeans-deployer/src/main/plan/plan.xml
Wed May  4 08:18:50 2011
@@ -43,6 +43,16 @@
                         <artifactId>openwebbeans-impl</artifactId>
                         <type>jar</type>
                     </dependency>
+                    <dependency>
+                        <groupId>org.apache.openwebbeans</groupId>
+                        <artifactId>openwebbeans-jsf</artifactId>
+                        <type>jar</type>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.apache.openwebbeans</groupId>
+                        <artifactId>openwebbeans-web</artifactId>
+                        <type>jar</type>
+                    </dependency>
                 </dependencies>
                 <!-- Import added so that MyFaces can discover 
                      META-INF/faces-config.xml in openwebbeans-jsf bundle -->

Modified: geronimo/server/trunk/plugins/wab/geronimo-web-extender/src/main/java/org/apache/geronimo/osgi/web/extender/WebApplication.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/wab/geronimo-web-extender/src/main/java/org/apache/geronimo/osgi/web/extender/WebApplication.java?rev=1099364&r1=1099363&r2=1099364&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/wab/geronimo-web-extender/src/main/java/org/apache/geronimo/osgi/web/extender/WebApplication.java
(original)
+++ geronimo/server/trunk/plugins/wab/geronimo-web-extender/src/main/java/org/apache/geronimo/osgi/web/extender/WebApplication.java
Wed May  4 08:18:50 2011
@@ -44,6 +44,10 @@ import org.apache.geronimo.kernel.config
 import org.apache.geronimo.kernel.config.LifecycleException;
 import org.apache.geronimo.kernel.config.NoSuchConfigException;
 import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.util.IOUtils;
+import org.apache.geronimo.system.configuration.DependencyManager;
+import org.apache.geronimo.system.plugin.model.PluginType;
+import org.apache.geronimo.system.plugin.model.PluginXmlUtil;
 import org.osgi.framework.Bundle;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -198,12 +202,12 @@ public class WebApplication implements R
                         bundle);
                 webModule.setEarContext(deploymentContext);
                 webModule.setRootEarContext(deploymentContext);
-                
+
                 deploymentContext.flush();
                 deploymentContext.initializeConfiguration();
 
                 webModule.getJndiScope(JndiScope.app).put("app/AppName", webModule.getName());
-                
+
                 webModuleBuilder.initContext(deploymentContext, webModule, bundle);
 
                 AbstractName appJndiName = naming.createChildName(deploymentContext.getModuleName(),
"ApplicationJndi", "ApplicationJndi");
@@ -218,17 +222,28 @@ public class WebApplication implements R
                 deploymentContext.addGBean(appContexts);
 
                 configurationData = deploymentContext.getConfigurationData();
-                FileOutputStream out = new FileOutputStream(configSer);
+                FileOutputStream configSerOut =  null;
                 try {
-                    ConfigurationUtil.writeConfigurationData(configurationData, out);
+                    configSerOut = new FileOutputStream(configSer);
+                    ConfigurationUtil.writeConfigurationData(configurationData, configSerOut);
                 } finally {
-                    out.close();
+                    IOUtils.close(configSerOut);
                 }
 
-                deploymentContext.close();
-
                 // set config.ser last modified time to be of the bundle
                 configSer.setLastModified(bundle.getLastModified());
+
+                File geronimoPlugin = bundle.getBundleContext().getDataFile("geronimo-plugin.xml");
+                FileOutputStream geronimoPluginOut = null;
+                try {
+                    geronimoPluginOut = new FileOutputStream(geronimoPlugin);
+                    PluginType pluginMetadata = deploymentContext.getPluginMetadata();
+                    PluginXmlUtil.writePluginMetadata(pluginMetadata, geronimoPluginOut);
+                    DependencyManager.updatePluginMetadata(bundle.getBundleContext(), bundle);
+                } finally {
+                    IOUtils.close(geronimoPluginOut);
+                }
+                deploymentContext.close();
             }
 
             configurationData.setUseEnvironment(true);



Mime
View raw message