Author: bsnyder
Date: Thu Nov 8 15:20:38 2007
New Revision: 593354
URL: http://svn.apache.org/viewvc?rev=593354&view=rev
Log:
Adding an initial JavaUtil class for reading JARs and manifests for the offline
JBI tools.
Added:
incubator/servicemix/branches/servicemix-4.0/jbi/offline/pom.xml (with
props)
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/main/
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/main/java/
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/main/java/org/
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/main/java/org/apache/
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/main/java/org/apache/servicemix/
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/main/java/org/apache/servicemix/offline/
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/main/java/org/apache/servicemix/offline/JarUtil.java
(with props)
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/test/
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/test/java/
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/test/java/org/
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/test/java/org/apache/
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/test/java/org/apache/servicemix/
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/test/java/org/apache/servicemix/offline/
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/test/java/org/apache/servicemix/offline/JarUtilTest.java
(with props)
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/test/resources/
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/test/resources/org.apache.servicemix.api-4.0-SNAPSHOT.jar
(with props)
Modified:
incubator/servicemix/branches/servicemix-4.0/jbi/offline/ (props changed)
Propchange: incubator/servicemix/branches/servicemix-4.0/jbi/offline/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Nov 8 15:20:38 2007
@@ -0,0 +1,4 @@
+.classpath
+.project
+.settings
+target
Added: incubator/servicemix/branches/servicemix-4.0/jbi/offline/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/jbi/offline/pom.xml?rev=593354&view=auto
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/jbi/offline/pom.xml (added)
+++ incubator/servicemix/branches/servicemix-4.0/jbi/offline/pom.xml Thu Nov 8
15:20:38 2007
@@ -0,0 +1,90 @@
+<?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.jbi</groupId>
+ <artifactId>jbi</artifactId>
+ <version>4.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.servicemix.jbi</groupId>
+ <artifactId>org.apache.servicemix.jbi.offline</artifactId>
+ <packaging>bundle</packaging>
+ <version>4.0-SNAPSHOT</version>
+ <name>ServiceMix JBI Offline Tool</name>
+
+ <dependencies>
+ <!--dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>org.apache.servicemix.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.jbi</groupId>
+ <artifactId>org.apache.servicemix.jbi.api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-eip</artifactId>
+ <scope>test</scope>
+ </dependency-->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.osgi</groupId>
+ <artifactId>spring-osgi-test</artifactId>
+ <version>${spring.osgi.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+ <Export-Package>${pom.artifactId}*</Export-Package>
+ <DynamicImport-Package>*</DynamicImport-Package>
+ <Spring-Context>*;publish-context:=false</Spring-Context>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Propchange: incubator/servicemix/branches/servicemix-4.0/jbi/offline/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/branches/servicemix-4.0/jbi/offline/pom.xml
------------------------------------------------------------------------------
svn:keywords = Id Revision
Added:
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/main/java/org/apache/servicemix/offline/JarUtil.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/main/java/org/apache/servicemix/offline/JarUtil.java?rev=593354&view=auto
==============================================================================
---
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/main/java/org/apache/servicemix/offline/JarUtil.java
(added)
+++
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/main/java/org/apache/servicemix/offline/JarUtil.java
Thu Nov 8 15:20:38 2007
@@ -0,0 +1,44 @@
+package org.apache.servicemix.offline;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.springframework.core.io.Resource;
+import org.springframework.osgi.internal.test.util.JarUtils;
+
+public class JarUtil {
+
+ private Manifest manifest;
+
+ public String getJarContent(Resource resource) {
+ return JarUtils.dumpJarContent(resource);
+ }
+
+ public String getManifestContent(Resource resource) {
+ manifest = JarUtils.getManifest(resource);
+ StringBuffer content = new StringBuffer();
+ final String indent = " ";
+
+ Map entries = manifest.getEntries();
+
+ for (Iterator iter0 = (Iterator) entries.keySet().iterator();
iter0.hasNext();) {
+ String entryName = (String) iter0.next();
+ content.append(entryName);
+ Attributes attrs = (Attributes) entries.get(entryName);
+
+ for (Iterator iter1 = (Iterator) attrs.keySet().iterator();
iter1.hasNext();) {
+ Attributes.Name name = (Attributes.Name) iter1.next();
+ String attr = attrs.getValue(name);
+ content.append(indent + attr);
+ }
+ }
+
+ return content.toString();
+ }
+
+}
Propchange:
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/main/java/org/apache/servicemix/offline/JarUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/main/java/org/apache/servicemix/offline/JarUtil.java
------------------------------------------------------------------------------
svn:keywords = Id Revision
Added:
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/test/java/org/apache/servicemix/offline/JarUtilTest.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/test/java/org/apache/servicemix/offline/JarUtilTest.java?rev=593354&view=auto
==============================================================================
---
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/test/java/org/apache/servicemix/offline/JarUtilTest.java
(added)
+++
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/test/java/org/apache/servicemix/offline/JarUtilTest.java
Thu Nov 8 15:20:38 2007
@@ -0,0 +1,48 @@
+package org.apache.servicemix.offline;
+
+
+import java.io.File;
+import java.net.URL;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.core.io.UrlResource;
+
+public class JarUtilTest {
+
+ private static final String JAR_FILENAME =
"org.apache.servicemix.api-4.0-SNAPSHOT.jar";
+
+ private URL jarUrl =
Thread.currentThread().getContextClassLoader().getResource(JAR_FILENAME);
+
+ private JarUtil jarUtil = null;
+
+ @Before
+ public void setUp() throws Exception {
+ jarUtil = new JarUtil();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+// @Test
+// public void readJarFile() throws Exception {
+// File jarFile = new File(jarUrl.toURI());
+// jarUtil.loadJarFile(jarFile);
+// }
+
+ @Test
+ public void getJarContent() throws Exception {
+ System.out.println("Using JAR: " + jarUrl.toURI().toString());
+ String content = jarUtil.getJarContent(new UrlResource(jarUrl));
+ System.out.println("JAR content: " + content);
+ }
+
+ @Test
+ public void getManifestContent() throws Exception {
+ String content = jarUtil.getManifestContent(new UrlResource(jarUrl));
+ System.out.println("Manifest content: " + content);
+ }
+
+}
Propchange:
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/test/java/org/apache/servicemix/offline/JarUtilTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/test/java/org/apache/servicemix/offline/JarUtilTest.java
------------------------------------------------------------------------------
svn:keywords = Id Revision
Added:
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/test/resources/org.apache.servicemix.api-4.0-SNAPSHOT.jar
URL:
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/test/resources/org.apache.servicemix.api-4.0-SNAPSHOT.jar?rev=593354&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
incubator/servicemix/branches/servicemix-4.0/jbi/offline/src/test/resources/org.apache.servicemix.api-4.0-SNAPSHOT.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream