[jboss-cvs] JBossAS SVN: r90236 - in projects/jboss-osgi/trunk: spi/src/main/java/org/jboss/osgi/spi/testing/internal and 9 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jun 16 03:55:57 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-06-16 03:55:57 -0400 (Tue, 16 Jun 2009)
New Revision: 90236
Added:
projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-felix.properties
projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/
projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/
projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/
projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/jboss/
projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/jboss/osgi/
projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/jboss/osgi/trailblazer/
projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/jboss/osgi/trailblazer/web/
projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/jboss/osgi/trailblazer/web/MainServlet.java
Removed:
projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-framework.properties
Modified:
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
projects/jboss-osgi/trunk/testsuite/trailblazer/.classpath
Log:
Runtime maintains single bundle list for shutdown
Copied: projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-felix.properties (from rev 90230, projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-framework.properties)
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-felix.properties (rev 0)
+++ projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-felix.properties 2009-06-16 07:55:57 UTC (rev 90236)
@@ -0,0 +1,38 @@
+#
+# Properties read by the org.jboss.osgi.spi.framework.PropertiesBootstrapProvider
+#
+# $Id$
+#
+
+# The OSGiFramework implementation
+org.jboss.osgi.spi.framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
+
+# Properties to configure the Framework
+org.osgi.framework.storage=${test.archive.directory}/../osgi-store
+org.osgi.framework.storage.clean=onFirstInit
+
+# Husky socket connector properties
+org.jboss.osgi.husky.runtime.connector.host=localhost
+org.jboss.osgi.husky.runtime.connector.port=5401
+
+# Framework bootdelegation
+# org.osgi.framework.bootdelegation=org.osgi.service.log
+
+# Extra System Packages
+org.osgi.framework.system.packages.extra=\
+ org.jboss.logging, \
+ org.jboss.osgi.spi;version=1.0, \
+ org.jboss.osgi.spi.capability;version=1.0, \
+ org.jboss.osgi.spi.management;version=1.0, \
+ org.jboss.osgi.spi.service;version=1.0, \
+ org.jboss.osgi.spi.testing;version=1.0, \
+ org.osgi.framework;version=1.4
+
+# Bundles that need to be installed with the Framework automatically
+org.jboss.osgi.spi.framework.autoInstall=\
+ file://${test.archive.directory}/bundles/org.osgi.compendium.jar
+
+# Bundles that need to be started automatically
+org.jboss.osgi.spi.framework.autoStart=\
+ file://${test.archive.directory}/bundles/org.apache.felix.log.jar \
+ file://${test.archive.directory}/bundles/jboss-osgi-common.jar
Deleted: projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-framework.properties
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-framework.properties 2009-06-16 07:48:03 UTC (rev 90235)
+++ projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-framework.properties 2009-06-16 07:55:57 UTC (rev 90236)
@@ -1,38 +0,0 @@
-#
-# Properties read by the org.jboss.osgi.spi.framework.PropertiesBootstrapProvider
-#
-# $Id$
-#
-
-# The OSGiFramework implementation
-org.jboss.osgi.spi.framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
-
-# Properties to configure the Framework
-org.osgi.framework.storage=${test.archive.directory}/../osgi-store
-org.osgi.framework.storage.clean=onFirstInit
-
-# Husky socket connector properties
-org.jboss.osgi.husky.runtime.connector.host=localhost
-org.jboss.osgi.husky.runtime.connector.port=5401
-
-# Framework bootdelegation
-# org.osgi.framework.bootdelegation=org.osgi.service.log
-
-# Extra System Packages
-org.osgi.framework.system.packages.extra=\
- org.jboss.logging, \
- org.jboss.osgi.spi;version=1.0, \
- org.jboss.osgi.spi.capability;version=1.0, \
- org.jboss.osgi.spi.management;version=1.0, \
- org.jboss.osgi.spi.service;version=1.0, \
- org.jboss.osgi.spi.testing;version=1.0, \
- org.osgi.framework;version=1.4
-
-# Bundles that need to be installed with the Framework automatically
-org.jboss.osgi.spi.framework.autoInstall=\
- file://${test.archive.directory}/bundles/org.osgi.compendium.jar
-
-# Bundles that need to be started automatically
-org.jboss.osgi.spi.framework.autoStart=\
- file://${test.archive.directory}/bundles/org.apache.felix.log.jar \
- file://${test.archive.directory}/bundles/jboss-osgi-common.jar
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java 2009-06-16 07:48:03 UTC (rev 90235)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java 2009-06-16 07:55:57 UTC (rev 90236)
@@ -75,7 +75,7 @@
service.deploy(bundleURL);
OSGiBundle bundle = getBundle(symbolicName, null);
- return registerBundleForUninstall(bundle);
+ return registerBundleForUninstall(location, bundle);
}
public OSGiBundle[] getBundles()
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-06-16 07:48:03 UTC (rev 90235)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-06-16 07:55:57 UTC (rev 90236)
@@ -26,7 +26,7 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.jar.Attributes;
@@ -61,8 +61,7 @@
final Logger log = Logger.getLogger(OSGiRuntimeImpl.class);
private OSGiTestHelper helper;
- private List<OSGiBundle> registeredBundles = new ArrayList<OSGiBundle>();
- private Map<String, OSGiBundle> capBundles = new HashMap<String, OSGiBundle>();
+ private Map<String, OSGiBundle> bundles = new LinkedHashMap<String, OSGiBundle>();
private List<Capability> capabilities = new ArrayList<Capability>();
private LogReaderService logReaderService;
@@ -88,9 +87,9 @@
return logReaderService;
}
- protected OSGiBundle registerBundleForUninstall(OSGiBundle bundle)
+ protected OSGiBundle registerBundleForUninstall(String location, OSGiBundle bundle)
{
- registeredBundles.add(bundle);
+ bundles.put(location, bundle);
return bundle;
}
@@ -109,11 +108,11 @@
for (String location : capability.getBundles())
{
String symName = getSymbolicName(location);
- if (capBundles.get(location) == null && getBundle(symName, null) == null)
+ if (bundles.get(location) == null && getBundle(symName, null) == null)
{
OSGiBundle bundle = installBundle(location);
bundle.start();
- capBundles.put(location, bundle);
+ bundles.put(location, bundle);
}
else
{
@@ -139,7 +138,7 @@
for (String location : bundleLocations)
{
- OSGiBundle bundle = capBundles.remove(location);
+ OSGiBundle bundle = bundles.remove(location);
if (bundle != null)
{
try
@@ -184,19 +183,25 @@
stopLogEntryTracking();
// Uninstall the registered bundles
- Collections.reverse(registeredBundles);
- while (registeredBundles.size() > 0)
+ ArrayList<String> bundleLocations = new ArrayList<String>(bundles.keySet());
+ Collections.reverse(bundleLocations);
+
+ while (bundleLocations.size() > 0)
{
- OSGiBundle bundle = registeredBundles.remove(0);
- try
+ String location = bundleLocations.remove(0);
+ OSGiBundle bundle = bundles.remove(location);
+ if (bundle != null)
{
- if (bundle.getState() != Bundle.UNINSTALLED)
- bundle.uninstall();
+ try
+ {
+ if (bundle.getState() != Bundle.UNINSTALLED)
+ bundle.uninstall();
+ }
+ catch (BundleException ex)
+ {
+ log.warn("Cannot uninstall: " + bundle, ex);
+ }
}
- catch (BundleException ex)
- {
- log.warn("Cannot uninstall: " + bundle, ex);
- }
}
// Uninstall the capabilities
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-06-16 07:48:03 UTC (rev 90235)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-06-16 07:55:57 UTC (rev 90236)
@@ -79,7 +79,7 @@
deploy(location);
ManagedBundleMBean bundleMBean = getRemoteFramework().getBundle(symbolicName);
RemoteBundle bundle = new RemoteBundle(this, bundleMBean, location);
- return registerBundleForUninstall(bundle);
+ return registerBundleForUninstall(location, bundle);
}
catch (RuntimeException rte)
{
Modified: projects/jboss-osgi/trunk/testsuite/trailblazer/.classpath
===================================================================
--- projects/jboss-osgi/trunk/testsuite/trailblazer/.classpath 2009-06-16 07:48:03 UTC (rev 90235)
+++ projects/jboss-osgi/trunk/testsuite/trailblazer/.classpath 2009-06-16 07:55:57 UTC (rev 90236)
@@ -2,6 +2,7 @@
<classpath>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
Added: projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/jboss/osgi/trailblazer/web/MainServlet.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/jboss/osgi/trailblazer/web/MainServlet.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/jboss/osgi/trailblazer/web/MainServlet.java 2009-06-16 07:55:57 UTC (rev 90236)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.trailblazer.web;
+
+//$Id$
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.URL;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.osgi.common.log.LogServiceTracker;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.http.HttpService;
+import org.osgi.service.log.LogService;
+
+
+/**
+ * A servlet that gets registered with the {@link HttpService} to
+ * render the Trailblazer portal
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 10-May-2009
+ */
+ at SuppressWarnings("serial")
+public class MainServlet extends HttpServlet
+{
+ private LogService log;
+
+ private BundleContext context;
+
+ public MainServlet(BundleContext context)
+ {
+ this.log = new LogServiceTracker(context);
+ this.context = context;
+
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
+ {
+ PrintWriter out = res.getWriter();
+
+ String path = req.getPathInfo();
+ if (path == null)
+ path = "/";
+
+ renderHeader(req, res);
+
+ renderFooter(req, res);
+
+ out.close();
+ }
+
+ private void renderHeader(HttpServletRequest req, HttpServletResponse res) throws IOException
+ {
+ PrintWriter out = res.getWriter();
+
+ out.println("<html>");
+ out.println("<head>");
+ out.println("<link rel='stylesheet' href='" + req.getServletPath() + "/style/osgishop.css' type='text/css'>");
+ out.println("</head>");
+ out.println("<body>");
+
+ out.println("<a href='" + req.getServletPath() + "'>home</a>");
+ out.println("<a href='" + req.getServletPath() + "/cart'>cart</a>");
+ out.println("<p/>");
+ out.println("<table><tr valign='top'><td width='400'>");
+ }
+
+ private void renderFooter(HttpServletRequest req, HttpServletResponse res) throws IOException
+ {
+ PrintWriter out = res.getWriter();
+
+ out.println("</td><td>");
+
+ renderNotes(req, res);
+
+ out.println("</td></tr>");
+ out.println("</table>");
+ out.println("</body>");
+ out.println("</html>");
+ }
+
+ private void renderNotes(HttpServletRequest req, HttpServletResponse res) throws IOException
+ {
+ PrintWriter out = res.getWriter();
+
+ String path = req.getPathInfo();
+ if (path == null)
+ path = "/";
+
+ if (path.equals("/"))
+ path = "/home";
+
+ out.println("<div class='notes'>");
+
+ String notesPath = "notes" + path;
+
+ if (path.equals("/list"))
+ {
+ String paramShop = req.getParameter("shop");
+ if (paramShop != null)
+ notesPath += "-" + paramShop;
+ }
+
+ notesPath = notesPath.toLowerCase() + ".html";
+
+ URL htmlRes = context.getBundle().getResource(notesPath);
+ if (htmlRes != null)
+ {
+ BufferedReader br = new BufferedReader(new InputStreamReader(htmlRes.openStream()));
+ String line = br.readLine();
+ while (line != null)
+ {
+ out.println(line);
+ line = br.readLine();
+ }
+ }
+ else
+ {
+ out.println("Cannot find: " + notesPath);
+ }
+ out.println("</div>");
+ }
+}
Property changes on: projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/jboss/osgi/trailblazer/web/MainServlet.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the jboss-cvs-commits
mailing list