You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ge...@apache.org on 2009/03/05 23:05:40 UTC

svn commit: r750623 - in /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/ lifecycle/ servlet/ spi/deployer/ spi/ee/deployer/ spi/se/deployer/ xml/

Author: gerdogdu
Date: Thu Mar  5 22:05:40 2009
New Revision: 750623

URL: http://svn.apache.org/viewvc?rev=750623&view=rev
Log:
Creating the SPI for the beans discovery process. Adding the MetaDataDiscoveryService as the main
SPI interface.

Added:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/MetaDataDiscoveryService.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/EJBMetaDataDiscoveryImpl.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/deployer/
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/deployer/MetaDataDiscoveryStandard.java   (with props)
Removed:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansScanner.java
Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java?rev=750623&r1=750622&r2=750623&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java Thu Mar  5 22:05:40 2009
@@ -39,6 +39,7 @@
 import org.apache.webbeans.deployment.StereoTypeModel;
 import org.apache.webbeans.exception.WebBeansDeploymentException;
 import org.apache.webbeans.logger.WebBeansLogger;
+import org.apache.webbeans.spi.deployer.MetaDataDiscoveryService;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
@@ -73,7 +74,7 @@
      * 
      * @throws WebBeansDeploymentException if any deployment exception occurs
      */
-    public void deploy(WebBeansScanner scanner) throws WebBeansDeploymentException
+    public void deploy(MetaDataDiscoveryService scanner) throws WebBeansDeploymentException
     {
         try
         {
@@ -151,7 +152,7 @@
         logger.info("Injection points are validated succesfully");
     }
 
-    protected void deployFromClassPath(WebBeansScanner scanner) throws ClassNotFoundException
+    protected void deployFromClassPath(MetaDataDiscoveryService scanner) throws ClassNotFoundException
     {
         logger.info("Deploying configurations from class files is started");
 
@@ -185,7 +186,7 @@
 
     }
 
-    protected void deployFromXML(WebBeansScanner scanner)
+    protected void deployFromXML(MetaDataDiscoveryService scanner)
     {
         logger.info("Deploying configurations from XML files is started");
 
@@ -202,7 +203,7 @@
         logger.info("Deploying configurations from XML is ended succesfully");
     }
 
-    protected void configureInterceptors(WebBeansScanner scanner) throws ClassNotFoundException
+    protected void configureInterceptors(MetaDataDiscoveryService scanner) throws ClassNotFoundException
     {
         logger.info("Configuring the Interceptors is started");
 
@@ -226,7 +227,7 @@
 
     }
 
-    protected void configureDecorators(WebBeansScanner scanner) throws ClassNotFoundException
+    protected void configureDecorators(MetaDataDiscoveryService scanner) throws ClassNotFoundException
     {
         logger.info("Configuring the Decorators is started");
 
@@ -248,7 +249,7 @@
 
     }
 
-    protected void checkSpecializations(WebBeansScanner scanner)
+    protected void checkSpecializations(MetaDataDiscoveryService scanner)
     {
         logger.info("Checking Specialization constraints is started");
 
@@ -346,7 +347,7 @@
         }
     }
 
-    protected void checkStereoTypes(WebBeansScanner scanner)
+    protected void checkStereoTypes(MetaDataDiscoveryService scanner)
     {
         logger.info("Checking StereoTypes constraints is started");
 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java?rev=750623&r1=750622&r2=750623&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java Thu Mar  5 22:05:40 2009
@@ -30,7 +30,6 @@
 import org.apache.webbeans.WebBeansConstants;
 import org.apache.webbeans.config.WebBeansContainerDeployer;
 import org.apache.webbeans.config.WebBeansFinder;
-import org.apache.webbeans.config.WebBeansScanner;
 import org.apache.webbeans.container.ManagerImpl;
 import org.apache.webbeans.context.ContextFactory;
 import org.apache.webbeans.el.WebBeansELResolver;
@@ -39,6 +38,7 @@
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.spi.JNDIService;
 import org.apache.webbeans.spi.ServiceLoader;
+import org.apache.webbeans.spi.deployer.MetaDataDiscoveryService;
 import org.apache.webbeans.xml.WebBeansXMLConfigurator;
 
 public final class WebBeansLifeCycle
@@ -47,7 +47,7 @@
 
     private ScheduledExecutorService service = null;
 
-    private WebBeansScanner scanner = null;
+    private MetaDataDiscoveryService discovery = null;
 
     private WebBeansContainerDeployer deployer = null;
 
@@ -57,7 +57,6 @@
 
     public WebBeansLifeCycle()
     {
-        this.scanner = new WebBeansScanner();
         this.xmlDeployer = new WebBeansXMLConfigurator();
         this.deployer = new WebBeansContainerDeployer(xmlDeployer);
         this.jndiService = ServiceLoader.getService(JNDIService.class);
@@ -94,6 +93,9 @@
 
     public void applicationStarted(ServletContextEvent event)
     {
+        this.discovery = ServiceLoader.getService(MetaDataDiscoveryService.class);
+        this.discovery.init(event.getServletContext());
+        
         // I do not know this is the correct way, spec is not so explicit.
         service = Executors.newScheduledThreadPool(1);
         service.scheduleWithFixedDelay(new Runnable()
@@ -112,13 +114,13 @@
 
         logger.info("Scanning classpaths for WebBeans artifacts is started");
 
-        scanner.scan(event.getServletContext());
+        this.discovery.scan();
 
         logger.info("Scanning is ended.");
 
         logger.info("Deploying the scanned WebBeans artifacts.");
 
-        deployer.deploy(this.scanner);
+        deployer.deploy(this.discovery);
 
         logger.info("Deploying is ended.");
 
@@ -135,7 +137,8 @@
         {
             // check this application is JSF application
             URL url = context.getResource("/WEB-INF/faces-config.xml");
-            if (url == null)
+            URL urlWeb = context.getResource("/WEB-INF/web.xml");
+            if (url == null && urlWeb != null)
             {
                 JspApplicationContext applicationCtx = JspFactory.getDefaultFactory().getJspApplicationContext(context);
                 applicationCtx.addELResolver(new WebBeansELResolver());
@@ -160,7 +163,7 @@
         jndiService.unbind(WebBeansConstants.WEB_BEANS_MANAGER_JNDI_NAME);
 
         this.deployer = null;
-        this.scanner = null;
+        this.discovery = null;
         this.service = null;
         this.xmlDeployer = null;
         

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java?rev=750623&r1=750622&r2=750623&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java Thu Mar  5 22:05:40 2009
@@ -39,6 +39,7 @@
     public void contextDestroyed(ServletContextEvent event)
     {
         this.lifeCycle.applicationEnded(event);
+        this.lifeCycle = null;
     }
 
     /**

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java?rev=750623&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java Thu Mar  5 22:05:40 2009
@@ -0,0 +1,100 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.apache.webbeans.spi.deployer;
+
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.exception.WebBeansDeploymentException;
+import org.scannotation.AnnotationDB;
+
+public abstract class AbstractMetaDataDiscovery implements MetaDataDiscoveryService
+{
+    /** Location of the beans.xml files. */
+    protected Map<String, InputStream> WEBBEANS_XML_LOCATIONS = new HashMap<String, InputStream>();
+
+    //private Map<String, InputStream> EJB_XML_LOCATIONS = new HashMap<String, InputStream>();
+
+    /** Annotation Database */
+    protected AnnotationDB ANNOTATION_DB = null;
+
+    protected AbstractMetaDataDiscovery()
+    {
+        try
+        {
+            if (ANNOTATION_DB == null)
+            {
+                ANNOTATION_DB = new AnnotationDB();
+                ANNOTATION_DB.setScanClassAnnotations(true);
+                ANNOTATION_DB.crossReferenceMetaAnnotations();    
+            }            
+            
+        }
+        catch(Exception e)
+        {
+            throw new WebBeansDeploymentException(e);
+        }                
+    }
+    
+    /**
+     * Configure the Web Beans Container with deployment information and fills
+     * annotation database and beans.xml stream database.
+     * 
+     * @throws WebBeansConfigurationException if any run time exception occurs
+     */
+    public void scan() throws WebBeansDeploymentException
+    {
+        try
+        {
+            configure();
+        }
+        catch (Exception e)
+        {
+            throw new WebBeansDeploymentException(e);
+        }
+    }
+    
+    
+    abstract protected void configure() throws Exception;
+    
+    public void init(Object object)
+    {
+        
+    }
+    
+    /**
+     * @return the wEBBEANS_XML_LOCATIONS
+     */
+    public Map<String, InputStream> getWEBBEANS_XML_LOCATIONS()
+    {
+        return WEBBEANS_XML_LOCATIONS;
+    }
+
+    /**
+     * @return the aNNOTATION_DB
+     */
+    public AnnotationDB getANNOTATION_DB()
+    {
+        return ANNOTATION_DB;
+    }
+    
+    
+    
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/MetaDataDiscoveryService.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/MetaDataDiscoveryService.java?rev=750623&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/MetaDataDiscoveryService.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/MetaDataDiscoveryService.java Thu Mar  5 22:05:40 2009
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.apache.webbeans.spi.deployer;
+
+import java.io.InputStream;
+import java.util.Map;
+
+import org.apache.webbeans.exception.WebBeansDeploymentException;
+import org.scannotation.AnnotationDB;
+
+public interface MetaDataDiscoveryService
+{
+    public void scan() throws WebBeansDeploymentException;
+    
+    public Map<String, InputStream> getWEBBEANS_XML_LOCATIONS();
+    
+    public AnnotationDB getANNOTATION_DB();
+    
+    public void init(Object object);
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/MetaDataDiscoveryService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/EJBMetaDataDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/EJBMetaDataDiscoveryImpl.java?rev=750623&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/EJBMetaDataDiscoveryImpl.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/EJBMetaDataDiscoveryImpl.java Thu Mar  5 22:05:40 2009
@@ -0,0 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.apache.webbeans.spi.ee.deployer;
+
+public interface EJBMetaDataDiscoveryImpl
+{
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/EJBMetaDataDiscoveryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java?rev=750623&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java Thu Mar  5 22:05:40 2009
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You 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.apache.webbeans.spi.ee.deployer;
+
+import java.net.URL;
+import java.util.HashSet;
+
+import java.util.Set;
+
+import javax.servlet.ServletContext;
+
+import org.apache.webbeans.logger.WebBeansLogger;
+import org.apache.webbeans.spi.deployer.AbstractMetaDataDiscovery;
+import org.apache.webbeans.util.WebBeansUtil;
+import org.scannotation.ClasspathUrlFinder;
+import org.scannotation.WarUrlFinder;
+
+/**
+ * Configures the web application to find beans.
+ */
+public class WarMetaDataDiscoveryImpl extends AbstractMetaDataDiscovery
+{
+    private WebBeansLogger logger = WebBeansLogger.getLogger(WarMetaDataDiscoveryImpl.class);
+
+    private boolean configure = false;
+
+    private ServletContext servletContext = null;
+
+    public WarMetaDataDiscoveryImpl()
+    {
+        
+    }
+
+    public void init(Object context)
+    {
+        this.servletContext = (ServletContext) context;        
+    }
+    
+    protected void configure() throws Exception
+    {
+        try
+        {
+            if (!configure)
+            {
+                Set<URL> arcs = getArchieves();
+                URL[] urls = new URL[arcs.size()];
+                arcs.toArray(urls);
+
+                ANNOTATION_DB.scanArchives(urls);
+                configure = true;
+            }
+
+        }
+        catch (Exception e)
+        {
+            logger.error("Initializing of the WebBeans container is failed.", e);
+            throw e;
+        }
+
+    }
+
+    /* Collects all URLs */
+    private Set<URL> getArchieves() throws Exception
+    {
+        Set<URL> lists = createURLFromMarkerFile();
+        URL warUrl = createURLFromWARFile();
+
+        if (warUrl != null)
+        {
+            lists.add(warUrl);
+        }
+
+        return lists;
+    }
+
+    /* Creates URLs from the marker file */
+    private Set<URL> createURLFromMarkerFile() throws Exception
+    {
+        Set<URL> listURL = new HashSet<URL>();
+        URL[] urls = null;
+
+        // Root with beans.xml marker.
+        urls = ClasspathUrlFinder.findResourceBases("META-INF/beans.xml", WebBeansUtil.getCurrentClassLoader());
+
+        if (urls != null)
+        {
+            for (URL url : urls)
+            {
+
+                URL addPath = null;
+
+                String fileDir = url.getFile();
+                if (fileDir.endsWith(".jar!/"))
+                {
+                    fileDir = fileDir.substring(0, fileDir.lastIndexOf("/")) + "/META-INF/beans.xml";
+                    addPath = new URL("jar:" + fileDir);
+                }
+                else
+                {
+                    addPath = new URL("file:" + url.getFile() + "META-INF/beans.xml");
+                }
+
+                listURL.add(url);
+
+                WEBBEANS_XML_LOCATIONS.put(addPath.getFile(), addPath.openStream());
+            }
+        }
+
+        return listURL;
+    }
+
+    private URL createURLFromWARFile() throws Exception
+    {
+        URL url = this.servletContext.getResource("/WEB-INF/beans.xml");
+
+        if (url != null)
+        {
+            WEBBEANS_XML_LOCATIONS.put(url.getFile(), url.openStream());
+
+            return WarUrlFinder.findWebInfClassesPath(this.servletContext);
+        }
+
+        return null;
+    }
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/deployer/MetaDataDiscoveryStandard.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/deployer/MetaDataDiscoveryStandard.java?rev=750623&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/deployer/MetaDataDiscoveryStandard.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/deployer/MetaDataDiscoveryStandard.java Thu Mar  5 22:05:40 2009
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You 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.apache.webbeans.spi.se.deployer;
+
+import java.io.IOException;
+
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Enumeration;
+
+import org.apache.webbeans.spi.deployer.AbstractMetaDataDiscovery;
+
+import org.scannotation.ClasspathUrlFinder;
+
+public class MetaDataDiscoveryStandard extends AbstractMetaDataDiscovery
+{
+    public MetaDataDiscoveryStandard()
+    {
+        super();
+    }
+
+    protected void configure() throws Exception
+    {
+        configureAnnotationDB();
+    }
+
+    private void configureAnnotationDB() throws Exception
+    {
+        ClassLoader loader = null;
+
+        loader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+        {
+
+            public ClassLoader run()
+            {
+                try
+                {
+                    return Thread.currentThread().getContextClassLoader();
+
+                }
+                catch (Exception e)
+                {
+                    return null;
+                }
+            }
+
+        });
+
+        if (loader == null)
+        {
+            loader = this.getClass().getClassLoader();
+        }
+
+        URL[] urls = ClasspathUrlFinder.findResourceBases("META-INF/beans.xml", loader);
+        this.ANNOTATION_DB.scanArchives(urls);
+
+        configureXML();
+
+    }
+
+    private void configureXML() throws Exception
+    {
+        try
+        {
+            Enumeration<URL> resources = getClass().getClassLoader().getResources("META-INF/beans.xml");
+
+            while (resources.hasMoreElements())
+            {
+                URL resource = resources.nextElement();
+                this.WEBBEANS_XML_LOCATIONS.put(resource.getFile(), resource.openStream());
+            }
+
+        }
+        catch (IOException e)
+        {
+            throw e;
+        }
+    }
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/deployer/MetaDataDiscoveryStandard.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java?rev=750623&r1=750622&r2=750623&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java Thu Mar  5 22:05:40 2009
@@ -13,6 +13,7 @@
  */
 package org.apache.webbeans.xml;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
@@ -109,7 +110,18 @@
     
     public void configure(InputStream xmlStream)
     {
-        configure(xmlStream, "No-name XML Stream");
+        try
+        {
+            if(xmlStream.available() > 0)
+            {
+                configure(xmlStream, "No-name XML Stream");    
+            }
+        }
+        catch (IOException e)
+        {
+            throw new WebBeansConfigurationException(e);
+        }
+        
     }
 
     /**