[jboss-cvs] JBossAS SVN: r94277 - in projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal: deployment and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 2 12:15:05 EDT 2009
Author: jesper.pedersen
Date: 2009-10-02 12:15:03 -0400 (Fri, 02 Oct 2009)
New Revision: 94277
Modified:
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/bootstrap/Unmarshaller.java
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployment/Unmarshaller.java
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java
Log:
Use java.net.URL and support file: and jar:
Modified: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/bootstrap/Unmarshaller.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/bootstrap/Unmarshaller.java 2009-10-02 16:08:39 UTC (rev 94276)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/bootstrap/Unmarshaller.java 2009-10-02 16:15:03 UTC (rev 94277)
@@ -26,6 +26,8 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.JarURLConnection;
+import java.net.URL;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
@@ -46,27 +48,34 @@
/**
* Unmarshal
- * @param file The file
+ * @param url The URL
* @return The result
* @exception IOException If an I/O error occurs
*/
- public Bootstrap unmarshal(File file) throws IOException
+ public Bootstrap unmarshal(URL url) throws IOException
{
- if (file == null)
- throw new IllegalArgumentException("File is null");
+ if (url == null)
+ throw new IllegalArgumentException("URL is null");
- if (!file.exists())
- throw new IOException("File doesn't exists: " + file);
-
- if (file.isDirectory())
- throw new IOException("File is a directory: " + file);
-
InputStream is = null;
try
{
Bootstrap bootstrap = new Bootstrap();
- is = new FileInputStream(file);
+ if ("file".equals(url.getProtocol()))
+ {
+ File file = new File(url.toURI());
+ is = new FileInputStream(file);
+ }
+ else if ("jar".equals(url.getProtocol()))
+ {
+ JarURLConnection jarConnection = (JarURLConnection)url.openConnection();
+ is = jarConnection.getInputStream();
+ }
+ else
+ {
+ throw new IOException("Unsupport protocol: " + url);
+ }
XMLInputFactory xmlInputFactory = null;
Modified: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployment/Unmarshaller.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployment/Unmarshaller.java 2009-10-02 16:08:39 UTC (rev 94276)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployment/Unmarshaller.java 2009-10-02 16:15:03 UTC (rev 94277)
@@ -26,7 +26,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URISyntaxException;
+import java.net.JarURLConnection;
import java.net.URL;
import javax.xml.stream.XMLInputFactory;
@@ -57,28 +57,25 @@
if (url == null)
throw new IllegalArgumentException("File is null");
- File file = null;
- try
- {
- file = new File(url.toURI());
- }
- catch (URISyntaxException use)
- {
- throw new IOException("File cant be constructed: " + file, use);
- }
-
- if (!file.exists())
- throw new IOException("File doesn't exists: " + file);
-
- if (file.isDirectory())
- throw new IOException("File is a directory: " + file);
-
InputStream is = null;
try
{
Deployment deployment = new Deployment();
- is = new FileInputStream(file);
+ if ("file".equals(url.getProtocol()))
+ {
+ File file = new File(url.toURI());
+ is = new FileInputStream(file);
+ }
+ else if ("jar".equals(url.getProtocol()))
+ {
+ JarURLConnection jarConnection = (JarURLConnection)url.openConnection();
+ is = jarConnection.getInputStream();
+ }
+ else
+ {
+ throw new IOException("Unsupport protocol: " + url);
+ }
XMLInputFactory xmlInputFactory = null;
Modified: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java 2009-10-02 16:08:39 UTC (rev 94276)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java 2009-10-02 16:15:03 UTC (rev 94277)
@@ -209,7 +209,7 @@
{
org.jboss.jca.fungal.bootstrap.Unmarshaller bootstrapU =
new org.jboss.jca.fungal.bootstrap.Unmarshaller();
- org.jboss.jca.fungal.bootstrap.Bootstrap bootstrap = bootstrapU.unmarshal(bootstrapXml);
+ org.jboss.jca.fungal.bootstrap.Bootstrap bootstrap = bootstrapU.unmarshal(bootstrapXml.toURI().toURL());
// Bootstrap urls
if (bootstrap != null)
More information about the jboss-cvs-commits
mailing list