You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rs...@apache.org on 2008/05/18 11:03:02 UTC
svn commit: r657517 - in /incubator/tuscany/java/sca/itest/osgi-tuscany: ./
osgi-tuscany-test/src/main/java/org/apache/tuscany/sca/test/util/
osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/harness/
osgi-tuscany-test/src/test/java/org/...
Author: rsivaram
Date: Sun May 18 02:03:02 2008
New Revision: 657517
URL: http://svn.apache.org/viewvc?rev=657517&view=rev
Log:
Add OSGi installer for Tuscany in itest/osgi-tuscany
Added:
incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/
incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/pom.xml (with props)
incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/
incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/main/
incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/main/java/
incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/main/java/org/
incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/main/java/org/apache/
incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/main/java/org/apache/tuscany/
incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/main/java/org/apache/tuscany/sca/
incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/main/java/org/apache/tuscany/sca/installer/
incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/main/java/org/apache/tuscany/sca/installer/InstallerBundleActivator.java (with props)
Removed:
incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-3rdparty-manifest/
incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-manifest/
Modified:
incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/main/java/org/apache/tuscany/sca/test/util/TuscanyLoader.java
incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/harness/OSGiTuscanyNonOSGiTestHarness.java
incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/harness/OSGiTuscanyTestHarness.java
incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/tuscany/OSGiSupplyChainTestCase.java
incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/tuscany/OSGiTuscanyRuntimeTestCase.java
incubator/tuscany/java/sca/itest/osgi-tuscany/pom.xml
Modified: incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/main/java/org/apache/tuscany/sca/test/util/TuscanyLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/main/java/org/apache/tuscany/sca/test/util/TuscanyLoader.java?rev=657517&r1=657516&r2=657517&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/main/java/org/apache/tuscany/sca/test/util/TuscanyLoader.java (original)
+++ incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/main/java/org/apache/tuscany/sca/test/util/TuscanyLoader.java Sun May 18 02:03:02 2008
@@ -4,7 +4,6 @@
import java.io.File;
import java.io.FilenameFilter;
import java.lang.reflect.Method;
-import java.util.HashSet;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -16,58 +15,16 @@
*/
public class TuscanyLoader {
- public enum TuscanyRuntimeBundleType {
- ITEST_4_BUNDLES,
- MODULE_BUNDLES
- };
-
- public enum Tuscany3rdPartyBundleType {
- ITEST_SINGLE_BUNDLE,
- VIRTUAL_BUNDLES
- };
+ private static final String tuscanyInstallerDir = "../tuscany-osgi-installer";
+ private static final String tuscanyInstallerJar = "tuscany-sca-osgi-installer.jar";
+ // 5-bundle version of Tuscany
private static final String scaApiDir = "../sca-api";
private static final String tuscanySpiDir = "../tuscany-spi";
private static final String tuscanyRuntimeDir = "../tuscany-runtime";
private static final String tuscanyExtensionsDir = "../tuscany-extensions";
private static final String thirdPartyDir = "../tuscany-3rdparty";
- private static final String tuscanyManifestDir = "../tuscany-manifest";
- private static final String tuscanyManifestJar = "tuscany-sca-manifest.jar";
-
- private static final String tuscanyModulesDir = "../../../modules";
- private static final String[] tuscanyModulesToIgnore = {
- "node2-api",
- "node2-impl",
- "node2-launcher",
- "node2-launcher-webapp",
- "implementation-node-runtime", // uses node2
- "saxon",
- "runtime",
- "runtime-webapp",
- "runtime-tomcat",
- "runtime-war",
- "host-webapp",
- "host-tomcat",
- "policy-transaction",
- "implementation-bpel",
- "binding-ejb",
- "implementation-ejb",
- "implementation-ejb-xml",
-
- };
-
- private static final HashSet<String> ignoreTuscanyModules = new HashSet<String>();
-
- private static String manifestClassPath = null;
-
- static {
- for (String ignoreModule : tuscanyModulesToIgnore) {
- ignoreTuscanyModules.add(ignoreModule);
- }
- }
-
-
private static String findBundle(String subDirName, final String jarPrefix) throws Exception {
File dir = new File(subDirName + "/target");
@@ -87,96 +44,36 @@
}
public static Bundle loadTuscanyIntoOSGi(BundleContext bundleContext) throws Exception {
- return loadTuscanyIntoOSGi(bundleContext, TuscanyRuntimeBundleType.MODULE_BUNDLES, Tuscany3rdPartyBundleType.VIRTUAL_BUNDLES);
- }
-
- public static Bundle loadTuscanyIntoOSGi(BundleContext bundleContext,
- TuscanyRuntimeBundleType runtimeBundleType,
- Tuscany3rdPartyBundleType thirdPartyBundleType)
- throws Exception {
-
-
- if (thirdPartyBundleType == Tuscany3rdPartyBundleType.ITEST_SINGLE_BUNDLE)
- loadCombinedThirdPartyBundle(bundleContext);
- else
- loadVirtualThirdPartyBundles(bundleContext);
-
- if (runtimeBundleType == TuscanyRuntimeBundleType.ITEST_4_BUNDLES)
- return load4BundleTuscanyRuntime(bundleContext);
- else
- return loadTuscanyModules(bundleContext);
-
- }
-
- public static void loadCombinedThirdPartyBundle(BundleContext bundleContext) throws Exception {
-
- String thirdPartyBundleName = findBundle(thirdPartyDir, null);
- Bundle thirdPartyBundle = bundleContext.installBundle(thirdPartyBundleName);
- thirdPartyBundle.start();
- }
-
-
- public static void loadVirtualThirdPartyBundles(BundleContext bundleContext) throws Exception {
-
- String tuscanyManifestBundleName = new File(tuscanyManifestDir + "/target/" + tuscanyManifestJar).toURI().toURL().toString();
- Bundle tuscanyManifestBundle = bundleContext.installBundle(tuscanyManifestBundleName);
- tuscanyManifestBundle.start();
-
- manifestClassPath = (String)tuscanyManifestBundle.getHeaders().get("Class-Path");
- }
-
-
- /**
- * Load Tuscany module bundles
- *
- * @param bundleContext
- */
- public static Bundle loadTuscanyModules(BundleContext bundleContext) throws Exception {
-
-
- Bundle tuscanyRuntimeBundle = null;
- File dir = new File(tuscanyModulesDir);
- if (dir.exists() && dir.isDirectory()) {
- File[] files = dir.listFiles(new FilenameFilter() {
-
- public boolean accept(File dir, String name) {
- return true;
- }
-
- });
-
- if (files != null && files.length > 0) {
- for (File file : files) {
- if (ignoreTuscanyModules.contains(file.getName()))
- continue;
- if (manifestClassPath != null && manifestClassPath.indexOf(file.getName()) < 0)
- continue;
- String bundleURL = findBundle(file.toString(), "tuscany");
- if (bundleURL != null) {
- Bundle bundle = bundleContext.installBundle(bundleURL);
- if (bundle != null && file.getName().equals("osgi-runtime")) {
- tuscanyRuntimeBundle = bundle;
- }
- }
- }
+ String tuscanyInstallerBundleName = new File(tuscanyInstallerDir + "/target/" + tuscanyInstallerJar).toURI().toURL().toString();
+ Bundle tuscanyInstallerBundle = bundleContext.installBundle(tuscanyInstallerBundleName);
+ tuscanyInstallerBundle.start();
+ Bundle[] bundles = bundleContext.getBundles();
+ Bundle tuscanyRuntimeBundle = tuscanyInstallerBundle;
+ for (Bundle bundle : bundles) {
+ if ("org.apache.tuscany.sca.osgi.runtime".equals(bundle.getSymbolicName())) {
+ tuscanyRuntimeBundle = bundle;
+ break;
}
}
+ setThreadContextClassLoader(tuscanyRuntimeBundle);
return tuscanyRuntimeBundle;
-
}
-
-
/**
- * Load four Tuscany bundles (API, Core-SPI, Runtime, Extensions)
+ * Load four Tuscany bundles (API, Core-SPI, Runtime, Extensions) and combined third party bundle
*
* @param bundleContext
*/
- public static Bundle load4BundleTuscanyRuntime(BundleContext bundleContext) throws Exception {
+ public static Bundle load5BundleTuscanyIntoOSGi(BundleContext bundleContext) throws Exception {
+ String thirdPartyBundleName = findBundle(thirdPartyDir, null);
+ Bundle thirdPartyBundle = bundleContext.installBundle(thirdPartyBundleName);
+ thirdPartyBundle.start();
+
+
String scaApiBundleName = findBundle(scaApiDir, null);
Bundle scaApiBundle = bundleContext.installBundle(scaApiBundleName);
scaApiBundle.start();
@@ -194,24 +91,24 @@
tuscanySpiBundle.start();
tuscanyExtensionsBundle.start();
+ setThreadContextClassLoader(tuscanyRuntimeBundle);
return tuscanyRuntimeBundle;
}
- public static void startTuscany(Bundle tuscanyRuntimeBundle) throws BundleException {
+
+ // Tuscany runtime is started on a different thread when previously cached bundle is used.
+ // Set this thread's TCCL to the one used by the runtime.
+ public static void setThreadContextClassLoader(Bundle tuscanyRuntimeBundle) throws BundleException {
if (tuscanyRuntimeBundle != null) {
- tuscanyRuntimeBundle.start();
- // Tuscany runtime is started on a different thread when previously cached bundle is used.
- // Set this thread's TCCL to the one used by the runtime.
try {
Class<?> runtimeClass = tuscanyRuntimeBundle.loadClass("org.apache.tuscany.sca.osgi.runtime.OSGiRuntime");
Method getRuntimeMethod = runtimeClass.getMethod("findRuntime");
Object runtime = getRuntimeMethod.invoke(runtimeClass);
Method getTCCLMethod = runtimeClass.getMethod("getContextClassLoader");
ClassLoader runtimeTCCL = (ClassLoader) getTCCLMethod.invoke(runtime);
- Thread.currentThread().setContextClassLoader(runtimeTCCL);
-
+ Thread.currentThread().setContextClassLoader(runtimeTCCL);
} catch (Throwable e) {
}
Modified: incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/harness/OSGiTuscanyNonOSGiTestHarness.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/harness/OSGiTuscanyNonOSGiTestHarness.java?rev=657517&r1=657516&r2=657517&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/harness/OSGiTuscanyNonOSGiTestHarness.java (original)
+++ incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/harness/OSGiTuscanyNonOSGiTestHarness.java Sun May 18 02:03:02 2008
@@ -65,9 +65,6 @@
tuscanyRuntime = TuscanyLoader.loadTuscanyIntoOSGi(getBundleContext());
- TuscanyLoader.startTuscany(tuscanyRuntime);
-
-
long endTime = System.currentTimeMillis();
System.out.println("Loaded Tuscany, time taken = " + (endTime-startTime) + " ms" );
Modified: incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/harness/OSGiTuscanyTestHarness.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/harness/OSGiTuscanyTestHarness.java?rev=657517&r1=657516&r2=657517&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/harness/OSGiTuscanyTestHarness.java (original)
+++ incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/harness/OSGiTuscanyTestHarness.java Sun May 18 02:03:02 2008
@@ -118,8 +118,6 @@
);
- TuscanyLoader.startTuscany(tuscanyRuntime);
-
long endTime = System.currentTimeMillis();
Modified: incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/tuscany/OSGiSupplyChainTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/tuscany/OSGiSupplyChainTestCase.java?rev=657517&r1=657516&r2=657517&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/tuscany/OSGiSupplyChainTestCase.java (original)
+++ incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/tuscany/OSGiSupplyChainTestCase.java Sun May 18 02:03:02 2008
@@ -51,7 +51,7 @@
if (bundleContext != null) {
Bundle[] bundles = bundleContext.getBundles();
for (Bundle bundle : bundles) {
- if (bundle.getSymbolicName() != null && bundle.getSymbolicName().startsWith("supplychain"))
+ if (bundle.getSymbolicName() != null && bundle.getSymbolicName().contains("supplychain"))
bundle.uninstall();
}
}
Modified: incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/tuscany/OSGiTuscanyRuntimeTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/tuscany/OSGiTuscanyRuntimeTestCase.java?rev=657517&r1=657516&r2=657517&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/tuscany/OSGiTuscanyRuntimeTestCase.java (original)
+++ incubator/tuscany/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/test/java/org/apache/tuscany/sca/test/osgi/tuscany/OSGiTuscanyRuntimeTestCase.java Sun May 18 02:03:02 2008
@@ -23,11 +23,12 @@
import java.lang.reflect.Method;
import java.net.URL;
+import junit.framework.Assert;
+
import org.apache.tuscany.sca.test.osgi.runtime.impl.OSGiTestRuntime;
import org.apache.tuscany.sca.test.util.OSGiRuntimeLoader;
import org.apache.tuscany.sca.test.util.TuscanyLoader;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -77,8 +78,16 @@
tuscanyRuntime = TuscanyLoader.loadTuscanyIntoOSGi(osgiRuntime.getBundleContext());
Assert.assertNotNull(tuscanyRuntime);
- TuscanyLoader.startTuscany(tuscanyRuntime);
- Class<?> clazz = tuscanyRuntime.loadClass("org.apache.tuscany.sca.osgi.runtime.OSGiRuntime");
+ Bundle[] bundles = osgiRuntime.getBundleContext().getBundles();
+ Bundle runtimeBundle = null;
+ for (Bundle bundle : bundles) {
+ if ("org.apache.tuscany.sca.osgi.runtime".equals(bundle.getSymbolicName())) {
+ runtimeBundle = bundle;
+ break;
+ }
+ }
+ Assert.assertNotNull(runtimeBundle);
+ Class<?> clazz = runtimeBundle.loadClass("org.apache.tuscany.sca.osgi.runtime.OSGiRuntime");
Assert.assertNotNull(clazz);
}
@@ -97,7 +106,6 @@
private void testOSGiTuscanyUsingOSGiClient(String contributionJarName) throws Exception {
tuscanyRuntime = TuscanyLoader.loadTuscanyIntoOSGi(osgiRuntime.getBundleContext());
- TuscanyLoader.startTuscany(tuscanyRuntime);
String folderName = "../test-bundles/target/";
String supplychainJarName = contributionJarName;
Modified: incubator/tuscany/java/sca/itest/osgi-tuscany/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-tuscany/pom.xml?rev=657517&r1=657516&r2=657517&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-tuscany/pom.xml (original)
+++ incubator/tuscany/java/sca/itest/osgi-tuscany/pom.xml Sun May 18 02:03:02 2008
@@ -30,22 +30,8 @@
<name>Apache Tuscany OSGi-based Tuscany Runtime Integration Tests</name>
<modules>
-
-<!--
- <module>sca-api</module>
- <module>tuscany-spi</module>
- <module>tuscany-runtime</module>
- <module>tuscany-extensions</module>
- <module>tuscany-3rdparty</module>
-
-
- <module>tuscany-3rdparty-manifest</module>
--->
-
- <module>tuscany-manifest</module>
-
-
<module>test-bundles</module>
+ <module>tuscany-osgi-installer</module>
<module>osgi-tuscany-test</module>
</modules>
Added: incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/pom.xml?rev=657517&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/pom.xml (added)
+++ incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/pom.xml Sun May 18 02:03:02 2008
@@ -0,0 +1,703 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-incubating-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-osgi-tuscany-installer</artifactId>
+ <name>Apache Tuscany OSGi - Tuscany Installer Bundle</name>
+
+ <properties>
+ <maven.test.skip>true</maven.test.skip>
+ <tuscany.version>${pom.version}</tuscany.version>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-dwr</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-ejb</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-atom</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+<!--
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-atom-abdera</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+-->
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-feed</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-rss</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-rss-rome</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-http</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-jms</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>apache-activemq</artifactId>
+ <version>4.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-console</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-optional</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-web</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-web-demo</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-jaas</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-j2ee-jacc_1.0_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jsp_2.0_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-j2ee-management_1.0_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>servlet-api-2.5</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>activesoap</groupId>
+ <artifactId>jaxp-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>activemq</groupId>
+ <artifactId>jmdns</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jrms</groupId>
+ <artifactId>jrms</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xmlParserAPIs</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xstream</groupId>
+ <artifactId>xstream</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xmlpull</groupId>
+ <artifactId>xmlpull</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>mx4j</groupId>
+ <artifactId>mx4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>mx4j</groupId>
+ <artifactId>mx4j-remote</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-jsonrpc</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-notification</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-rmi</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-sca</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-sca-axis2</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-sca-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-ws</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-ws-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-contribution-groovy</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-contribution-impl</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-contribution-java</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-contribution-namespace</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-databinding-axiom</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-databinding-fastinfoset</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-databinding-sdo</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-databinding-sdo-axiom</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-databinding-xmlbeans</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-databinding-xstream</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-domain</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-domain-api</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-domain-impl</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-host-rmi</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-interface</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-interface-java-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-interface-wsdl-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+<!--
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-bpel</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+-->
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-das</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-ejb</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-ejb-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-java</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-java-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-node</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-node-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-node-runtime</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-host-tomcat</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-osgi</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-resource</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-script</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>groovy</groupId>
+ <artifactId>groovy-all-minimal</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-spring</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-xquery</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-widget</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-node</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+<!--
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-node2-api</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-node2-impl</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-node2-launcher</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+-->
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-policy</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-policy-logging</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-policy-security</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-policy-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-definitions</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-workspace</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-domain-manager</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-host-tomcat</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-workspace-impl</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-workspace-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+<!--
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-java2wsdl</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-wsdl2java</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+-->
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-impl</artifactId>
+ <version>1.1-incubating</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-tools</artifactId>
+ <version>1.1-incubating</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.1.6</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.xml.stream</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>2.2</version>
+ </dependency>
+ </dependencies>
+
+
+ <build>
+
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <configuration>
+ <cpFile>${project.build.directory}/classes/org/apache/tuscany/sca/installer/.classpath</cpFile>
+ <includeScope>runtime</includeScope>
+ </configuration>
+ <executions>
+ <execution>
+ <id>build-classpath</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>build-classpath</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <finalName>tuscany-sca-osgi-installer</finalName>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ </manifest>
+ <manifestEntries>
+
+ <Bundle-Version>2.0</Bundle-Version>
+ <Bundle-SymbolicName>org.apache.tuscany.sca.installer</Bundle-SymbolicName>
+ <Bundle-Description>${pom.name}</Bundle-Description>
+ <Import-Package>org.osgi.framework</Import-Package>
+ <Export-Package>org.apache.tuscany.sca.installer</Export-Package>
+ <Bundle-Activator>org.apache.tuscany.sca.installer.InstallerBundleActivator</Bundle-Activator>
+kage>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
Propchange: incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/main/java/org/apache/tuscany/sca/installer/InstallerBundleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/main/java/org/apache/tuscany/sca/installer/InstallerBundleActivator.java?rev=657517&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/main/java/org/apache/tuscany/sca/installer/InstallerBundleActivator.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/main/java/org/apache/tuscany/sca/installer/InstallerBundleActivator.java Sun May 18 02:03:02 2008
@@ -0,0 +1,400 @@
+package org.apache.tuscany.sca.installer;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.jar.Attributes;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.zip.ZipEntry;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Bundle activator which installs Tuscany modules and 3rd party jars into an OSGi runtime.
+ *
+ */
+public class InstallerBundleActivator implements BundleActivator {
+
+ private static final String TUSCANY_INSTALLER_JAR = "tuscany-sca-osgi-installer.jar";
+ private static final String TUSCANY_CLASSPATH = "org/apache/tuscany/sca/installer/.classpath";
+
+ private static final String TUSCANY_OSGI_MANIFEST_DIR = "org/apache/tuscany/sca/manifest";
+
+ private ArrayList<Bundle> tuscanyBundles = new ArrayList<Bundle>();
+
+ private static final String[] immutableJars = {
+ "bcprov"
+ };
+
+ private static final String[] tuscanyModulesToIgnore = {
+ "node2-api",
+ "node2-impl",
+ "node2-launcher",
+ "node2-launcher-webapp",
+ "implementation-node-runtime", // uses node2
+ "saxon",
+ "runtime",
+ "runtime-webapp",
+ "runtime-tomcat",
+ "runtime-war",
+ "host-webapp",
+ "host-tomcat",
+ "policy-transaction",
+ "implementation-bpel",
+ "binding-ejb",
+ "implementation-ejb",
+ "implementation-ejb-xml",
+
+ };
+
+ public void start(BundleContext bundleContext) throws Exception {
+
+ installTuscanyIntoOSGi(bundleContext);
+ }
+
+ public void stop(BundleContext bundleContext) throws Exception {
+
+ for (Bundle bundle : tuscanyBundles) {
+ try {
+ bundle.stop();
+ } catch (Exception e) {
+ // Ignore error
+ }
+ }
+ }
+
+ private void installTuscanyIntoOSGi(BundleContext bundleContext) {
+
+ try {
+ Bundle[] installedBundles = bundleContext.getBundles();
+ HashSet<String> installedBundleSet = new HashSet<String>();
+ for (Bundle bundle : installedBundles) {
+ if (bundle.getSymbolicName() != null)
+ installedBundleSet.add(bundle.getSymbolicName());
+ }
+
+ // FIXME: SDO bundles dont have the correct dependencies
+ System.setProperty("commonj.sdo.impl.HelperProvider", "org.apache.tuscany.sdo.helper.HelperProviderImpl");
+
+ HashSet<File> tuscanyJars = new HashSet<File>();
+ HashMap<File, InputStream> thirdPartyJarsWithManifests = new HashMap<File, InputStream>();
+ HashSet<File> thirdPartyJars = new HashSet<File>();
+
+ findJars(bundleContext, tuscanyJars, thirdPartyJars, thirdPartyJarsWithManifests);
+
+ for (File bundleFile : thirdPartyJarsWithManifests.keySet()) {
+
+ String bundleLocation = bundleFile.toURI().toURL().toString();
+ InputStream bundleManifestStream = thirdPartyJarsWithManifests.get(bundleFile);
+ HashSet<File> jarSet = new HashSet<File>();
+ jarSet.add(bundleFile);
+
+ createAndInstallBundle(bundleContext, bundleLocation, bundleManifestStream, jarSet);
+ bundleManifestStream.close();
+
+ }
+
+ for (File bundleFile : thirdPartyJars) {
+
+ String bundleName = bundleFile.getName();
+ if (bundleName.startsWith("org.apache.felix"))
+ continue;
+
+ String bundleSymbolicName = "org.apache.tuscany.sca.3rdparty." + bundleName;
+ if (bundleSymbolicName.endsWith(".jar")) bundleSymbolicName = bundleSymbolicName.substring(0, bundleSymbolicName.length()-4);
+ if (installedBundleSet.contains(bundleSymbolicName))
+ continue;
+
+ String bundleLocation = bundleFile.toURI().toURL().toString();
+ InputStream bundleManifestStream = createBundleManifest(bundleFile, bundleSymbolicName);
+ HashSet<File> jarSet = new HashSet<File>();
+ jarSet.add(bundleFile);
+
+ createAndInstallBundle(bundleContext, bundleLocation, bundleManifestStream, jarSet);
+ bundleManifestStream.close();
+
+ }
+
+ Bundle osgiRuntimeBundle = null;
+ for (File bundleFile : tuscanyJars) {
+ Bundle bundle = bundleContext.installBundle(bundleFile.toURI().toURL().toString());
+ if ("org.apache.tuscany.sca.osgi.runtime".equals(bundle.getSymbolicName()))
+ osgiRuntimeBundle = bundle;
+ }
+ if (osgiRuntimeBundle != null)
+ osgiRuntimeBundle.start();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void findJars(BundleContext bundleContext,
+ HashSet<File> tuscanyJars,
+ HashSet<File> thirdPartyJars,
+ HashMap<File, InputStream> thirdPartyBundleManifests)
+ throws IOException
+ {
+
+ Bundle installerBundle = bundleContext.getBundle();
+ File tuscanyInstallDir = findTuscanyInstallDir(installerBundle);
+
+ URL classPathURL = installerBundle.getResource(TUSCANY_CLASSPATH);
+ InputStream stream = classPathURL.openStream();
+ byte[] classPathBytes = new byte[stream.available()];
+ stream.read(classPathBytes);
+ String classPath = new String(classPathBytes);
+
+ // Path separator overrides are not supported by older versions of maven
+ String pathSeparator = ":";
+ if (classPath.indexOf(";") > 0) pathSeparator = ";";
+
+ String[] classPathEntries = classPath.split(pathSeparator);
+ for (String classPathEntry : classPathEntries) {
+ classPathEntry = classPathEntry.trim();
+ File jar = new File(classPathEntry);
+ if (!jar.isAbsolute()&&!jar.exists()) {
+ jar = new File(tuscanyInstallDir, jar.getName());
+ }
+
+ String jarName = jar.getName();
+ if (!jarName.startsWith("tuscany") || jarName.startsWith("tuscany-sdo") || jarName.startsWith("tuscany-das")) {
+ if (jarName.endsWith(".jar")) {
+ String manifestName = TUSCANY_OSGI_MANIFEST_DIR + "/" + jarName.substring(0, jarName.length()-4) + ".mf";
+ InputStream manifestStream;
+ if ((manifestStream = this.getClass().getClassLoader().getResourceAsStream(manifestName)) != null)
+ thirdPartyBundleManifests.put(jar, manifestStream);
+ else
+ thirdPartyJars.add(jar);
+ }
+ } else {
+ boolean installTuscanyJar = true;
+ for (String name : tuscanyModulesToIgnore) {
+ if (jarName.startsWith("tuscany-" + name)) {
+ installTuscanyJar = false;
+ break;
+ }
+ }
+ if (installTuscanyJar)
+ tuscanyJars.add(jar);
+ }
+ }
+
+
+ }
+
+ private File findTuscanyInstallDir(Bundle installerBundle)
+ throws IOException
+ {
+
+ File tuscanyInstallDir = null;
+ String location = installerBundle.getLocation();
+
+ String tuscanyDirName;
+ if ((tuscanyDirName = System.getenv("TUSCANY_HOME")) != null) {
+ tuscanyInstallDir = new File(tuscanyDirName);
+ if (!tuscanyInstallDir.exists() || !tuscanyInstallDir.isDirectory())
+ tuscanyInstallDir = null;
+ }
+ if (tuscanyInstallDir == null && System.getProperty("TUSCANY_HOME") != null) {
+ tuscanyInstallDir = new File(tuscanyDirName);
+ if (!tuscanyInstallDir.exists() || !tuscanyInstallDir.isDirectory())
+ tuscanyInstallDir = null;
+ }
+
+ if (tuscanyInstallDir == null && location != null && location.startsWith("file:") && location.endsWith(TUSCANY_INSTALLER_JAR)) {
+ tuscanyDirName = location.substring(5, location.length()-TUSCANY_INSTALLER_JAR.length()); // strip "file:" and installer jar name
+ tuscanyInstallDir = new File(tuscanyDirName);
+ if (!tuscanyInstallDir.exists() || !tuscanyInstallDir.isDirectory())
+ tuscanyInstallDir = null;
+ }
+ return tuscanyInstallDir;
+ }
+
+ public Bundle createAndInstallBundle(BundleContext bundleContext,
+ String bundleLocation,
+ InputStream manifestStream,
+ final HashSet<File> thirdPartyJars) throws Exception {
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ Manifest manifest = new Manifest();
+ manifest.read(manifestStream);
+
+ StringBuilder bundleClassPath = new StringBuilder(".");
+ for (File jar : thirdPartyJars) {
+ bundleClassPath.append(',');
+ bundleClassPath.append(jar.getName());
+ }
+
+ if (thirdPartyJars.size() > 1)
+ manifest.getMainAttributes().putValue("Bundle-ClassPath", bundleClassPath.toString());
+
+ JarOutputStream jarOut = new JarOutputStream(out, manifest);
+
+ String classpath = manifest.getMainAttributes().getValue("Bundle-ClassPath");
+ boolean embed = classpath != null && !classpath.trim().equals(".");
+ for (File jarFile : thirdPartyJars) {
+ if (embed)
+ addFileToJar(jarFile, jarOut);
+ else {
+ copyJar(jarFile, jarOut);
+ }
+ }
+
+ jarOut.close();
+ out.close();
+
+ ByteArrayInputStream inStream = new ByteArrayInputStream(out.toByteArray());
+ return bundleContext.installBundle(bundleLocation, inStream);
+
+ }
+
+ private void addFileToJar(File file, JarOutputStream jarOut) throws Exception {
+
+ ZipEntry ze = new ZipEntry(file.getName());
+
+ try {
+ jarOut.putNextEntry(ze);
+ FileInputStream inStream = new FileInputStream(file);
+ byte[] fileContents = new byte[inStream.available()];
+ inStream.read(fileContents);
+ jarOut.write(fileContents);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ private void copyJar(File file, JarOutputStream jarOut) throws Exception {
+
+ try {
+ JarInputStream jarIn = new JarInputStream(new FileInputStream(file));
+ ZipEntry ze;
+ byte[] readBuf = new byte[1000];
+ int bytesRead;
+ while ((ze = jarIn.getNextEntry()) != null) {
+ if (ze.getName().equals("META-INF/MANIFEST.MF"))
+ continue;
+ jarOut.putNextEntry(ze);
+ while ((bytesRead = jarIn.read(readBuf)) > 0) {
+ jarOut.write(readBuf, 0, bytesRead);
+ }
+ }
+ jarIn.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private InputStream createBundleManifest(File jarFile, String bundleSymbolicName) throws Exception {
+
+ if (!jarFile.exists())
+ return null;
+ JarInputStream jar = new JarInputStream(new FileInputStream(jarFile));
+ Manifest manifest = jar.getManifest();
+ if (manifest == null)
+ manifest = new Manifest();
+
+ String bundleName = jarFile.getName();
+ boolean isImmutableJar = false;
+ for (String immutableJar : immutableJars) {
+ if (bundleName.startsWith(immutableJar)) {
+ isImmutableJar = true;
+ break;
+ }
+ }
+ Attributes attributes = manifest.getMainAttributes();
+ if (attributes.getValue("Manifest-Version") == null) {
+ attributes.putValue("Manifest-Version", "1.0");
+ }
+ if (isImmutableJar)
+ attributes.putValue("Bundle-ClassPath", bundleName);
+
+ String packages = getPackagesInJar(bundleName, jar);
+ String version = getJarVersion(bundleName);
+
+ attributes.remove(new Attributes.Name("Require-Bundle"));
+ attributes.remove(new Attributes.Name("Import-Package"));
+
+ if (attributes.getValue("Bundle-SymbolicName") == null)
+ attributes.putValue("Bundle-SymbolicName", bundleSymbolicName);
+ if (attributes.getValue("Bundle-Version") == null)
+ attributes.putValue("Bundle-Version", version);
+ // Existing export statements in bundles may contain versions, so they should be used as is
+ // SDO exports are not sufficient, and should be changed
+ if (attributes.getValue("Export-Package") == null || bundleName.startsWith("tuscany-sdo-impl")) {
+ attributes.putValue("Export-Package", packages);
+ attributes.putValue("Import-Package", packages);
+ }
+
+ attributes.putValue("DynamicImport-Package", "*");
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ manifest.write(out);
+ ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+ out.close();
+
+ return in;
+
+ }
+
+ private String getPackagesInJar(String bundleName, JarInputStream jar) throws Exception {
+ HashSet<String> packages = new HashSet<String>();
+ ZipEntry entry;
+ while ((entry = jar.getNextEntry()) != null) {
+ String entryName = entry.getName();
+ if (!entry.isDirectory() && entryName != null && entryName.length() > 0 &&
+ !entryName.startsWith(".") && !entryName.startsWith("META-INF") &&
+ entryName.lastIndexOf("/") > 0) {
+ String pkg = entryName.substring(0, entryName.lastIndexOf("/")).replace('/', '.');
+ packages.add(pkg);
+
+ }
+ }
+ // FIXME: Split package
+ if (bundleName.startsWith("axis2-adb"))
+ packages.remove("org.apache.axis2.util");
+ else if (bundleName.startsWith("axis2-codegen")) {
+ packages.remove("org.apache.axis2.wsdl");
+ packages.remove("org.apache.axis2.wsdl.util");
+ }
+ else if (bundleName.startsWith("bsf-all"))
+ packages.remove("org.mozilla.javascript");
+
+ StringBuilder pkgBuf = new StringBuilder();
+ for (String pkg : packages) {
+ if (pkgBuf.length() >0) pkgBuf.append(',');
+ pkgBuf.append(pkg);
+ }
+ return pkgBuf.toString();
+ }
+
+ private String getJarVersion(String bundleName) {
+ Pattern pattern = Pattern.compile("-([0-9.]+)");
+ Matcher matcher = pattern.matcher(bundleName);
+ String version = "1.0.0";
+ if (matcher.find()) {
+ version = matcher.group();
+ if (version.endsWith("."))
+ version = version.substring(1, version.length()-1);
+ else
+ version = version.substring(1);
+ }
+ return version;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/main/java/org/apache/tuscany/sca/installer/InstallerBundleActivator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/main/java/org/apache/tuscany/sca/installer/InstallerBundleActivator.java
------------------------------------------------------------------------------
svn:keywords = Rev Date