| Commit in servicemix/base/src on MAIN | |||
| test/java/org/servicemix/jbi/installation/ExplodedComponentInstallationTest.java | +107 | added 1.1 | |
| test/components/logger-component-1.0-exploded.jar/lib/logger-component-1.0.jar | [binary] | added 1.1 | |
| test/components/logger-component-1.0-exploded.jar/service.xsd | +47 | added 1.1 | |
| /jbi.xsd | +265 | added 1.1 | |
| main/java/org/servicemix/jbi/framework/InstallationService.java | +13 | -1 | 1.19 -> 1.20 |
| main/java/org/servicemix/jbi/util/FileUtil.java | +40 | -3 | 1.7 -> 1.8 |
| test/components/logger-component-1.0-exploded.jar/META-INF/jbi.xml | +14 | added 1.1 | |
| +486 | -4 | ||
Added the ability to deploy an exploded jar/zip and also added a test case to prove that it is working
servicemix/base/src/test/java/org/servicemix/jbi/installation
ExplodedComponentInstallationTest.java added at 1.1
diff -N ExplodedComponentInstallationTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ExplodedComponentInstallationTest.java 17 Aug 2005 21:59:06 -0000 1.1 @@ -0,0 +1,107 @@
+/**
+ *
+ * Copyright 2005 Unity Systems, LLC. http://www.unity-systems.com
+ *
+ * Licensed 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.servicemix.jbi.installation;
+
+import java.io.File;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.servicemix.jbi.container.JBIContainer;
+
+/**
+ *
+ * Tests the ability of the deployer to deploy an exploded component
+ *
+ * @version $Revision: 1.1 $
+ */
+public class ExplodedComponentInstallationTest extends TestCase {
+ protected JBIContainer container = new JBIContainer();
+
+ private File tempRootDir;
+
+ private static final String COMPONENT_NAME = "logger-component-1.0-exploded.jar";
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ container.setCreateMBeanServer(true);
+ container.setMonitorInstallationDirectory(true);
+ tempRootDir = File.createTempFile("servicemix", "rootDir");
+ tempRootDir.delete();
+ File tempTemp = new File(tempRootDir.getAbsolutePath() + "/temp");
+ if (!tempTemp.mkdirs())
+ fail("Unable to create temporary working root directory ["
+ + tempTemp.getAbsolutePath() + "]");
+
+ System.out.println("Using temporary root directory ["
+ + tempRootDir.getAbsolutePath() + "]");
+
+ container.setRootDir(tempRootDir.getAbsolutePath());
+ container.init();
+ container.start();
+
+ }
+
+ public void testInstallation() throws Exception {
+ try {
+ // Get the component
+ URL componentResource = getClass().getClassLoader().getResource(
+ COMPONENT_NAME);
+ assertNotNull("Unable to find exploded resource " + COMPONENT_NAME,
+ componentResource);
+ container.installArchive(componentResource.getFile());
+
+ // Give it is bit of time to deploy
+ Thread.sleep(3000);
+
+ // Make sure it has
+ assertNotNull(container.getComponent("logger-component"));
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ container.shutDown();
+ //deleteDir(tempRootDir);
+ }
+
+ public static boolean deleteDir(File dir) {
+ System.out.println("Deleting directory : " + dir.getAbsolutePath());
+ if (dir.isDirectory()) {
+ String[] children = dir.list();
+ for (int i = 0; i < children.length; i++) {
+ boolean success = deleteDir(new File(dir, children[i]));
+ if (!success) {
+ return false;
+ }
+ }
+ }
+
+ // The directory is now empty so delete it
+ return dir.delete();
+ }
+}
servicemix/base/src/test/components/logger-component-1.0-exploded.jar
service.xsd added at 1.1
diff -N service.xsd --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ service.xsd 17 Aug 2005 21:59:08 -0000 1.1 @@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sun.com/ns/jbi/engines/transformation/deploy/service-config" targetNamespace="http://www.sun.com/ns/jbi/engines/transformation/deploy/service-config" elementFormDefault="qualified"> + <xsd:complexType name="qnameType"> + <xsd:sequence> + <xsd:element name="namespace-uri" type="xsd:anyURI"/> + <xsd:element name="local-part" type="xsd:NCName"/> + </xsd:sequence> + </xsd:complexType> + <xsd:element name="service-list"> + <xsd:complexType> + <xsd:sequence> + <!-- Service Metadata Information --> + <xsd:element name="service"> + <xsd:complexType> + <xsd:sequence> + <!-- Service NAme in QName format --> + <xsd:element name="service-name" type="qnameType"/> + <!-- endpoint-name Name of the Jbi local endpoint for this service --> + <xsd:element name="endpoint-name" type="xsd:string"/> + <!-- service-description Service Description --> + <xsd:element name="service-description" type="xsd:string" minOccurs="0"/> + <!-- create-cache - Whether to catche the xml stylesheet or not.--> + <xsd:element name="create-cache" type="xsd:string"/> + <!-- service-id - Unique ID representing this service.--> + <xsd:element name="service-id" type="xsd:string"/> + <!-- Elements for Non XML data parsing --> + <!-- column-separator - This is the column separator for non XML data. It should be a character generally not found in + the input data. The default value can be a semi colon (;)--> + <xsd:element name="column-separator" type="xsd:string" default=";" minOccurs="0"/> + <!-- first-row-col-headers - This element decides if the first row in the input data should be trated asColumn Headers. --> + <xsd:element name="first-row-col-headers" type="xsd:string" minOccurs="0"/> + <!-- column-headers Optional element. If present denotes that following column headers should be used for input data. --> + <xsd:element name="column-headers" minOccurs="0"> + <xsd:complexType> + <xsd:sequence> + <!-- column-header Name of the column --> + <xsd:element name="column-header" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + </xsd:sequence> + </xsd:complexType> + </xsd:element> +</xsd:schema>
servicemix/base/src/test/components/logger-component-1.0-exploded.jar
jbi.xsd added at 1.1
diff -N jbi.xsd --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ jbi.xsd 17 Aug 2005 21:59:08 -0000 1.1 @@ -0,0 +1,265 @@
+<?xml version="1.0" encoding="UTF-8"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://java.sun.com/xml/ns/jbi" xmlns:this="http://java.sun.com/xml/ns/jbi"> + <xs:element name="jbi"> + <xs:complexType> + <xs:choice> + <xs:element ref="this:component"/> + <xs:element ref="this:service-assembly"/> + <xs:group ref="this:shared-library"/> + <xs:element ref="this:services"/> + </xs:choice> + <xs:attribute name="version" use="required" type="xs:decimal"/> + </xs:complexType> + </xs:element> + <xs:element name="component"> + <xs:complexType> + <xs:sequence> + <xs:element ref="this:identification"/> + <xs:element ref="this:component-class-name"/> + <xs:element ref="this:component-class-path"/> + <xs:element ref="this:bootstrap-class-name"/> + <xs:element ref="this:bootstrap-class-path"/> + <xs:group minOccurs="0" maxOccurs="unbounded" ref="this:shared-library-list"/> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:any namespace="##other" processContents="skip"/> + <xs:any namespace="##local" processContents="skip"/> + </xs:choice> + </xs:sequence> + <xs:attribute name="type" use="required"> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="service-engine"/> + <xs:enumeration value="binding-component"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="component-class-loader-delegation"> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="parent-first"/> + <xs:enumeration value="self-first"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="bootstrap-class-loader-delegation"> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="parent-first"/> + <xs:enumeration value="self-first"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + </xs:complexType> + </xs:element> + <xs:element name="component-class-name"> + <xs:complexType mixed="true"> + <xs:attribute name="description"/> + </xs:complexType> + </xs:element> + <xs:element name="component-class-path" type="this:class-path"/> + <xs:element name="bootstrap-class-name" type="xs:string"/> + <xs:element name="bootstrap-class-path" type="this:class-path"/> + <xs:group name="shared-library"> + <xs:sequence> + <xs:element name="shared-library"> + <xs:complexType> + <xs:sequence> + <xs:element ref="this:identification"/> + <xs:element ref="this:shared-library-class-path"/> + </xs:sequence> + <xs:attribute name="class-loader-delegation"> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="parent-first"/> + <xs:enumeration value="self-first"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="version"/> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:group> + <xs:element name="shared-library-class-path" type="this:class-path"/> + <xs:group name="shared-library-list"> + <xs:sequence> + <xs:element name="shared-library"> + <xs:complexType mixed="true"> + <xs:attribute name="version"/> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:group> + <xs:element name="service-assembly"> + <xs:complexType> + <xs:sequence> + <xs:element ref="this:identification"/> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="this:service-unit"/> + <xs:element minOccurs="0" ref="this:connections"/> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:any namespace="##other" processContents="skip"/> + <xs:any namespace="##local" processContents="skip"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="service-unit"> + <xs:complexType> + <xs:sequence> + <xs:element ref="this:identification"/> + <xs:element ref="this:target"/> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:any namespace="##other" processContents="skip"/> + <xs:any namespace="##local" processContents="skip"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="target"> + <xs:complexType> + <xs:sequence> + <xs:element ref="this:artifacts-zip"/> + <xs:element ref="this:component-name"/> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="artifacts-zip" type="xs:string"/> + <xs:element name="component-name" type="xs:string"/> + <xs:element name="identification"> + <xs:complexType> + <xs:sequence> + <xs:element ref="this:name"/> + <xs:element ref="this:description"/> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:any namespace="##other" processContents="skip"/> + <xs:any namespace="##local" processContents="skip"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="name" type="xs:string"/> + <xs:element name="description" type="xs:string"/> + <xs:complexType name="class-path"> + <xs:sequence> + <xs:element maxOccurs="unbounded" ref="this:path-element"/> + </xs:sequence> + </xs:complexType> + <xs:element name="path-element" type="xs:string"/> + <xs:element name="connections"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="this:connection"/> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:any namespace="##other" processContents="skip"/> + <xs:any namespace="##local" processContents="skip"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="connection"> + <xs:complexType> + <xs:sequence> + <xs:element ref="this:consumer"/> + <xs:element ref="this:provider"/> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="consumer"> + <xs:complexType> + <xs:attribute name="interface-name" type="xs:QName"/> + <xs:attribute name="service-name" type="xs:QName"/> + <xs:attribute name="endpoint-name"/> + </xs:complexType> + </xs:element> + <xs:element name="provider"> + <xs:complexType> + <xs:attribute name="service-name" use="required" type="xs:QName"/> + <xs:attribute name="endpoint-name" use="required"/> + </xs:complexType> + </xs:element> + <xs:element name="services"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="this:provides"/> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="this:consumes"/> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:any namespace="##other" processContents="skip"/> + <xs:any namespace="##local" processContents="skip"/> + </xs:choice> + </xs:sequence> + <xs:attribute name="binding-component" use="required" type="xs:boolean"/> + </xs:complexType> + </xs:element> + <xs:element name="provides"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" ref="this:requires-capabilities"/> + <xs:element minOccurs="0" ref="this:provides-capabilities"/> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:any namespace="##other" processContents="skip"/> + <xs:any namespace="##local" processContents="skip"/> + </xs:choice> + </xs:sequence> + <xs:attribute name="interface-name" use="required" type="xs:QName"/> + <xs:attribute name="service-name" use="required" type="xs:QName"/> + <xs:attribute name="endpoint-name" use="required"/> + </xs:complexType> + </xs:element> + <xs:element name="consumes"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" ref="this:requires-capabilities"/> + <xs:element minOccurs="0" ref="this:provides-capabilities"/> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:any namespace="##other" processContents="skip"/> + <xs:any namespace="##local" processContents="skip"/> + </xs:choice> + </xs:sequence> + <xs:attribute name="interface-name" use="required" type="xs:QName"/> + <xs:attribute name="service-name" type="xs:QName"/> + <xs:attribute name="endpoint-name"/> + <xs:attribute name="link-type"> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="standard"/> + <xs:enumeration value="hard"/> + <xs:enumeration value="soft"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + </xs:complexType> + </xs:element> + <xs:element name="requires-capabilities"> + <xs:complexType> + <xs:sequence> + <xs:element maxOccurs="unbounded" ref="this:capability"/> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="provides-capabilities"> + <xs:complexType> + <xs:sequence> + <xs:element maxOccurs="unbounded" ref="this:capability"/> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="capability"> + <xs:complexType> + <xs:sequence> + <xs:element ref="this:value"/> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:any namespace="##other" processContents="skip"/> + <xs:any namespace="##local" processContents="skip"/> + </xs:choice> + </xs:sequence> + <xs:attribute name="name" use="required"/> + </xs:complexType> + </xs:element> + <xs:element name="value"> + <xs:complexType> + <xs:sequence> + <xs:any minOccurs="0" maxOccurs="unbounded" processContents="skip"/> + </xs:sequence> + </xs:complexType> + </xs:element> +</xs:schema>
servicemix/base/src/main/java/org/servicemix/jbi/framework
diff -u -r1.19 -r1.20 --- InstallationService.java 10 Aug 2005 19:08:58 -0000 1.19 +++ InstallationService.java 17 Aug 2005 21:59:08 -0000 1.20 @@ -60,7 +60,7 @@
/** * Installation Service - installs/uninstalls archives *
- * @version $Revision: 1.19 $
+ * @version $Revision: 1.20 $
*/
public class InstallationService extends BaseLifeCycle implements FrameworkInstallationService, ProcessArchive {
private static final Log log = LogFactory.getLog(InstallationService.class);
@@ -383,6 +383,18 @@
File tmpRoot = environmentContext.getTmpDir();
try {
File file = new File(location);
+ if (file.isDirectory()) {
+ log
+ .info("Deploying an exploded jar/zip, we will create a temporary jar for it.");
+ // If we have a directory then we should move it over
+ File newFile = new File(tmpRoot.getAbsolutePath()
+ + "/exploded.jar");
+ newFile.delete();
+ FileUtil.zipDir(file.getAbsolutePath(), newFile
+ .getAbsolutePath());
+ file = newFile;
+ log.info("Deployment will now work from "+file.getAbsolutePath());
+ }
if (!file.exists()) {
// assume it's a URL
try {
servicemix/base/src/main/java/org/servicemix/jbi/util
diff -u -r1.7 -r1.8 --- FileUtil.java 3 Aug 2005 16:47:56 -0000 1.7 +++ FileUtil.java 17 Aug 2005 21:59:10 -0000 1.8 @@ -22,6 +22,7 @@
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream;
@@ -30,11 +31,12 @@
import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
/** * File utilities *
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
*/
public class FileUtil {
private static final int DEFAULT_BUFFER_SIZE = 4096;
@@ -109,7 +111,7 @@
ZipFile zipFile;
zipFile = new ZipFile(theFile);
for (Enumeration entries = zipFile.entries(); entries.hasMoreElements();) {
- ZipEntry entry = (ZipEntry) entries.nextElement();
+ ZipEntry entry = (ZipEntry) entries.nextElement();
File file = new File(targetDir, File.separator + entry.getName()); // Take the sledgehammer approach to creating directories // to work around ZIP's that incorrectly miss directories
@@ -231,4 +233,39 @@
} return result; }
-}
+
+ public static void zipDir(String directory, String zipName)
+ throws IOException {
+ // create a ZipOutputStream to zip the data to
+ ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipName));
+ String path = "";
+ zipDir(directory, zos, path);
+ // close the stream
+ zos.close();
+ }
+
+ public static void zipDir(String directory, ZipOutputStream zos, String path)
+ throws IOException {
+ File zipDir = new File(directory);
+ // get a listing of the directory content
+ String[] dirList = zipDir.list();
+ byte[] readBuffer = new byte[2156];
+ int bytesIn = 0;
+ // loop through dirList, and zip the files
+ for (int i = 0; i < dirList.length; i++) {
+ File f = new File(zipDir, dirList[i]);
+ if (f.isDirectory()) {
+ String filePath = f.getPath();
+ zipDir(filePath, zos,path+f.getName()+"/");
+ continue;
+ }
+ FileInputStream fis = new FileInputStream(f);
+ ZipEntry anEntry = new ZipEntry(path+f.getName());
+ zos.putNextEntry(anEntry);
+ while ((bytesIn = fis.read(readBuffer)) != -1) {
+ zos.write(readBuffer, 0, bytesIn);
+ }
+ fis.close();
+ }
+ }
+}
\ No newline at end of file
servicemix/base/src/test/components/logger-component-1.0-exploded.jar/META-INF
jbi.xml added at 1.1
diff -N jbi.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ jbi.xml 17 Aug 2005 21:59:11 -0000 1.1 @@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?> + +<jbi xmlns="http://java.sun.com/xml/ns/jbi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/jbi" version="1.0"> + <component type="service-engine"> + <identification> + <name>logger-component</name> + <description>An example of a Logger JBI componet that can be configured through a service assembly to consume messages and dump them to the log</description> + </identification> + <component-class-name description="Component Implementation">org.servicemix.component.logger.LoggerComponent</component-class-name> + <component-class-path> + <path-element>lib/logger-component-1.0.jar</path-element> + </component-class-path> + </component> +</jbi>
\ No newline at end of file
