You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by zo...@apache.org on 2011/02/27 21:02:56 UTC
svn commit: r1075127 [3/7] - in /aries/tags/application-0.2.1: ./
application-api/ application-api/src/ application-api/src/main/
application-api/src/main/java/ application-api/src/main/java/org/
application-api/src/main/java/org/apache/ application-ap...
Added: aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/application/runtime/itests/MinimumImportsTest.java
URL: http://svn.apache.org/viewvc/aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/application/runtime/itests/MinimumImportsTest.java?rev=1075127&view=auto
==============================================================================
--- aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/application/runtime/itests/MinimumImportsTest.java (added)
+++ aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/application/runtime/itests/MinimumImportsTest.java Sun Feb 27 20:02:48 2011
@@ -0,0 +1,160 @@
+/*
+ * 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.
+ */
+package org.apache.aries.application.runtime.itests;
+
+import java.io.File;
+import java.io.FileOutputStream;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.AriesApplicationContext;
+import org.apache.aries.application.management.AriesApplicationManager;
+import org.apache.aries.application.utils.filesystem.FileSystem;
+import org.apache.aries.unittest.fixture.ArchiveFixture;
+import org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.blueprint.container.BlueprintEvent;
+import org.osgi.service.blueprint.container.BlueprintListener;
+
+
+@RunWith(JUnit4TestRunner.class)
+public class MinimumImportsTest extends AbstractIntegrationTest {
+
+ /* Use @Before not @BeforeClass so as to ensure that these resources
+ * are created in the paxweb temp directory, and not in the svn tree
+ */
+ static boolean createdApplications = false;
+ @Before
+ public static void createApplications() throws Exception {
+
+ if (createdApplications) {
+ return;
+ }
+ ZipFixture testEba = ArchiveFixture.newZip()
+ .jar("org.apache.aries.application.itests.minimports.jar")
+ .manifest().symbolicName("org.apache.aries.application.itests.minimports")
+ .attribute("Bundle-Version", "1.0.0")
+ .attribute("Import-Package", "org.apache.aries.application.management")
+ .end()
+ .binary("org/apache/aries/application/sample/appmgrclient/AppMgrClient.class",
+ MinimumImportsTest.class.getClassLoader().getResourceAsStream("org/apache/aries/application/sample/appmgrclient/AppMgrClient.class"))
+ .binary("OSGI-INF/blueprint/app-mgr-client.xml",
+ MinimumImportsTest.class.getClassLoader().getResourceAsStream("app-mgr-client.xml"))
+ .end();
+
+ FileOutputStream fout = new FileOutputStream("appmgrclienttest.eba");
+ testEba.writeOut(fout);
+ fout.close();
+
+ createdApplications = true;
+ }
+
+ public static class AppMgrClientBlueprintListener implements BlueprintListener {
+
+ Boolean success = null;
+
+ public void blueprintEvent(BlueprintEvent event) {
+ if (event.getBundle().getSymbolicName().equals(
+ "org.apache.aries.application.itests.minimports")) {
+ if (event.getType() == event.FAILURE) {
+ success = Boolean.FALSE;
+ }
+ if (event.getType() == event.CREATED) {
+ success = Boolean.TRUE;
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testAppUsingAriesApplicationManager() throws Exception {
+
+ // Register a BlueprintListener to listen for the events from the BlueprintContainer for the bundle in the appmgrclienttest.eba
+
+ AppMgrClientBlueprintListener acbl = new AppMgrClientBlueprintListener();
+ ServiceRegistration sr = bundleContext.registerService("org.osgi.service.blueprint.container.BlueprintListener", acbl, null);
+
+ AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
+ AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("appmgrclienttest.eba")));
+ AriesApplicationContext ctx = manager.install(app);
+ ctx.start();
+
+ int sleepfor = 3000;
+ while ((acbl.success == null || acbl.success == false) && sleepfor > 0) {
+ Thread.sleep(100);
+ sleepfor-=100;
+ }
+ assertNotNull("Timed out - didn't receive Blueprint CREATED or FAILURE event", acbl.success);
+ assertTrue("Received Blueprint FAILURE event", acbl.success);
+
+ ctx.stop();
+ manager.uninstall(ctx);
+ sr.unregister();
+ }
+
+ @org.ops4j.pax.exam.junit.Configuration
+ public static Option[] configuration() {
+ Option[] options = options(
+ // Log
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
+ // Felix Config Admin
+ mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+ // Felix mvn url handler
+ mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+
+ // this is how you set the default log level when using pax
+ // logging (logProfile)
+ systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
+
+ // Bundles
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.api"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.management"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.itest.interfaces"),
+ mavenBundle("org.apache.aries", "org.apache.aries.util"),
+ mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
+ mavenBundle("org.osgi", "org.osgi.compendium"),
+ mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit"),
+
+ /* For debugging, uncomment the next two lines
+ vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"),
+ waitForFrameworkStartup(),
+
+ and add these imports:
+ import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
+ import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+ */
+
+ equinox().version("3.5.0"));
+ options = updateOptions(options);
+ return options;
+ }
+}
Added: aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRAppManagerTest.java
URL: http://svn.apache.org/viewvc/aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRAppManagerTest.java?rev=1075127&view=auto
==============================================================================
--- aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRAppManagerTest.java (added)
+++ aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRAppManagerTest.java Sun Feb 27 20:02:48 2011
@@ -0,0 +1,188 @@
+/*
+ * 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.
+ */
+package org.apache.aries.application.runtime.itests;
+
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.InputStreamReader;
+
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.AriesApplicationManager;
+import org.apache.aries.application.utils.filesystem.FileSystem;
+import org.apache.aries.unittest.fixture.ArchiveFixture;
+import org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.apache.felix.bundlerepository.Capability;
+import org.apache.felix.bundlerepository.Repository;
+import org.apache.felix.bundlerepository.RepositoryAdmin;
+import org.apache.felix.bundlerepository.Resource;
+
+@RunWith(JUnit4TestRunner.class)
+public class OBRAppManagerTest extends AbstractIntegrationTest {
+
+ /* Use @Before not @BeforeClass so as to ensure that these resources
+ * are created in the paxweb temp directory, and not in the svn tree
+ */
+ static boolean createdApplications = false;
+ @Before
+ public static void createApplications() throws Exception {
+ if (createdApplications) {
+ return;
+ }
+ ZipFixture testBundle = ArchiveFixture.newZip()
+ .manifest().symbolicName("org.apache.aries.sample")
+ .attribute("Bundle-Version", "1.0.0")
+ .attribute("Export-Package", "org.apache.aries.sample.impl")
+ .end()
+ .binary("org/apache/aries/sample/impl/HelloWorldImpl.class",
+ OBRAppManagerTest.class.getClassLoader().getResourceAsStream("org/apache/aries/sample/impl/HelloWorldImpl.class"))
+ .end();
+
+ FileOutputStream fout = new FileOutputStream("bundle.jar");
+ testBundle.writeOut(fout);
+ fout.close();
+
+ ZipFixture testEba = ArchiveFixture.newZip()
+ .jar("sample.jar")
+ .manifest().symbolicName("org.apache.aries.sample")
+ .attribute("Bundle-Version", "1.0.0")
+ .attribute("Import-Package", "org.apache.aries.sample.impl")
+ .end()
+ .binary("OSGI-INF/blueprint/sample-blueprint.xml",
+ OBRAppManagerTest.class.getClassLoader().getResourceAsStream("basic/sample-blueprint.xml"))
+ .end()
+ .binary("META-INF/APPLICATION.MF",
+ OBRAppManagerTest.class.getClassLoader().getResourceAsStream("basic/APPLICATION.MF"))
+ .end();
+ fout = new FileOutputStream("test.eba");
+ testEba.writeOut(fout);
+ fout.close();
+
+ StringBuilder repositoryXML = new StringBuilder();
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(OBRAppManagerTest.class.getResourceAsStream("/obr/repository.xml")));
+ String line;
+
+ while ((line = reader.readLine()) != null) {
+ repositoryXML.append(line);
+ repositoryXML.append("\r\n");
+ }
+
+ String repo = repositoryXML.toString().replaceAll("bundle_location", new File("bundle.jar").getAbsolutePath());
+
+ System.out.println(repo);
+
+ FileWriter writer = new FileWriter("repository.xml");
+ writer.write(repo);
+ writer.close();
+
+ createdApplications = true;
+ }
+
+ @Test
+ public void testAppWithApplicationManifest() throws Exception {
+ startApplicationRuntimeBundle();
+
+ RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
+
+ repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());
+
+ Repository[] repos = repositoryAdmin.listRepositories();
+
+ for (Repository repo : repos) {
+ Resource[] resources = repo.getResources();
+
+ for (Resource r : resources) {
+ Capability[] cs = r.getCapabilities();
+
+ for (Capability c : cs) {
+ System.out.println(c.getName() + " : " + c.getProperties());
+ }
+ }
+ }
+
+ AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
+ AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
+ app = manager.resolve(app);
+ //installing requires a valid url for the bundle in repository.xml.
+// ApplicationContext ctx = manager.install(app);
+// ctx.start();
+
+// HelloWorld hw = getOsgiService(HelloWorld.class);
+// String result = hw.getMessage();
+// assertEquals (result, "hello world");
+//
+// ctx.stop();
+// manager.uninstall(ctx);
+ }
+
+
+ @org.ops4j.pax.exam.junit.Configuration
+ public static Option[] configuration() {
+ Option[] options = options(
+ // Log
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
+ // Felix Config Admin
+ mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+ // Felix mvn url handler
+ mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+
+ // this is how you set the default log level when using pax
+ // logging (logProfile)
+ systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
+
+ // Bundles
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.api"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.management"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime").noStart(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr"),
+ mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.itest.interfaces"),
+ mavenBundle("org.apache.aries", "org.apache.aries.util"),
+ mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
+ mavenBundle("org.osgi", "org.osgi.compendium"),
+ mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit"),
+
+// /* For debugging, uncomment the next two lines
+// vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
+// waitForFrameworkStartup(),
+
+ /* For debugging, uncomment the next two lines
+ and add these imports:
+ import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
+ import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+ */
+
+ equinox().version("3.5.0"));
+ options = updateOptions(options);
+ return options;
+ }
+}
\ No newline at end of file
Added: aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverTest.java
URL: http://svn.apache.org/viewvc/aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverTest.java?rev=1075127&view=auto
==============================================================================
--- aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverTest.java (added)
+++ aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverTest.java Sun Feb 27 20:02:48 2011
@@ -0,0 +1,372 @@
+/*
+ * 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.
+ */
+package org.apache.aries.application.runtime.itests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.lang.reflect.Constructor;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.aries.application.ApplicationMetadataFactory;
+import org.apache.aries.application.DeploymentContent;
+import org.apache.aries.application.DeploymentMetadata;
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.AriesApplicationContext;
+import org.apache.aries.application.management.AriesApplicationManager;
+import org.apache.aries.application.management.BundleInfo;
+import org.apache.aries.application.management.ResolverException;
+import org.apache.aries.application.resolver.obr.generator.RepositoryDescriptorGenerator;
+import org.apache.aries.application.utils.filesystem.FileSystem;
+import org.apache.aries.application.utils.manifest.BundleManifest;
+import org.apache.aries.unittest.fixture.ArchiveFixture;
+import org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+import org.apache.felix.bundlerepository.Repository;
+import org.apache.felix.bundlerepository.RepositoryAdmin;
+import org.w3c.dom.Document;
+
+@RunWith(JUnit4TestRunner.class)
+public class OBRResolverTest extends AbstractIntegrationTest
+{
+ public static final String CORE_BUNDLE_BY_VALUE = "core.bundle.by.value";
+ public static final String CORE_BUNDLE_BY_REFERENCE = "core.bundle.by.reference";
+ public static final String TRANSITIVE_BUNDLE_BY_VALUE = "transitive.bundle.by.value";
+ public static final String TRANSITIVE_BUNDLE_BY_REFERENCE = "transitive.bundle.by.reference";
+ public static final String BUNDLE_IN_FRAMEWORK = "org.apache.aries.util";
+
+ public static final String CORE_BUNDLE1_BY_VALUE = "core.bundle1.by.value";
+ public static final String CORE_BUNDLE2_BY_VALUE = "core.bundle2.by.value";
+
+
+ /* Use @Before not @BeforeClass so as to ensure that these resources
+ * are created in the paxweb temp directory, and not in the svn tree
+ */
+ @Before
+ public static void createApplications() throws Exception
+ {
+ ZipFixture bundle;
+ FileOutputStream fout;
+
+ bundle = ArchiveFixture.newJar().manifest()
+ .attribute(Constants.BUNDLE_SYMBOLICNAME, CORE_BUNDLE_BY_VALUE)
+ .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
+ .attribute(Constants.IMPORT_PACKAGE, "p.q.r, x.y.z, javax.naming, " + BUNDLE_IN_FRAMEWORK)
+ .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
+
+
+ fout = new FileOutputStream(CORE_BUNDLE_BY_VALUE + ".jar");
+ bundle.writeOut(fout);
+ fout.close();
+
+ bundle = ArchiveFixture.newJar().manifest()
+ .attribute(Constants.BUNDLE_SYMBOLICNAME, TRANSITIVE_BUNDLE_BY_VALUE)
+ .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
+ .attribute(Constants.EXPORT_PACKAGE, "p.q.r")
+ .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
+
+ fout = new FileOutputStream(TRANSITIVE_BUNDLE_BY_VALUE + ".jar");
+ bundle.writeOut(fout);
+ fout.close();
+
+ bundle = ArchiveFixture.newJar().manifest()
+ .attribute(Constants.BUNDLE_SYMBOLICNAME, TRANSITIVE_BUNDLE_BY_REFERENCE)
+ .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
+ .attribute(Constants.EXPORT_PACKAGE, "x.y.z")
+ .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
+
+ fout = new FileOutputStream(TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar");
+ bundle.writeOut(fout);
+ fout.close();
+
+ bundle = ArchiveFixture.newJar().manifest()
+ .attribute(Constants.BUNDLE_SYMBOLICNAME, CORE_BUNDLE_BY_REFERENCE)
+ .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
+ .attribute(Constants.EXPORT_PACKAGE, "d.e.f")
+ .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
+
+ fout = new FileOutputStream(CORE_BUNDLE_BY_REFERENCE + ".jar");
+ bundle.writeOut(fout);
+ fout.close();
+
+ bundle = ArchiveFixture.newJar().manifest()
+ .attribute(Constants.BUNDLE_SYMBOLICNAME, CORE_BUNDLE_BY_REFERENCE)
+ .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
+ .attribute(Constants.EXPORT_PACKAGE, "d.e.f").end();
+
+ fout = new FileOutputStream(CORE_BUNDLE_BY_REFERENCE + "_0.0.0.jar");
+ bundle.writeOut(fout);
+ fout.close();
+
+ ZipFixture testEba = ArchiveFixture.newZip()
+ .binary("META-INF/APPLICATION.MF",
+ OBRResolverTest.class.getClassLoader().getResourceAsStream("obr/APPLICATION.MF"))
+ .end()
+ .binary(CORE_BUNDLE_BY_VALUE + ".jar", new FileInputStream(CORE_BUNDLE_BY_VALUE + ".jar")).end()
+ .binary(TRANSITIVE_BUNDLE_BY_VALUE + ".jar", new FileInputStream(TRANSITIVE_BUNDLE_BY_VALUE + ".jar")).end();
+
+ fout = new FileOutputStream("blog.eba");
+ testEba.writeOut(fout);
+ fout.close();
+
+
+ // prepare bundles for require-bundle header test
+ // bundle1
+ bundle = ArchiveFixture.newJar().manifest()
+ .attribute(Constants.BUNDLE_SYMBOLICNAME, CORE_BUNDLE1_BY_VALUE)
+ .attribute(Constants.BUNDLE_NAME, "Bundle1")
+ .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
+ .attribute(Constants.REQUIRE_BUNDLE, CORE_BUNDLE2_BY_VALUE+";bundle-version=\"0.0.0\"")
+ .attribute(Constants.BUNDLE_VERSION, "1.0.0")
+ .end();
+
+
+ fout = new FileOutputStream(CORE_BUNDLE1_BY_VALUE + ".jar");
+ bundle.writeOut(fout);
+ fout.close();
+
+ // bundle2
+ bundle = ArchiveFixture.newJar().manifest()
+ .attribute(Constants.BUNDLE_SYMBOLICNAME, CORE_BUNDLE2_BY_VALUE)
+ .attribute(Constants.BUNDLE_NAME, "Bundle2")
+ .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
+ .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
+
+
+ fout = new FileOutputStream(CORE_BUNDLE2_BY_VALUE + ".jar");
+ bundle.writeOut(fout);
+ fout.close();
+
+ //eba that made up of bundle1 and bundle2
+ ZipFixture testRequireBundle = ArchiveFixture.newZip()
+ .binary("META-INF/APPLICATION.MF",
+ OBRResolverTest.class.getClassLoader().getResourceAsStream("obr/APPLICATION2.MF"))
+ .end()
+ .binary(CORE_BUNDLE1_BY_VALUE + ".jar", new FileInputStream(CORE_BUNDLE1_BY_VALUE + ".jar")).end()
+ .binary(CORE_BUNDLE2_BY_VALUE + ".jar", new FileInputStream(CORE_BUNDLE2_BY_VALUE + ".jar")).end();
+
+ fout = new FileOutputStream("testRequireBundle.eba");
+ testRequireBundle.writeOut(fout);
+ fout.close();
+
+ }
+
+ @Test(expected=ResolverException.class)
+ public void testBlogAppResolveFail() throws ResolverException, Exception
+ {
+ startApplicationRuntimeBundle();
+
+ generateOBRRepoXML(TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar", CORE_BUNDLE_BY_REFERENCE + "_0.0.0.jar");
+
+ RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
+
+ Repository[] repos = repositoryAdmin.listRepositories();
+ for (Repository repo : repos) {
+ repositoryAdmin.removeRepository(repo.getURI());
+ }
+
+ repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());
+
+ AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
+ AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("blog.eba")));
+ //installing requires a valid url for the bundle in repository.xml.
+
+ app = manager.resolve(app);
+ }
+
+ @Test
+ public void testBlogApp() throws Exception
+ {
+ startApplicationRuntimeBundle();
+
+ //generate the repository.xml for this test
+ generateOBRRepoXML(TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar", CORE_BUNDLE_BY_REFERENCE + ".jar");
+
+ RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
+
+ //clear all other repo info
+ Repository[] repos = repositoryAdmin.listRepositories();
+ for (Repository repo : repos) {
+ repositoryAdmin.removeRepository(repo.getURI());
+ }
+
+ //add our generated repository.xml
+ repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());
+
+ AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
+ AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("blog.eba")));
+ //installing requires a valid url for the bundle in repository.xml.
+
+ app = manager.resolve(app);
+
+ DeploymentMetadata depMeta = app.getDeploymentMetadata();
+
+ List<DeploymentContent> provision = depMeta.getApplicationProvisionBundles();
+
+ assertEquals(provision.toString(), 3, provision.size());
+
+ List<String> bundleSymbolicNames = new ArrayList<String>();
+
+ for (DeploymentContent dep : provision) {
+ bundleSymbolicNames.add(dep.getContentName());
+ }
+
+ assertTrue("Bundle " + TRANSITIVE_BUNDLE_BY_REFERENCE + " not found.", bundleSymbolicNames.contains(TRANSITIVE_BUNDLE_BY_REFERENCE));
+ assertTrue("Bundle " + TRANSITIVE_BUNDLE_BY_VALUE + " not found.", bundleSymbolicNames.contains(TRANSITIVE_BUNDLE_BY_VALUE));
+ assertTrue("Bundle " + BUNDLE_IN_FRAMEWORK + " not found.", bundleSymbolicNames.contains(BUNDLE_IN_FRAMEWORK));
+
+ AriesApplicationContext ctx = manager.install(app);
+ ctx.start();
+
+ Set<Bundle> bundles = ctx.getApplicationContent();
+
+ assertEquals("Number of bundles provisioned in the app", 4, bundles.size());
+
+ ctx.stop();
+ manager.uninstall(ctx);
+ }
+
+ @Test
+ public void testRequireBundleResolve() throws Exception
+ {
+ startApplicationRuntimeBundle();
+
+
+ RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
+
+ //clear all other repo info
+ Repository[] repos = repositoryAdmin.listRepositories();
+ for (Repository repo : repos) {
+ repositoryAdmin.removeRepository(repo.getURI());
+ }
+
+ AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
+ AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("testRequireBundle.eba")));
+
+ app = manager.resolve(app);
+
+ DeploymentMetadata depMeta = app.getDeploymentMetadata();
+
+ List<DeploymentContent> depContents = depMeta.getApplicationDeploymentContents();
+
+ List<String> bundleSymbolicNames = new ArrayList<String>();
+
+ for (DeploymentContent dep : depContents) {
+ bundleSymbolicNames.add(dep.getContentName());
+ }
+
+ assertTrue("Bundle " + CORE_BUNDLE1_BY_VALUE + " not found.", bundleSymbolicNames.contains(CORE_BUNDLE1_BY_VALUE));
+ assertTrue("Bundle " + CORE_BUNDLE2_BY_VALUE + " not found.", bundleSymbolicNames.contains(CORE_BUNDLE2_BY_VALUE));
+
+
+ }
+
+ private void generateOBRRepoXML(String ... bundleFiles) throws Exception
+ {
+ Set<BundleInfo> bundles = new HashSet<BundleInfo>();
+
+ for (String file : bundleFiles) {
+ bundles.add(createBundleInfo(new File(file).toURI().toURL().toExternalForm()));
+ }
+
+ Document doc = RepositoryDescriptorGenerator.generateRepositoryDescriptor("Test repo description", bundles);
+
+ FileOutputStream fout = new FileOutputStream("repository.xml");
+
+ TransformerFactory.newInstance().newTransformer().transform(new DOMSource(doc), new StreamResult(fout));
+
+ fout.close();
+
+ TransformerFactory.newInstance().newTransformer().transform(new DOMSource(doc), new StreamResult(System.out));
+ }
+
+ private BundleInfo createBundleInfo(String urlToBundle) throws Exception
+ {
+ ApplicationMetadataFactory factory = getOsgiService(ApplicationMetadataFactory.class);
+
+ Bundle b = getBundle("org.apache.aries.application.management");
+ @SuppressWarnings("unchecked")
+ Class<BundleInfo> clazz = b.loadClass("org.apache.aries.application.utils.management.SimpleBundleInfo");
+ Constructor<BundleInfo> c = clazz.getConstructor(ApplicationMetadataFactory.class, BundleManifest.class, String.class);
+
+ return c.newInstance(factory, BundleManifest.fromBundle(new URL(urlToBundle).openStream()), urlToBundle);
+ }
+
+ @org.ops4j.pax.exam.junit.Configuration
+ public static Option[] configuration() {
+ Option[] options = options(
+ // Log
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
+ // Felix Config Admin
+ mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+ // Felix mvn url handler
+ mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+
+ // this is how you set the default log level when using pax
+ // logging (logProfile)
+ systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
+
+ // Bundles
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.api"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.management"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime").noStart(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr"),
+ mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.itest.interfaces"),
+ mavenBundle("org.apache.aries", "org.apache.aries.util"),
+ mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
+ mavenBundle("org.osgi", "org.osgi.compendium"),
+ mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit"),
+
+ /* For debugging, uncomment the next two lines */
+ //vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=7777"),
+ //waitForFrameworkStartup(),
+
+ /* For debugging, and add these imports:
+ import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
+ import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+ */
+
+ equinox().version("3.5.0"));
+ options = updateOptions(options);
+ return options;
+ }
+}
\ No newline at end of file
Added: aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/application/sample/appmgrclient/AppMgrClient.java
URL: http://svn.apache.org/viewvc/aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/application/sample/appmgrclient/AppMgrClient.java?rev=1075127&view=auto
==============================================================================
--- aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/application/sample/appmgrclient/AppMgrClient.java (added)
+++ aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/application/sample/appmgrclient/AppMgrClient.java Sun Feb 27 20:02:48 2011
@@ -0,0 +1,46 @@
+/*
+ * 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 WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.application.sample.appmgrclient;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.aries.application.management.AriesApplicationManager;
+import org.apache.aries.application.management.ManagementException;
+
+public class AppMgrClient
+{
+ private AriesApplicationManager applicationManager;
+
+ public AriesApplicationManager getApplicationManager()
+ {
+ return applicationManager;
+ }
+
+ public void setApplicationManager(AriesApplicationManager applicationManager)
+ {
+ this.applicationManager = applicationManager;
+ }
+
+ public void doSomething() throws MalformedURLException, ManagementException
+ {
+ applicationManager.createApplication(new URL("foo"));
+ }
+
+}
Added: aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/sample/impl/HelloWorldImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/sample/impl/HelloWorldImpl.java?rev=1075127&view=auto
==============================================================================
--- aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/sample/impl/HelloWorldImpl.java (added)
+++ aries/tags/application-0.2.1/application-itests/src/test/java/org/apache/aries/sample/impl/HelloWorldImpl.java Sun Feb 27 20:02:48 2011
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+package org.apache.aries.sample.impl;
+
+import org.apache.aries.sample.HelloWorld;
+
+public class HelloWorldImpl implements HelloWorld {
+
+ public String getMessage() {
+ return "hello world";
+ }
+
+}
Added: aries/tags/application-0.2.1/application-itests/src/test/resources/app-mgr-client.xml
URL: http://svn.apache.org/viewvc/aries/tags/application-0.2.1/application-itests/src/test/resources/app-mgr-client.xml?rev=1075127&view=auto
==============================================================================
--- aries/tags/application-0.2.1/application-itests/src/test/resources/app-mgr-client.xml (added)
+++ aries/tags/application-0.2.1/application-itests/src/test/resources/app-mgr-client.xml Sun Feb 27 20:02:48 2011
@@ -0,0 +1,28 @@
+<?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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <reference id="app-manager" interface="org.apache.aries.application.management.AriesApplicationManager"/>
+
+ <bean id="app-mgr-client" class="org.apache.aries.application.sample.appmgrclient.AppMgrClient" scope="singleton" activation="lazy">
+ <property name="applicationManager" ref="app-manager"/>
+ </bean>
+
+</blueprint>
Added: aries/tags/application-0.2.1/application-itests/src/test/resources/basic/APPLICATION.MF
URL: http://svn.apache.org/viewvc/aries/tags/application-0.2.1/application-itests/src/test/resources/basic/APPLICATION.MF?rev=1075127&view=auto
==============================================================================
--- aries/tags/application-0.2.1/application-itests/src/test/resources/basic/APPLICATION.MF (added)
+++ aries/tags/application-0.2.1/application-itests/src/test/resources/basic/APPLICATION.MF Sun Feb 27 20:02:48 2011
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Application-ManifestVersion: 1.0
+Application-Name: test application 2
+Application-SymbolicName: org.apache.aries.sample2
+Application-Version: 1.0
+Application-Content: org.apache.aries.sample; version=1.0.0
+
Added: aries/tags/application-0.2.1/application-itests/src/test/resources/basic/sample-blueprint.xml
URL: http://svn.apache.org/viewvc/aries/tags/application-0.2.1/application-itests/src/test/resources/basic/sample-blueprint.xml?rev=1075127&view=auto
==============================================================================
--- aries/tags/application-0.2.1/application-itests/src/test/resources/basic/sample-blueprint.xml (added)
+++ aries/tags/application-0.2.1/application-itests/src/test/resources/basic/sample-blueprint.xml Sun Feb 27 20:02:48 2011
@@ -0,0 +1,25 @@
+<?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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <bean id="hello" class="org.apache.aries.sample.impl.HelloWorldImpl"/>
+ <service interface="org.apache.aries.sample.HelloWorld" ref="hello" />
+
+</blueprint>
Added: aries/tags/application-0.2.1/application-itests/src/test/resources/obr/APPLICATION.MF
URL: http://svn.apache.org/viewvc/aries/tags/application-0.2.1/application-itests/src/test/resources/obr/APPLICATION.MF?rev=1075127&view=auto
==============================================================================
--- aries/tags/application-0.2.1/application-itests/src/test/resources/obr/APPLICATION.MF (added)
+++ aries/tags/application-0.2.1/application-itests/src/test/resources/obr/APPLICATION.MF Sun Feb 27 20:02:48 2011
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Application-ManifestVersion: 1.0
+Application-Name: test application 1
+Application-SymbolicName: org.apache.obr.resolver.test.app
+Application-Version: 1.0
+Application-Content: core.bundle.by.value; version=1.0.0,
+ core.bundle.by.reference; version=1.0.0
Added: aries/tags/application-0.2.1/application-itests/src/test/resources/obr/APPLICATION2.MF
URL: http://svn.apache.org/viewvc/aries/tags/application-0.2.1/application-itests/src/test/resources/obr/APPLICATION2.MF?rev=1075127&view=auto
==============================================================================
--- aries/tags/application-0.2.1/application-itests/src/test/resources/obr/APPLICATION2.MF (added)
+++ aries/tags/application-0.2.1/application-itests/src/test/resources/obr/APPLICATION2.MF Sun Feb 27 20:02:48 2011
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Application-ManifestVersion: 1.0
+Application-Name: test application 222
+Application-SymbolicName: org.apache.obr.resolver.test.app2
+Application-Version: 1.0
+Application-Content: core.bundle1.by.value; version=1.0.0,
+ core.bundle2.by.value; version=1.0.0
+Manifest-Version: 1.0
+Application-ManifestVersion: 1.0
+Application-Name: test application 222
+Application-SymbolicName: org.apache.obr.resolver.test.app2
+Application-Version: 1.0
+Application-Content: core.bundle1.by.value; version=1.0.0,
+ core.bundle2.by.value; version=1.0.0
Added: aries/tags/application-0.2.1/application-itests/src/test/resources/obr/repository.xml
URL: http://svn.apache.org/viewvc/aries/tags/application-0.2.1/application-itests/src/test/resources/obr/repository.xml?rev=1075127&view=auto
==============================================================================
--- aries/tags/application-0.2.1/application-itests/src/test/resources/obr/repository.xml (added)
+++ aries/tags/application-0.2.1/application-itests/src/test/resources/obr/repository.xml Sun Feb 27 20:02:48 2011
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<repository name="Geronimo Framework, Configs :: J2EE System">
+ <resource version="1.3.0.3" uri="file:/bundle_location"
+ symbolicname="org.apache.aries.sample"
+ presentationname="org.apache.aries.sample" id="1266103855623">
+ <description>sample</description>
+ <license>http://www.apache.org/licenses/LICENSE-2.0.txt</license>
+ <capability name="bundle">
+ <p v="org.apache.aries.sample" n="symbolicname"/>
+ <p v="1.3.0" t="version" n="version"/>
+ <p v="2" t="version" n="manifestversion"/>
+ </capability>
+ <capability name="package">
+ <p v="org.apache.aries.sample.impl" n="package"/>
+ <p v="1.0" t="version" n="version"/>
+ <p n='mandatory' v=''/>
+ </capability>
+ </resource>
+
+</repository>
\ No newline at end of file
Added: aries/tags/application-0.2.1/application-management/pom.xml
URL: http://svn.apache.org/viewvc/aries/tags/application-0.2.1/application-management/pom.xml?rev=1075127&view=auto
==============================================================================
--- aries/tags/application-0.2.1/application-management/pom.xml (added)
+++ aries/tags/application-0.2.1/application-management/pom.xml Sun Feb 27 20:02:48 2011
@@ -0,0 +1,80 @@
+<!--
+ 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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>application</artifactId>
+ <version>0.2.1</version>
+ </parent>
+
+ <artifactId>org.apache.aries.application.management</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Aries Application Management</name>
+ <description>
+ Implementation of the application management API
+ </description>
+
+ <properties>
+ <aries.osgi.export.pkg>
+ </aries.osgi.export.pkg>
+ <aries.osgi.private.pkg>
+ org.apache.aries.application.management.impl;
+ org.apache.aries.application.management.internal
+ </aries.osgi.private.pkg>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.testsupport</groupId>
+ <artifactId>org.apache.aries.testsupport.unit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
Added: aries/tags/application-0.2.1/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/application-0.2.1/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java?rev=1075127&view=auto
==============================================================================
--- aries/tags/application-0.2.1/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java (added)
+++ aries/tags/application-0.2.1/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java Sun Feb 27 20:02:48 2011
@@ -0,0 +1,191 @@
+/*
+ * 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 WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.aries.application.management.impl;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.aries.application.ApplicationMetadata;
+import org.apache.aries.application.Content;
+import org.apache.aries.application.DeploymentMetadata;
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.BundleConversion;
+import org.apache.aries.application.management.BundleInfo;
+import org.apache.aries.application.management.LocalPlatform;
+import org.apache.aries.application.utils.AppConstants;
+import org.apache.aries.application.utils.filesystem.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AriesApplicationImpl implements AriesApplication {
+
+ private static final Logger _logger = LoggerFactory.getLogger("org.apache.aries.application.management");
+
+ private Set<BundleInfo> _bundleInfo;
+ private ApplicationMetadata _applicationMetadata;
+ private DeploymentMetadata _deploymentMetadata;
+ private LocalPlatform _localPlatform;
+
+ // Placeholders for information we'll need for store()
+ private Map<String, BundleConversion> _modifiedBundles = null;
+
+ public AriesApplicationImpl(ApplicationMetadata meta, Set<BundleInfo> bundleInfo,
+ LocalPlatform lp) {
+ _applicationMetadata = meta;
+ _bundleInfo = bundleInfo;
+ _deploymentMetadata = null;
+ _localPlatform = lp;
+
+ }
+
+ public AriesApplicationImpl(ApplicationMetadata meta, DeploymentMetadata dep,
+ Set<BundleInfo> bundleInfo, LocalPlatform lp) {
+ _applicationMetadata = meta;
+ _bundleInfo = bundleInfo;
+ _deploymentMetadata = dep;
+ _localPlatform = lp;
+
+ }
+
+ public ApplicationMetadata getApplicationMetadata() {
+ return _applicationMetadata;
+ }
+
+ public Set<BundleInfo> getBundleInfo() {
+ return _bundleInfo;
+ }
+
+ public DeploymentMetadata getDeploymentMetadata() {
+ return _deploymentMetadata;
+ }
+
+ public void setDeploymentMetadata (DeploymentMetadata dm) {
+ _deploymentMetadata = dm;
+ }
+
+ public Map<String, BundleConversion> getModifiedBundles() {
+ return _modifiedBundles;
+ }
+
+ public void setModifiedBundles (Map<String, BundleConversion> modifiedBundles) {
+ _modifiedBundles = modifiedBundles;
+ }
+
+ public void setLocalPlatform (LocalPlatform lp) {
+ _localPlatform = lp;
+ }
+
+ public boolean isResolved() {
+ return getDeploymentMetadata() != null;
+ }
+
+ public void store(File f) throws FileNotFoundException, IOException {
+ if (f.isDirectory()) {
+ storeInDirectory(f);
+ } else {
+ OutputStream os = new FileOutputStream (f);
+ store(os);
+ os.close();
+ }
+ }
+
+ /**
+ * Construct an eba in a temporary directory
+ * Copy the eba to the target output stream
+ * Delete the temporary directory.
+ * Leave target output stream open
+ */
+ public void store(OutputStream targetStream) throws FileNotFoundException, IOException {
+
+ //
+ // This code will be run on various application server platforms, each of which
+ // will have its own policy about where to create temporary directories. We
+ // can't just ask the local filesystem for a temporary directory since it may
+ // be quite large: the app server implementation will be better able to select
+ // an appropriate location.
+ File tempDir = _localPlatform.getTemporaryDirectory();
+ storeInDirectory(tempDir);
+ // We now have an exploded eba in tempDir which we need to copy into targetStream
+ IOUtils.zipUp(tempDir, targetStream);
+ if (!IOUtils.deleteRecursive(tempDir))
+ {
+ _logger.warn("APPMANAGEMENT0001E", tempDir);
+ }
+ }
+
+ private void storeInDirectory(File dir) throws IOException, MalformedURLException {
+ OutputStream out = null;
+ InputStream in = null;
+ try {
+ out = IOUtils.getOutputStream(dir, AppConstants.APPLICATION_MF);
+ _applicationMetadata.store(out);
+
+ } finally {
+ IOUtils.close(out);
+ }
+ if (_deploymentMetadata != null) {
+ try {
+ out = IOUtils.getOutputStream(dir, AppConstants.DEPLOYMENT_MF);
+ _deploymentMetadata.store(out);
+ } finally {
+ IOUtils.close(out);
+ }
+ }
+
+ // Write the by-value eba files out
+ for (BundleInfo bi : _bundleInfo) {
+ // bi.getLocation() will return a URL to the source bundle. It may be of the form
+ // file:/path/to/my/file.jar, or
+ // jar:file:/my/path/to/eba.jar!/myBundle.jar
+ String bundleLocation = bi.getLocation();
+ String bundleFileName = bundleLocation.substring(bundleLocation.lastIndexOf('/') + 1);
+ try {
+ out = IOUtils.getOutputStream(dir, bundleFileName);
+ URL bundleURL = new URL (bundleLocation);
+ InputStream is = bundleURL.openStream();
+ IOUtils.copy(is, out);
+ } finally {
+ IOUtils.close(out);
+ IOUtils.close(in);
+ }
+ }
+
+ // Write the migrated bundles out
+ if (_modifiedBundles != null) {
+ for (Map.Entry<String, BundleConversion> modifiedBundle : _modifiedBundles.entrySet()) {
+ try {
+ out = IOUtils.getOutputStream(dir, modifiedBundle.getKey());
+ IOUtils.copy(modifiedBundle.getValue().getInputStream(), out);
+ } finally {
+ IOUtils.close(out);
+ }
+ }
+ }
+ }
+}
Added: aries/tags/application-0.2.1/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/application-0.2.1/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java?rev=1075127&view=auto
==============================================================================
--- aries/tags/application-0.2.1/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java (added)
+++ aries/tags/application-0.2.1/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java Sun Feb 27 20:02:48 2011
@@ -0,0 +1,332 @@
+/*
+ * 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 WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.aries.application.management.impl;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.Manifest;
+
+import org.apache.aries.application.ApplicationMetadata;
+import org.apache.aries.application.ApplicationMetadataFactory;
+import org.apache.aries.application.DeploymentMetadata;
+import org.apache.aries.application.DeploymentMetadataFactory;
+import org.apache.aries.application.filesystem.IDirectory;
+import org.apache.aries.application.filesystem.IFile;
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.AriesApplicationContext;
+import org.apache.aries.application.management.AriesApplicationContextManager;
+import org.apache.aries.application.management.AriesApplicationListener;
+import org.apache.aries.application.management.AriesApplicationManager;
+import org.apache.aries.application.management.AriesApplicationResolver;
+import org.apache.aries.application.management.BundleConversion;
+import org.apache.aries.application.management.BundleConverter;
+import org.apache.aries.application.management.BundleInfo;
+import org.apache.aries.application.management.ConversionException;
+import org.apache.aries.application.management.LocalPlatform;
+import org.apache.aries.application.management.ManagementException;
+import org.apache.aries.application.management.ResolveConstraint;
+import org.apache.aries.application.management.ResolverException;
+import org.apache.aries.application.management.internal.MessageUtil;
+import org.apache.aries.application.utils.AppConstants;
+import org.apache.aries.application.utils.filesystem.FileSystem;
+import org.apache.aries.application.utils.filesystem.IOUtils;
+import org.apache.aries.application.utils.management.SimpleBundleInfo;
+import org.apache.aries.application.utils.manifest.BundleManifest;
+import org.apache.aries.application.utils.manifest.ManifestDefaultsInjector;
+import org.apache.aries.application.utils.manifest.ManifestProcessor;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AriesApplicationManagerImpl implements AriesApplicationManager {
+
+ private ApplicationMetadataFactory _applicationMetadataFactory;
+ private DeploymentMetadataFactory _deploymentMetadataFactory;
+ private List<BundleConverter> _bundleConverters;
+ private AriesApplicationResolver _resolver;
+ private LocalPlatform _localPlatform;
+ private AriesApplicationContextManager _applicationContextManager;
+
+ private static final Logger _logger = LoggerFactory.getLogger("org.apache.aries.application.management.impl");
+
+ public void setApplicationMetadataFactory (ApplicationMetadataFactory amf) {
+ _applicationMetadataFactory = amf;
+ }
+
+ public void setDeploymentMetadataFactory (DeploymentMetadataFactory dmf) {
+ _deploymentMetadataFactory = dmf;
+ }
+
+ public void setBundleConverters (List<BundleConverter> bcs) {
+ _bundleConverters = bcs;
+ }
+
+ public void setResolver (AriesApplicationResolver resolver) {
+ _resolver = resolver;
+ }
+
+ public void setLocalPlatform (LocalPlatform lp) {
+ _localPlatform = lp;
+ }
+
+ public void setApplicationContextManager (AriesApplicationContextManager acm) {
+ _applicationContextManager = acm;
+ }
+
+
+ /**
+ * Create an AriesApplication from a .eba file: a zip file with a '.eba' extension
+ * as per http://incubator.apache.org/aries/applications.html
+ */
+ public AriesApplication createApplication(IDirectory ebaFile) throws ManagementException {
+ ApplicationMetadata applicationMetadata = null;
+ DeploymentMetadata deploymentMetadata = null;
+ Map<String, BundleConversion> modifiedBundles = new HashMap<String, BundleConversion>();
+ AriesApplicationImpl application = null;
+ String appPath = ebaFile.toString();
+ try {
+ // try to read the app name out of the application.mf
+ Manifest applicationManifest = parseApplicationManifest (ebaFile);
+ String appName = applicationManifest.getMainAttributes().getValue(AppConstants.APPLICATION_NAME);
+
+ //If the application name is null, we will try to get the file name.
+ if (appName == null || appName.isEmpty()) {
+ String fullPath = appPath;
+ if (fullPath.endsWith("/")) {
+ fullPath = fullPath.substring(0, fullPath.length() -1);
+ }
+
+ int last_slash = fullPath.lastIndexOf("/");
+ appName = fullPath.substring(last_slash + 1, fullPath.length());
+ }
+
+ IFile deploymentManifest = ebaFile.getFile(AppConstants.DEPLOYMENT_MF);
+ /* We require that all other .jar and .war files included by-value be valid bundles
+ * because a DEPLOYMENT.MF has been provided. If no DEPLOYMENT.MF, migrate
+ * wars to wabs, plain jars to bundles
+ */
+ Set<BundleInfo> extraBundlesInfo = new HashSet<BundleInfo>();
+ for (IFile f : ebaFile) {
+ if (f.isDirectory()) {
+ continue;
+ }
+ BundleManifest bm = getBundleManifest (f);
+ if (bm != null) {
+ if (bm.isValid()) {
+ extraBundlesInfo.add(new SimpleBundleInfo(_applicationMetadataFactory, bm, f.toURL().toExternalForm()));
+ } else if (deploymentManifest == null) {
+ // We have a jar that needs converting to a bundle, or a war to migrate to a WAB
+ // We only do this if a DEPLOYMENT.MF does not exist.
+ BundleConversion convertedBinary = null;
+ Iterator<BundleConverter> converters = _bundleConverters.iterator();
+ List<ConversionException> conversionExceptions = Collections.emptyList();
+ while (converters.hasNext() && convertedBinary == null) {
+ try {
+ convertedBinary = converters.next().convert(ebaFile, f);
+ } catch (ServiceException sx) {
+ // We'll get this if our optional BundleConverter has not been injected.
+ } catch (ConversionException cx) {
+ conversionExceptions.add(cx);
+ }
+ }
+ if (conversionExceptions.size() > 0) {
+ for (ConversionException cx : conversionExceptions) {
+ _logger.error("APPMANAGEMENT0004E", new Object[]{f.getName(), appName, cx});
+ }
+ throw new ManagementException (MessageUtil.getMessage("APPMANAGEMENT0005E", appName));
+ }
+ if (convertedBinary != null) {
+ modifiedBundles.put (f.getName(), convertedBinary);
+ extraBundlesInfo.add(convertedBinary.getBundleInfo(_applicationMetadataFactory));
+ }
+ }
+ }
+ }
+
+ // if Application-Content header was not specified build it based on the bundles included by value
+ if (applicationManifest.getMainAttributes().getValue(AppConstants.APPLICATION_CONTENT) == null) {
+ String appContent = buildAppContent(extraBundlesInfo);
+ applicationManifest.getMainAttributes().putValue(AppConstants.APPLICATION_CONTENT, appContent);
+ }
+
+ ManifestDefaultsInjector.updateManifest(applicationManifest, appName, ebaFile);
+ applicationMetadata = _applicationMetadataFactory.createApplicationMetadata(applicationManifest);
+
+ if (deploymentManifest != null) {
+ deploymentMetadata = _deploymentMetadataFactory.createDeploymentMetadata(deploymentManifest);
+
+ // Validate: symbolic names must match
+ String appSymbolicName = applicationMetadata.getApplicationSymbolicName();
+ String depSymbolicName = deploymentMetadata.getApplicationSymbolicName();
+ if (!appSymbolicName.equals(depSymbolicName)) {
+ throw new ManagementException (MessageUtil.getMessage("APPMANAGEMENT0002E", appName, appSymbolicName, depSymbolicName));
+ }
+ }
+
+ application = new AriesApplicationImpl (applicationMetadata, extraBundlesInfo, _localPlatform);
+ application.setDeploymentMetadata(deploymentMetadata);
+ // Store a reference to any modified bundles
+ application.setModifiedBundles (modifiedBundles);
+ } catch (IOException iox) {
+ _logger.error ("APPMANAGEMENT0006E", new Object []{appPath, iox});
+ throw new ManagementException(iox);
+ }
+ return application;
+ }
+
+ private String buildAppContent(Set<BundleInfo> bundleInfos) {
+ StringBuilder builder = new StringBuilder();
+ Iterator<BundleInfo> iterator = bundleInfos.iterator();
+ while (iterator.hasNext()) {
+ BundleInfo info = iterator.next();
+ builder.append(info.getSymbolicName());
+
+ // bundle version is not a required manifest header
+ if (info.getVersion() != null) {
+ String version = info.getVersion().toString();
+ builder.append(";version=\"[");
+ builder.append(version);
+ builder.append(',');
+ builder.append(version);
+ builder.append("]\"");
+ }
+
+ if (iterator.hasNext()) {
+ builder.append(",");
+ }
+ }
+ return builder.toString();
+ }
+
+ /**
+ * Create an application from a URL.
+ * The first version of this method isn't smart enough to check whether
+ * the input URL is file://
+ */
+ public AriesApplication createApplication(URL url) throws ManagementException {
+ OutputStream os = null;
+ AriesApplication app = null;
+ try {
+ File tempFile = _localPlatform.getTemporaryFile();
+ InputStream is = url.openStream();
+ os = new FileOutputStream (tempFile);
+ IOUtils.copy(is, os);
+ IDirectory downloadedSource = FileSystem.getFSRoot(tempFile);
+ app = createApplication (downloadedSource);
+ } catch (IOException iox) {
+ throw new ManagementException (iox);
+ }
+ finally {
+ IOUtils.close(os);
+ }
+ return app;
+ }
+
+ public AriesApplication resolve(AriesApplication originalApp, ResolveConstraint... constraints) throws ResolverException {
+ AriesApplicationImpl application = new AriesApplicationImpl(originalApp.getApplicationMetadata(), originalApp.getBundleInfo(), _localPlatform);
+ Set<BundleInfo> additionalBundlesRequired = _resolver.resolve(application, constraints);
+ DeploymentMetadata deploymentMetadata = _deploymentMetadataFactory.createDeploymentMetadata(application, additionalBundlesRequired);
+ application.setDeploymentMetadata(deploymentMetadata);
+ // Store a reference to any modified bundles
+ if (originalApp instanceof AriesApplicationImpl) {
+ // TODO: are we really passing streams around ?
+ application.setModifiedBundles(((AriesApplicationImpl) originalApp).getModifiedBundles());
+ }
+ return application;
+ }
+
+ public AriesApplicationContext install(AriesApplication app) throws BundleException, ManagementException, ResolverException {
+ if (!app.isResolved()) {
+ app = resolve(app);
+ }
+ AriesApplicationContext result = _applicationContextManager.getApplicationContext(app);
+ return result;
+ }
+
+ public void uninstall(AriesApplicationContext app) throws BundleException
+ {
+ _applicationContextManager.remove(app);
+ }
+
+ public void addApplicationListener(AriesApplicationListener l) {
+ // Need application listener lifecycle support
+ }
+
+ public void removeApplicationListener(AriesApplicationListener l) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+
+ /**
+ * Locate and parse an application.mf in an eba
+ * @param source An aries application file
+ * @return parsed manifest, or an empty Manifest
+ * @throws IOException
+ */
+ private Manifest parseApplicationManifest (IDirectory source) throws IOException {
+ Manifest result = new Manifest();
+ IFile f = source.getFile(AppConstants.APPLICATION_MF);
+ if (f != null) {
+ InputStream is = null;
+ try {
+ is = f.open();
+ result = ManifestProcessor.parseManifest(is);
+ } catch (IOException iox) {
+ _logger.error ("APPMANAGEMENT0007E", new Object[]{source.getName(), iox});
+ throw iox;
+ } finally {
+ IOUtils.close(is);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Extract a bundle manifest from an IFile representing a bundle
+ * @param file The bundle to extract the manifest from
+ * @return bundle manifest
+ */
+ private BundleManifest getBundleManifest(IFile file) throws IOException {
+ BundleManifest mf = null;
+ InputStream in = null;
+ try {
+ in = file.open();
+ mf = BundleManifest.fromBundle(in);
+ } finally {
+ IOUtils.close(in);
+ }
+ return mf;
+ }
+
+}
Added: aries/tags/application-0.2.1/application-management/src/main/java/org/apache/aries/application/management/internal/MessageUtil.java
URL: http://svn.apache.org/viewvc/aries/tags/application-0.2.1/application-management/src/main/java/org/apache/aries/application/management/internal/MessageUtil.java?rev=1075127&view=auto
==============================================================================
--- aries/tags/application-0.2.1/application-management/src/main/java/org/apache/aries/application/management/internal/MessageUtil.java (added)
+++ aries/tags/application-0.2.1/application-management/src/main/java/org/apache/aries/application/management/internal/MessageUtil.java Sun Feb 27 20:02:48 2011
@@ -0,0 +1,46 @@
+/*
+ * 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 WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.aries.application.management.internal;
+
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+
+public class MessageUtil
+{
+ /** The resource bundle for blueprint messages */
+ private final static ResourceBundle messages = ResourceBundle.getBundle("org.apache.aries.application.management.messages.AppManagementMessages");
+
+ /**
+ * Resolve a message from the bundle, including any necessary formatting.
+ *
+ * @param key the message key.
+ * @param inserts any required message inserts.
+ * @return the message translated into the server local.
+ */
+ public static final String getMessage(String key, Object ... inserts)
+ {
+ String msg = messages.getString(key);
+
+ if (inserts.length > 0)
+ msg = MessageFormat.format(msg, inserts);
+
+ return msg;
+ }
+}
Added: aries/tags/application-0.2.1/application-management/src/main/resources/OSGI-INF/blueprint/app-management.xml
URL: http://svn.apache.org/viewvc/aries/tags/application-0.2.1/application-management/src/main/resources/OSGI-INF/blueprint/app-management.xml?rev=1075127&view=auto
==============================================================================
--- aries/tags/application-0.2.1/application-management/src/main/resources/OSGI-INF/blueprint/app-management.xml (added)
+++ aries/tags/application-0.2.1/application-management/src/main/resources/OSGI-INF/blueprint/app-management.xml Sun Feb 27 20:02:48 2011
@@ -0,0 +1,42 @@
+<?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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <bean id="app-manager" class="org.apache.aries.application.management.impl.AriesApplicationManagerImpl" scope="singleton" activation="lazy">
+ <property name="applicationMetadataFactory" ref="app-metadata-factory"/>
+ <property name="deploymentMetadataFactory" ref="deployment-metadata-factory"/>
+ <property name="bundleConverters" ref="bundle-converters"/>
+ <property name="resolver" ref="resolver"/>
+ <property name="localPlatform" ref="localPlatform"/>
+ <property name="applicationContextManager" ref="application-context-manager"/>
+ </bean>
+
+ <reference id="app-metadata-factory" interface="org.apache.aries.application.ApplicationMetadataFactory"/>
+ <reference id="deployment-metadata-factory" interface="org.apache.aries.application.DeploymentMetadataFactory"/>
+ <reference-list id="bundle-converters"
+ interface="org.apache.aries.application.management.BundleConverter"
+ availability="optional"/>
+ <reference id="resolver" interface="org.apache.aries.application.management.AriesApplicationResolver"/>
+ <reference id="localPlatform" interface="org.apache.aries.application.management.LocalPlatform"/>
+ <reference id="application-context-manager" interface="org.apache.aries.application.management.AriesApplicationContextManager"/>
+
+ <service interface="org.apache.aries.application.management.AriesApplicationManager" ref="app-manager" />
+
+</blueprint>
Added: aries/tags/application-0.2.1/application-management/src/main/resources/org/apache/aries/application/messages/AppManagementMessages.properties
URL: http://svn.apache.org/viewvc/aries/tags/application-0.2.1/application-management/src/main/resources/org/apache/aries/application/messages/AppManagementMessages.properties?rev=1075127&view=auto
==============================================================================
--- aries/tags/application-0.2.1/application-management/src/main/resources/org/apache/aries/application/messages/AppManagementMessages.properties (added)
+++ aries/tags/application-0.2.1/application-management/src/main/resources/org/apache/aries/application/messages/AppManagementMessages.properties Sun Feb 27 20:02:48 2011
@@ -0,0 +1,25 @@
+#
+# 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.
+#
+APPMANAGEMENT0001E=APPMANAGEMENT0001E: Unable to fully delete directory {0}.
+APPMANAGEMENT0002E=APPMANAGEMENT0002E: Unable to create Aries application from {0} since APPLICATION.MF symbolic name {1} does not equals DEPLOYMENT.MF symbolic name {2}.
+APPMANAGEMENT0004E=APPMANAGEMENT0004E: Exception caught when converting artifact {0} in {1}: {2}.
+APPMANAGEMENT0005E=APPMANAGEMENT0005E: Failed to create application from {0} due to conversion errors: see log for details.
+APPMANAGEMENT0006E=APPMANAGEMENT0006E: IOException encountered while constructing Aries application from {0}: {1}.
+APPMANAGEMENT0007E=APPMANAGEMENT0007E: IOException encountered while parsing APPICATION.MF in {0}: {1}.
+APPMANAGEMENT0008E=APPMANAGEMENT0008E: ResolverException encountered while constructing Aries application from {0}: {1}.