[jboss-cvs] JBossAS SVN: r108102 - in trunk: server/src/etc/deployers and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Sep 10 06:36:36 EDT 2010


Author: alesj
Date: 2010-09-10 06:36:35 -0400 (Fri, 10 Sep 2010)
New Revision: 108102

Added:
   trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/LibraryDiscoveryService.java
Modified:
   trunk/component-matrix/pom.xml
   trunk/server/src/etc/deployers/scanning-deployers-jboss-beans.xml
   trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/ArchiveDiscoveryDeployer.java
   trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldDiscoveryEnvironment.java
   trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/SecurityActions.java
Log:
[JBAS-8402]; update MC libs - CL, Deployers, Scanning.
Add initial lib discovery service -- TODO on the actual usage.


Modified: trunk/component-matrix/pom.xml
===================================================================
--- trunk/component-matrix/pom.xml	2010-09-10 08:58:53 UTC (rev 108101)
+++ trunk/component-matrix/pom.xml	2010-09-10 10:36:35 UTC (rev 108102)
@@ -97,7 +97,7 @@
     <version.org.jboss.bootstrap>2.1.0-alpha-5</version.org.jboss.bootstrap>
     <version.org.jboss.cache.core>3.2.5.GA</version.org.jboss.cache.core>
     <version.org.jboss.cache.pojo>3.0.0.GA</version.org.jboss.cache.pojo>
-    <version.org.jboss.cl>2.2.0.Alpha7</version.org.jboss.cl>
+    <version.org.jboss.cl>2.2.0.Alpha8</version.org.jboss.cl>
     <version.org.jboss.classpool>1.0.0.Alpha6</version.org.jboss.classpool>
     <version.org.jboss.cluster.cache.jbc>3.0.0.Alpha1</version.org.jboss.cluster.cache.jbc>
     <version.org.jboss.cluster.cache.spi>3.0.0.Alpha1</version.org.jboss.cluster.cache.spi>
@@ -105,13 +105,13 @@
     <version.org.jboss.cluster.server.api>2.0.0.Alpha5</version.org.jboss.cluster.server.api>
     <version.org.jboss.cluster.server.core>1.0.0.Alpha2</version.org.jboss.cluster.server.core>
     <version.org.jboss.common.core>2.2.17.GA</version.org.jboss.common.core>
-    <version.org.jboss.deployers>2.2.0.Alpha6</version.org.jboss.deployers>
+    <version.org.jboss.deployers>2.2.0.Alpha7</version.org.jboss.deployers>
     <version.org.jboss.ejb3.depchain>1.0.0-alpha-4</version.org.jboss.ejb3.depchain>
     <!-- This to move into the EJB3 BOM -->
     <version.org.jboss.ejb3.embedded>1.0.0-alpha-1</version.org.jboss.ejb3.embedded>
     <version.org.jboss.ejb.api>1.0-alpha-1</version.org.jboss.ejb.api>
     <version.org.jboss.embedded>1.0.0-alpha-3</version.org.jboss.embedded>
-   <version.org.jboss.injection>0.1.0-alpha-2</version.org.jboss.injection>
+    <version.org.jboss.injection>0.1.0-alpha-2</version.org.jboss.injection>
     <version.org.jboss.interceptor>1.0.0-CR11</version.org.jboss.interceptor>
     <version.org.jboss.integration>6.0.0.CR1</version.org.jboss.integration>
     <version.org.jboss.javaee.specs.bom>1.0.0.Beta6</version.org.jboss.javaee.specs.bom>
@@ -147,7 +147,7 @@
     <version.org.jboss.remoting>2.5.3</version.org.jboss.remoting>
     <version.org.jboss.remoting3>3.1.0.Beta2</version.org.jboss.remoting3>
     <version.org.jboss.remoting3.metadata>1.0.0.Beta2</version.org.jboss.remoting3.metadata>
-    <version.org.jboss.scanning>1.0.0.Alpha5</version.org.jboss.scanning>
+    <version.org.jboss.scanning>1.0.0.Alpha6</version.org.jboss.scanning>
     <version.org.jboss.security>3.0.0.Beta4</version.org.jboss.security>
     <version.org.jboss.security.negotiation>2.0.3.SP1</version.org.jboss.security.negotiation>
     <version.org.jboss.service.binding>1.1.1.Final</version.org.jboss.service.binding>

Modified: trunk/server/src/etc/deployers/scanning-deployers-jboss-beans.xml
===================================================================
--- trunk/server/src/etc/deployers/scanning-deployers-jboss-beans.xml	2010-09-10 08:58:53 UTC (rev 108101)
+++ trunk/server/src/etc/deployers/scanning-deployers-jboss-beans.xml	2010-09-10 10:36:35 UTC (rev 108102)
@@ -143,6 +143,7 @@
     <property name="patterns">
         <set>
             <value>**/*.hbm.xml</value>
+            <value>META-INF/orm.xml</value>
         </set>
     </property>
   </bean>

Modified: trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/ArchiveDiscoveryDeployer.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/ArchiveDiscoveryDeployer.java	2010-09-10 08:58:53 UTC (rev 108101)
+++ trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/ArchiveDiscoveryDeployer.java	2010-09-10 10:36:35 UTC (rev 108102)
@@ -124,11 +124,11 @@
    }
 
    
-   private static class WBDiscoveryVisitor implements ResourceVisitor
+   static class WBDiscoveryVisitor implements ResourceVisitor
    {
       private WeldDiscoveryEnvironment wbdi;
 
-      private WBDiscoveryVisitor(WeldDiscoveryEnvironment wbdi)
+      WBDiscoveryVisitor(WeldDiscoveryEnvironment wbdi)
       {
          this.wbdi = wbdi;
       }

Modified: trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldDiscoveryEnvironment.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldDiscoveryEnvironment.java	2010-09-10 08:58:53 UTC (rev 108101)
+++ trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldDiscoveryEnvironment.java	2010-09-10 10:36:35 UTC (rev 108102)
@@ -27,6 +27,8 @@
 import java.util.HashSet;
 import java.util.Set;
 
+import org.jboss.classloading.spi.visitor.ResourceVisitor;
+
 /**
  * WBD env impl.
  *
@@ -38,6 +40,16 @@
    private Set<URL> urls = new HashSet<URL>();
 
    /**
+    * Create visitor.
+    *
+    * @return the weld discovery visitor
+    */
+   public ResourceVisitor visitor()
+   {
+      return new ArchiveDiscoveryDeployer.WBDiscoveryVisitor(this);
+   }
+
+   /**
     * Add weld class.
     *
     * @param clazz the weld class

Added: trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/LibraryDiscoveryService.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/LibraryDiscoveryService.java	                        (rev 0)
+++ trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/LibraryDiscoveryService.java	2010-09-10 10:36:35 UTC (rev 108102)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.weld.integration.deployer.env.bda;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classloading.spi.visitor.ClassFilter;
+import org.jboss.classloading.spi.visitor.ResourceVisitor;
+import org.jboss.deployers.spi.classloading.ResourceLookupProvider;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
+import org.jboss.weld.bootstrap.api.ServiceRegistry;
+import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.ejb.spi.EjbDescriptor;
+import org.jboss.weld.integration.deployer.env.WeldDiscoveryEnvironment;
+
+/**
+ * Find all Weld libraries.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class LibraryDiscoveryService
+{
+   private ResourceLookupProvider<Module> provider;
+   private Iterable<URL> excludedUrls;
+
+   private Set<BeanDeploymentArchive> libs;
+   private AtomicBoolean checked = new AtomicBoolean();
+
+   public LibraryDiscoveryService(ResourceLookupProvider<Module> provider)
+   {
+      if (provider == null)
+         throw new IllegalArgumentException("Null provider");
+      this.provider = provider;
+   }
+
+   /**
+    * Get libraries.
+    *
+    * @return the weld libraries
+    * @throws Exception for any error
+    */
+   public synchronized Set<BeanDeploymentArchive> getLibraries() throws Exception
+   {
+      if (libs == null || checked.get() == false)
+      {
+         libs = new HashSet<BeanDeploymentArchive>();
+
+         List<VirtualFile> excludedFiles = null;
+         Map<Module, Set<URL>> modules = provider.getMatchingModules();
+         for (Map.Entry<Module, Set<URL>> entry : modules.entrySet())
+         {
+            Set<URL> urls = entry.getValue();
+            if (excludedUrls != null && excludedFiles == null)
+            {
+               excludedFiles = new ArrayList<VirtualFile>();
+               for (URL eu : excludedUrls)
+                  excludedFiles.add(VFS.getChild(eu));
+            }
+            Set<VirtualFile> files = new HashSet<VirtualFile>();
+            for (URL u : urls)
+            {
+               VirtualFile vf = VFS.getChild(u);
+               boolean include = true;
+               if (excludedFiles != null)
+               {
+                  for (VirtualFile ef : excludedFiles)
+                  {
+                     if (vf.getParentFileList().contains(ef))
+                     {
+                        include = false;
+                        break;
+                     }
+                  }
+               }
+               if (include)
+                  files.add(vf);
+            }
+            if (files.isEmpty() == false)
+            {                                                     
+               ClassLoader cl = SecurityActions.getClassLoaderForModule(entry.getKey());
+               // is this module already installed; past CL stage
+               if (cl != null)
+               {
+                  // create an ArchiveInfo with the ClassLoader
+                  ArchiveInfo archiveInfo = new ArchiveInfo(cl);
+                  // finally create the Archive
+                  Archive archive = ArchiveFactory.createArchive(archiveInfo, new ArrayList<EjbDescriptor<?>>());
+                  // ... and the corresponding BDA
+                  ServiceRegistry serviceRegistry = new SimpleServiceRegistry();
+                  // TODO: fill in serviceRegistry? With which services?
+
+                  libs.add(archive.createBeanDeploymentArchive(serviceRegistry));
+
+                  // the env
+                  WeldDiscoveryEnvironment environment = archiveInfo.getEnvironment();
+                  // fill in the Weld classes
+                  // the WBDiscoveryVisitor from ArchiveDiscoveryDeployer...
+                  ResourceVisitor visitor = environment.visitor();
+                  Module module = entry.getKey();
+
+                  for (VirtualFile child : files)
+                  {
+                     URL beansXmlURL = child.getChild(provider.getResourceName()).toURL();
+                     environment.addWeldXmlURL(beansXmlURL);
+
+                     module.visit(visitor, ClassFilter.INSTANCE, null, child.toURL());
+                  }
+               }
+            }
+         }
+         checked.set(true);
+      }
+      return libs;
+   }
+
+   /**
+    * Refresh libs
+    */
+   public synchronized void refresh()
+   {
+      checked.set(false);
+   }
+
+   public void setExcludedUrls(Iterable<URL> excludedUrls)
+   {
+      this.excludedUrls = excludedUrls;
+   }
+}

Modified: trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/SecurityActions.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/SecurityActions.java	2010-09-10 08:58:53 UTC (rev 108101)
+++ trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/SecurityActions.java	2010-09-10 10:36:35 UTC (rev 108102)
@@ -92,4 +92,15 @@
          }
       });
    }
+
+   public static ClassLoader getClassLoaderForModule(final Module module)
+   {
+      return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+      {
+         public ClassLoader run()
+         {
+            return ClassLoading.getClassLoaderForModule(module);
+         }
+      });
+   }
 }



More information about the jboss-cvs-commits mailing list