You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2007/12/10 04:27:45 UTC
svn commit: r602775 - in /servicemix/branches/servicemix-4.0:
apache-servicemix/ apache-servicemix/src/main/descriptors/
apache-servicemix/src/main/release/bin/ jbi/offline/
jbi/offline/src/main/java/org/apache/servicemix/jbi/offline/
Author: ffang
Date: Sun Dec 9 19:27:40 2007
New Revision: 602775
URL: http://svn.apache.org/viewvc?rev=602775&view=rev
Log:
[SM-1090] apply patch on behalf of Jeff Yu
Added:
servicemix/branches/servicemix-4.0/apache-servicemix/src/main/release/bin/convert.bat (with props)
servicemix/branches/servicemix-4.0/apache-servicemix/src/main/release/bin/convert.sh (with props)
Modified:
servicemix/branches/servicemix-4.0/apache-servicemix/pom.xml
servicemix/branches/servicemix-4.0/apache-servicemix/src/main/descriptors/unix-bin.xml
servicemix/branches/servicemix-4.0/apache-servicemix/src/main/descriptors/windows-bin.xml
servicemix/branches/servicemix-4.0/jbi/offline/pom.xml
servicemix/branches/servicemix-4.0/jbi/offline/src/main/java/org/apache/servicemix/jbi/offline/Main.java
Modified: servicemix/branches/servicemix-4.0/apache-servicemix/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/apache-servicemix/pom.xml?rev=602775&r1=602774&r2=602775&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/apache-servicemix/pom.xml (original)
+++ servicemix/branches/servicemix-4.0/apache-servicemix/pom.xml Sun Dec 9 19:27:40 2007
@@ -162,6 +162,10 @@
</dependency>
<dependency>
<groupId>org.apache.servicemix.jbi</groupId>
+ <artifactId>org.apache.servicemix.jbi.offline</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.jbi</groupId>
<artifactId>org.apache.servicemix.jbi.osgi</artifactId>
</dependency>
<dependency>
Modified: servicemix/branches/servicemix-4.0/apache-servicemix/src/main/descriptors/unix-bin.xml
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/apache-servicemix/src/main/descriptors/unix-bin.xml?rev=602775&r1=602774&r2=602775&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/apache-servicemix/src/main/descriptors/unix-bin.xml (original)
+++ servicemix/branches/servicemix-4.0/apache-servicemix/src/main/descriptors/unix-bin.xml Sun Dec 9 19:27:40 2007
@@ -83,6 +83,9 @@
<includes>
<include>bin/servicemix.bat</include>
<include>bin/servicemix.sh</include>
+ <include>bin/convert.sh</include>
+ <include>bin/convert.bat</include>
+
<include>bin/linux/servicemix.sh</include>
<include>bin/macosx/servicemix.sh</include>
<include>bin/win32/servicemix.bat</include>
@@ -96,6 +99,15 @@
<directory>target/dependencies</directory>
<outputDirectory>/bin/</outputDirectory>
</fileSet>
+
+ <!--Copy convert jar to bin folder -->
+ <fileSet>
+ <directory>../jbi/offline/target</directory>
+ <outputDirectory>/bin/</outputDirectory>
+ <includes>
+ <include>convert.jar</include>
+ </includes>
+ </fileSet>
</fileSets>
Modified: servicemix/branches/servicemix-4.0/apache-servicemix/src/main/descriptors/windows-bin.xml
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/apache-servicemix/src/main/descriptors/windows-bin.xml?rev=602775&r1=602774&r2=602775&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/apache-servicemix/src/main/descriptors/windows-bin.xml (original)
+++ servicemix/branches/servicemix-4.0/apache-servicemix/src/main/descriptors/windows-bin.xml Sun Dec 9 19:27:40 2007
@@ -84,6 +84,8 @@
<includes>
<include>bin/servicemix.bat</include>
<include>bin/servicemix.sh</include>
+ <include>bin/convert.bat</include>
+ <include>bin/convert.sh</include>
<include>bin/linux/servicemix.sh</include>
<include>bin/macosx/servicemix.sh</include>
<include>bin/win32/servicemix.bat</include>
@@ -97,6 +99,15 @@
<directory>target/dependencies</directory>
<outputDirectory>/bin/</outputDirectory>
</fileSet>
+
+ <!--Copy convert jar to bin folder -->
+ <fileSet>
+ <directory>../jbi/offline/target</directory>
+ <outputDirectory>/bin/</outputDirectory>
+ <includes>
+ <include>convert.jar</include>
+ </includes>
+ </fileSet>
</fileSets>
Added: servicemix/branches/servicemix-4.0/apache-servicemix/src/main/release/bin/convert.bat
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/apache-servicemix/src/main/release/bin/convert.bat?rev=602775&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/apache-servicemix/src/main/release/bin/convert.bat (added)
+++ servicemix/branches/servicemix-4.0/apache-servicemix/src/main/release/bin/convert.bat Sun Dec 9 19:27:40 2007
@@ -0,0 +1,63 @@
+@echo off
+rem
+rem
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements. See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License. You may obtain a copy of the License at
+rem
+rem http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+rem
+rem
+rem
+
+if not "%ECHO%" == "" echo %ECHO%
+
+setlocal
+set DIRNAME=%~dp0%
+set PROGNAME=%~nx0%
+set ARGS=%*
+
+goto BEGIN
+
+:warn
+ echo %PROGNAME%: %*
+goto :EOF
+
+:BEGIN
+
+rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+if not "%SERVICEMIX_HOME%" == "" (
+ call :warn Ignoring predefined value for SERVICEMIX_HOME
+)
+set SERVICEMIX_HOME=%DIRNAME%..
+if not exist "%SERVICEMIX_HOME%" (
+ call :warn SERVICEMIX_HOME is not valid: %SERVICEMIX_HOME%
+ goto END
+)
+
+if not exist "%JAVA_HOME%" (
+ call:warn JAVA_HOME is not valid: %JAVA_HOME%
+ goto END
+)
+
+:EXECUTE
+ set CLASSPATH=%SERVICEMIX_HOME%\bin\org.apache.servicemix.jbi.offline-4.0-SNAPSHOT.jar;%CLASSPATH%
+ cd "%SERVICEMIX_HOME%"
+ "%JAVA_HOME%\bin\java" -cp "%CLASSPATH%" org.apache.servicemix.jbi.offline.Main %*
+
+rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+:END
+
+endlocal
+
Propchange: servicemix/branches/servicemix-4.0/apache-servicemix/src/main/release/bin/convert.bat
------------------------------------------------------------------------------
svn:eol-style = native
Added: servicemix/branches/servicemix-4.0/apache-servicemix/src/main/release/bin/convert.sh
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/apache-servicemix/src/main/release/bin/convert.sh?rev=602775&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/apache-servicemix/src/main/release/bin/convert.sh (added)
+++ servicemix/branches/servicemix-4.0/apache-servicemix/src/main/release/bin/convert.sh Sun Dec 9 19:27:40 2007
@@ -0,0 +1,256 @@
+#!/bin/sh
+#
+# 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.
+#
+#
+
+DIRNAME=`dirname $0`
+PROGNAME=`basename $0`
+
+#
+# Check/Set up some easily accessible MIN/MAX params for JVM mem usage
+#
+
+if [ "x$JAVA_MIN_MEM" = "x" ]; then
+ JAVA_MIN_MEM=128M
+ export JAVA_MIN_MEM
+fi
+
+if [ "x$JAVA_MAX_MEM" = "x" ]; then
+ JAVA_MAX_MEM=512M
+ export JAVA_MAX_MEM
+fi
+
+warn() {
+ echo "${PROGNAME}: $*"
+}
+
+die() {
+ warn "$*"
+ exit 1
+}
+
+maybeSource() {
+ file="$1"
+ if [ -f "$file" ] ; then
+ . $file
+ fi
+}
+
+detectOS() {
+ # OS specific support (must be 'true' or 'false').
+ cygwin=false;
+ darwin=false;
+ aix=false;
+ os400=false;
+ case "`uname`" in
+ CYGWIN*)
+ cygwin=true
+ ;;
+ Darwin*)
+ darwin=true
+ ;;
+ AIX*)
+ aix=true
+ ;;
+ OS400*)
+ os400=true
+ ;;
+ esac
+ # For AIX, set an environment variable
+ if $aix; then
+ export LDR_CNTRL=MAXDATA=0xB0000000@DSA
+ export IBM_JAVA_HEAPDUMP_TEXT=true
+ echo $LDR_CNTRL
+ fi
+}
+
+unlimitFD() {
+ # Use the maximum available, or set MAX_FD != -1 to use that
+ if [ "x$MAX_FD" = "x" ]; then
+ MAX_FD="maximum"
+ fi
+
+ # Increase the maximum file descriptors if we can
+ if [ "$os400" = "false" ] && [ "$cygwin" = "false" ]; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ]; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
+ # use the system max
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+
+ ulimit -n $MAX_FD
+ # echo "ulimit -n" `ulimit -n`
+ if [ $? -ne 0 ]; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query system maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+ fi
+}
+
+locateHome() {
+ if [ "x$SERVICEMIX_HOME" != "x" ]; then
+ warn "Ignoring predefined value for SERVICEMIX_HOME"
+ fi
+
+ SERVICEMIX_HOME=`cd $DIRNAME/..; pwd`
+ if [ ! -d "$SERVICEMIX_HOME" ]; then
+ die "SERVICEMIX_HOME is not valid: $SERVICEMIX_HOME"
+ fi
+}
+
+setupNativePath() {
+ # Support for loading native libraries
+ LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:$SERVICEMIX_HOME/lib"
+
+ # For Cygwin, set PATH from LD_LIBRARY_PATH
+ if $cygwin; then
+ LD_LIBRARY_PATH=`cygpath --path --windows "$LD_LIBRARY_PATH"`
+ PATH="$PATH;$LD_LIBRARY_PATH"
+ export PATH
+ fi
+ export LD_LIBRARY_PATH
+}
+
+locateJava() {
+ # Setup the Java Virtual Machine
+ if $cygwin ; then
+ [ -n "$JAVA" ] && JAVA=`cygpath --unix "$JAVA"`
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ fi
+
+ if [ "x$JAVA" = "x" ]; then
+ if [ "x$JAVA_HOME" = "x" ] && [ "$darwin" = "true" ]; then
+ JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
+ fi
+ if [ "x$JAVA_HOME" != "x" ]; then
+ if [ ! -d "$JAVA_HOME" ]; then
+ die "JAVA_HOME is not valid: $JAVA_HOME"
+ fi
+ JAVA="$JAVA_HOME/bin/java"
+ else
+ warn "JAVA_HOME not set; results may vary"
+ JAVA="java"
+ fi
+ fi
+}
+
+detectJVM() {
+ #echo "`$JAVA -version`"
+ # This service should call `java -version`,
+ # read stdout, and look for hints
+ if $JAVA -version 2>&1 | grep "^IBM" ; then
+ JVM_VENDOR="IBM"
+ # on OS/400, java -version does not contain IBM explicitly
+ elif $os400; then
+ JVM_VENDOR="IBM"
+ else
+ JVM_VENDOR="SUN"
+ fi
+ # echo "JVM vendor is $JVM_VENDOR"
+}
+
+setupDebugOptions() {
+ if [ "x$JAVA_OPTS" = "x" ]; then
+ JAVA_OPTS="$DEFAULT_JAVA_OPTS"
+ fi
+ export JAVA_OPTS
+
+ # Set Debug options if enabled
+ if [ "x$SERVICEMIX_DEBUG" != "x" ]; then
+ # Use the defaults if JAVA_DEBUG_OPTS was not set
+ if [ "x$JAVA_DEBUG_OPTS" = "x" ]; then
+ JAVA_DEBUG_OPTS="$DEFAULT_JAVA_DEBUG_OPTS"
+ fi
+
+ JAVA_OPTS="$JAVA_DEBUG_OPTS $JAVA_OPTS"
+ warn "Enabling Java debug options: $JAVA_DEBUG_OPTS"
+ fi
+}
+
+setupDefaults() {
+ DEFAULT_JAVA_OPTS="-Xms$JAVA_MIN_MEM -Xmx$JAVA_MAX_MEM "
+
+ #Set the JVM_VENDOR specific JVM flags
+ if [ "$JVM_VENDOR" = "SUN" ]; then
+ DEFAULT_JAVA_OPTS="-server $DEFAULT_JAVA_OPTS -Dcom.sun.management.jmxremote"
+ elif [ "$JVM_VENDOR" = "IBM" ]; then
+ if $os400; then
+ DEFAULT_JAVA_OPTS="$DEFAULT_JAVA_OPTS"
+ elif $aix; then
+ DEFAULT_JAVA_OPTS="-Xverify:none -Xlp $DEFAULT_JAVA_OPTS"
+ else
+ DEFAULT_JAVA_OPTS="-Xverify:none $DEFAULT_JAVA_OPTS"
+ fi
+ fi
+
+ # Add the conf directory so it picks up the Log4J config
+ CLASSPATH="$CLASSPATH:$SERVICEMIX_HOME/conf"
+ DEFAULT_JAVA_DEBUG_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
+
+}
+
+init() {
+ # Determine if there is special OS handling we must perform
+ detectOS
+
+ # Unlimit the number of file descriptors if possible
+ unlimitFD
+
+ # Locate the ServiceMix home directory
+ locateHome
+
+ # Setup the native library path
+ setupNativePath
+
+ # Locate the Java VM to execute
+ locateJava
+
+ # Determine the JVM vendor
+ detectJVM
+
+ # Setup default options
+ setupDefaults
+
+ # Install debug options
+ setupDebugOptions
+
+}
+
+run() {
+ JAR=$SERVICEMIX_HOME/bin/convert.jar
+ CLASSPATH=$SERVICEMIX_HOME/bin/convert.jar:$CLASSPATH
+ if $cygwin; then
+ SERVICEMIX_HOME=`cygpath --path --windows "$SERVICEMIX_HOME"`
+ CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+ CLASSWORLDS_CONF=`cygpath --path --windows "$CLASSWORLDS_CONF"`
+ CYGHOME=`cygpath --windows "$HOME"`
+ JAR=`cygpath --windows "$JAR"`
+ fi
+ cd "$SERVICEMIX_HOME"
+ exec $JAVA $JAVA_OPTS -cp $CLASSPATH org.apache.servicemix.jbi.offline.Main "$@"
+}
+
+main() {
+ init
+ run $@
+}
+
+main $@
+
Propchange: servicemix/branches/servicemix-4.0/apache-servicemix/src/main/release/bin/convert.sh
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: servicemix/branches/servicemix-4.0/apache-servicemix/src/main/release/bin/convert.sh
------------------------------------------------------------------------------
svn:executable = *
Modified: servicemix/branches/servicemix-4.0/jbi/offline/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/jbi/offline/pom.xml?rev=602775&r1=602774&r2=602775&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/jbi/offline/pom.xml (original)
+++ servicemix/branches/servicemix-4.0/jbi/offline/pom.xml Sun Dec 9 19:27:40 2007
@@ -33,6 +33,7 @@
<version>4.0-SNAPSHOT</version>
<name>ServiceMix JBI Offline Tool</name>
+
<dependencies>
<!--dependency>
<groupId>org.apache.servicemix</groupId>
@@ -83,6 +84,7 @@
</dependencies>
<build>
+ <finalName>convert</finalName>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
@@ -91,6 +93,7 @@
<instructions>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
<Export-Package>${pom.artifactId}*</Export-Package>
+ <Private-Package>org.apache.servicemix.jbi.deployer*</Private-Package>
<Import-Package>org.springframework*;resolution:=optional,*</Import-Package>
</instructions>
</configuration>
Modified: servicemix/branches/servicemix-4.0/jbi/offline/src/main/java/org/apache/servicemix/jbi/offline/Main.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/jbi/offline/src/main/java/org/apache/servicemix/jbi/offline/Main.java?rev=602775&r1=602774&r2=602775&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/jbi/offline/src/main/java/org/apache/servicemix/jbi/offline/Main.java (original)
+++ servicemix/branches/servicemix-4.0/jbi/offline/src/main/java/org/apache/servicemix/jbi/offline/Main.java Sun Dec 9 19:27:40 2007
@@ -18,11 +18,11 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.util.Map;
import java.util.jar.Attributes;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
@@ -36,41 +36,65 @@
public class Main {
public static void main(String[] args) throws Exception {
- new Main().run(args);
+ new Main().run(args);
+ }
+
+ public void run(String... args) throws Exception{
+
+ if (args != null && args.length == 1 && "-help".equals(args[0])) {
+ showUsage();
+ } else if ( args != null && args.length == 2) {
+ Options options = new Options(args);
+ run(options);
+ } else {
+ System.out.println("Bad Usage!");
+ showUsage();
+ }
}
- public void run(String... args) throws Exception {
- File f = new File(args[0]);
+ public void run(Options options) throws Exception {
+ File f = new File(options.getOrginalFile());
if (!f.exists()) {
throw new IllegalStateException("File " + f.toString() + " does not exists.");
}
- JarFile jar = new JarFile(args[0]);
+ JarFile jar = new JarFile(options.getOrginalFile());
Manifest m = jar.getManifest();
JarEntry entry = jar.getJarEntry("META-INF/jbi.xml");
InputStream is = jar.getInputStream(entry);
Descriptor desc = DescriptorFactory.buildDescriptor(is);
-
+
+ String version = m.getMainAttributes().getValue("Implementation-Version");
+ String name = m.getMainAttributes().getValue("Implementation-Title");
+
if (desc.getComponent() != null) {
- String name = desc.getComponent().getIdentification().getName();
- String version = m.getMainAttributes().getValue("Implementation-Version");
- m.getMainAttributes().put(new Attributes.Name("Bundle-SymbolicName"), name);
- m.getMainAttributes().put(new Attributes.Name("Bundle-Version"), version);
+ name = desc.getComponent().getIdentification().getName();
+ } else if (desc.getSharedLibrary() != null) {
+ name = desc.getSharedLibrary().getIdentification().getName();
+ } else if (desc.getServiceAssembly() != null) {
+ name = desc.getServiceAssembly().getIdentification().getName();
}
+
+ m.getMainAttributes().put(new Attributes.Name("Bundle-SymbolicName"), name);
+ m.getMainAttributes().put(new Attributes.Name("Bundle-Version"), version);
- JarInputStream jis = new JarInputStream(new FileInputStream(args[0]));
- JarOutputStream jos = new JarOutputStream(new FileOutputStream(args[1]), m);
+ generateBundle(options, m);
+
+ }
- byte[] buffer = new byte[8192];
- entry = jis.getNextJarEntry();
+ private void generateBundle(Options options, Manifest m) throws IOException, FileNotFoundException {
+ JarInputStream jis = new JarInputStream(new FileInputStream(options.getOrginalFile()));
+ JarOutputStream jos = new JarOutputStream(new FileOutputStream(options.getDestFile()), m);
+
+ JarEntry entry = jis.getNextJarEntry();
while (entry != null) {
- jos.putNextEntry(entry);
+ jos.putNextEntry(entry);
copyInputStream(jis, jos);
jos.closeEntry();
entry = jis.getNextJarEntry();
}
jos.close();
jis.close();
- }
+ }
protected static void copyInputStream(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[4096];
@@ -78,5 +102,31 @@
while ((len = in.read(buffer)) >= 0) {
out.write(buffer, 0, len);
}
+ }
+
+ protected static void showUsage() {
+ System.out.println("usage: convert [jar/zip file (Component, SL, SA) ] [OSGied jar/zip file (Component, SL, SA)]");
+ }
+
+
+ public static class Options {
+
+ private String orginalFile ;
+
+ private String destFile;
+
+ public Options(String... args) {
+ this.orginalFile = args[0];
+ this.destFile = args[1];
+ }
+
+ public String getOrginalFile() {
+ return orginalFile;
+ }
+ public String getDestFile() {
+ return destFile;
+ }
+
+
}
}