[jboss-osgi-commits] JBoss-OSGI SVN: r95822 - in projects/jboss-osgi: projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky and 21 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Fri Oct 30 07:09:22 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-10-30 07:09:19 -0400 (Fri, 30 Oct 2009)
New Revision: 95822

Added:
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/PackageListener.java
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyInterceptor.java
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/ManifestProcessor.java
Removed:
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/LocalInvocation.java
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/PackageListener.java
Modified:
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/pom.xml
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractConnector.java
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractPackageListener.java
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/OSGiInvoker.java
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/Connector.java
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyActivator.java
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyExtender.java
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/SocketConnector.java
   projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/pom.xml
   projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/resources/jboss-osgi-framework.properties
   projects/jboss-osgi/projects/bundles/webapp/trunk/pom.xml
   projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebAppActivator.java
   projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebAppPublisherInterceptor.java
   projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebXMLParserInterceptor.java
   projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-equinox.xml
   projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-felix.xml
   projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml
   projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/conf/jboss-osgi-equinox.properties
   projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml
   projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-all.properties
   projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-default.properties
   projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-minimal.properties
   projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-web.properties
   projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintInterceptor.java
   projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptorService.java
   projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorService.java
   projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/LifecycleInterceptorServiceImpl.java
   projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/InterceptorOrderTestCase.java
   projects/jboss-osgi/trunk/reactor/framework/pom.xml
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java
   projects/jboss-osgi/trunk/reactor/pom.xml
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/interceptor/processor/InterceptorActivator.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
   projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-equinox.properties
   projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties
   projects/jboss-osgi/trunk/testsuite/example/src/test/resources/mcservice/example-mcservice-bundleA.bnd
Log:
Use WhiteboardPattern in interceptor and husky API

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/pom.xml	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/pom.xml	2009-10-30 11:09:19 UTC (rev 95822)
@@ -73,11 +73,13 @@
             <Import-Package>
               javax.management,
               javax.naming,
+              org.jboss.osgi.deployment.interceptor;version="[1.0,1.1)",
               org.jboss.osgi.spi.capability;version="[1.0,1.1)",
               org.jboss.osgi.spi.management;version="[1.0,1.1)", 
               org.jboss.osgi.spi.util;version="[1.0,1.1)", 
               org.junit;version="[4.6,5.0)",
               org.osgi.framework,
+              org.osgi.util.tracker,
               org.slf4j;version="[1.5,1.6)",
               
               <!-- ignore client side -->

Copied: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/PackageListener.java (from rev 95821, projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/PackageListener.java)
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/PackageListener.java	                        (rev 0)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/PackageListener.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -0,0 +1,59 @@
+/*
+ * 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.husky;
+
+import java.util.List;
+
+import org.jboss.osgi.husky.runtime.Connector;
+
+// $Id$
+
+/**
+ * A PackageListener that is associated with a {@link Connector}.
+ * 
+ * The PackageListener matches test {@link Request}s with the package names 
+ * that it can handle. On a successful match the {@link Connector} will invoke
+ * the {@link #runTests(Request)} method.
+ * 
+ * @author Thomas.Diesler at jboss.com
+ * @since 16-May-2009
+ */
+public interface PackageListener
+{
+   /**
+    * Return the list of packages that this listener can handle.
+    */
+   List<String> getPackageNames();
+   
+   /**
+    * Return true if the given {@link Request} is from a package 
+    * that this listener can handle.
+    */
+   boolean match(Request request);
+
+   /**
+    * Called by {@link Connector} when this listener indicated that it can 
+    * handle the test request.
+    */
+   Response runTests(Request request) throws Throwable;
+
+}
\ No newline at end of file

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractConnector.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractConnector.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractConnector.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -29,14 +29,14 @@
 import java.io.InputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
 
+import org.jboss.osgi.husky.PackageListener;
 import org.jboss.osgi.husky.Request;
 import org.jboss.osgi.husky.Response;
 import org.jboss.osgi.husky.runtime.Connector;
-import org.jboss.osgi.husky.runtime.PackageListener;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
 
 /**
  * An abstract {@link Connector} implementation 
@@ -46,67 +46,86 @@
  */
 public abstract class AbstractConnector implements Connector
 {
-   private List<PackageListener> listeners = new ArrayList<PackageListener>();
+   private BundleContext context;
 
-   public void addPackageListener(PackageListener listener)
+   public AbstractConnector(BundleContext context)
    {
-      synchronized (listeners)
-      {
-         listeners.add(listener);
-         listeners.notifyAll();
-      }
+      this.context = context;
    }
 
-   public List<PackageListener> getPackageListeners()
+   public BundleContext getBundleContext()
    {
-      return Collections.unmodifiableList(listeners);
+      return context;
    }
 
-   public void removePackageListener(PackageListener listener)
+   protected void start() throws Exception
    {
-      synchronized (listeners)
-      {
-         listeners.remove(listener);
-      }
    }
 
-   public Response process(Request req) throws ClassNotFoundException
+   protected void stop() throws Exception
    {
-      String testClass = req.getClassName();
+   }
 
-      int timeout = 50;
-      PackageListener listener = null;
-      while (listener == null && 0 < timeout--)
+   public Response process(final Request req) throws Throwable
+   {
+      class PackageListenerTracker extends ServiceTracker
       {
-         synchronized (listeners)
+         Throwable error;
+         Response response;
+         boolean done;
+
+         PackageListenerTracker(BundleContext context)
          {
-            for (PackageListener aux : listeners)
-            {
-               if (aux.match(req))
-               {
-                  listener = aux;
-                  break;
-               }
-            }
+            super(context, PackageListener.class.getName(), null);
+         }
 
-            if (listener == null)
+         @Override
+         public Object addingService(ServiceReference reference)
+         {
+            PackageListener service = (PackageListener)super.addingService(reference);
+            if (service.match(req))
             {
                try
                {
-                  listeners.wait(200);
+                  response = service.runTests(req);
                }
-               catch (InterruptedException e)
+               catch (Throwable th)
                {
-                  // ignore
+                  error = th;
                }
+               finally
+               {
+                  done = true;
+               }
             }
+            return service;
          }
+      };
+
+      PackageListenerTracker tracker = new PackageListenerTracker(context);
+      tracker.open();
+
+      int timeout = 50;
+      while (tracker.done == false && 0 < timeout--)
+      {
+         try
+         {
+            Thread.currentThread().wait(200);
+         }
+         catch (InterruptedException e)
+         {
+            // ignore
+         }
       }
+      tracker.close();
+      
+      if (tracker.error != null)
+         throw tracker.error;
 
-      if (listener == null)
-         throw new IllegalStateException("Cannot find listener to handle: " + testClass + ", we have " + listeners);
+      if (tracker.response != null)
+         return tracker.response;
 
-      return listener.runTests(req);
+      throw new IllegalStateException("Cannot find listener to handle: " + req.getClassName());
    }
 
    protected InputStream process(InputStream reqStream)
@@ -122,10 +141,10 @@
          // Field the request through the abstract connector
          response = process(request);
       }
-      catch (Exception ex)
+      catch (Throwable th)
       {
          response = new BasicResponse();
-         BasicFailure failure = new BasicFailure(ex.getMessage(), ex);
+         BasicFailure failure = new BasicFailure(th.getMessage(), th);
          if (request != null)
          {
             failure.setClassName(request.getClassName());

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractPackageListener.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractPackageListener.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractPackageListener.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -27,9 +27,9 @@
 import java.util.List;
 
 import org.jboss.osgi.husky.Context;
+import org.jboss.osgi.husky.PackageListener;
 import org.jboss.osgi.husky.Request;
 import org.jboss.osgi.husky.Response;
-import org.jboss.osgi.husky.runtime.PackageListener;
 import org.jboss.osgi.husky.runtime.Runner;
 
 /**

Deleted: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/LocalInvocation.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/LocalInvocation.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/LocalInvocation.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -1,78 +0,0 @@
-/*
- * 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.husky.internal;
-
-// $Id$
-
-import java.util.Arrays;
-
-import org.jboss.osgi.husky.Context;
-import org.jboss.osgi.husky.Request;
-import org.jboss.osgi.husky.Response;
-import org.jboss.osgi.husky.runtime.Connector;
-import org.jboss.osgi.husky.runtime.Runner;
-import org.jboss.osgi.husky.runtime.junit.JUnitRunner;
-
-/**
- * An 'in-memory' invocation. 
- * 
- * @author Thomas.Diesler at jboss.com
- * @since 16-May-2009
- */
-public class LocalInvocation
-{
-   public Response invoke(Request req) throws Exception
-   {
-      Connector connector = new LocalConnector();
-      connector.addPackageListener(new MatchAllJUnitPackageListener());
-      return connector.process(req);
-   }
-
-   class LocalConnector extends AbstractConnector
-   {
-   }
-
-   class MatchAllJUnitPackageListener extends AbstractPackageListener
-   {
-      public MatchAllJUnitPackageListener()
-      {
-         super(Arrays.asList(new String[] { "org.jboss.test" }));
-      }
-
-      public Context getContext()
-      {
-         return new BasicContext();
-      }
-
-      @Override
-      public Runner getRunner()
-      {
-         return new JUnitRunner();
-      }
-
-      @Override
-      public Class<?> loadTestClass(String className)
-      {
-         return Util.loadClass(className);
-      }
-   }
-}

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/OSGiInvoker.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/OSGiInvoker.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/OSGiInvoker.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -32,7 +32,6 @@
 import org.jboss.osgi.husky.Invoker;
 import org.jboss.osgi.husky.Request;
 import org.jboss.osgi.husky.Response;
-import org.jboss.osgi.husky.runtime.osgi.JMXConnector;
 
 /**
  * An {@link Invoker} suitable for OSGi bundle testing.
@@ -41,7 +40,6 @@
  * 
  * #1 {@link SocketInvocation}
  * #2 {@link JMXInvocation}
- * #3 {@link LocalInvocation}
  * 
  * @author Thomas.Diesler at jboss.com
  * @since 16-May-2009
@@ -57,14 +55,10 @@
          {
             return new SocketInvocation().invoke(req);
          }
-         else if (server.isRegistered(JMXConnector.OBJECT_NAME))
+         else 
          {
             return new JMXInvocation().invoke(server, req);
          }
-         else
-         {
-            return new LocalInvocation().invoke(req);
-         }
       }
       catch (RuntimeException rte)
       {

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/Connector.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/Connector.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/Connector.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -21,14 +21,12 @@
  */
 package org.jboss.osgi.husky.runtime;
 
+//$Id$
 
-import java.util.List;
-
+import org.jboss.osgi.husky.PackageListener;
 import org.jboss.osgi.husky.Request;
 import org.jboss.osgi.husky.Response;
 
-// $Id$
-
 /**
  * A Connector is the receiving side of a test request.
  * 
@@ -46,23 +44,6 @@
    /**
     * Handles the test request by dispatching to one of the 
     * associated {@link PackageListener}s. 
-    *
-    * @throws RuntimeException if no {@link PackageListener} can be found
     */
-   Response process(Request req) throws ClassNotFoundException;
-   
-   /**
-    * Get the set of registered {@link PackageListener}s for this connector
-    */
-   List<PackageListener> getPackageListeners();
-   
-   /**
-    * Add a {@link PackageListener} to this connector
-    */
-   void addPackageListener(PackageListener listener);
-   
-   /**
-    * Remove a {@link PackageListener} from this connector
-    */
-   void removePackageListener(PackageListener listener);
+   Response process(Request req) throws Throwable;
 }

Deleted: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/PackageListener.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/PackageListener.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/PackageListener.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -1,60 +0,0 @@
-/*
- * 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.husky.runtime;
-
-import java.util.List;
-
-import org.jboss.osgi.husky.Request;
-import org.jboss.osgi.husky.Response;
-
-// $Id$
-
-/**
- * A PackageListener that is associated with a {@link Connector}.
- * 
- * The PackageListener matches test {@link Request}s with the package names 
- * that it can handle. On a successful match the {@link Connector} will invoke
- * the {@link #runTests(Request)} method.
- * 
- * @author Thomas.Diesler at jboss.com
- * @since 16-May-2009
- */
-public interface PackageListener
-{
-   /**
-    * Return the list of packages that this listener can handle.
-    */
-   List<String> getPackageNames();
-   
-   /**
-    * Return true if the given {@link Request} is from a package 
-    * that this listener can handle.
-    */
-   boolean match(Request request);
-
-   /**
-    * Called by {@link Connector} when this listener indicated that it can 
-    * handle the test request.
-    */
-   Response runTests(Request request) throws ClassNotFoundException;
-
-}
\ No newline at end of file

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyActivator.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyActivator.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyActivator.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -23,6 +23,7 @@
 
 // $Id$
 
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleListener;
@@ -47,19 +48,22 @@
 {
    private SocketConnector socketConnector;
    private JMXConnector jmxConnector;
-   
+
    public void start(BundleContext context) throws Exception
    {
       jmxConnector = new JMXConnector(context);
       jmxConnector.start();
-      
+
       if (SocketConnector.isRemoteConnection(context))
       {
          socketConnector = new SocketConnector(context);
          socketConnector.start();
       }
-      
-      context.addBundleListener(new HuskyExtender(context));
+
+      ManifestProcessor processor = new ManifestProcessor(context);
+      LifecycleInterceptor interceptor = new HuskyInterceptor(processor);
+      context.registerService(LifecycleInterceptor.class.getName(), interceptor, null);
+      context.addBundleListener(new HuskyExtender(processor));
    }
 
    public void stop(BundleContext context) throws Exception
@@ -69,7 +73,7 @@
          socketConnector.stop();
          socketConnector = null;
       }
-      
+
       if (jmxConnector != null)
       {
          jmxConnector.stop();

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyExtender.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyExtender.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyExtender.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -23,120 +23,37 @@
 
 // $Id$
 
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
-import org.jboss.osgi.husky.runtime.Connector;
-import org.jboss.osgi.husky.runtime.PackageListener;
-import org.jboss.osgi.husky.runtime.junit.JUnitPackageListener;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleListener;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
 import org.osgi.framework.SynchronousBundleListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
- * The Husky extender is a {@link BundleListener} that checkes the {@link #HEADER_TEST_PACKAGE}
+ * The Husky extender is a {@link BundleListener} that processes 
+ * the {@link ManifestProcessor#HEADER_TEST_PACKAGE}.
  * 
  * @author Thomas.Diesler at jboss.com
  * @since 17-May-2009
  */
 public class HuskyExtender implements SynchronousBundleListener
 {
-   /** The manifest header that identifies a bundle as Husky test bundle: 'Test-Package' */
-   public static final String HEADER_TEST_PACKAGE = "Test-Package";
+   private ManifestProcessor processor;
 
-   // Provide Logging
-   private Logger log = LoggerFactory.getLogger(HuskyExtender.class);
-   
-   private BundleContext context;
-
-   public HuskyExtender(BundleContext context)
+   public HuskyExtender(ManifestProcessor processor)
    {
-      this.context = context;
+      this.processor = processor;
    }
 
    public void bundleChanged(BundleEvent event)
    {
-      if (event.getType() == BundleEvent.STARTED)
+      if (event.getType() == BundleEvent.STARTING)
       {
          Bundle bundle = event.getBundle();
-         List<String> packages = getTestPackages(bundle);
+         List<String> packages = processor.getTestPackages(bundle);
          if (packages != null)
-            registerPackageListener(bundle, packages);
+            processor.registerPackageListener(bundle, packages);
       }
-      else if (event.getType() == BundleEvent.STOPPED)
-      {
-         Bundle bundle = event.getBundle();
-         List<String> packages = getTestPackages(bundle);
-         if (packages != null)
-            unregisterPackageListener(bundle, packages);
-      }
    }
-
-   private void registerPackageListener(Bundle bundle, List<String> packages)
-   {
-      ServiceReference[] srefs = null;
-      try
-      {
-         srefs = context.getServiceReferences(Connector.class.getName(), null);
-      }
-      catch (InvalidSyntaxException ex)
-      {
-         // cannot get here
-      }
-
-      if (srefs != null)
-      {
-         log.info("Register test packages " + packages);
-         for (ServiceReference sref : srefs)
-         {
-            Connector connector = (Connector)context.getService(sref);
-            JUnitPackageListener listener = new OSGiJUnitPackageListener(bundle, packages);
-            connector.addPackageListener(listener);
-         }
-      }
-   }
-
-   private void unregisterPackageListener(Bundle bundle, List<String> packages)
-   {
-      ServiceReference[] srefs = null;
-      try
-      {
-         srefs = context.getServiceReferences(Connector.class.getName(), null);
-      }
-      catch (InvalidSyntaxException ex)
-      {
-         // cannot get here
-      }
-
-      if (srefs != null)
-      {
-         log.info("Unregister test packages " + packages);
-         for (ServiceReference sref : srefs)
-         {
-            Connector connector = (Connector)context.getService(sref);
-            for (PackageListener listener : new ArrayList<PackageListener>(connector.getPackageListeners()))
-            {
-               List<String> auxNames = listener.getPackageNames();
-               if (auxNames.equals(packages))
-                  connector.removePackageListener(listener);
-            }
-         }
-      }
-   }
-
-   private List<String> getTestPackages(Bundle bundle)
-   {
-      String testPackage = (String)bundle.getHeaders().get(HEADER_TEST_PACKAGE);
-      if (testPackage != null)
-         return Arrays.asList(testPackage.split("[,\\s]"));
-
-      return null;
-   }
 }
\ No newline at end of file

Added: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyInterceptor.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyInterceptor.java	                        (rev 0)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyInterceptor.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -0,0 +1,58 @@
+/*
+ * 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.husky.runtime.osgi;
+
+// $Id$
+
+import java.util.List;
+
+import org.jboss.osgi.deployment.interceptor.AbstractLifecycleInterceptor;
+import org.jboss.osgi.deployment.interceptor.InvocationContext;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorException;
+import org.osgi.framework.Bundle;
+
+/**
+ * The Husky interceptor processes the {@link ManifestProcessor#HEADER_TEST_PACKAGE}.
+ * 
+ * @author Thomas.Diesler at jboss.com
+ * @since 30-Oct-2009
+ */
+public class HuskyInterceptor extends AbstractLifecycleInterceptor
+{
+   private ManifestProcessor processor;
+
+   public HuskyInterceptor(ManifestProcessor processor)
+   {
+      this.processor = processor;
+   }
+
+   public void invoke(int state, InvocationContext context) throws LifecycleInterceptorException
+   {
+      if (Bundle.STARTING == state)
+      {
+         Bundle bundle = context.getBundle();
+         List<String> packages = processor.getTestPackages(bundle);
+         if (packages != null)
+            processor.registerPackageListener(bundle, packages);
+      }
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyInterceptor.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -49,10 +49,8 @@
 public class JMXConnector extends AbstractConnector implements JMXConnectorMBean
 {
    // Provide Logging
-   private Logger log = LoggerFactory.getLogger(HuskyExtender.class);
+   private Logger log = LoggerFactory.getLogger(JMXConnector.class);
 
-   private BundleContext context;
-
    /** The ObjectName for this service: jboss.osgi.husky:service=jmx-connector */
    public static ObjectName OBJECT_NAME;
    static
@@ -69,23 +67,29 @@
 
    public JMXConnector(BundleContext context)
    {
-      this.context = context;
+      super(context);
    }
 
+   @Override
    public void start() throws Exception
    {
+      super.start();
+      
       MBeanServer mbeanServer = getMBeanServer();
       mbeanServer.registerMBean(this, OBJECT_NAME);
 
       Properties props = new Properties();
       props.setProperty("transport", "jmx");
-      context.registerService(Connector.class.getName(), this, props);
+      getBundleContext().registerService(Connector.class.getName(), this, props);
 
       log.info("JMXConnector registered: " + OBJECT_NAME);
    }
 
+   @Override
    public void stop() throws Exception
    {
+      super.stop();
+      
       MBeanServer mbeanServer = getMBeanServer();
       if (mbeanServer.isRegistered(OBJECT_NAME))
          mbeanServer.unregisterMBean(OBJECT_NAME);
@@ -101,6 +105,7 @@
    private MBeanServer getMBeanServer()
    {
       MBeanServer mbeanServer = null;
+      BundleContext context = getBundleContext();
 
       // Check if there is an MBeanServer service already
       ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());

Added: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/ManifestProcessor.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/ManifestProcessor.java	                        (rev 0)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/ManifestProcessor.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -0,0 +1,91 @@
+/*
+ * 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.husky.runtime.osgi;
+
+// $Id$
+
+import java.util.Arrays;
+import java.util.Hashtable;
+import java.util.List;
+
+import org.jboss.osgi.husky.PackageListener;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Processed the {@link #HEADER_TEST_PACKAGE} and registers the listeners.
+ * 
+ * @author Thomas.Diesler at jboss.com
+ * @since 30-Oct-2009
+ */
+public class ManifestProcessor
+{
+   // Provide Logging
+   private Logger log = LoggerFactory.getLogger(ManifestProcessor.class);
+
+   /** The manifest header that identifies a bundle as Husky test bundle: 'Test-Package' */
+   public static final String HEADER_TEST_PACKAGE = "Test-Package";
+
+   private BundleContext context;
+
+   public ManifestProcessor(BundleContext context)
+   {
+      this.context = context;
+   }
+
+   public void registerPackageListener(Bundle bundle, List<String> packages)
+   {
+      // Check if we already have PackageListener serices for this bundle
+      ServiceReference[] srefs = null;
+      try
+      {
+         String filter = "(bundle=" + bundle.getSymbolicName() + ")";
+         srefs = context.getServiceReferences(PackageListener.class.getName(), filter);
+      }
+      catch (InvalidSyntaxException ex)
+      {
+         // cannot get here
+      }
+
+      if (srefs == null)
+      {
+         log.info("Register test packages " + packages);
+         Hashtable<String, String> properties = new Hashtable<String, String>();
+         properties.put("bundle", bundle.getSymbolicName());
+         PackageListener listener = new OSGiJUnitPackageListener(bundle, packages);
+         bundle.getBundleContext().registerService(PackageListener.class.getName(), listener, properties);
+      }
+   }
+
+   public List<String> getTestPackages(Bundle bundle)
+   {
+      String testPackage = (String)bundle.getHeaders().get(HEADER_TEST_PACKAGE);
+      if (testPackage != null)
+         return Arrays.asList(testPackage.split("[,\\s]"));
+
+      return null;
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/ManifestProcessor.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/SocketConnector.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/SocketConnector.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/SocketConnector.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -52,20 +52,19 @@
 public class SocketConnector extends AbstractConnector
 {
    // Provide Logging
-   private Logger log = LoggerFactory.getLogger(HuskyExtender.class);
+   private Logger log = LoggerFactory.getLogger(SocketConnector.class);
    
    /** The Husky socket connector host poperty: 'org.jboss.osgi.husky.runtime.connector.host' */
    public static final String PROP_SOCKET_CONNECTOR_HOST = Connector.class.getName().toLowerCase() + ".host";
    /** The Husky socket connector port poperty: 'org.jboss.osgi.husky.runtime.connector.port' */
    public static final String PROP_SOCKET_CONNECTOR_PORT = Connector.class.getName().toLowerCase() + ".port";
    
-   private BundleContext context;
    private ServiceRegistration sreg;
    private ListenerThread listenerThread;
 
    public SocketConnector(BundleContext context)
    {
-      this.context = context;
+      super(context);
    }
 
    public static boolean isRemoteConnection(BundleContext context)
@@ -85,8 +84,12 @@
       return host;
    }
 
+   @Override
    public void start() throws Exception
    {
+      super.start();
+      
+      BundleContext context = getBundleContext();
       String host = getHost(context);
       String port = getPort(context);
 
@@ -102,8 +105,11 @@
       log.info("SocketConnector registered: " + props);
    }
 
+   @Override
    public void stop() throws Exception
    {
+      super.stop();
+      
       if (sreg != null)
          sreg.unregister();
 
@@ -166,12 +172,22 @@
                {
                   InputStream resStream = process(socket.getInputStream());
                   Util.copyStream(resStream, socket.getOutputStream());
-                  socket.close();
                }
                catch (Exception ex)
                {
-                  log.warn("Cannot process request", ex);
+                  log.error("Cannot process request", ex);
                }
+               finally
+               {
+                  try
+                  {
+                     socket.close();
+                  }
+                  catch (IOException ex)
+                  {
+                     log.error("Cannot close socket", ex);
+                  }
+               }
             }
          }
       }

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/pom.xml	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/pom.xml	2009-10-30 11:09:19 UTC (rev 95822)
@@ -28,6 +28,11 @@
     <version>1.0.2-SNAPSHOT</version>
   </parent>
 
+  <!-- Properties -->
+  <properties>
+    <surefire.jpda.args></surefire.jpda.args>
+  </properties>
+  
   <!-- Dependencies -->
   <dependencies>
     <dependency>
@@ -100,6 +105,7 @@
       <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
+          <argLine>${surefire.jpda.args}</argLine>
           <systemProperties>
             <property>
               <name>java.protocol.handler.pkgs</name>
@@ -127,53 +133,21 @@
   <profiles>
 
     <!--
-      Name: framework-equinox
-      Descr: Setup for Equinox framework integration testing
+      Name: jpda
+      Descr: Enable JPDA remote debuging
     -->
     <profile>
-      <id>framework-equinox</id>
+      <id>jpda</id>
       <activation>
         <property>
-          <name>framework</name>
-          <value>equinox</value>
+          <name>jpda</name>
         </property>
       </activation>
-      <build>
-        <plugins>
-          <plugin>
-            <artifactId>maven-surefire-plugin</artifactId>
-            <configuration>
-              <skipTests>true</skipTests>
-            </configuration>
-          </plugin>
-        </plugins>
-      </build>
+      <properties>
+        <surefire.jpda.args>-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</surefire.jpda.args>
+      </properties>
     </profile>
 
-    <!--
-      Name: framework-knopflerfish
-      Descr: Setup for Knopflerfish framework integration testing
-    -->
-    <profile>
-      <id>framework-knopflerfish</id>
-      <activation>
-        <property>
-          <name>framework</name>
-          <value>knopflerfish</value>
-        </property>
-      </activation>
-      <build>
-        <plugins>
-          <plugin>
-            <artifactId>maven-surefire-plugin</artifactId>
-            <configuration>
-              <skipTests>true</skipTests>
-            </configuration>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
-
   </profiles>
 
 </project>

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/resources/jboss-osgi-framework.properties
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/resources/jboss-osgi-framework.properties	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/resources/jboss-osgi-framework.properties	2009-10-30 11:09:19 UTC (rev 95822)
@@ -17,6 +17,7 @@
 
 # Extra System Packages
 org.osgi.framework.system.packages.extra=\
+    org.jboss.osgi.deployment.interceptor;version=1.0, \
   	org.jboss.osgi.spi;version=1.0, \
   	org.jboss.osgi.spi.capability;version=1.0, \
   	org.jboss.osgi.spi.management;version=1.0, \

Modified: projects/jboss-osgi/projects/bundles/webapp/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/webapp/trunk/pom.xml	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/projects/bundles/webapp/trunk/pom.xml	2009-10-30 11:09:19 UTC (rev 95822)
@@ -39,7 +39,7 @@
   
   <!-- Properties -->
   <properties>
-    <version.jboss.osgi.deployment>0.0.1-SNAPSHOT</version.jboss.osgi.deployment>
+    <version.jboss.osgi.deployment>1.0.0-SNAPSHOT</version.jboss.osgi.deployment>
     <version.ops4j.pax.web>0.7.2-SNAPSHOT</version.ops4j.pax.web>
     <version.osgi>4.2.0</version.osgi>
   </properties>
@@ -84,7 +84,6 @@
       <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
-        <extensions>true</extensions>
         <configuration>
           <instructions>
             <Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
@@ -101,7 +100,7 @@
                javax.servlet.http, 
                javax.xml.parsers, 
                org.apache.commons.logging;version=1.1,
-               org.jboss.osgi.deployment.interceptor,
+               org.jboss.osgi.deployment.interceptor;version=1.0,
                org.jboss.osgi.spi.capability;version=1.0,
                org.jboss.virtual,
                org.ops4j.pax.web.service,

Modified: projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebAppActivator.java
===================================================================
--- projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebAppActivator.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebAppActivator.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -23,6 +23,7 @@
 
 //$Id$
 
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
 import org.jboss.osgi.webapp.WebAppService;
 import org.ops4j.pax.web.extender.war.internal.WebAppPublisherExt;
 import org.osgi.framework.BundleActivator;
@@ -36,9 +37,6 @@
  */
 public class WebAppActivator implements BundleActivator
 {
-   private WebXMLParserInterceptor webappParserInterceptor;
-   private WebAppPublisherInterceptor webappPublishInterceptor;
-   
    public void start(BundleContext context)
    {
       // Register the marker service
@@ -46,27 +44,16 @@
       context.registerService(WebAppService.class.getName(), service, null);
 
       // Register the web.xml parser interceptor
-      webappParserInterceptor = new WebXMLParserInterceptor();
-      webappParserInterceptor.start(context);
+      LifecycleInterceptor webappParser = new WebXMLParserInterceptor();
+      context.registerService(LifecycleInterceptor.class.getName(), webappParser, null);
 
       // Register the WebApp publisher interceptor
       WebAppPublisherExt publisher = new WebAppPublisherExt();
-      webappPublishInterceptor = new WebAppPublisherInterceptor(publisher);
-      webappPublishInterceptor.start(context);
+      LifecycleInterceptor webappPublisher = new WebAppPublisherInterceptor(publisher);
+      context.registerService(LifecycleInterceptor.class.getName(), webappPublisher, null);
    }
 
    public void stop(BundleContext context)
    {
-      if (webappParserInterceptor != null)
-      {
-         webappParserInterceptor.stop();
-         webappParserInterceptor = null;
-      }
-      
-      if (webappPublishInterceptor != null)
-      {
-         webappPublishInterceptor.stop();
-         webappPublishInterceptor = null;
-      }
    }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebAppPublisherInterceptor.java
===================================================================
--- projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebAppPublisherInterceptor.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebAppPublisherInterceptor.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -27,13 +27,9 @@
 import org.jboss.osgi.deployment.interceptor.InvocationContext;
 import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
 import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorException;
-import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
 import org.ops4j.pax.web.extender.war.internal.WebAppPublisherExt;
 import org.ops4j.pax.web.extender.war.internal.model.WebApp;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -48,7 +44,6 @@
    // Provide logging
    private Logger log = LoggerFactory.getLogger(WebAppPublisherInterceptor.class);
    
-   private ServiceTracker serviceTracker;
    private WebAppPublisherExt publisher;
 
    public WebAppPublisherInterceptor(WebAppPublisherExt publisher)
@@ -59,38 +54,6 @@
       addInput(WebApp.class);
    }
 
-   public void start(BundleContext context)
-   {
-      final LifecycleInterceptor interceptor = this;
-      serviceTracker = new ServiceTracker(context, LifecycleInterceptorService.class.getName(), null)
-      {
-         @Override
-         public Object addingService(ServiceReference reference)
-         {
-            LifecycleInterceptorService service = (LifecycleInterceptorService)super.addingService(reference);
-            service.addInterceptor(interceptor);
-            return service;
-         }
-
-         @Override
-         public void removedService(ServiceReference reference, Object service)
-         {
-            ((LifecycleInterceptorService)service).removeInterceptor(interceptor);
-            super.removedService(reference, service);
-         }
-      };
-      serviceTracker.open();
-   }
-
-   public void stop()
-   {
-      if (serviceTracker != null)
-      {
-         serviceTracker.close();
-         serviceTracker = null;
-      }
-   }
-
    public void invoke(int state, InvocationContext context) throws LifecycleInterceptorException
    {
       if (state == Bundle.STARTING)

Modified: projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebXMLParserInterceptor.java
===================================================================
--- projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebXMLParserInterceptor.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebXMLParserInterceptor.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -29,14 +29,10 @@
 import org.jboss.osgi.deployment.interceptor.InvocationContext;
 import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
 import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorException;
-import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
 import org.jboss.virtual.VirtualFile;
 import org.ops4j.pax.web.extender.war.internal.model.WebApp;
 import org.ops4j.pax.web.extender.war.internal.parser.dom.DOMWebXmlParser;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -51,46 +47,12 @@
    // Provide logging
    private Logger log = LoggerFactory.getLogger(WebXMLParserInterceptor.class);
    
-   private ServiceTracker serviceTracker;
-
    public WebXMLParserInterceptor()
    {
       // Advertise output
       addOutput(WebApp.class);
    }
 
-   public void start(BundleContext context)
-   {
-      final LifecycleInterceptor interceptor = this;
-      serviceTracker = new ServiceTracker(context, LifecycleInterceptorService.class.getName(), null)
-      {
-         @Override
-         public Object addingService(ServiceReference reference)
-         {
-            LifecycleInterceptorService service = (LifecycleInterceptorService)super.addingService(reference);
-            service.addInterceptor(interceptor);
-            return service;
-         }
-
-         @Override
-         public void removedService(ServiceReference reference, Object service)
-         {
-            ((LifecycleInterceptorService)service).removeInterceptor(interceptor);
-            super.removedService(reference, service);
-         }
-      };
-      serviceTracker.open();
-   }
-
-   public void stop()
-   {
-      if (serviceTracker != null)
-      {
-         serviceTracker.close();
-         serviceTracker = null;
-      }
-   }
-
    public void invoke(int state, InvocationContext context) throws LifecycleInterceptorException
    {
       WebApp webApp = context.getAttachment(WebApp.class);

Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-equinox.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-equinox.xml	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-equinox.xml	2009-10-30 11:09:19 UTC (rev 95822)
@@ -36,7 +36,6 @@
             org.jboss.osgi.spi.management;version=1.0,
             org.jboss.osgi.spi.service;version=1.0,
             org.jboss.osgi.spi.util;version=1.0, 
-            org.jboss.osgi.testing,
 
             <!-- jboss -->
             org.jboss.logging

Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-felix.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-felix.xml	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-felix.xml	2009-10-30 11:09:19 UTC (rev 95822)
@@ -35,7 +35,7 @@
             
             <!-- jboss-osgi -->
             org.jboss.osgi.deployment.deployer,
-            org.jboss.osgi.deployment.interceptor,
+            org.jboss.osgi.deployment.internal,
             org.jboss.osgi.jbossxb;version=2.0,
             org.jboss.osgi.microcontainer;version=1.0,
             org.jboss.osgi.spi;version=1.0,
@@ -43,7 +43,6 @@
             org.jboss.osgi.spi.management;version=1.0,
             org.jboss.osgi.spi.service;version=1.0,
             org.jboss.osgi.spi.util;version=1.0, 
-            org.jboss.osgi.testing,
             
             <!-- jboss -->
             org.jboss.beans.metadata.plugins;version=2.0,

Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml	2009-10-30 11:09:19 UTC (rev 95822)
@@ -49,8 +49,6 @@
           org.jboss.osgi.spi.management;version=1.0,
           org.jboss.osgi.spi.service;version=1.0,
           org.jboss.osgi.spi.util;version=1.0,
-          org.jboss.osgi.testing
-          
         </value></entry>
         <!-- Husky socket connector properties -->
         <entry><key>org.jboss.osgi.husky.runtime.connector.host</key><value>${jboss.bind.address}</value></entry>

Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/conf/jboss-osgi-equinox.properties
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/conf/jboss-osgi-equinox.properties	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/conf/jboss-osgi-equinox.properties	2009-10-30 11:09:19 UTC (rev 95822)
@@ -69,7 +69,6 @@
    org.jboss.osgi.spi.management;version=1.0, \
    org.jboss.osgi.spi.service;version=1.0, \
    org.jboss.osgi.spi.util;version=1.0, \
-   org.jboss.osgi.testing, \
    org.jboss.virtual, \
    org.jboss.virtual.plugins.registry, \
    org.jboss.virtual.plugins.context.jar, \

Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml	2009-10-30 11:09:19 UTC (rev 95822)
@@ -42,7 +42,6 @@
           org.jboss.osgi.spi.management;version=1.0,
           org.jboss.osgi.spi.service;version=1.0,
           org.jboss.osgi.spi.util;version=1.0,
-          org.jboss.osgi.testing,
         </value></entry>
         <!-- Hot Deployment -->
         <entry><key>org.jboss.osgi.hotdeploy.scandir</key><value>${osgi.server.home}/deploy</value></entry>

Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-all.properties
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-all.properties	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-all.properties	2009-10-30 11:09:19 UTC (rev 95822)
@@ -41,7 +41,6 @@
    org.jboss.osgi.spi.management;version=1.0, \
    org.jboss.osgi.spi.service;version=1.0, \
    org.jboss.osgi.spi.util;version=1.0, \
-   org.jboss.osgi.testing, \
    org.jboss.virtual, \
    org.jboss.virtual.plugins.registry, \
    org.jboss.virtual.plugins.context.jar, \

Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-default.properties
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-default.properties	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-default.properties	2009-10-30 11:09:19 UTC (rev 95822)
@@ -32,7 +32,6 @@
    org.jboss.osgi.spi.management;version=1.0, \
    org.jboss.osgi.spi.service;version=1.0, \
    org.jboss.osgi.spi.util;version=1.0, \
-   org.jboss.osgi.testing, \
    org.jboss.virtual, \
    org.jboss.virtual.plugins.registry, \
    org.jboss.virtual.plugins.context.jar, \

Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-minimal.properties
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-minimal.properties	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-minimal.properties	2009-10-30 11:09:19 UTC (rev 95822)
@@ -17,6 +17,5 @@
    org.jboss.osgi.spi.framework;version=1.0, \
    org.jboss.osgi.spi.management;version=1.0, \
    org.jboss.osgi.spi.service;version=1.0, \
-   org.jboss.osgi.spi.util;version=1.0, \
-   org.jboss.osgi.testing
+   org.jboss.osgi.spi.util;version=1.0
  
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-web.properties
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-web.properties	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-web.properties	2009-10-30 11:09:19 UTC (rev 95822)
@@ -38,7 +38,6 @@
    org.jboss.osgi.spi.management;version=1.0, \
    org.jboss.osgi.spi.service;version=1.0, \
    org.jboss.osgi.spi.util;version=1.0, \
-   org.jboss.osgi.testing, \
    org.jboss.virtual, \
    org.jboss.virtual.plugins.registry, \
    org.jboss.virtual.plugins.context.jar, \

Modified: projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintInterceptor.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintInterceptor.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintInterceptor.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -28,11 +28,8 @@
 import org.jboss.osgi.deployment.interceptor.InvocationContext;
 import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
 import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorException;
-import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -48,7 +45,6 @@
    private Logger log = LoggerFactory.getLogger(BlueprintInterceptor.class);
    
    private BlueprintProcessor processor;
-   private ServiceTracker serviceTracker;
    
    public BlueprintInterceptor(BlueprintProcessor processor)
    {
@@ -59,36 +55,12 @@
    {
       BlueprintContext bpContext = processor.getBlueprintContext();
       BundleContext context = bpContext.getBundleContext();
-      
-      final LifecycleInterceptor interceptor = this;
-      serviceTracker = new ServiceTracker(context, LifecycleInterceptorService.class.getName(), null)
-      {
-         @Override
-         public Object addingService(ServiceReference reference)
-         {
-            LifecycleInterceptorService service = (LifecycleInterceptorService)super.addingService(reference);
-            service.addInterceptor(interceptor);
-            return service;
-         }
-
-         @Override
-         public void removedService(ServiceReference reference, Object service)
-         {
-            ((LifecycleInterceptorService)service).removeInterceptor(interceptor);
-            super.removedService(reference, service);
-         }
-      };
-      serviceTracker.open();
+      context.registerService(LifecycleInterceptor.class.getName(), this, null);
    }
    
    public void stop()
    {
       processor.stopAllContainers();
-      if (serviceTracker != null)
-      {
-         serviceTracker.close();
-         serviceTracker = null;
-      }
    }
 
    public void invoke(int state, InvocationContext context) throws LifecycleInterceptorException

Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptorService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptorService.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptorService.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -34,6 +34,8 @@
 import org.jboss.osgi.spi.util.ConstantsHelper;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -59,6 +61,27 @@
       if (context == null)
          throw new IllegalStateException("Null context");
       this.context = context;
+      
+      // Track the LifecycleInterceptor services
+      ServiceTracker tracker = new ServiceTracker(context, LifecycleInterceptor.class.getName(), null)
+      {
+         @Override
+         public Object addingService(ServiceReference reference)
+         {
+            LifecycleInterceptor interceptor = (LifecycleInterceptor)super.addingService(reference);
+            addInterceptor(interceptor);
+            return interceptor;
+         }
+
+         @Override
+         public void removedService(ServiceReference reference, Object service)
+         {
+            super.removedService(reference, service);
+            LifecycleInterceptor interceptor = (LifecycleInterceptor)service;
+            removeInterceptor(interceptor);
+         }
+      };
+      tracker.open();
    }
    
    public BundleContext getSystemContext()
@@ -74,7 +97,7 @@
     * 
     * @param interceptor The interceptor
     */
-   public void addInterceptor(LifecycleInterceptor interceptor)
+   protected void addInterceptor(LifecycleInterceptor interceptor)
    {
       if (interceptor == null)
          throw new IllegalArgumentException("Null interceptor");
@@ -181,7 +204,7 @@
     * 
     * @param interceptor The interceptor
     */
-   public void removeInterceptor(LifecycleInterceptor interceptor)
+   protected void removeInterceptor(LifecycleInterceptor interceptor)
    {
       if (interceptor == null)
          throw new IllegalArgumentException("Null interceptor");

Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorService.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorService.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -23,30 +23,25 @@
 
 //$Id$
 
+import org.osgi.framework.Bundle;
 
 /**
- * A service that manages bundle lifecycle interceptors.
+ * A service that invokes lifecycle interceptors.
  * 
+ * This service tracks {@link LifecycleInterceptor} services and orders them 
+ * to an interceptor chain according to their input/output requirements and relative order.
+ * 
  * @author thomas.diesler at jboss.com
  * @since 15-Oct-2009
  */
 public interface LifecycleInterceptorService
 {
    /**
-    * Add a LifecycleInterceptor to the service.
-    * 
-    * The interceptor is added according to its input requirements 
-    * and relative order. 
-    * 
-    * @param interceptor The interceptor
+    * Invoke the registered set of interceptors for the given bundle state change.
+    *  
+    * @param state The future state of the bundle
+    * @param bundle The bundle that changes state
+    * @throws LifecycleInterceptorException if the invocation of an interceptor fails 
     */
-   void addInterceptor(LifecycleInterceptor interceptor);
-
-   /**
-    * Remove an LifecycleInterceptor to the service.
-    * 
-    * @param interceptor The interceptor
-    */
-   void removeInterceptor(LifecycleInterceptor interceptor);
-
+   void handleStateChange(int state, Bundle bundle);
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/LifecycleInterceptorServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/LifecycleInterceptorServiceImpl.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/LifecycleInterceptorServiceImpl.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -54,6 +54,18 @@
    }
 
    @Override
+   protected void addInterceptor(LifecycleInterceptor interceptor)
+   {
+      super.addInterceptor(interceptor);
+   }
+
+   @Override
+   protected void removeInterceptor(LifecycleInterceptor interceptor)
+   {
+      super.removeInterceptor(interceptor);
+   }
+
+   @Override
    protected InvocationContext getInvocationContext(Bundle bundle)
    {
       DeploymentRegistryService service = getDeploymentRegistryService();

Modified: projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/InterceptorOrderTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/InterceptorOrderTestCase.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/InterceptorOrderTestCase.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -29,12 +29,13 @@
 import java.util.List;
 
 import org.jboss.osgi.deployment.interceptor.AbstractLifecycleInterceptor;
+import org.jboss.osgi.deployment.interceptor.AbstractLifecycleInterceptorService;
 import org.jboss.osgi.deployment.interceptor.InvocationContext;
 import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
 import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorException;
 import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
-import org.jboss.osgi.deployment.internal.LifecycleInterceptorServiceImpl;
 import org.junit.Test;
+import org.osgi.framework.Bundle;
 
 /**
  * Test the {@link LifecycleInterceptorService}
@@ -49,8 +50,8 @@
    @Test
    public void testRelativeOrder()
    {
-      LifecycleInterceptor rel0000 = new BasicLifecycleInterceptor();
-      LifecycleInterceptor rel2000 = new BasicLifecycleInterceptor()
+      LifecycleInterceptor rel0000 = new MockLifecycleInterceptor();
+      LifecycleInterceptor rel2000 = new MockLifecycleInterceptor()
       {
          public int getRelativeOrder()
          {
@@ -59,7 +60,7 @@
       };
 
       // Add ordered
-      LifecycleInterceptorServiceImpl service = new LifecycleInterceptorServiceImpl(new MockBundleContext());
+      MockLifecycleInterceptorService service = new MockLifecycleInterceptorService();
       service.addInterceptor(rel0000);
       service.addInterceptor(rel2000);
 
@@ -69,7 +70,7 @@
       assertEquals(RELATIVE_ORDER, chain.get(1).getRelativeOrder());
 
       // Add unordered
-      service = new LifecycleInterceptorServiceImpl(new MockBundleContext());
+      service = new MockLifecycleInterceptorService();
       service.addInterceptor(rel2000);
       service.addInterceptor(rel0000);
 
@@ -86,14 +87,14 @@
       {
       }
 
-      AbstractLifecycleInterceptor inA = new BasicLifecycleInterceptor();
+      AbstractLifecycleInterceptor inA = new MockLifecycleInterceptor();
       inA.addInput(A.class);
 
-      AbstractLifecycleInterceptor outA = new BasicLifecycleInterceptor();
+      AbstractLifecycleInterceptor outA = new MockLifecycleInterceptor();
       outA.addOutput(A.class);
 
       // Add ordered
-      LifecycleInterceptorServiceImpl service = new LifecycleInterceptorServiceImpl(new MockBundleContext());
+      MockLifecycleInterceptorService service = new MockLifecycleInterceptorService();
       service.addInterceptor(outA);
       service.addInterceptor(inA);
 
@@ -103,7 +104,7 @@
       assertEquals(inA, chain.get(1));
 
       // Add unordered
-      service = new LifecycleInterceptorServiceImpl(new MockBundleContext());
+      service = new MockLifecycleInterceptorService();
       service.addInterceptor(inA);
       service.addInterceptor(outA);
 
@@ -113,11 +114,44 @@
       assertEquals(inA, chain.get(1));
    }
    
-   class BasicLifecycleInterceptor extends AbstractLifecycleInterceptor
+   class MockLifecycleInterceptor extends AbstractLifecycleInterceptor
    {
       public void invoke(int state, InvocationContext context) throws LifecycleInterceptorException
       {
          // do nothing
       }
    }
+   
+   class MockLifecycleInterceptorService extends AbstractLifecycleInterceptorService
+   {
+      protected MockLifecycleInterceptorService()
+      {
+         super(new MockBundleContext());
+      }
+
+      @Override
+      public void addInterceptor(LifecycleInterceptor interceptor)
+      {
+         super.addInterceptor(interceptor);
+      }
+
+      @Override
+      public void removeInterceptor(LifecycleInterceptor interceptor)
+      {
+         super.removeInterceptor(interceptor);
+      }
+
+      @Override
+      public List<LifecycleInterceptor> getInterceptorChain()
+      {
+         return super.getInterceptorChain();
+      }
+
+      @Override
+      protected InvocationContext getInvocationContext(Bundle bundle)
+      {
+         // do nothing
+         return null;
+      }
+   }
 }

Modified: projects/jboss-osgi/trunk/reactor/framework/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/pom.xml	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/reactor/framework/pom.xml	2009-10-30 11:09:19 UTC (rev 95822)
@@ -343,6 +343,7 @@
         <configuration>
           <instructions>
             <Bundle-SymbolicName>org.jboss.osgi.framework</Bundle-SymbolicName>
+            <Bundle-Name>JBossOSGi Framework</Bundle-Name>
             <Bundle-Version>${version}</Bundle-Version>
             <Export-Package>
               org.osgi.framework;version="1.5",

Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -113,14 +113,12 @@
       }
       else
       {
-         delegate.addInterceptor(interceptor);
+         getSystemContext().registerService(LifecycleInterceptor.class.getName(), interceptor, null);
       }
    }
 
    public void removeInterceptor(LifecycleInterceptor interceptor)
    {
-      if (delegate != null)
-         delegate.removeInterceptor(interceptor);
    }
 
    public void handleStateChange(int state, Bundle bundle)

Modified: projects/jboss-osgi/trunk/reactor/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/pom.xml	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/reactor/pom.xml	2009-10-30 11:09:19 UTC (rev 95822)
@@ -44,9 +44,9 @@
 
   <modules>
     <module>deployment</module>
-    <module>blueprint</module>
     <module>jmx</module>
     <module>jta</module>
+    <module>blueprint</module>
   </modules>
 
   <profiles>

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/interceptor/processor/InterceptorActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/interceptor/processor/InterceptorActivator.java	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/interceptor/processor/InterceptorActivator.java	2009-10-30 11:09:19 UTC (rev 95822)
@@ -23,10 +23,10 @@
 
 //$Id$
 
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
 import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
 
 /**
  * Registers the interceptors with the {@link LifecycleInterceptorService}
@@ -36,29 +36,17 @@
  */
 public class InterceptorActivator implements BundleActivator
 {
-   private LifecycleInterceptorService service;
-   private PublisherInterceptor publisher;
-   private ParserInterceptor parser;
-   
    public void start(BundleContext context)
    {
-      publisher = new PublisherInterceptor();
-      parser = new ParserInterceptor();
+      LifecycleInterceptor publisher = new PublisherInterceptor();
+      LifecycleInterceptor parser = new ParserInterceptor();
       
-      // This is a system service, which should always be available
-      ServiceReference sref = context.getServiceReference(LifecycleInterceptorService.class.getName());
-      if (sref == null)
-         throw new IllegalStateException("Required LifecycleInterceptorService not available");
-      
       // Add the interceptors, the order of which is handles by the service
-      service = (LifecycleInterceptorService)context.getService(sref);
-      service.addInterceptor(publisher);
-      service.addInterceptor(parser);
+      context.registerService(LifecycleInterceptor.class.getName(), publisher, null);
+      context.registerService(LifecycleInterceptor.class.getName(), parser, null);
    }
 
    public void stop(BundleContext context)
    {
-      service.removeInterceptor(publisher);
-      service.removeInterceptor(parser);
    }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml	2009-10-30 11:09:19 UTC (rev 95822)
@@ -42,7 +42,6 @@
           org.jboss.osgi.spi.management;version=1.0,
           org.jboss.osgi.spi.service;version=1.0,
           org.jboss.osgi.spi.util;version=1.0,
-          org.jboss.osgi.testing,
         </value></entry>
       </map>
     </property>

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-equinox.properties
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-equinox.properties	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-equinox.properties	2009-10-30 11:09:19 UTC (rev 95822)
@@ -25,7 +25,6 @@
   	org.jboss.osgi.spi.management;version=1.0, \
   	org.jboss.osgi.spi.service;version=1.0, \
   	org.jboss.osgi.spi.util;version=1.0, \
-  	org.jboss.osgi.testing, \
   	org.jboss.virtual, \
   	org.jboss.virtual.plugins.registry, \
   	org.jboss.virtual.plugins.context.jar, \

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties	2009-10-30 11:09:19 UTC (rev 95822)
@@ -29,7 +29,6 @@
   	org.jboss.osgi.spi.management;version=1.0, \
   	org.jboss.osgi.spi.service;version=1.0, \
   	org.jboss.osgi.spi.util;version=1.0, \
-  	org.jboss.osgi.testing, \
   	org.jboss.virtual, \
   	org.jboss.virtual.plugins.registry, \
   	org.jboss.virtual.plugins.context.jar, \

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/mcservice/example-mcservice-bundleA.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/mcservice/example-mcservice-bundleA.bnd	2009-10-30 07:00:49 UTC (rev 95821)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/mcservice/example-mcservice-bundleA.bnd	2009-10-30 11:09:19 UTC (rev 95822)
@@ -3,6 +3,6 @@
 Bundle-SymbolicName: example-mcservice-bundleA
 Bundle-Activator: org.jboss.test.osgi.example.microcontainer.bundleA.SomeServiceActivator
 Export-Package: org.jboss.test.osgi.example.microcontainer.bundleA
-Import-Package: org.jboss.osgi.spi.management, org.jboss.osgi.spi.service, org.jboss.osgi.testing, org.osgi.framework, javax.management
+Import-Package: javax.management, org.jboss.osgi.spi.management, org.jboss.osgi.spi.service, org.osgi.framework
 Include-Resource: META-INF/mcservice-jboss-beans.xml=META-INF/mcservice-jboss-beans.xml
 -removeheaders: Include-Resource



More information about the jboss-osgi-commits mailing list