[Jboss-cvs] JBossAS SVN: r56137 - in projects/microcontainer/trunk: . osgi-int osgi-int/src osgi-int/src/etc osgi-int/src/main osgi-int/src/main/org osgi-int/src/main/org/jboss osgi-int/src/main/org/jboss/vfs osgi-int/src/main/org/jboss/vfs/bundle osgi-int/src/tests osgi-int/src/tests/org osgi-int/src/tests/org/jboss osgi-int/src/tests/org/jboss/test osgi-int/src/tests/org/jboss/test/bundle osgi-int/src/tests/org/jboss/test/bundle/support osgi-int/src/tests/org/jboss/test/bundle/support/jar1 osgi-int/src/tests/org/jboss/test/bundle/support/jar2
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Aug 21 17:15:58 EDT 2006
Author: scott.stark at jboss.org
Date: 2006-08-21 17:15:52 -0400 (Mon, 21 Aug 2006)
New Revision: 56137
Added:
projects/microcontainer/trunk/osgi-int/
projects/microcontainer/trunk/osgi-int/.classpath
projects/microcontainer/trunk/osgi-int/.project
projects/microcontainer/trunk/osgi-int/build-test.xml
projects/microcontainer/trunk/osgi-int/build.bat
projects/microcontainer/trunk/osgi-int/build.sh
projects/microcontainer/trunk/osgi-int/build.xml
projects/microcontainer/trunk/osgi-int/src/
projects/microcontainer/trunk/osgi-int/src/etc/
projects/microcontainer/trunk/osgi-int/src/etc/default.mf
projects/microcontainer/trunk/osgi-int/src/main/
projects/microcontainer/trunk/osgi-int/src/main/org/
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/BundleClassLoader.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/HeaderValue.jj
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/VFSBundle.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/VersionRange.java
projects/microcontainer/trunk/osgi-int/src/tests/
projects/microcontainer/trunk/osgi-int/src/tests/org/
projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/
projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/
projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/
projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestBundleHeaders.java
projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestVersionRange.java
projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/forexport/
projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/forimport/
projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/
projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/CommonClass.java
projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestBundleActivator.java
projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/jar1/
projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/jar1/ClassInJar1.java
projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/jar2/
projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/jar2/ClassInJar2.java
Log:
Add an OSGi integration project
Added: projects/microcontainer/trunk/osgi-int/.classpath
===================================================================
--- projects/microcontainer/trunk/osgi-int/.classpath 2006-08-21 21:14:45 UTC (rev 56136)
+++ projects/microcontainer/trunk/osgi-int/.classpath 2006-08-21 21:15:52 UTC (rev 56137)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main"/>
+ <classpathentry output="output/eclipse-classes-tests" kind="src" path="src/tests"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="/thirdparty/jboss/common/lib/jboss-common.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/apache-log4j/lib/log4j.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/oswego-concurrent/lib/concurrent.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/javassist/lib/javassist.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jboss/profiler/jvmti/lib/jboss-profiler-jvmti.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jboss/test/lib/jboss-test.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+ <classpathentry kind="output" path="output/eclipse-classes"/>
+</classpath>
Property changes on: projects/microcontainer/trunk/osgi-int/.classpath
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/microcontainer/trunk/osgi-int/.project
===================================================================
--- projects/microcontainer/trunk/osgi-int/.project 2006-08-21 21:14:45 UTC (rev 56136)
+++ projects/microcontainer/trunk/osgi-int/.project 2006-08-21 21:15:52 UTC (rev 56137)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>osgi-int</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: projects/microcontainer/trunk/osgi-int/.project
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/microcontainer/trunk/osgi-int/build-test.xml
===================================================================
--- projects/microcontainer/trunk/osgi-int/build-test.xml 2006-08-21 21:14:45 UTC (rev 56136)
+++ projects/microcontainer/trunk/osgi-int/build-test.xml 2006-08-21 21:15:52 UTC (rev 56137)
@@ -0,0 +1,388 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE project [
+ <!ENTITY buildmagic SYSTEM "../tools/etc/buildmagic/buildmagic.ent">
+ <!ENTITY libraries SYSTEM "../thirdparty/libraries.ent">
+ <!ENTITY targets SYSTEM "../tools/etc/buildmagic/targets.ent">
+]>
+
+<!-- ====================================================================== -->
+<!-- -->
+<!-- JBoss, the OpenSource J2EE webOS -->
+<!-- -->
+<!-- Distributable under LGPL license. -->
+<!-- See terms of license at http://www.gnu.org. -->
+<!-- -->
+<!-- ====================================================================== -->
+
+<!-- $Id: build-test.xml 55205 2006-08-04 16:46:15Z kabir.khan at jboss.com $ -->
+
+<project default="main" name="JBoss/Container Tests">
+
+ <!-- ================================================================== -->
+ <!-- Setup -->
+ <!-- ================================================================== -->
+
+ <!--
+ | Include the common Buildmagic elements.
+ |
+ | This defines several different targets, properties and paths.
+ | It also sets up the basic extention tasks amoung other things.
+ -->
+
+ &buildmagic;
+
+ <!--
+ | Include the normal targets.
+ -->
+ &targets;
+
+ <!-- ================================================================== -->
+ <!-- Configuration -->
+ <!-- ================================================================== -->
+
+ <!--
+ | Configure the build system.
+ |
+ | This target is invoked by the Buildmagic initialization logic and
+ | should contain module specific configuration elements.
+ -->
+
+ <target name="configure" unless="configure.disable">
+
+ <!-- =================== -->
+ <!-- Basic Configuration -->
+ <!-- =================== -->
+
+ <!-- Module name(s) & version -->
+ <property name="module.name" value="container"/>
+ <property name="module.Name" value="JBoss Container"/>
+ <property name="module.version" value="M1"/>
+
+ <!-- ========= -->
+ <!-- Libraries -->
+ <!-- ========= -->
+
+ &libraries;
+
+ <!-- The combined library classpath -->
+ <path id="library.classpath">
+ <path refid="junit.junit.classpath"/>
+ <path refid="javassist.classpath"/>
+ <path refid="junit4.classpath"/>
+ <path refid="apache.log4j.classpath"/>
+ <path refid="oswego.concurrent.classpath"/>
+ <path refid="osgi.core.classpath" />
+ <path refid="jboss.common.classpath"/>
+ <path refid="jboss.test.classpath"/>
+ <path refid="jboss.profiler.jvmti.classpath"/>
+ </path>
+
+<!-- this -->
+<property name="jboss.this.root" value="${module.root}/output"/>
+<property name="jboss.this.lib" value="${jboss.this.root}/lib"/>
+<path id="jboss.this.classpath">
+ <fileset dir="${jboss.this.lib}">
+ <include name="*.jar"/>
+ <exclude name="${jar.prefix}.jar"/>
+ </fileset>
+</path>
+
+ <!-- The combined dependant module classpath -->
+ <path id="dependentmodule.classpath">
+ <path refid="jboss.this.classpath"/>
+ </path>
+
+ <!-- ===== -->
+ <!-- Tasks -->
+ <!-- ===== -->
+
+ <property name="source.java" value="${module.source}/tests"/>
+ <property name="javac.target" value="1.5"/>
+ <property name="javac.source" value="1.5"/>
+ <property name="build.classes" value="${module.output}/classes-tests"/>
+ <property name="build.testlog" value="${module.output}/log"/>
+ <property name="build-bypass.disabled" value="true"/>
+
+ <call target="_default:task-init"/>
+
+ <path id="thirdparty.classpath">
+ <path refid="library.classpath"/>
+ <path refid="dependentmodule.classpath"/>
+ </path>
+
+ <path id="no.javassist.classpath">
+ <path refid="dependentmodule.classpath"/>
+ <path refid="junit.junit.classpath"/>
+ <path refid="junit4.classpath"/>
+ <path refid="apache.log4j.classpath"/>
+ <path refid="oswego.concurrent.classpath"/>
+ <path refid="osgi.core.classpath"/>
+ <path refid="jboss.profiler.jvmti.classpath"/>
+ <path refid="jboss.test.classpath"/>
+ <path refid="jboss.common.classpath"/>
+ </path>
+
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Compile -->
+ <!-- ================================================================== -->
+
+ <!--
+ | Compile everything.
+ |
+ | This target should depend on other compile-* targets for each
+ | different type of compile that needs to be performed, short of
+ | documentation compiles.
+ -->
+
+ <target name="compile"
+ description="Compile all source files."
+ depends="_default:compile-classes"
+ />
+
+ <!-- ================================================================== -->
+ <!-- Archives -->
+ <!-- ================================================================== -->
+
+ <!--
+ | Build all jar files.
+ -->
+ <target name="module-jars" depends="init">
+
+ <jar jarfile="${build.lib}/jboss-container-test.jar" manifest="${build.etc}/default.mf">
+ <fileset dir="${build.classes}"/>
+ </jar>
+
+ <!-- vfs test jars -->
+ <jar destfile="${build.lib}/jar1.jar">
+ <manifest>
+ <attribute name="Specification-Title" value="jar1" />
+ <attribute name="Specification-Version" value="1.0.0.GA-jar1" />
+ <attribute name="Specification-Vendor" value="JBoss Inc." />
+ </manifest>
+ <zipfileset dir="${build.classes}">
+ <include name="org/jboss/test/vfs/support/jar1/**" />
+ </zipfileset>
+ </jar>
+ <jar destfile="${build.lib}/jar2.jar">
+ <manifest>
+ <attribute name="Specification-Title" value="jar2" />
+ <attribute name="Specification-Version" value="1.0.0.GA-jar2" />
+ <attribute name="Specification-Vendor" value="JBoss Inc." />
+ </manifest>
+ <zipfileset dir="${build.classes}">
+ <include name="org/jboss/test/vfs/support/jar2/**" />
+ </zipfileset>
+ </jar>
+ <jar destfile="${build.lib}/outer.jar">
+ <manifest>
+ <attribute name="Specification-Title" value="outer-jar" />
+ <attribute name="Specification-Version" value="1.0.0.GA" />
+ <attribute name="Specification-Vendor" value="JBoss Inc." />
+ <attribute name="Implementation-Title" value="outer-jar-test" />
+ <attribute name="Implementation-URL" value="www.jboss.org" />
+ <attribute name="Implementation-Version" value="1.0.0.GA-jboss" />
+ <attribute name="Implementation-Vendor" value="JBoss Inc." />
+ </manifest>
+ <zipfileset dir="${build.lib}">
+ <include name="jar1.jar" />
+ <include name="jar2.jar" />
+ </zipfileset>
+ <zipfileset dir="${build.classes}">
+ <include name="org/jboss/test/vfs/support/*" />
+ </zipfileset>
+ </jar>
+ <!-- unpacked versions of vfs test jars -->
+ <unzip dest="${build.lib}/unpacked-outer.jar" src="${build.lib}/outer.jar">
+
+ </unzip>
+
+ <!-- Profile service test jars -->
+ <jar destfile="${build.lib}/p0.jar">
+ <manifest>
+ <attribute name="Specification-Title" value="profile0-jar" />
+ <attribute name="Specification-Version" value="1.0.0.GA" />
+ <attribute name="Specification-Vendor" value="JBoss Inc." />
+ <attribute name="Implementation-Title" value="p0-jar-test" />
+ <attribute name="Implementation-URL" value="www.jboss.org" />
+ <attribute name="Implementation-Version" value="1.0.0.GA-jboss" />
+ <attribute name="Implementation-Vendor" value="JBoss Inc." />
+ </manifest>
+ <zipfileset dir="${build.classes}">
+ <include name="org/jboss/test/profileservice/profiles/p0/**" />
+ </zipfileset>
+ </jar>
+
+ <!-- OSGi bundle jars -->
+ <jar destfile="${build.lib}/osgi-bundle1.jar">
+ <manifest>
+ <attribute name="Bundle-ManifestVersion" value="2" />
+ <attribute name="Bundle-Category" value="osgi-bundle1" />
+ <attribute name="Bundle-ClassPath" value="jar1.jar,jar2.jar,."/>
+ <attribute name="Bundle-Copyright" value="2006, JBoss Inc." />
+ <attribute name="Bundle-Description" value="An OSGi test bundle" />
+ <attribute name="Bundle-Name" value="osgi-bundle" />
+ <attribute name="Bundle-SymbolicName" value="org.jboss.test.bundle1;singleton:=true" />
+ <attribute name="Bundle-Vendor" value="JBoss Inc." />
+ <attribute name="Bundle-Version" value="1.0.0" />
+ <attribute name="Bundle-Activator" value="org.jboss.test.bundle.TestBundleActivator" />
+ <attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-1.4" />
+
+ <attribute name="Import-Package" value="org.jboss.test.vfs.support.jar1,
+ org.jboss.test.vfs.support.jar2,version="[1.0,2.0]"resolution=mandatory" />
+ </manifest>
+ <zipfileset dir="${build.classes}">
+ <include name="org/jboss/test/bundle/support/*" />
+ </zipfileset>
+ </jar>
+ <jar destfile="${build.lib}/osgi-bundle-export.jar">
+ <manifest>
+ <attribute name="Bundle-ManifestVersion" value="2" />
+ <attribute name="Bundle-Category" value="osgi-bundle-export-jar1" />
+ <attribute name="Bundle-Copyright" value="2006, JBoss Inc." />
+ <attribute name="Bundle-Description" value="A bundle which exports org.jboss.test.vfs.support.jar1" />
+ <attribute name="Bundle-Name" value="osgi-bundle" />
+ <attribute name="Bundle-SymbolicName" value="org.jboss.test.vfs.support.jar1" />
+ <attribute name="Bundle-Vendor" value="JBoss Inc." />
+ <attribute name="Bundle-Version" value="1.0.1" />
+ <attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-1.5" />
+
+ <attribute name="Export-Package" value="org.jboss.test.vfs.support.jar1;version=1.0.1,
+ org.jboss.test.vfs.support.jar2;version=1.1;,
+ uses=org.jboss.test.vfs.support;" />
+ </manifest>
+ <zipfileset dir="${build.lib}">
+ <include name="jar1.jar" />
+ <include name="jar2.jar" />
+ </zipfileset>
+ <zipfileset dir="${build.classes}">
+ <include name="org/jboss/test/bundle/support/*" />
+ </zipfileset>
+ </jar>
+
+ <!-- unpacked versions of osgi-bundle test jars -->
+ <unzip dest="${build.lib}/unpacked-osgi-bundle-export.jar" src="${build.lib}/osgi-bundle-export.jar" />
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Tests -->
+ <!-- ================================================================== -->
+
+ <target name="tests" depends="most"
+ description="Execute all tests in the given test directory.">
+ <mkdir dir="${build.reports}"/>
+ <mkdir dir="${build.testlog}"/>
+ <!-- Remove the test.log so each run has a fresh log -->
+ <delete file="${build.testlog}/test.log"/>
+ <junit dir="${module.output}"
+ printsummary="yes"
+ haltonerror="false"
+ haltonfailure="false"
+ fork="true">
+
+ <sysproperty key="build.testlog" value="${build.testlog}"/>
+
+ <classpath>
+ <pathelement location="${build.classes}"/>
+ <pathelement location="${build.resources}"/>
+ <path refid="javac.classpath"/>
+ <path refid="apache.xerces.classpath"/>
+ </classpath>
+
+ <formatter type="plain" usefile="true"/>
+ <formatter type="xml" usefile="true"/>
+
+ <batchtest todir="${build.reports}"
+ haltonerror="false"
+ haltonfailure="false"
+ fork="true">
+
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/**/*TestCase.class"/>
+ <exclude name="org/jboss/test/**/NoJavassistAnnotationCreatorTestCase.class"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ <junit dir="${module.output}"
+ printsummary="yes"
+ haltonerror="false"
+ haltonfailure="false"
+ fork="true">
+
+ <sysproperty key="build.testlog" value="${build.testlog}"/>
+
+ <classpath>
+ <pathelement location="${build.classes}"/>
+ <pathelement location="${build.resources}"/>
+ <path refid="no.javassist.classpath"/>
+ <path refid="apache.xerces.classpath"/>
+ </classpath>
+
+ <formatter type="plain" usefile="true"/>
+ <formatter type="xml" usefile="true"/>
+
+ <batchtest todir="${build.reports}"
+ haltonerror="false"
+ haltonfailure="false"
+ fork="true">
+
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/**/NoJavassistAnnotationCreatorTestCase.class"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="one-test" depends="init"
+ description="Execute all tests in the given test directory.">
+ <mkdir dir="${build.reports}"/>
+ <mkdir dir="${build.testlog}"/>
+ <!-- Remove the test.log so each run has a fresh log -->
+ <delete file="${build.testlog}/test.log"/>
+ <junit dir="${module.output}"
+ printsummary="yes"
+ haltonerror="false"
+ haltonfailure="false"
+ fork="true">
+
+ <sysproperty key="build.testlog" value="${build.testlog}"/>
+
+ <classpath>
+ <pathelement location="${build.classes}"/>
+ <pathelement location="${build.resources}"/>
+ <path refid="javac.classpath"/>
+ <path refid="apache.xerces.classpath"/>
+ </classpath>
+
+ <formatter type="plain" usefile="true"/>
+ <formatter type="xml" usefile="true"/>
+
+ <test todir="${build.reports}" name="${test}"
+ haltonerror="${junit.batchtest.haltonerror}"
+ haltonfailure="${junit.batchtest.haltonfailure}"
+ fork="${junit.batchtest.fork}"/>
+ </junit>
+ </target>
+
+ <target name="memory-test" depends="most" description="Execute MemoryLeakTestCase">
+ <mkdir dir="${build.reports}"/>
+ <mkdir dir="${build.testlog}"/>
+
+ <junit printsummary="yes" fork="yes" haltonfailure="no">
+ <classpath>
+ <pathelement location="${build.classes}"/>
+ <pathelement location="${build.resources}"/>
+ <path refid="thirdparty.classpath"/>
+ <path refid="javac.classpath"/>
+ <path refid="apache.xerces.classpath"/>
+ </classpath>
+ <jvmarg value="-agentlib:jbossAgent"/>
+ <formatter type="plain" usefile="true"/>
+ <formatter type="xml" usefile="true"/>
+ <test fork="yes" todir="${build.reports}" name="org.jboss.test.memorytests.ClassInfoMemoryTestCase"/>
+ </junit>
+
+ </target>
+
+</project>
Added: projects/microcontainer/trunk/osgi-int/build.bat
===================================================================
--- projects/microcontainer/trunk/osgi-int/build.bat 2006-08-21 21:14:45 UTC (rev 56136)
+++ projects/microcontainer/trunk/osgi-int/build.bat 2006-08-21 21:15:52 UTC (rev 56137)
@@ -0,0 +1,89 @@
+ at echo off
+REM ======================================================================
+REM
+REM This is the main entry point for the build system.
+REM
+REM Users should be sure to execute this file rather than 'ant' to ensure
+REM the correct version is being used with the correct configuration.
+REM
+REM ======================================================================
+REM
+REM $Id: build.bat 27983 2005-01-26 22:51:29Z ejort $
+REM
+REM Authors:
+REM Jason Dillon <jason at planet57.com>
+REM Sacha Labourey <sacha.labourey at cogito-info.ch>
+REM
+
+REM ******************************************************
+REM Ignore the ANT_HOME variable: we want to use *our*
+REM ANT version and associated JARs.
+REM ******************************************************
+REM Ignore the users classpath, cause it might mess
+REM things up
+REM ******************************************************
+
+SETLOCAL
+
+set CLASSPATH=
+set ANT_HOME=
+set ANT_OPTS=-Djava.protocol.handler.pkgs=org.jboss.net.protocol -Dbuild.script=build.bat
+
+REM ******************************************************
+REM - "for" loops have been unrolled for compatibility
+REM with some WIN32 systems.
+REM ******************************************************
+
+set NAMES=tools;tools\ant;tools\apache\ant
+set SUBFOLDERS=..;..\..;..\..\..;..\..\..\..
+
+REM ******************************************************
+REM ******************************************************
+
+SET EXECUTED=FALSE
+for %%i in (%NAMES%) do call :subLoop %%i %1 %2 %3 %4 %5 %6
+
+goto :EOF
+
+
+REM ******************************************************
+REM ********* Search for names in the subfolders *********
+REM ******************************************************
+
+:subLoop
+for %%j in (%SUBFOLDERS%) do call :testIfExists %%j\%1\bin\ant.bat %2 %3 %4 %5 %6 %7
+
+goto :EOF
+
+
+REM ******************************************************
+REM ************ Test if ANT Batch file exists ***********
+REM ******************************************************
+
+:testIfExists
+if exist %1 call :BatchFound %1 %2 %3 %4 %5 %6 %7 %8
+
+goto :EOF
+
+
+REM ******************************************************
+REM ************** Batch file has been found *************
+REM ******************************************************
+
+:BatchFound
+if (%EXECUTED%)==(FALSE) call :ExecuteBatch %1 %2 %3 %4 %5 %6 %7 %8
+set EXECUTED=TRUE
+
+goto :EOF
+
+REM ******************************************************
+REM ************* Execute Batch file only once ***********
+REM ******************************************************
+
+:ExecuteBatch
+echo Calling %1 %2 %3 %4 %5 %6 %7 %8
+call %1 %2 %3 %4 %5 %6 %7 %8
+
+:end
+
+if "%NOPAUSE%" == "" pause
Added: projects/microcontainer/trunk/osgi-int/build.sh
===================================================================
--- projects/microcontainer/trunk/osgi-int/build.sh 2006-08-21 21:14:45 UTC (rev 56136)
+++ projects/microcontainer/trunk/osgi-int/build.sh 2006-08-21 21:15:52 UTC (rev 56137)
@@ -0,0 +1,172 @@
+#!/bin/sh
+### ====================================================================== ###
+## ##
+## This is the main entry point for the build system. ##
+## ##
+## Users should be sure to execute this file rather than 'ant' to ensure ##
+## the correct version is being used with the correct configuration. ##
+## ##
+### ====================================================================== ###
+
+# $Id: build.sh 27983 2005-01-26 22:51:29Z ejort $
+
+PROGNAME=`basename $0`
+DIRNAME=`dirname $0`
+GREP="grep"
+ROOT="/"
+
+# Ignore user's ANT_HOME if it is set
+ANT_HOME=""
+
+# the default search path for ant
+ANT_SEARCH_PATH="\
+ tools
+ tools/ant \
+ tools/apache/ant \
+ ant"
+
+# the default build file name
+ANT_BUILD_FILE="build.xml"
+
+# the default arguments
+ANT_OPTIONS="-find $ANT_BUILD_FILE"
+
+# Use the maximum available, or set MAX_FD != -1 to use that
+MAX_FD="maximum"
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false;
+darwin=false;
+case "`uname`" in
+ CYGWIN*)
+ cygwin=true
+ ;;
+
+ Darwin*)
+ darwin=true
+ ;;
+esac
+
+#
+# Helper to complain.
+#
+die() {
+ echo "${PROGNAME}: $*"
+ exit 1
+}
+
+#
+# Helper to complain.
+#
+warn() {
+ echo "${PROGNAME}: $*"
+}
+
+#
+# Helper to source a file if it exists.
+#
+maybe_source() {
+ for file in $*; do
+ if [ -f "$file" ]; then
+ . $file
+ fi
+ done
+}
+
+search() {
+ search="$*"
+ for d in $search; do
+ ANT_HOME="`pwd`/$d"
+ ANT="$ANT_HOME/bin/ant"
+ if [ -x "$ANT" ]; then
+ # found one
+ echo $ANT_HOME
+ break
+ fi
+ done
+}
+
+#
+# Main function.
+#
+main() {
+ # if there is a build config file. then source it
+ maybe_source "$DIRNAME/build.conf" "$HOME/.build.conf"
+
+ # Increase the maximum file descriptors if we can
+ if [ $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
+ 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
+
+ # try the search path
+ ANT_HOME=`search $ANT_SEARCH_PATH`
+
+ # try looking up to root
+ if [ "x$ANT_HOME" = "x" ]; then
+ target="build"
+ _cwd=`pwd`
+
+ while [ "x$ANT_HOME" = "x" ] && [ "$cwd" != "$ROOT" ]; do
+ cd ..
+ cwd=`pwd`
+ ANT_HOME=`search $ANT_SEARCH_PATH`
+ done
+
+ # make sure we get back
+ cd $_cwd
+
+ if [ "$cwd" != "$ROOT" ]; then
+ found="true"
+ fi
+
+ # complain if we did not find anything
+ if [ "$found" != "true" ]; then
+ die "Could not locate Ant; check \$ANT or \$ANT_HOME."
+ fi
+ fi
+
+ # make sure we have one
+ ANT=$ANT_HOME/bin/ant
+ if [ ! -x "$ANT" ]; then
+ die "Ant file is not executable: $ANT"
+ fi
+
+ # need to specify planet57/buildmagic protocol handler package
+ ANT_OPTS="-Djava.protocol.handler.pkgs=org.jboss.net.protocol"
+
+ # setup some build properties
+ ANT_OPTS="$ANT_OPTS -Dbuild.script=$0"
+
+ # change to the directory where the script lives so users are not forced
+ # to be in the same directory as build.xml
+ cd $DIRNAME
+
+ # export some stuff for ant
+ export ANT ANT_HOME ANT_OPTS
+
+ # execute in debug mode, or simply execute
+ if [ "x$ANT_DEBUG" != "x" ]; then
+ /bin/sh -x $ANT $ANT_OPTIONS "$@"
+ else
+ exec $ANT $ANT_OPTIONS "$@"
+ fi
+}
+
+##
+## Bootstrap
+##
+
+main "$@"
Added: projects/microcontainer/trunk/osgi-int/build.xml
===================================================================
--- projects/microcontainer/trunk/osgi-int/build.xml 2006-08-21 21:14:45 UTC (rev 56136)
+++ projects/microcontainer/trunk/osgi-int/build.xml 2006-08-21 21:15:52 UTC (rev 56137)
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE project [
+ <!ENTITY buildmagic SYSTEM "../tools/etc/buildmagic/buildmagic.ent">
+ <!ENTITY libraries SYSTEM "../thirdparty/libraries.ent">
+ <!ENTITY modules SYSTEM "../tools/etc/buildmagic/modules.ent">
+ <!ENTITY targets SYSTEM "../tools/etc/buildmagic/targets.ent">
+]>
+
+<!-- ====================================================================== -->
+<!-- -->
+<!-- JBoss, the OpenSource J2EE webOS -->
+<!-- -->
+<!-- Distributable under LGPL license. -->
+<!-- See terms of license at http://www.gnu.org. -->
+<!-- -->
+<!-- ====================================================================== -->
+
+<!-- $Id: build.xml 55339 2006-08-05 15:16:29Z adrian at jboss.org $ -->
+
+<project default="main" name="OSGi Integration">
+
+ <!-- ================================================================== -->
+ <!-- Setup -->
+ <!-- ================================================================== -->
+
+ <!--
+ | Include the common Buildmagic elements.
+ |
+ | This defines several different targets, properties and paths.
+ | It also sets up the basic extention tasks amoung other things.
+ -->
+
+ &buildmagic;
+
+ <!--
+ | Include the normal targets.
+ -->
+ &targets;
+
+ <!-- ================================================================== -->
+ <!-- Configuration -->
+ <!-- ================================================================== -->
+
+ <!--
+ | Configure the build system.
+ |
+ | This target is invoked by the Buildmagic initialization logic and
+ | should contain module specific configuration elements.
+ -->
+
+ <target name="configure" unless="configure.disable">
+
+ <!-- =================== -->
+ <!-- Basic Configuration -->
+ <!-- =================== -->
+
+ <!-- Module name(s) & version -->
+ <property name="module.name" value="container"/>
+ <property name="module.Name" value="JBoss Container"/>
+ <property name="module.version" value="M1"/>
+
+ <!-- ========= -->
+ <!-- Libraries -->
+ <!-- ========= -->
+
+ &libraries;
+
+ <!-- The combined library classpath -->
+ <path id="library.classpath">
+ <path refid="junit.junit.classpath"/>
+ <path refid="javassist.classpath"/>
+ <path refid="apache.log4j.classpath"/>
+ <path refid="oswego.concurrent.classpath"/>
+ <path refid="osgi.osgi.classpath"/>
+ <path refid="jboss.common.classpath"/>
+ <path refid="jboss.test.classpath"/>
+ <path refid="jboss.container.classpath"/>
+ </path>
+
+ <!-- ======= -->
+ <!-- Modules -->
+ <!-- ======= -->
+
+ &modules;
+ <!-- The combined dependant module classpath -->
+ <path id="dependentmodule.classpath">
+ </path>
+
+ <!-- ===== -->
+ <!-- Tasks -->
+ <!-- ===== -->
+
+ <property name="source.java" value="${module.source}/main"/>
+ <property name="javac.target" value="1.5"/>
+ <property name="javac.source" value="1.5"/>
+ <property name="jar.prefix" value="jboss-osgi"/>
+
+ <call target="_default:task-init"/>
+
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Compile -->
+ <!-- ================================================================== -->
+
+ <!--
+ | Compile everything.
+ |
+ | This target should depend on other compile-* targets for each
+ | different type of compile that needs to be performed, short of
+ | documentation compiles.
+ -->
+
+ <target name="compile"
+ description="Compile all source files."
+ depends="compile-parsers,
+ _default:compile-classes,
+ _default:compile-etc"
+ />
+
+ <!-- Compile parsers -->
+ <target name="compile-parsers" depends="init">
+ <mkdir dir="${build.parsers}/org/jboss/vfs/bundle"/>
+
+ <!-- OSGi bundle header parser -->
+ <javacc target="${source.java}/org/jboss/vfs/bundle/HeaderValue.jj"
+ outputdirectory="${build.parsers}/org/jboss/vfs/bundle"
+ javacchome="${sun.javacc.lib}"
+ static="false"/>
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Archives -->
+ <!-- ================================================================== -->
+
+ <!--
+ | Build all jar files.
+ -->
+ <target name="module-jars" depends="init">
+ <!-- Build jboss-kernel.jar -->
+ <jar jarfile="${build.lib}/jboss-osgi.jar" manifest="${build.etc}/default.mf">
+ <fileset dir="${build.classes}"/>
+ </jar>
+ </target>
+
+
+</project>
Added: projects/microcontainer/trunk/osgi-int/src/etc/default.mf
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/etc/default.mf 2006-08-21 21:14:45 UTC (rev 56136)
+++ projects/microcontainer/trunk/osgi-int/src/etc/default.mf 2006-08-21 21:15:52 UTC (rev 56137)
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Created-By: @java.vm.version@ (@java.vm.vendor@)
+Specification-Title: @specification.title@
+Specification-Version: @specification.version@
+Specification-Vendor: @specification.vendor@
+Implementation-Title: @implementation.title@
+Implementation-URL: @implementation.url@
+Implementation-Version: @implementation.version@
+Implementation-Vendor: @implementation.vendor@
+Implementation-Vendor-Id: @implementation.vendor.id@
\ No newline at end of file
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/BundleClassLoader.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/BundleClassLoader.java 2006-08-21 21:14:45 UTC (rev 56136)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/BundleClassLoader.java 2006-08-21 21:15:52 UTC (rev 56137)
@@ -0,0 +1,77 @@
+package org.jboss.vfs.bundle;
+
+import java.net.URL;
+import java.security.SecureClassLoader;
+
+import org.jboss.classloading.spi.ClassLoadingDomain;
+import org.jboss.classloading.spi.DomainClassLoader;
+import org.jboss.logging.Logger;
+import org.osgi.framework.Bundle;
+
+public class BundleClassLoader extends SecureClassLoader
+ implements DomainClassLoader
+{
+
+ private static Logger log = Logger.getLogger(BundleClassLoader.class);
+
+ public BundleClassLoader(Bundle bundle)
+ {
+
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.ClassLoader#getPackages()
+ */
+ @Override
+ public Package[] getPackages()
+ {
+ // TODO Auto-generated method stub
+ return super.getPackages();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.ClassLoader#getPackage(java.lang.String)
+ */
+ @Override
+ public Package getPackage(String name)
+ {
+ // TODO Auto-generated method stub
+ return super.getPackage(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.classloading.spi.DomainClassLoader#getDomain()
+ */
+ public ClassLoadingDomain getDomain()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.classloading.spi.DomainClassLoader#loadClassLocally(java.lang.String, boolean)
+ */
+ public Class loadClassLocally(String name, boolean resolve) throws ClassNotFoundException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.classloading.spi.DomainClassLoader#loadResourceLocally(java.lang.String)
+ */
+ public URL loadResourceLocally(String name)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.classloading.spi.DomainClassLoader#setDomain(org.jboss.classloading.spi.ClassLoadingDomain)
+ */
+ public void setDomain(ClassLoadingDomain domain)
+ {
+ // TODO Auto-generated method stub
+
+ }
+}
Property changes on: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/BundleClassLoader.java
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/HeaderValue.jj
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/HeaderValue.jj 2006-08-21 21:14:45 UTC (rev 56136)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/HeaderValue.jj 2006-08-21 21:15:52 UTC (rev 56137)
@@ -0,0 +1,252 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+ options {
+ LOOKAHEAD=1;
+ DEBUG_PARSER=true;
+ DEBUG_LOOKAHEAD=true;
+ DEBUG_TOKEN_MANAGER=false;
+ STATIC=false;
+}
+
+PARSER_BEGIN(HeaderValue)
+package org.jboss.vfs.bundle;
+
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A JavaCC 3.2 grammar for the OSGi R4 bundle headers
+
+ * @see https://javacc.dev.java.net/
+ * eclipse plugin: http://sourceforge.net/projects/eclipse-javacc
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 16662 $
+ */
+ public class HeaderValue
+ {
+ /**
+ */
+ public static class PkgInfo
+ {
+ List<String> pkgNames = new ArrayList<String>();
+ Map<String, String> paramMap = new HashMap<String, String>();
+ }
+
+ public HeaderValue()
+ {
+ this(new StringReader(""));
+ }
+ public HeaderValue(String value)
+ {
+ this(new StringReader(value));
+ }
+
+ public PkgInfo parseImportPackage(StringReader header, boolean trace)
+ throws ParseException
+ {
+ ReInit(header);
+
+ // This will have no effect unless the debugging options are true
+ if (trace)
+ {
+ this.enable_tracing();
+ }
+ else
+ {
+ this.disable_tracing();
+ }
+
+ return this.ImportPackage();
+ }
+ public static PkgInfo parseImportPackage(String header, boolean trace)
+ throws ParseException
+ {
+ HeaderValue parser = new HeaderValue();
+ return parser.parseImportPackage(new StringReader(header), trace);
+ }
+}
+PARSER_END(HeaderValue)
+
+/* IGNORE WHITESPACE */
+
+SKIP :
+{
+ " "
+ | "\r"
+ | "\t"
+ | "\n"
+}
+
+/* Common tokens */
+TOKEN:
+{
+ <#ALPHA: [ "a"-"z", "A"-"Z" ] >
+|
+ <#ALPHANUM: <ALPHA>|<DIGIT> >
+|
+ <#DIGIT: ["0" - "9"] >
+|
+ <#TOKN: (<ALPHANUM>|"_"|"-")+ >
+|
+ <NUMBER: (<DIGIT>)+ >
+|
+ <QNAME: <JLETTER> (<JLETTER>|<DIGIT>)* ("." <JLETTER> (<JLETTER>|<DIGIT>)*)* >
+|
+ <#JLETTER: [ "_", "a"-"z", "A"-"Z" ] >
+|
+ <#JLETTER_OR_DIGIT: <JLETTER> | <DIGIT> >
+|
+ <IDENTIFIER: <JLETTER> (<JLETTER> | <JLETTER_OR_DIGIT>)* >
+|
+ <QUOTED_STRING: "\"" ( ~["\"", "\\", "\r", "\n", "\u0000"] | "\\\"")* "\"" >
+|
+ <ARGUMENT: <TOKN>|<QUOTED_STRING> >
+|
+ <DIRECTIVE: <TOKN> ":=" <ARGUMENT> >
+|
+ <ATTRIBUTE: <TOKN> "=" <ARGUMENT> >
+|
+ <PARAMETER: <DIRECTIVE>|<ATTRIBUTE> >
+|
+ <UNIQUE_NAME: <IDENTIFIER> ("." <IDENTIFIER>)* >
+|
+ <SYMBOLIC_NAME: <TOKN> ("." <TOKN>)* >
+|
+ <PACKAGE_NAME: <UNIQUE_NAME> >
+|
+ <PATH: <PATH_UNQUOTED> | "\"" <PATH_UNQUOTED> "\"" >
+|
+ <PATH_UNQUOTED: <PATH_SEP> | (<PATH_SEP>)? <PATH_ELEMENT> (<PATH_SEP> <PATH_ELEMENT>)* >
+|
+ <PATH_ELEMENT: (~["/", "\"", "\n", "\r", "\u0000"])+ >
+|
+ <PATH_SEP: "/" >
+}
+
+/* Directives */
+TOKEN [IGNORE_CASE]:
+{
+ <EXCLUDE_DIRECTIVE: "exclude">
+|
+ <EXTENSION_DIRECTIVE: "extension">
+|
+ <FRAGMENT_ATTACHMENT_DIRECTIVE: "fragment-attachment">
+|
+ <INCLUDE_DIRECTIVE: "include">
+|
+ <MANDATORY_DIRECTIVE: "mandatory">
+|
+ <RESOLUTION_DIRECTIVE: "resolution">
+|
+ <RESOLUTION_DIRECTIVE_VALUE: "mandatory"|"optional">
+|
+ <SINGLETON_DIRECTIVE: "singleton">
+|
+ <USES_DIRECTIVE: "uses">
+|
+ <VISIBILITY_DIRECTIVE: "visibility">
+}
+
+/* Attributes */
+TOKEN [IGNORE_CASE]:
+{
+ <BUNDLE_SYMBOLICNAME_ATTRIBUTE: "bundle-symbolic-name">
+|
+ <BUNDLE_VERSION_ATTRIBUTE: "bundle-version">
+|
+ <SELECTION_FILTER_ATTRIBUTE: "selection-filter">
+|
+ <VERSION_ATTRIBUTE: "version">
+|
+ <VERSION_VALUE: (<NUMBER> ("." <NUMBER> ("." <NUMBER> ("." <ALPHANUM>)? )? )?) >
+}
+
+/** Start of the grammar */
+
+void headers() :
+{
+}
+{
+ header() <EOF>
+}
+void header() :
+{
+}
+{
+ (BundleManifestVersion())?
+ | (ImportPackage())?
+}
+
+void BundleManifestVersion() :
+{
+}
+{
+ <NUMBER>
+}
+
+/**
+Entry point for the Import-Package header value parsing.
+*/
+PkgInfo ImportPackage() :
+{
+ PkgInfo info = new PkgInfo();
+}
+{
+ Import(info) ( "," Import(info) )*
+ {
+ return info;
+ }
+}
+
+void Import(PkgInfo info) :
+{
+}
+{
+ PackageNames(info) ( ";" <PARAMETER> )*
+}
+
+void PackageNames(PkgInfo info) :
+{
+ Token t = null;
+}
+{
+ t=<PACKAGE_NAME> {info.pkgNames.add(t.image);} ( ";" t=<PACKAGE_NAME> {info.pkgNames.add(t.image);})*
+}
+void ImportParameters(PkgInfo info) :
+{
+ Token t = null;
+}
+{
+ <RESOLUTION_DIRECTIVE> <DIRECTIVE> t=<RESOLUTION_DIRECTIVE_VALUE>
+ {
+ info.paramMap.put("resolution", t.image);
+ }
+ | <VERSION_ATTRIBUTE> <ATTRIBUTE> t=<VERSION_VALUE>
+ {
+ info.paramMap.put("version", t.image);
+ }
+}
+
\ No newline at end of file
Property changes on: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/HeaderValue.jj
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/VFSBundle.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/VFSBundle.java 2006-08-21 21:14:45 UTC (rev 56136)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/VFSBundle.java 2006-08-21 21:15:52 UTC (rev 56137)
@@ -0,0 +1,408 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.vfs.bundle;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.security.AccessController;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.Map.Entry;
+import java.util.jar.Attributes;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
+
+import org.jboss.vfs.spi.ReadOnlyVFS;
+import org.jboss.vfs.spi.VirtualFile;
+import org.osgi.framework.AdminPermission;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * An implementation of the OSGi bundle interface that uses a vfs to access the bundle contents.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class VFSBundle implements Bundle
+{
+ private ReadOnlyVFS vfs;
+ private String vfsPath;
+ private long bundleID;
+ /** Is this an extension bundle */
+ private boolean extensionBundle;
+ /** Bundle headers - how to handle localization */
+ private Hashtable<String, String> headers = new Hashtable<String, String>();
+ /** Constants.BUNDLE_CATEGORY = Bundle-Category */
+ private String category;
+ /** Constants.BUNDLE_CLASSPATH Bundle-ClassPath */
+ private ArrayList<String> classpath;
+ /** Constants.BUNDLE_DESCRIPTION = "Bundle-Description" */
+ private String description;
+
+ /**
+ * Create a bundle from a bundle path in the given VFS.
+ *
+ * @param vfs - the VFS holding the bundle
+ * @param vfsPath - the path in the VFS for the bundle root
+ */
+ public VFSBundle(ReadOnlyVFS vfs, String vfsPath, long bundleID)
+ {
+ this.vfs = vfs;
+ this.vfsPath = vfsPath;
+ this.bundleID = bundleID;
+ }
+
+ // -------- Begin Bundle implementation
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.Bundle#findEntries(java.lang.String,
+ * java.lang.String, boolean)
+ */
+ public Enumeration findEntries(String path, String filePattern,
+ boolean recurse)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * Get the bundle id
+ *
+ * @see org.osgi.framework.Bundle#getBundleId()
+ */
+ public long getBundleId()
+ {
+ return bundleID;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.Bundle#getEntry(java.lang.String)
+ */
+ public URL getEntry(String name)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.Bundle#getEntryPaths(java.lang.String)
+ */
+ public Enumeration getEntryPaths(String path)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * Return the manifest headers
+ *
+ * @see org.osgi.framework.Bundle#getHeaders()
+ */
+ public Dictionary getHeaders()
+ {
+ if( System.getSecurityManager() != null )
+ {
+ AdminPermission p = new AdminPermission(this, "metadata");
+ AccessController.checkPermission(p);
+ }
+ return headers;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.Bundle#getHeaders(java.lang.String)
+ */
+ public Dictionary getHeaders(String locale)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.Bundle#getLastModified()
+ */
+ public long getLastModified()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.Bundle#getLocation()
+ */
+ public String getLocation()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.Bundle#getRegisteredServices()
+ */
+ public ServiceReference[] getRegisteredServices()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.Bundle#getResource(java.lang.String)
+ */
+ public URL getResource(String name)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.Bundle#getResources(java.lang.String)
+ */
+ public Enumeration getResources(String name) throws IOException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.Bundle#getServicesInUse()
+ */
+ public ServiceReference[] getServicesInUse()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.Bundle#getState()
+ */
+ public int getState()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.Bundle#getSymbolicName()
+ */
+ public String getSymbolicName()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.Bundle#hasPermission(java.lang.Object)
+ */
+ public boolean hasPermission(Object permission)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.Bundle#loadClass(java.lang.String)
+ */
+ public Class loadClass(String name) throws ClassNotFoundException
+ {
+ if( System.getSecurityManager() != null )
+ {
+ AdminPermission p = new AdminPermission(this, "class");
+ AccessController.checkPermission(p);
+ }
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.Bundle#start()
+ */
+ public void start() throws BundleException
+ {
+ if( System.getSecurityManager() != null )
+ {
+ AdminPermission p = new AdminPermission(this, "execute");
+ AccessController.checkPermission(p);
+ }
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.Bundle#stop()
+ */
+ public void stop() throws BundleException
+ {
+ if( System.getSecurityManager() != null )
+ {
+ AdminPermission p = new AdminPermission(this, "execute");
+ AccessController.checkPermission(p);
+ }
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.Bundle#uninstall()
+ */
+ public void uninstall() throws BundleException
+ {
+ if( System.getSecurityManager() != null )
+ {
+ AdminPermission p = new AdminPermission(this, extensionBundle ? "extensionLifecycle" : "lifecycle");
+ AccessController.checkPermission(p);
+ }
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * Update the bundle from the vfspath
+ * @see org.osgi.framework.Bundle#update()
+ */
+ public void update() throws BundleException
+ {
+ if( System.getSecurityManager() != null )
+ {
+ AdminPermission p = new AdminPermission(this, "extensionLifecycle");
+ AccessController.checkPermission(p);
+ }
+
+ try
+ {
+ VirtualFile bundleFile = vfs.resolveFile(this.vfsPath);
+ update(bundleFile);
+ }
+ catch(IOException e)
+ {
+ throw new BundleException("Failed to update from vfsPath: "+vfsPath, e);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.Bundle#update(java.io.InputStream)
+ */
+ public void update(InputStream in) throws BundleException
+ {
+ try
+ {
+ JarInputStream jis = new JarInputStream(in);
+ Manifest mf = jis.getManifest();
+ Attributes attrs = mf.getMainAttributes();
+ Iterator<Entry<Object,Object>> iter = attrs.entrySet().iterator();
+ while( iter.hasNext() )
+ {
+ Entry<Object,Object> entry = iter.next();
+ String key = (String) entry.getKey();
+ String value = (String) entry.getValue();
+ String lkey = key.toLowerCase();
+ headers.put(lkey, value);
+ }
+ jis.close();
+ // Validate the bundle headers
+ // TODO: Need to parse the values to extract the header attributes
+ extractImports();
+ extractExports();
+ }
+ catch(IOException e)
+ {
+ throw new BundleException("", e);
+ }
+ }
+
+ // -------- End Bundle implementation
+ public void update(VirtualFile bundleFile)
+ throws IOException, BundleException
+ {
+ InputStream is = bundleFile.openStream();
+ update(is);
+ }
+
+ protected void validateFragmentHost()
+ {
+ String key = Constants.FRAGMENT_HOST.toLowerCase();
+ String value = headers.get(key);
+
+ }
+ /**
+ Import-Package ::= import ( ',' import )*
+ import ::= package-names ( ';' parameter )*
+ package-names ::= package-name ( ';' package-name )*
+ */
+ protected void extractImports()
+ {
+ String key = Constants.IMPORT_PACKAGE;
+ String value = headers.get(key);
+ HeaderValue.PkgInfo pkgInfo = new HeaderValue.PkgInfo();
+ }
+ protected void extractExports()
+ {
+
+ }
+
+}
Property changes on: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/VFSBundle.java
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/VersionRange.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/VersionRange.java 2006-08-21 21:14:45 UTC (rev 56136)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/VersionRange.java 2006-08-21 21:15:52 UTC (rev 56137)
@@ -0,0 +1,147 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.vfs.bundle;
+
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.osgi.framework.Version;
+
+/**
+ * Represents an OSGi version range:
+ * version-range ::= interval | atleast
+ * interval ::= ( '[' | '(' ) floor ',' ceiling ( ']' | ')' )
+ * atleast ::= version
+ * floor ::= version
+ * ceiling ::= version
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class VersionRange
+{
+ /** The lower bound of the range */
+ private Version floor;
+ /** The upper bound of the range */
+ private Version ceiling;
+ /** is the floor version a >(true) or >= constraint(false) */
+ private boolean floorIsGreaterThan;
+ /** is the ceiling version a <(true) or <= constraint(false) */
+ private boolean ceilingIsLessThan;
+
+ public static VersionRange parseRangeSpec(String rangeSpec)
+ {
+ VersionRange range = null;
+ Version floor = null;
+ Version ceiling = null;
+ StringTokenizer st = new StringTokenizer(rangeSpec, ",[]()", true);
+ boolean floorIsGreaterThan = false;
+ boolean ceilingIsLessThan = false;
+ while( st.hasMoreTokens() )
+ {
+ String token = st.nextToken();
+ if( token.equals("[") )
+ floorIsGreaterThan = false;
+ else if( token.equals("(") )
+ floorIsGreaterThan = true;
+ else if( token.equals("]") )
+ ceilingIsLessThan = false;
+ else if( token.equals(")") )
+ ceilingIsLessThan = true;
+ else if( token.equals(",") )
+ continue;
+ else
+ {
+ // A version token
+ if( floor == null )
+ floor = new Version(token);
+ else
+ ceiling = new Version(token);
+ }
+
+ }
+ range = new VersionRange(floor, ceiling, floorIsGreaterThan, ceilingIsLessThan);
+ return range;
+ }
+
+ public VersionRange(String rangeSpec)
+ {
+
+ }
+
+ public VersionRange(Version floor, Version ceiling, boolean floorIsLessThan, boolean ceilingIsLessThan)
+ {
+ this.floor = floor;
+ this.ceiling = ceiling;
+ this.floorIsGreaterThan = floorIsLessThan;
+ this.ceilingIsLessThan = ceilingIsLessThan;
+ }
+
+ public boolean isInRange(Version v)
+ {
+ // Test a null floor version which implies 0.0.0 <= v <= inf
+ boolean isInRange = floor == null;
+ if( isInRange == false )
+ {
+ // Test the floor version
+ int floorCompare = v.compareTo(floor);
+ if( (floorIsGreaterThan && floorCompare > 0) || (floorIsGreaterThan == false && floorCompare >= 0) )
+ {
+ isInRange = ceiling == null;
+ if( isInRange == false )
+ {
+ // Test the ceiling version
+ int ceilingCompare = v.compareTo(ceiling);
+ if( (ceilingIsLessThan && ceilingCompare < 0) || (ceilingIsLessThan == false && ceilingCompare <= 0) )
+ {
+ isInRange = true;
+ }
+ }
+ }
+ }
+ return isInRange;
+ }
+
+ public String toString()
+ {
+ StringBuilder tmp = new StringBuilder();
+ if( floor == null )
+ tmp.append("0.0.0");
+ else
+ tmp.append(floor.toString());
+ tmp.append(" <");
+ if( floorIsGreaterThan == false )
+ tmp.append('=');
+ tmp.append(" v ");
+ // Ceiling
+ tmp.append('<');
+ if( ceilingIsLessThan == false )
+ tmp.append('=');
+ tmp.append(' ');
+ if( ceiling == null )
+ tmp.append("inf");
+ else
+ tmp.append(ceiling.toString());
+ return tmp.toString();
+ }
+}
Property changes on: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/vfs/bundle/VersionRange.java
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestBundleHeaders.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestBundleHeaders.java 2006-08-21 21:14:45 UTC (rev 56136)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestBundleHeaders.java 2006-08-21 21:15:52 UTC (rev 56137)
@@ -0,0 +1,117 @@
+
+package org.jboss.test.bundle;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.jboss.vfs.bundle.VersionRange;
+import org.osgi.framework.Version;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+/**
+ * Tests of the bundle manifest headers
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class TestBundleHeaders
+{
+ @Test
+ public void testRangeSpecRE()
+ {
+ String rangeSpec = "1.0.0";
+ // ( 1 ) (2 (3) (4) ) (5 (6) (7) (8) ) (9 (10) (11) (12) (13) )
+ String versionPat = "\\[?(\\d+)|((\\d+).(\\d+))|((\\d+).(\\d+).(\\d+))|((\\d+).(\\d+).(\\d+).(\\p{Alnum}))\\]";
+ Pattern VERSION_RANGE_RE = Pattern.compile(versionPat);
+ Matcher matcher = VERSION_RANGE_RE.matcher(rangeSpec);
+ if( matcher.matches() == true )
+ {
+ System.out.println("groupCount: "+matcher.groupCount());
+ for(int n = 1; n <= matcher.groupCount(); n ++)
+ {
+ String g = matcher.group(n);
+ System.out.println(n+":"+g);
+ }
+ }
+ }
+
+ @Test
+ public void testExclusiveRanges()
+ {
+ VersionRange v100to110ExclusiveRange = VersionRange.parseRangeSpec("(1.0.0,1.1.0)");
+ VersionRange v100GAto110GAExclusvieRange = VersionRange.parseRangeSpec("(1.0.0.GA,1.1.0.GA)");
+ Version v100 = new Version("1.0.0");
+ Version v100ga = new Version("1.0.0.GA");
+ Version v110 = new Version("1.1.0");
+ Version v110ga = new Version("1.1.0.GA");
+ Version v101ga = new Version("1.0.1.GA");
+ Version v102 = new Version("1.0.2");
+ assertFalse("1.0.0 is in "+v100to110ExclusiveRange, v100to110ExclusiveRange.isInRange(v100));
+ assertFalse("1.1.0 is in "+v100to110ExclusiveRange, v100to110ExclusiveRange.isInRange(v110));
+ assertFalse("1.0.0.GA is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v100ga));
+ assertFalse("1.1.0.GA is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v110ga));
+ assertTrue("1.0.1.GA is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v101ga));
+ assertTrue("1.0.2 is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v102));
+ }
+
+ @Test
+ public void testInclusiveRanges()
+ {
+ VersionRange v100to110InclusiveRange = VersionRange.parseRangeSpec("[1.0.0,1.1.0]");
+ VersionRange v100GAto110GAInclusiveRange = VersionRange.parseRangeSpec("[1.0.0.GA,1.1.0.GA]");
+ Version v100 = new Version("1.0.0");
+ Version v100ga = new Version("1.0.0.GA");
+ Version v110 = new Version("1.1.0");
+ Version v110ga = new Version("1.1.0.GA");
+ Version v101ga = new Version("1.0.1.GA");
+ Version v102 = new Version("1.0.2");
+ assertTrue("1.0.0 is in "+v100to110InclusiveRange, v100to110InclusiveRange.isInRange(v100));
+ assertTrue("1.1.0 is in "+v100to110InclusiveRange, v100to110InclusiveRange.isInRange(v110));
+ assertTrue("1.0.0.GA is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v100ga));
+ assertTrue("1.1.0.GA is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v110ga));
+ assertTrue("1.0.1.GA is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v101ga));
+ assertTrue("1.0.2 is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v102));
+ }
+
+ @Test
+ public void testMixedRanges()
+ {
+ VersionRange v100to110InclusiveLowerExclusiveUpperRange = VersionRange.parseRangeSpec("[1.0.0,1.1.0)");
+ VersionRange v100to110ExclusiveLowerInclusiveUpperRange = VersionRange.parseRangeSpec("(1.0.0,1.1.0]");
+ VersionRange v100GAto110GAInclusiveLowerExclusiveUpperRange = VersionRange.parseRangeSpec("[1.0.0.GA,1.1.0.GA)");
+ VersionRange v100GAto110GAExclusiveLowerInclusiveUpperRange = VersionRange.parseRangeSpec("(1.0.0.GA,1.1.0.GA]");
+ Version v100 = new Version("1.0.0");
+ Version v100ga = new Version("1.0.0.GA");
+ Version v110 = new Version("1.1.0");
+ Version v110ga = new Version("1.1.0.GA");
+ Version v101ga = new Version("1.0.1.GA");
+ Version v102 = new Version("1.0.2");
+ assertTrue("1.0.0 is in "+v100to110InclusiveLowerExclusiveUpperRange, v100to110InclusiveLowerExclusiveUpperRange.isInRange(v100));
+ assertFalse("1.0.0 is in "+v100to110ExclusiveLowerInclusiveUpperRange, v100to110ExclusiveLowerInclusiveUpperRange.isInRange(v100));
+ assertFalse("1.1.0 is in "+v100to110InclusiveLowerExclusiveUpperRange, v100to110InclusiveLowerExclusiveUpperRange.isInRange(v110));
+ assertTrue("1.1.0 is in "+v100to110ExclusiveLowerInclusiveUpperRange, v100to110ExclusiveLowerInclusiveUpperRange.isInRange(v110));
+
+ assertTrue("1.0.0.GA is in "+v100GAto110GAInclusiveLowerExclusiveUpperRange, v100GAto110GAInclusiveLowerExclusiveUpperRange.isInRange(v100ga));
+ assertFalse("1.1.0.GA is in "+v100GAto110GAInclusiveLowerExclusiveUpperRange, v100GAto110GAInclusiveLowerExclusiveUpperRange.isInRange(v110ga));
+ assertFalse("1.0.0.GA is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v100ga));
+ assertTrue("1.1.0.GA is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v110ga));
+ assertTrue("1.0.1.GA is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v101ga));
+ assertTrue("1.0.2 is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v102));
+ }
+
+ @Test
+ public void testSingleRange()
+ {
+ VersionRange v100Range = VersionRange.parseRangeSpec("1.0.0");
+ Version v100 = new Version("1.0.0");
+ assertTrue("1.0.0 is in "+v100Range, v100Range.isInRange(v100));
+ Version v200 = new Version("2.0.0");
+ assertTrue("2.0.0 is in "+v100Range, v100Range.isInRange(v200));
+ Version v200ga = new Version("2.0.0.GA");
+ assertTrue("2.0.0.GA is in "+v100Range, v100Range.isInRange(v200ga));
+ Version v09beta = new Version("0.9.0.beta");
+ assertFalse("0.9.0.beta is in "+v100Range, v100Range.isInRange(v09beta));
+ }
+}
Property changes on: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestBundleHeaders.java
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestVersionRange.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestVersionRange.java 2006-08-21 21:14:45 UTC (rev 56136)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestVersionRange.java 2006-08-21 21:15:52 UTC (rev 56137)
@@ -0,0 +1,117 @@
+
+package org.jboss.test.bundle;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.jboss.vfs.bundle.VersionRange;
+import org.osgi.framework.Version;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+/**
+ * Tests of the version range comparision
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class TestVersionRange
+{
+ @Test
+ public void testRangeSpecRE()
+ {
+ String rangeSpec = "1.0.0";
+ // ( 1 ) (2 (3) (4) ) (5 (6) (7) (8) ) (9 (10) (11) (12) (13) )
+ String versionPat = "\\[?(\\d+)|((\\d+).(\\d+))|((\\d+).(\\d+).(\\d+))|((\\d+).(\\d+).(\\d+).(\\p{Alnum}))\\]";
+ Pattern VERSION_RANGE_RE = Pattern.compile(versionPat);
+ Matcher matcher = VERSION_RANGE_RE.matcher(rangeSpec);
+ if( matcher.matches() == true )
+ {
+ System.out.println("groupCount: "+matcher.groupCount());
+ for(int n = 1; n <= matcher.groupCount(); n ++)
+ {
+ String g = matcher.group(n);
+ System.out.println(n+":"+g);
+ }
+ }
+ }
+
+ @Test
+ public void testExclusiveRanges()
+ {
+ VersionRange v100to110ExclusiveRange = VersionRange.parseRangeSpec("(1.0.0,1.1.0)");
+ VersionRange v100GAto110GAExclusvieRange = VersionRange.parseRangeSpec("(1.0.0.GA,1.1.0.GA)");
+ Version v100 = new Version("1.0.0");
+ Version v100ga = new Version("1.0.0.GA");
+ Version v110 = new Version("1.1.0");
+ Version v110ga = new Version("1.1.0.GA");
+ Version v101ga = new Version("1.0.1.GA");
+ Version v102 = new Version("1.0.2");
+ assertFalse("1.0.0 is in "+v100to110ExclusiveRange, v100to110ExclusiveRange.isInRange(v100));
+ assertFalse("1.1.0 is in "+v100to110ExclusiveRange, v100to110ExclusiveRange.isInRange(v110));
+ assertFalse("1.0.0.GA is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v100ga));
+ assertFalse("1.1.0.GA is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v110ga));
+ assertTrue("1.0.1.GA is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v101ga));
+ assertTrue("1.0.2 is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v102));
+ }
+
+ @Test
+ public void testInclusiveRanges()
+ {
+ VersionRange v100to110InclusiveRange = VersionRange.parseRangeSpec("[1.0.0,1.1.0]");
+ VersionRange v100GAto110GAInclusiveRange = VersionRange.parseRangeSpec("[1.0.0.GA,1.1.0.GA]");
+ Version v100 = new Version("1.0.0");
+ Version v100ga = new Version("1.0.0.GA");
+ Version v110 = new Version("1.1.0");
+ Version v110ga = new Version("1.1.0.GA");
+ Version v101ga = new Version("1.0.1.GA");
+ Version v102 = new Version("1.0.2");
+ assertTrue("1.0.0 is in "+v100to110InclusiveRange, v100to110InclusiveRange.isInRange(v100));
+ assertTrue("1.1.0 is in "+v100to110InclusiveRange, v100to110InclusiveRange.isInRange(v110));
+ assertTrue("1.0.0.GA is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v100ga));
+ assertTrue("1.1.0.GA is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v110ga));
+ assertTrue("1.0.1.GA is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v101ga));
+ assertTrue("1.0.2 is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v102));
+ }
+
+ @Test
+ public void testMixedRanges()
+ {
+ VersionRange v100to110InclusiveLowerExclusiveUpperRange = VersionRange.parseRangeSpec("[1.0.0,1.1.0)");
+ VersionRange v100to110ExclusiveLowerInclusiveUpperRange = VersionRange.parseRangeSpec("(1.0.0,1.1.0]");
+ VersionRange v100GAto110GAInclusiveLowerExclusiveUpperRange = VersionRange.parseRangeSpec("[1.0.0.GA,1.1.0.GA)");
+ VersionRange v100GAto110GAExclusiveLowerInclusiveUpperRange = VersionRange.parseRangeSpec("(1.0.0.GA,1.1.0.GA]");
+ Version v100 = new Version("1.0.0");
+ Version v100ga = new Version("1.0.0.GA");
+ Version v110 = new Version("1.1.0");
+ Version v110ga = new Version("1.1.0.GA");
+ Version v101ga = new Version("1.0.1.GA");
+ Version v102 = new Version("1.0.2");
+ assertTrue("1.0.0 is in "+v100to110InclusiveLowerExclusiveUpperRange, v100to110InclusiveLowerExclusiveUpperRange.isInRange(v100));
+ assertFalse("1.0.0 is in "+v100to110ExclusiveLowerInclusiveUpperRange, v100to110ExclusiveLowerInclusiveUpperRange.isInRange(v100));
+ assertFalse("1.1.0 is in "+v100to110InclusiveLowerExclusiveUpperRange, v100to110InclusiveLowerExclusiveUpperRange.isInRange(v110));
+ assertTrue("1.1.0 is in "+v100to110ExclusiveLowerInclusiveUpperRange, v100to110ExclusiveLowerInclusiveUpperRange.isInRange(v110));
+
+ assertTrue("1.0.0.GA is in "+v100GAto110GAInclusiveLowerExclusiveUpperRange, v100GAto110GAInclusiveLowerExclusiveUpperRange.isInRange(v100ga));
+ assertFalse("1.1.0.GA is in "+v100GAto110GAInclusiveLowerExclusiveUpperRange, v100GAto110GAInclusiveLowerExclusiveUpperRange.isInRange(v110ga));
+ assertFalse("1.0.0.GA is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v100ga));
+ assertTrue("1.1.0.GA is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v110ga));
+ assertTrue("1.0.1.GA is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v101ga));
+ assertTrue("1.0.2 is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v102));
+ }
+
+ @Test
+ public void testSingleRange()
+ {
+ VersionRange v100Range = VersionRange.parseRangeSpec("1.0.0");
+ Version v100 = new Version("1.0.0");
+ assertTrue("1.0.0 is in "+v100Range, v100Range.isInRange(v100));
+ Version v200 = new Version("2.0.0");
+ assertTrue("2.0.0 is in "+v100Range, v100Range.isInRange(v200));
+ Version v200ga = new Version("2.0.0.GA");
+ assertTrue("2.0.0.GA is in "+v100Range, v100Range.isInRange(v200ga));
+ Version v09beta = new Version("0.9.0.beta");
+ assertFalse("0.9.0.beta is in "+v100Range, v100Range.isInRange(v09beta));
+ }
+}
Property changes on: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestVersionRange.java
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/CommonClass.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/CommonClass.java 2006-08-21 21:14:45 UTC (rev 56136)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/CommonClass.java 2006-08-21 21:15:52 UTC (rev 56137)
@@ -0,0 +1,10 @@
+package org.jboss.test.vfs.support;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 44150 $
+ */
+public class CommonClass
+{
+
+}
Property changes on: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/CommonClass.java
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestBundleActivator.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestBundleActivator.java 2006-08-21 21:14:45 UTC (rev 56136)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestBundleActivator.java 2006-08-21 21:15:52 UTC (rev 56137)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.bundle;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class TestBundleActivator
+ implements BundleActivator
+{
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestBundleActivator.java
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/jar1/ClassInJar1.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/jar1/ClassInJar1.java 2006-08-21 21:14:45 UTC (rev 56136)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/jar1/ClassInJar1.java 2006-08-21 21:15:52 UTC (rev 56137)
@@ -0,0 +1,14 @@
+package org.jboss.test.vfs.support.jar1;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 55388 $
+ */
+public class ClassInJar1
+{
+ public static final String VERSION="1.0.0";
+ static class InnerClass
+ {
+ public static final String VERSION="1.0.0i";
+ }
+}
Property changes on: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/jar1/ClassInJar1.java
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/jar2/ClassInJar2.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/jar2/ClassInJar2.java 2006-08-21 21:14:45 UTC (rev 56136)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/jar2/ClassInJar2.java 2006-08-21 21:15:52 UTC (rev 56137)
@@ -0,0 +1,13 @@
+package org.jboss.test.vfs.support.jar2;
+
+import org.jboss.test.vfs.support.CommonClass;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 44150 $
+ */
+public class ClassInJar2
+{
+ public static final String VERSION="1.0.0";
+ public static Class commonClass = CommonClass.class;
+}
Property changes on: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/jar2/ClassInJar2.java
___________________________________________________________________
Name: svn:executable
+ *
More information about the jboss-cvs-commits
mailing list