felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r825093 - in /felix/trunk: fileinstall/src/main/java/org/apache/felix/fileinstall/ fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/ karaf/depl...
Date Wed, 14 Oct 2009 11:46:43 GMT
Author: gnodet
Date: Wed Oct 14 11:46:42 2009
New Revision: 825093

URL: http://svn.apache.org/viewvc?rev=825093&view=rev
Log:
FELIX-1715: osgi:update can not be used on transformed artifacts

Added:
    felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/ArtifactUrlTransformer.java
    felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/JarDirUrlHandler.java
Modified:
    felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Artifact.java
    felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/BundleTransformer.java
    felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
    felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/FileInstall.java
    felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Util.java
    felix/trunk/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintDeploymentListener.java
    felix/trunk/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintURLHandler.java
    felix/trunk/karaf/deployer/blueprint/src/main/resources/OSGI-INF/blueprint/blueprint-deployer.xml
    felix/trunk/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringDeploymentListener.java
    felix/trunk/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringURLHandler.java
    felix/trunk/karaf/deployer/spring/src/main/resources/OSGI-INF/blueprint/spring-deployer.xml

Added: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/ArtifactUrlTransformer.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/ArtifactUrlTransformer.java?rev=825093&view=auto
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/ArtifactUrlTransformer.java
(added)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/ArtifactUrlTransformer.java
Wed Oct 14 11:46:42 2009
@@ -0,0 +1,37 @@
+/**
+ *
+ * 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.felix.fileinstall;
+
+import java.net.URL;
+
+/**
+ * Objects implementing this interface are able to convert certain
+ * kind of artifacts to OSGi bundles on the fly through an URL handler.
+ *
+ * This kind of artifact listener should be favored over the {@link ArtifactTransformer}
+ * because it allows the use of the OSGi update feature on bundles.
+ */
+public interface ArtifactUrlTransformer extends ArtifactListener {
+
+    /**
+     * Process the given file (canHandle returned true previously)
+     * Can return <null> or a pointer to a transformed file.
+     */
+     URL transform(URL artifact) throws Exception;
+
+}
\ No newline at end of file

Modified: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Artifact.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Artifact.java?rev=825093&r1=825092&r2=825093&view=diff
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Artifact.java
(original)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Artifact.java
Wed Oct 14 11:46:42 2009
@@ -19,6 +19,7 @@
 package org.apache.felix.fileinstall.internal;
 
 import java.io.File;
+import java.net.URL;
 
 import org.apache.felix.fileinstall.ArtifactListener;
 
@@ -29,7 +30,9 @@
 
     private File path;
     private File jaredDirectory;
+    private URL jaredUrl;
     private ArtifactListener listener;
+    private URL transformedUrl;
     private File transformed;
     private long bundleId = -1;
     private long checksum;
@@ -50,6 +53,14 @@
         this.jaredDirectory = jaredDirectory;
     }
 
+    public URL getJaredUrl() {
+        return jaredUrl;
+    }
+
+    public void setJaredUrl(URL jaredUrl) {
+        this.jaredUrl = jaredUrl;
+    }
+
     public ArtifactListener getListener() {
         return listener;
     }
@@ -66,6 +77,14 @@
         this.transformed = transformed;
     }
 
+    public URL getTransformedUrl() {
+        return transformedUrl;
+    }
+
+    public void setTransformedUrl(URL transformedUrl) {
+        this.transformedUrl = transformedUrl;
+    }
+
     public long getBundleId() {
         return bundleId;
     }

Modified: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/BundleTransformer.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/BundleTransformer.java?rev=825093&r1=825092&r2=825093&view=diff
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/BundleTransformer.java
(original)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/BundleTransformer.java
Wed Oct 14 11:46:42 2009
@@ -20,16 +20,18 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.net.URL;
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
 import java.util.jar.Attributes;
 
 import org.apache.felix.fileinstall.ArtifactTransformer;
+import org.apache.felix.fileinstall.ArtifactUrlTransformer;
 
 /**
- * ArtifactTransformer for plain bundles.
+ * ArtifactUrlTransformer for plain bundles.
  */
-public class BundleTransformer implements ArtifactTransformer
+public class BundleTransformer implements ArtifactUrlTransformer
 {
     public boolean canHandle(File artifact)
     {
@@ -75,7 +77,7 @@
         return false;
     }
 
-    public File transform(File artifact, File tmpDir) {
+    public URL transform(URL artifact) {
         return artifact;
     }
 

Modified: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java?rev=825093&r1=825092&r2=825093&view=diff
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
(original)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
Wed Oct 14 11:46:42 2009
@@ -23,8 +23,10 @@
 import java.io.FilenameFilter;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Dictionary;
@@ -38,6 +40,7 @@
 import org.apache.felix.fileinstall.ArtifactInstaller;
 import org.apache.felix.fileinstall.ArtifactListener;
 import org.apache.felix.fileinstall.ArtifactTransformer;
+import org.apache.felix.fileinstall.ArtifactUrlTransformer;
 import org.apache.felix.fileinstall.internal.Util;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -222,6 +225,15 @@
             else
             {
                 File jar  = file;
+                URL jaredUrl = null;
+                try
+                {
+                    jaredUrl = file.toURI().toURL();
+                }
+                catch (MalformedURLException e)
+                {
+                    // Ignore, can't happen
+                }
                 // Jar up the directory if needed
                 if (file.isDirectory())
                 {
@@ -230,6 +242,7 @@
                     {
                         jar = new File(tmpDir, file.getName() + ".jar");
                         Util.jarDir(file, jar);
+                        jaredUrl = new URL(JarDirUrlHandler.PROTOCOL, null, file.getPath());
 
                     }
                     catch (IOException e)
@@ -268,6 +281,7 @@
                     {
                         deleteTransformedFile(artifact);
                         artifact.setJaredDirectory(jar);
+                        artifact.setJaredUrl(jaredUrl);
                         if (transformArtifact(artifact))
                         {
                             modified.add(artifact);
@@ -296,6 +310,7 @@
                     artifact = new Artifact();
                     artifact.setPath(file);
                     artifact.setJaredDirectory(jar);
+                    artifact.setJaredUrl(jaredUrl);
                     artifact.setListener(listener);
                     artifact.setChecksum(scanner.getChecksum(file));
                     if (transformArtifact(artifact))
@@ -345,7 +360,8 @@
         return null;
     }
 
-    boolean transformArtifact(Artifact artifact) {
+    boolean transformArtifact(Artifact artifact)
+    {
         if (artifact.getListener() instanceof ArtifactTransformer)
         {
             prepareDir(tmpDir);
@@ -364,10 +380,29 @@
             }
             return false;
         }
+        else if (artifact.getListener() instanceof ArtifactUrlTransformer)
+        {
+            try
+            {
+                URL url = artifact.getJaredUrl();
+                URL transformed = ((ArtifactUrlTransformer) artifact.getListener()).transform(url);
+                if (transformed != null)
+                {
+                    artifact.setTransformedUrl(transformed);
+                    return true;
+                }
+            }
+            catch (Exception e)
+            {
+                log("Unable to transform artifact: " + artifact.getPath().getAbsolutePath(),
e);
+            }
+            return false;
+        }
         return true;
     }
 
-    private void deleteTransformedFile(Artifact artifact) {
+    private void deleteTransformedFile(Artifact artifact)
+    {
         if (artifact.getTransformed() != null
                 && !artifact.getTransformed().equals(artifact.getPath())
                 && !artifact.getTransformed().delete())
@@ -673,6 +708,18 @@
             {
                 ((ArtifactInstaller) artifact.getListener()).install(path);
             }
+            // if the listener is an url transformer
+            else if (artifact.getListener() instanceof ArtifactUrlTransformer)
+            {
+                URL transformed = artifact.getTransformedUrl();
+                Artifact badArtifact = (Artifact) installationFailures.get(artifact.getPath());
+                if (badArtifact != null && badArtifact.getChecksum() == artifact.getChecksum())
+                {
+                    return null; // Don't attempt to install it; nothing has changed.
+                }
+                bundle = context.installBundle(transformed.toString());
+                artifact.setBundleId(bundle.getBundleId());
+            }
             // else we need to ask for an update on the bundle
             else if (artifact.getListener() instanceof ArtifactTransformer)
             {
@@ -769,6 +816,20 @@
             {
                 ((ArtifactInstaller) artifact.getListener()).update(path);
             }
+            // if the listener is an url transformer
+            else if (artifact.getListener() instanceof ArtifactUrlTransformer)
+            {
+                bundle = context.getBundle(artifact.getBundleId());
+                if (bundle == null)
+                {
+                    log("Failed to update bundle: "
+                        + path + " with ID "
+                        + artifact.getBundleId()
+                        + ". The bundle has been uninstalled", null);
+                    return null;
+                }
+                bundle.update();
+            }
             // else we need to ask for an update on the bundle
             else if (artifact.getListener() instanceof ArtifactTransformer)
             {

Modified: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/FileInstall.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/FileInstall.java?rev=825093&r1=825092&r2=825093&view=diff
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/FileInstall.java
(original)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/FileInstall.java
Wed Oct 14 11:46:42 2009
@@ -26,15 +26,19 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.imageio.spi.ServiceRegistry;
+
 import org.apache.felix.fileinstall.ArtifactInstaller;
 import org.apache.felix.fileinstall.ArtifactListener;
 import org.apache.felix.fileinstall.ArtifactTransformer;
+import org.apache.felix.fileinstall.ArtifactUrlTransformer;
 import org.apache.felix.fileinstall.internal.Util;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedServiceFactory;
@@ -65,8 +69,10 @@
         addListener(new BundleTransformer());
         Hashtable props = new Hashtable();
         props.put(Constants.SERVICE_PID, getName());
-        context.registerService(ManagedServiceFactory.class.getName(), this,
-            props);
+        context.registerService(ManagedServiceFactory.class.getName(), this, props);
+        props = new Hashtable();
+        props.put("url.handler.protocol", JarDirUrlHandler.PROTOCOL);
+        context.registerService(org.osgi.service.url.URLStreamHandlerService.class.getName(),
new JarDirUrlHandler(), props);
 
         padmin = new ServiceTracker(context, PackageAdmin.class.getName(), null);
         padmin.open();
@@ -90,7 +96,8 @@
         };
         cmTracker.open();
         String flt = "(|(" + Constants.OBJECTCLASS + "=" + ArtifactInstaller.class.getName()
+ ")"
-                     + "(" + Constants.OBJECTCLASS + "=" + ArtifactTransformer.class.getName()
+ "))";
+                     + "(" + Constants.OBJECTCLASS + "=" + ArtifactTransformer.class.getName()
+ ")"
+                     + "(" + Constants.OBJECTCLASS + "=" + ArtifactUrlTransformer.class.getName()
+ "))";
         listenersTracker = new ServiceTracker(context, FrameworkUtil.createFilter(flt), null)
         {
             public Object addingService(ServiceReference serviceReference)

Added: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/JarDirUrlHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/JarDirUrlHandler.java?rev=825093&view=auto
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/JarDirUrlHandler.java
(added)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/JarDirUrlHandler.java
Wed Oct 14 11:46:42 2009
@@ -0,0 +1,107 @@
+/**
+ *
+ * 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.felix.fileinstall.internal;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.osgi.service.url.AbstractURLStreamHandlerService;
+
+/**
+ * A URL handler that can jar a directory on the fly
+ */
+public class JarDirUrlHandler extends AbstractURLStreamHandlerService
+{
+
+    public static final String PROTOCOL = "jardir";
+
+    private static final String SYNTAX = PROTOCOL + ": file";
+
+    /**
+     * Open the connection for the given URL.
+     *
+     * @param url the url from which to open a connection.
+     * @return a connection on the specified URL.
+     * @throws java.io.IOException if an error occurs or if the URL is malformed.
+     */
+	public URLConnection openConnection(URL url) throws IOException
+    {
+		if (url.getPath() == null || url.getPath().trim().length() == 0)
+        {
+			throw new MalformedURLException("Path can not be null or empty. Syntax: " + SYNTAX );
+		}
+		return new Connection(url);
+	}
+
+    public class Connection extends URLConnection
+    {
+
+        public Connection(URL url)
+        {
+            super(url);
+        }
+
+        public void connect() throws IOException
+        {
+        }
+
+        public InputStream getInputStream() throws IOException
+        {
+            try
+            {
+                final PipedOutputStream pos = new PipedOutputStream();
+                final PipedInputStream pis = new PipedInputStream(pos);
+                new Thread()
+                {
+                    public void run()
+                    {
+                        try
+                        {
+                            Util.jarDir(new File(getURL().getPath()), pos);
+                        }
+                        catch (IOException e)
+                        {
+                            try
+                            {
+                                pos.close();
+                            }
+                            catch (IOException e2)
+                            {
+                                // Ignore
+                            }
+                        }
+                    }
+                }.start();
+                return pis;
+            }
+            catch (Exception e)
+            {
+                throw (IOException) new IOException("Error opening spring xml url").initCause(e);
+            }
+        }
+    }
+
+}

Modified: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Util.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Util.java?rev=825093&r1=825092&r2=825093&view=diff
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Util.java
(original)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Util.java
Wed Oct 14 11:46:42 2009
@@ -25,6 +25,7 @@
 import java.io.File;
 import java.io.BufferedOutputStream;
 import java.io.FileOutputStream;
+import java.io.OutputStream;
 import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.Map;
@@ -281,8 +282,12 @@
      * @throws IOException
      */
     public static void jarDir(File directory, File zipName) throws IOException {
+        jarDir(directory, new BufferedOutputStream(new FileOutputStream(zipName)));
+    }
+
+    public static void jarDir(File directory, OutputStream os) throws IOException {
         // create a ZipOutputStream to zip the data to
-        JarOutputStream zos = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(zipName)));
+        JarOutputStream zos = new JarOutputStream(os);
         String path = "";
         File manFile = new File(directory, JarFile.MANIFEST_NAME);
         if (manFile.exists()) {

Modified: felix/trunk/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintDeploymentListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintDeploymentListener.java?rev=825093&r1=825092&r2=825093&view=diff
==============================================================================
--- felix/trunk/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintDeploymentListener.java
(original)
+++ felix/trunk/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintDeploymentListener.java
Wed Oct 14 11:46:42 2009
@@ -19,6 +19,7 @@
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.net.URL;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -28,6 +29,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.felix.fileinstall.ArtifactTransformer;
+import org.apache.felix.fileinstall.ArtifactUrlTransformer;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXParseException;
 import org.xml.sax.SAXException;
@@ -36,7 +38,7 @@
  * A deployment listener that listens for spring xml applications
  * and creates bundles for these.
  */
-public class BlueprintDeploymentListener implements ArtifactTransformer {
+public class BlueprintDeploymentListener implements ArtifactUrlTransformer {
 
 
     private static final Log LOGGER = LogFactory.getLog(BlueprintDeploymentListener.class);
@@ -59,13 +61,9 @@
         return false;
     }
 
-    public File transform(File artifact, File tmpDir) {
+    public URL transform(URL artifact) {
         try {
-            File destFile = new File(tmpDir, artifact.getName() + ".jar");
-            FileOutputStream os = new FileOutputStream(destFile);
-            BlueprintTransformer.transform(artifact.toURL(), os);
-            os.close();
-            return destFile;
+            return new URL("blueprint", null, artifact.toString());
         } catch (Exception e) {
             LOGGER.error("Unable to build blueprint application bundle", e);
             return null;

Modified: felix/trunk/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintURLHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintURLHandler.java?rev=825093&r1=825092&r2=825093&view=diff
==============================================================================
--- felix/trunk/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintURLHandler.java
(original)
+++ felix/trunk/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintURLHandler.java
Wed Oct 14 11:46:42 2009
@@ -17,6 +17,8 @@
  */
 package org.apache.felix.karaf.deployer.blueprint;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -56,7 +58,7 @@
 		}
 		blueprintXmlURL = new URL(url.getPath());
 
-		logger.debug("Spring xml URL is: [" + blueprintXmlURL + "]");
+		logger.debug("Blueprint xml URL is: [" + blueprintXmlURL + "]");
 		return new Connection(url);
 	}
 	
@@ -77,19 +79,13 @@
         @Override
         public InputStream getInputStream() throws IOException {
             try {
-                final File f = File.createTempFile("smx", "xml");
-                FileOutputStream os = new FileOutputStream(f);
+                ByteArrayOutputStream os = new ByteArrayOutputStream();
                 BlueprintTransformer.transform(blueprintXmlURL, os);
                 os.close();
-                return new FileInputStream(f) {
-                    public void close() throws IOException {
-                        super.close();
-                        f.delete();
-                    }
-                };
+                return new ByteArrayInputStream(os.toByteArray());
             } catch (Exception e) {
-                logger.error("Error opening spring xml url", e);
-                throw (IOException) new IOException("Error opening spring xml url").initCause(e);
+                logger.error("Error opening blueprint xml url", e);
+                throw (IOException) new IOException("Error opening blueprint xml url").initCause(e);
             }
         }
     }

Modified: felix/trunk/karaf/deployer/blueprint/src/main/resources/OSGI-INF/blueprint/blueprint-deployer.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/deployer/blueprint/src/main/resources/OSGI-INF/blueprint/blueprint-deployer.xml?rev=825093&r1=825092&r2=825093&view=diff
==============================================================================
--- felix/trunk/karaf/deployer/blueprint/src/main/resources/OSGI-INF/blueprint/blueprint-deployer.xml
(original)
+++ felix/trunk/karaf/deployer/blueprint/src/main/resources/OSGI-INF/blueprint/blueprint-deployer.xml
Wed Oct 14 11:46:42 2009
@@ -17,8 +17,7 @@
     limitations under the License.
 
 -->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
-           xmlns:cm="http://geronimo.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0">
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
 
     <service auto-export="interfaces">
         <bean class="org.apache.felix.karaf.deployer.blueprint.BlueprintDeploymentListener"/>

Modified: felix/trunk/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringDeploymentListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringDeploymentListener.java?rev=825093&r1=825092&r2=825093&view=diff
==============================================================================
--- felix/trunk/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringDeploymentListener.java
(original)
+++ felix/trunk/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringDeploymentListener.java
Wed Oct 14 11:46:42 2009
@@ -19,6 +19,7 @@
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.net.URL;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -28,6 +29,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.felix.fileinstall.ArtifactTransformer;
+import org.apache.felix.fileinstall.ArtifactUrlTransformer;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXParseException;
 import org.xml.sax.SAXException;
@@ -36,7 +38,7 @@
  * A deployment listener that listens for spring xml applications
  * and creates bundles for these.
  */
-public class SpringDeploymentListener implements ArtifactTransformer {
+public class SpringDeploymentListener implements ArtifactUrlTransformer {
 
     private static final Log LOGGER = LogFactory.getLog(SpringDeploymentListener.class);
 
@@ -58,13 +60,9 @@
         return false;
     }
 
-    public File transform(File artifact, File tmpDir) {
+    public URL transform(URL artifact) {
         try {
-            File destFile = new File(tmpDir, artifact.getName() + ".jar");
-            FileOutputStream os = new FileOutputStream(destFile);
-            SpringTransformer.transform(artifact.toURL(), os);
-            os.close();
-            return destFile;
+            return new URL("spring", null, artifact.toString());
         } catch (Exception e) {
             LOGGER.error("Unable to build spring application bundle", e);
             return null;

Modified: felix/trunk/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringURLHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringURLHandler.java?rev=825093&r1=825092&r2=825093&view=diff
==============================================================================
--- felix/trunk/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringURLHandler.java
(original)
+++ felix/trunk/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringURLHandler.java
Wed Oct 14 11:46:42 2009
@@ -17,6 +17,8 @@
  */
 package org.apache.felix.karaf.deployer.spring;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -77,16 +79,10 @@
         @Override
         public InputStream getInputStream() throws IOException {
             try {
-                final File f = File.createTempFile("smx", "xml");
-                FileOutputStream os = new FileOutputStream(f);
+                ByteArrayOutputStream os = new ByteArrayOutputStream();
                 SpringTransformer.transform(springXmlURL, os);
                 os.close();
-                return new FileInputStream(f) {
-                    public void close() throws IOException {
-                        super.close();
-                        f.delete();
-                    }
-                };
+                return new ByteArrayInputStream(os.toByteArray());
             } catch (Exception e) {
                 logger.error("Error opening spring xml url", e);
                 throw (IOException) new IOException("Error opening spring xml url").initCause(e);

Modified: felix/trunk/karaf/deployer/spring/src/main/resources/OSGI-INF/blueprint/spring-deployer.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/deployer/spring/src/main/resources/OSGI-INF/blueprint/spring-deployer.xml?rev=825093&r1=825092&r2=825093&view=diff
==============================================================================
--- felix/trunk/karaf/deployer/spring/src/main/resources/OSGI-INF/blueprint/spring-deployer.xml
(original)
+++ felix/trunk/karaf/deployer/spring/src/main/resources/OSGI-INF/blueprint/spring-deployer.xml
Wed Oct 14 11:46:42 2009
@@ -17,8 +17,7 @@
     limitations under the License.
 
 -->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
-           xmlns:cm="http://geronimo.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0">
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
 
     <service auto-export="interfaces">
         <bean class="org.apache.felix.karaf.deployer.spring.SpringDeploymentListener"/>



Mime
View raw message