You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2013/03/04 08:11:58 UTC
svn commit: r1452199 -
/openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianScannerService.java
Author: struberg
Date: Mon Mar 4 07:11:58 2013
New Revision: 1452199
URL: http://svn.apache.org/r1452199
Log:
OWB-710 add handling for beans.xml in a Jar Archive
Modified:
openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianScannerService.java
Modified: openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianScannerService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianScannerService.java?rev=1452199&r1=1452198&r2=1452199&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianScannerService.java (original)
+++ openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianScannerService.java Mon Mar 4 07:11:58 2013
@@ -18,7 +18,11 @@
*/
package org.apache.webbeans.arquillian.standalone;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -115,16 +119,16 @@ public class OwbArquillianScannerService
private void scanJarArchive(JavaArchive archive)
{
- Node beansXml = archive.get("META-INF/beans.xml");
+ URL beansXmlUrl = getBeanXmlUrl(archive, "META-INF/beans.xml");
- if (beansXml == null)
+ if (beansXmlUrl == null)
{
// this is not a CDI archive
return;
}
// otherwise we store it for later use
- //X TODO beansXmls.add(beansXml.getAsset())
+ beansXmls.add(beansXmlUrl);
// and now add all classes
Map<ArchivePath, Node> classes = archive.getContent(Filters.include(".*\\.class"));
@@ -156,5 +160,49 @@ public class OwbArquillianScannerService
}
+ private URL getBeanXmlUrl(Archive archive, String beansXmlPath)
+ {
+ final Node beansXml = archive.get(beansXmlPath);
+
+ try
+ {
+ String urlLocation = "archive://" + archive.getName() + beansXmlPath;
+
+ return new URL(null, urlLocation, new URLStreamHandler()
+ {
+ @Override
+ protected URLConnection openConnection(URL u) throws IOException
+ {
+ return new URLConnection(u)
+ {
+ @Override
+ public void connect() throws IOException
+ {}
+
+ @Override
+ public InputStream getInputStream() throws IOException
+ {
+ return beansXml.getAsset().openStream();
+ }
+ };
+ };
+ });
+ }
+ catch (Exception e)
+ {
+ RuntimeException runtimeException;
+ if (e instanceof RuntimeException)
+ {
+ runtimeException = (RuntimeException) e;
+ }
+ else
+ {
+ runtimeException = new RuntimeException("Error while parsing beans.xml location", e);
+ }
+
+ throw runtimeException;
+ }
+ }
+
}