servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r614302 - in /servicemix/smx4/kernel/trunk: ./ assembly/ assembly/src/main/descriptors/ assembly/src/main/filtered-resources/etc/ filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/ spring/ spring/src/ spring/src/main/ sprin...
Date Tue, 22 Jan 2008 20:09:55 GMT
Author: gnodet
Date: Tue Jan 22 12:09:53 2008
New Revision: 614302

URL: http://svn.apache.org/viewvc?rev=614302&view=rev
Log:
SMX4KNL-14: Add a plain spring application deployer

Added:
    servicemix/smx4/kernel/trunk/spring/   (with props)
    servicemix/smx4/kernel/trunk/spring/pom.xml
    servicemix/smx4/kernel/trunk/spring/src/
    servicemix/smx4/kernel/trunk/spring/src/main/
    servicemix/smx4/kernel/trunk/spring/src/main/java/
    servicemix/smx4/kernel/trunk/spring/src/main/java/org/
    servicemix/smx4/kernel/trunk/spring/src/main/java/org/apache/
    servicemix/smx4/kernel/trunk/spring/src/main/java/org/apache/servicemix/
    servicemix/smx4/kernel/trunk/spring/src/main/java/org/apache/servicemix/kernel/
    servicemix/smx4/kernel/trunk/spring/src/main/java/org/apache/servicemix/kernel/spring/
    servicemix/smx4/kernel/trunk/spring/src/main/java/org/apache/servicemix/kernel/spring/SpringDeploymentListener.java
    servicemix/smx4/kernel/trunk/spring/src/main/resources/
    servicemix/smx4/kernel/trunk/spring/src/main/resources/META-INF/
    servicemix/smx4/kernel/trunk/spring/src/main/resources/META-INF/spring/
    servicemix/smx4/kernel/trunk/spring/src/main/resources/META-INF/spring/spring-deployer.xml
    servicemix/smx4/kernel/trunk/spring/src/test/
    servicemix/smx4/kernel/trunk/spring/src/test/java/
    servicemix/smx4/kernel/trunk/spring/src/test/java/org/
    servicemix/smx4/kernel/trunk/spring/src/test/java/org/apache/
    servicemix/smx4/kernel/trunk/spring/src/test/java/org/apache/servicemix/
    servicemix/smx4/kernel/trunk/spring/src/test/java/org/apache/servicemix/kernel/
    servicemix/smx4/kernel/trunk/spring/src/test/java/org/apache/servicemix/kernel/spring/
    servicemix/smx4/kernel/trunk/spring/src/test/java/org/apache/servicemix/kernel/spring/SpringDeploymentListenerTest.java
Modified:
    servicemix/smx4/kernel/trunk/assembly/pom.xml
    servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/unix-bin.xml
    servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/windows-bin.xml
    servicemix/smx4/kernel/trunk/assembly/src/main/filtered-resources/etc/startup.properties
    servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java
    servicemix/smx4/kernel/trunk/pom.xml

Modified: servicemix/smx4/kernel/trunk/assembly/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/assembly/pom.xml?rev=614302&r1=614301&r2=614302&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/assembly/pom.xml (original)
+++ servicemix/smx4/kernel/trunk/assembly/pom.xml Tue Jan 22 12:09:53 2008
@@ -45,6 +45,11 @@
             <version>1.0-m1-SNAPSHOT</version>
         </dependency>
         <dependency>
+            <groupId>org.apache.servicemix.kernel</groupId>
+            <artifactId>org.apache.servicemix.kernel.spring</artifactId>
+            <version>1.0-m1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
             <groupId>org.springframework.osgi</groupId>
             <artifactId>spring-osgi-extender</artifactId>
             <version>${spring.osgi.version}</version>

Modified: servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/unix-bin.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/unix-bin.xml?rev=614302&r1=614301&r2=614302&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/unix-bin.xml (original)
+++ servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/unix-bin.xml Tue Jan 22 12:09:53
2008
@@ -127,6 +127,7 @@
                 <include>org.springframework.osgi:spring-osgi-io</include>
                 <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.aopalliance-${aopalliance.version}</include>
                 <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.cglib-${cglib.version}</include>
+                <include>org.apache.servicemix.kernel:org.apache.servicemix.kernel.spring</include>
 
 		        <!-- GShell -->
                 <include>org.apache.geronimo.specs:geronimo-stax-api_1.0_spec</include>

Modified: servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/windows-bin.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/windows-bin.xml?rev=614302&r1=614301&r2=614302&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/windows-bin.xml (original)
+++ servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/windows-bin.xml Tue Jan 22
12:09:53 2008
@@ -119,6 +119,7 @@
                 <include>org.springframework.osgi:spring-osgi-io</include>
                 <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.aopalliance-${aopalliance.version}</include>
                 <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.cglib-${cglib.version}</include>
+                <include>org.apache.servicemix.kernel:org.apache.servicemix.kernel.spring</include>
 
 		        <!-- GShell -->
                 <include>org.apache.geronimo.specs:geronimo-stax-api_1.0_spec</include>

Modified: servicemix/smx4/kernel/trunk/assembly/src/main/filtered-resources/etc/startup.properties
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/assembly/src/main/filtered-resources/etc/startup.properties?rev=614302&r1=614301&r2=614302&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/assembly/src/main/filtered-resources/etc/startup.properties
(original)
+++ servicemix/smx4/kernel/trunk/assembly/src/main/filtered-resources/etc/startup.properties
Tue Jan 22 12:09:53 2008
@@ -46,6 +46,7 @@
 spring-osgi-core-${spring.osgi.version}.jar=50
 spring-osgi-extender-${spring.osgi.version}.jar=50
 spring-osgi-io-${spring.osgi.version}.jar=50
+org.apache.servicemix.kernel.spring-${version}.jar=50
 org.apache.felix.bundlerepository-${felix.bundlerepository.version}.jar=50
 pax-runner-handler-mvn-${pax.runner.version}.jar=50
 org.apache.servicemix.kernel.gshell.obr-${version}.jar=50

Modified: servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java?rev=614302&r1=614301&r2=614302&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java
(original)
+++ servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java
Tue Jan 22 12:09:53 2008
@@ -271,22 +271,14 @@
     
     
 	private File transformArtifact(File file) throws Exception {
-        // Handle OSGi bundles with the default deployer
-        JarFile jar = new JarFile(file);
-        Manifest m = jar.getManifest();
-        if (m.getMainAttributes().getValue(new Attributes.Name("Bundle-SymbolicName")) !=
null &&
-            m.getMainAttributes().getValue(new Attributes.Name("Bundle-Version")) != null)
{
-            return file;
-        }
-        jar.close();
-        // Else delegate to registered deployers
+        // Check registered deployers
         ServiceReference[] srvRefs = getContext().getAllServiceReferences(DeploymentListener.class.getName(),
null);
 		if(srvRefs != null) {
 		    for(ServiceReference sr : srvRefs) {
 		    	try {
 		    		DeploymentListener deploymentListener = (DeploymentListener)getContext().getService(sr);
 		    		if (deploymentListener.canHandle(file)) {
-		    			File transformedFile =  deploymentListener.handle(file, getGenerateDir());
+		    			File transformedFile = deploymentListener.handle(file, getGenerateDir());
 		    			artifactToBundle.put(file.getAbsolutePath(), transformedFile.getAbsolutePath());
 		    			return transformedFile;
 		    		}
@@ -295,7 +287,21 @@
 		    	}
 		    }
 		}
-		return null;
+        JarFile jar = null;
+        try {
+            // Handle OSGi bundles with the default deployer
+            jar = new JarFile(file);
+            Manifest m = jar.getManifest();
+            if (m.getMainAttributes().getValue(new Attributes.Name("Bundle-SymbolicName"))
!= null &&
+                m.getMainAttributes().getValue(new Attributes.Name("Bundle-Version")) !=
null) {
+                return file;
+            }
+        } catch (Exception e) {
+            // Ignore
+        } finally {
+            jar.close();
+        }
+        return null;
 	}
 
     protected void deployBundle(File file) throws IOException, BundleException {

Modified: servicemix/smx4/kernel/trunk/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/pom.xml?rev=614302&r1=614301&r2=614302&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/pom.xml (original)
+++ servicemix/smx4/kernel/trunk/pom.xml Tue Jan 22 12:09:53 2008
@@ -39,6 +39,7 @@
     <module>filemonitor</module>
     <module>testing</module>
     <module>gshell</module>
+    <module>spring</module>
     <module>assembly</module>
   </modules>
 
@@ -66,7 +67,7 @@
       <commons.logging.version>1.1</commons.logging.version>
       <felix.configadmin.version>0.9.0-r605854</felix.configadmin.version>
       <felix.main.version>1.1.0-r605854</felix.main.version>
-      <felix.plugin.version>1.1.0-r605854</felix.plugin.version>
+      <felix.plugin.version>1.2.0</felix.plugin.version>
       <felix.framework.version>1.1.0-r605854-patched</felix.framework.version>
       <felix.osgi.version>1.0.0</felix.osgi.version>
       <felix.compendium.version>0.9.0-r605854</felix.compendium.version>

Propchange: servicemix/smx4/kernel/trunk/spring/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jan 22 12:09:53 2008
@@ -0,0 +1,8 @@
+target
+*.iml
+*.ipr
+*.iws
+.classpath
+.project
+.settings
+eclipse-classes

Added: servicemix/smx4/kernel/trunk/spring/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/spring/pom.xml?rev=614302&view=auto
==============================================================================
--- servicemix/smx4/kernel/trunk/spring/pom.xml (added)
+++ servicemix/smx4/kernel/trunk/spring/pom.xml Tue Jan 22 12:09:53 2008
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <!--
+
+      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.
+  -->
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+      <groupId>org.apache.servicemix.kernel</groupId>
+      <artifactId>kernel</artifactId>
+      <version>1.0-m1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>org.apache.servicemix.kernel.spring</artifactId>
+  <packaging>bundle</packaging>
+  <version>1.0-m1-SNAPSHOT</version>
+  <name>ServiceMix Kernel :: Spring Deployer</name>
+
+  <description>This deployer transforms a plain spring xml file to a deployable bundle</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <version>${felix.osgi.version}</version>
+      <scope>provided</scope>
+    </dependency>
+      <dependency>
+          <groupId>org.springframework.osgi</groupId>
+          <artifactId>spring-osgi-core</artifactId>
+          <version>${spring.osgi.version}</version>
+      </dependency>
+      <dependency>
+          <groupId>org.apache.servicemix.kernel</groupId>
+          <artifactId>org.apache.servicemix.kernel.filemonitor</artifactId>
+          <version>${project.version}</version>
+      </dependency>
+      <dependency>
+          <groupId>junit</groupId>
+          <artifactId>junit</artifactId>
+          <version>${junit.version}</version>
+      </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <configuration>
+          <instructions>
+            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+            <Private-Package>org.apache.servicemix.kernel.spring</Private-Package>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Added: servicemix/smx4/kernel/trunk/spring/src/main/java/org/apache/servicemix/kernel/spring/SpringDeploymentListener.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/spring/src/main/java/org/apache/servicemix/kernel/spring/SpringDeploymentListener.java?rev=614302&view=auto
==============================================================================
--- servicemix/smx4/kernel/trunk/spring/src/main/java/org/apache/servicemix/kernel/spring/SpringDeploymentListener.java
(added)
+++ servicemix/smx4/kernel/trunk/spring/src/main/java/org/apache/servicemix/kernel/spring/SpringDeploymentListener.java
Tue Jan 22 12:09:53 2008
@@ -0,0 +1,183 @@
+/**
+ *
+ * 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.servicemix.kernel.spring;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.jar.JarFile;
+import java.util.zip.ZipEntry;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.kernel.filemonitor.DeploymentListener;
+
+/**
+ * A deployment listener that listens for spring xml applications
+ * and creates bundles for these.
+ */
+public class SpringDeploymentListener implements DeploymentListener {
+
+
+    private static final Log LOGGER = LogFactory.getLog(SpringDeploymentListener.class);
+
+    private DocumentBuilderFactory dbf;
+
+    public boolean canHandle(File artifact) {
+        try {
+            if (artifact.isFile() && artifact.getName().endsWith(".xml")) {
+                Document doc = parse(artifact);
+                String name = doc.getDocumentElement().getLocalName();
+                String uri  = doc.getDocumentElement().getNamespaceURI();
+                if ("beans".equals(name) && "http://www.springframework.org/schema/beans".equals(uri))
{
+                    return true;
+                }
+            }
+        } catch (Exception e) {
+            // Ignore
+        }
+        return false;
+    }
+
+    public File handle(File artifact, File tmpDir) {
+        InputStream is = null;
+        OutputStream os = null;
+        try {
+            Document doc = parse(artifact);
+            String name = artifact.getName();
+            String artifactId = name.substring(0, name.length() - 4);
+            String version = "0.0.0";
+            File destFile = new File(tmpDir, name + ".jar");
+            Manifest m = new Manifest();
+            m.getMainAttributes().putValue("Manifest-Version", "2");
+            m.getMainAttributes().putValue("Bundle-SymbolicName", artifactId);
+            m.getMainAttributes().putValue("Bundle-Version", version);
+            m.getMainAttributes().putValue("Spring-Context", "*;publish-context:=true;create-asynchronously:=true");
+            String importPkgs = getImportPackages(doc);
+            if (importPkgs != null && importPkgs.length() > 0) {
+                m.getMainAttributes().putValue("Import-Package", importPkgs);
+            }
+
+            os = new FileOutputStream(destFile);
+            JarOutputStream out = new JarOutputStream(os);
+            ZipEntry e = new ZipEntry(JarFile.MANIFEST_NAME);
+            out.putNextEntry(e);
+            m.write(out);
+            out.closeEntry();
+            e = new ZipEntry("META-INF/");
+            out.putNextEntry(e);
+            e = new ZipEntry("META-INF/spring/");
+            out.putNextEntry(e);
+            out.closeEntry();
+            e = new ZipEntry("META-INF/spring/" + artifact.getName());
+            out.putNextEntry(e);
+            is = new FileInputStream(artifact);
+            copyInputStream(is, out);
+            out.closeEntry();
+            out.close();
+            return destFile;
+        } catch (Exception e) {
+            LOGGER.info("Unable to build spring application bundle", e);
+            return null;
+        } finally {
+            try {
+                is.close();
+            } catch (Exception e) { }
+            try {
+                os.close();
+            } catch (Exception e) { }
+        }
+    }
+
+    protected String getImportPackages(Document doc) {
+        Set<String> packages = getBeanPackages(doc);
+        StringBuilder sb = new StringBuilder();
+        for (String pkg : packages) {
+            if (sb.length() > 0) {
+                sb.append(",");
+            }
+            sb.append(pkg);
+        }
+        return sb.toString();
+    }
+
+    protected Set<String> getBeanPackages(Document doc) {
+        Set<String> packages = new HashSet<String>();
+        extractBeanPackages(doc, packages);
+        return packages;
+    }
+
+    private void extractBeanPackages(Node node, Set<String> packages) {
+        if (node instanceof Element) {
+            Element element = (Element) node;
+            String name = element.getLocalName();
+            String uri  = element.getNamespaceURI();
+            if ("bean".equals(name) && "http://www.springframework.org/schema/beans".equals(uri))
{
+                String clazz = element.getAttribute("class");
+                if (clazz != null) {
+                    String pkg = clazz.substring(0, clazz.lastIndexOf('.'));
+                    packages.add(pkg);
+                }
+            }
+        }
+        if (node != null) {
+            extractBeanPackages(node.getFirstChild(), packages);
+            extractBeanPackages(node.getNextSibling(), packages);
+        }
+    }
+
+    protected Document parse(File artifact) throws Exception {
+        if (dbf == null) {
+            dbf = DocumentBuilderFactory.newInstance();
+            dbf.setNamespaceAware(true);
+        }
+        DocumentBuilder db = dbf.newDocumentBuilder();
+        return db.parse(artifact);
+    }
+
+    /**
+     * Copy in stream to an out stream
+     *
+     * @param in
+     * @param out
+     * @throws java.io.IOException
+     */
+    public static void copyInputStream(InputStream in, OutputStream out) throws IOException
{
+        byte[] buffer = new byte[4096];
+        int len = in.read(buffer);
+        while (len >= 0) {
+            out.write(buffer, 0, len);
+            len = in.read(buffer);
+        }
+    }
+
+}

Added: servicemix/smx4/kernel/trunk/spring/src/main/resources/META-INF/spring/spring-deployer.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/spring/src/main/resources/META-INF/spring/spring-deployer.xml?rev=614302&view=auto
==============================================================================
--- servicemix/smx4/kernel/trunk/spring/src/main/resources/META-INF/spring/spring-deployer.xml
(added)
+++ servicemix/smx4/kernel/trunk/spring/src/main/resources/META-INF/spring/spring-deployer.xml
Tue Jan 22 12:09:53 2008
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:osgi="http://www.springframework.org/schema/osgi"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+  http://www.springframework.org/schema/beans
+  http://www.springframework.org/schema/beans/spring-beans.xsd
+  http://www.springframework.org/schema/util
+  http://www.springframework.org/schema/util/spring-util.xsd
+  http://www.springframework.org/schema/osgi
+  http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+
+    <bean id="springDeploymentListener" class="org.apache.servicemix.kernel.spring.SpringDeploymentListener">
+
+    </bean>
+
+    <osgi:service ref="springDeploymentListener">
+        <osgi:interfaces>
+            <value>org.apache.servicemix.kernel.filemonitor.DeploymentListener</value>
+        </osgi:interfaces>
+    </osgi:service>
+
+</beans>
\ No newline at end of file

Added: servicemix/smx4/kernel/trunk/spring/src/test/java/org/apache/servicemix/kernel/spring/SpringDeploymentListenerTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/spring/src/test/java/org/apache/servicemix/kernel/spring/SpringDeploymentListenerTest.java?rev=614302&view=auto
==============================================================================
--- servicemix/smx4/kernel/trunk/spring/src/test/java/org/apache/servicemix/kernel/spring/SpringDeploymentListenerTest.java
(added)
+++ servicemix/smx4/kernel/trunk/spring/src/test/java/org/apache/servicemix/kernel/spring/SpringDeploymentListenerTest.java
Tue Jan 22 12:09:53 2008
@@ -0,0 +1,35 @@
+/**
+ *
+ * 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.servicemix.kernel.spring;
+
+import java.io.File;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+public class SpringDeploymentListenerTest extends TestCase {
+
+    public void testPackagesExtraction() throws Exception {
+        SpringDeploymentListener l = new SpringDeploymentListener();
+        File f = new File(getClass().getClassLoader().getResource("META-INF/spring/spring-deployer.xml").toURI());
+        Set<String> pkgs = l.getBeanPackages(l.parse(f));
+        assertNotNull(pkgs);
+        assertEquals(1, pkgs.size());
+        assertEquals("org.apache.servicemix.kernel.spring", pkgs.iterator().next());
+    }
+}



Mime
View raw message