[jboss-cvs] JBossAS SVN: r84735 - in projects/jboss-osgi/trunk: hudson and 10 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 25 10:06:53 EST 2009


Author: thomas.diesler at jboss.com
Date: 2009-02-25 10:06:53 -0500 (Wed, 25 Feb 2009)
New Revision: 84735

Added:
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/AbstractAttributeProvider.java
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/AttributeProvider.java
   projects/jboss-osgi/trunk/service/http/src/main/java/org/jboss/osgi/service/http/ServletContextAttributeProvider.java
Removed:
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/internal/KernelLocator.java
Modified:
   projects/jboss-osgi/trunk/hudson/
   projects/jboss-osgi/trunk/pom.xml
   projects/jboss-osgi/trunk/runtime/deployer/
   projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/OSGiDeployer.java
   projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/OSGiMetaData.java
   projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/OSGiMetaDataDeployer.java
   projects/jboss-osgi/trunk/runtime/deployer/src/main/resources/osgi-deployers-jboss-beans.xml
   projects/jboss-osgi/trunk/runtime/felix/
   projects/jboss-osgi/trunk/runtime/felix/src/main/resources/osgi-jboss-beans.xml
   projects/jboss-osgi/trunk/runtime/spi/
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiConfiguration.java
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiConfigurationProvider.java
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/internal/MicrocontainerConfigurationProvider.java
   projects/jboss-osgi/trunk/service/http/src/main/java/org/jboss/osgi/service/http/GenericEndpointServlet.java
   projects/jboss-osgi/trunk/testsuite/
   projects/jboss-osgi/trunk/testsuite/pom.xml
Log:
Remove KernelLocator hack


Property changes on: projects/jboss-osgi/trunk/hudson
___________________________________________________________________
Name: svn:ignore
   + target
ant.properties


Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml	2009-02-25 14:29:00 UTC (rev 84734)
+++ projects/jboss-osgi/trunk/pom.xml	2009-02-25 15:06:53 UTC (rev 84735)
@@ -196,7 +196,6 @@
   <build>
     <plugins>
       <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <configuration>
           <source>1.5</source>
@@ -207,9 +206,7 @@
         </configuration>
       </plugin>
       <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-release-plugin</artifactId>
-        <version>2.0-beta-7</version>
         <configuration>
           <tagBase>https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/tags</tagBase>
           <autoVersionSubmodules>true</autoVersionSubmodules>
@@ -226,19 +223,9 @@
           </configuration>
         </plugin>
         <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-jar-plugin</artifactId>
-          <version>2.2</version>
-        </plugin>
-        <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-surefire-plugin</artifactId>
-          <version>2.4.1</version>
           <configuration>
             <redirectTestOutputToFile>true</redirectTestOutputToFile>
-            <includes>
-              <include>org/jboss/test/**/*TestCase.java</include>
-            </includes>
           </configuration>
         </plugin>
       </plugins>


Property changes on: projects/jboss-osgi/trunk/runtime/deployer
___________________________________________________________________
Name: svn:ignore
   + target


Modified: projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/OSGiDeployer.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/OSGiDeployer.java	2009-02-25 14:29:00 UTC (rev 84734)
+++ projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/OSGiDeployer.java	2009-02-25 15:06:53 UTC (rev 84735)
@@ -27,83 +27,84 @@
 import java.util.List;
 
 import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.logging.Logger;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 
 /**
  * This is the OSGi Deployer
- * 
+ *
  * @author Thomas.Diesler at jboss.org
+ * @author Ales.Justin at jboss.org
  * @since 03-Feb-2009
  */
-public class OSGiDeployer extends AbstractRealDeployer
+public class OSGiDeployer extends AbstractSimpleRealDeployer<OSGiMetaData>
 {
-  // provide logging
-  private static final Logger log = Logger.getLogger(OSGiDeployer.class);
+   private BundleContext bundleContext;
+   private List<URI> skipBundles;
 
-  private BundleContext bundleContext;
-  private List<URI> skipBundles;
+   public OSGiDeployer()
+   {
+      super(OSGiMetaData.class);
+   }
 
-  public OSGiDeployer()
-  {
-    setInput(OSGiMetaData.class);
-  }
+   public void setBundleContext(BundleContext bundleContext)
+   {
+      this.bundleContext = bundleContext;
+   }
 
-  public void setBundleContext(BundleContext bundleContext)
-  {
-    this.bundleContext = bundleContext;
-  }
+   public void setSkipBundles(List<URI> skipBundles)
+   {
+      this.skipBundles = skipBundles;
+   }
 
-  public void setSkipBundles(List<URI> skipBundles)
-  {
-    this.skipBundles = skipBundles;
-  }
+   public void start()
+   {
+      if (bundleContext == null)
+         throw new IllegalArgumentException("No system bundle context.");
+   }
 
-  @Override
-  protected void internalDeploy(DeploymentUnit unit) throws DeploymentException
-  {
-    OSGiMetaData metadata = unit.getAttachment(OSGiMetaData.class);
-    log.info("Install Bundle: " + metadata.getSymbolicName());
-    
-    URI bundleUri = metadata.getBundleLocation();
-    if (bundleUri == null)
-      throw new IllegalStateException("Cannot obtain bundle location for: " + metadata);
-    
-    try
-    {
-      if (skipBundles.contains(bundleUri) == false)
-      {
-        Bundle bundle = bundleContext.installBundle(bundleUri.toString());
-        bundle.start();
-        
-        unit.addAttachment(Bundle.class, bundle);
-      }
-    }
-    catch (BundleException ex)
-    {
-      throw new DeploymentException("Cannot install bundle: " + metadata, ex);
-    }
-  }
+   public void deploy(DeploymentUnit unit, OSGiMetaData metadata) throws DeploymentException
+   {
+      log.info("Install Bundle: " + metadata.getSymbolicName());
 
-  @Override
-  protected void internalUndeploy(DeploymentUnit unit)
-  {
-    Bundle bundle = unit.getAttachment(Bundle.class);
-    if (bundle != null)
-    {
-      log.info("Uninstall Bundle: " + bundle.getSymbolicName());
+      URI bundleUri = metadata.getBundleLocation();
+      if (bundleUri == null)
+         throw new IllegalStateException("Cannot obtain bundle location for: " + metadata);
+
       try
       {
-        bundle.uninstall();
+         if (skipBundles != null && skipBundles.contains(bundleUri) == false)
+         {
+            Bundle bundle = bundleContext.installBundle(bundleUri.toString());
+            bundle.start();
+
+            unit.addAttachment(Bundle.class, bundle);
+         }
       }
       catch (BundleException ex)
       {
-        log.error(ex);
+         throw new DeploymentException("Cannot install bundle: " + metadata, ex);
       }
-    }
-  }
+   }
+
+   @Override
+   public void undeploy(DeploymentUnit unit, OSGiMetaData osGiMetaData)
+   {
+      Bundle bundle = unit.getAttachment(Bundle.class);
+      if (bundle != null)
+      {
+         log.info("Uninstall Bundle: " + bundle.getSymbolicName());
+         try
+         {
+            bundle.uninstall();
+         }
+         catch (BundleException ex)
+         {
+            log.error(ex);
+         }
+      }
+   }
 }

Modified: projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/OSGiMetaData.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/OSGiMetaData.java	2009-02-25 14:29:00 UTC (rev 84734)
+++ projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/OSGiMetaData.java	2009-02-25 15:06:53 UTC (rev 84735)
@@ -39,8 +39,13 @@
   private String symbolicName;
   private URI bundleLocation;
 
-  public OSGiMetaData(String symbolicName)
+   // exteralizable usage
+  public OSGiMetaData()
   {
+  }
+
+   public OSGiMetaData(String symbolicName)
+  {
     this.symbolicName = symbolicName;
   }
 

Modified: projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/OSGiMetaDataDeployer.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/OSGiMetaDataDeployer.java	2009-02-25 14:29:00 UTC (rev 84734)
+++ projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/OSGiMetaDataDeployer.java	2009-02-25 15:06:53 UTC (rev 84735)
@@ -27,10 +27,9 @@
 import java.util.jar.Manifest;
 
 import org.jboss.deployers.vfs.spi.deployer.ManifestDeployer;
-import org.jboss.deployers.vfs.spi.deployer.ManifestMetaData;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.logging.Logger;
 import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.Constants;
 
 /**
  * This is the OSGi Deployer
@@ -38,11 +37,8 @@
  * @author Thomas.Diesler at jboss.org
  * @since 03-Feb-2009
  */
-public class OSGiMetaDataDeployer<T extends ManifestMetaData> extends ManifestDeployer<OSGiMetaData>
+public class OSGiMetaDataDeployer extends ManifestDeployer<OSGiMetaData>
 {
-  // provide logging
-  private static final Logger log = Logger.getLogger(OSGiMetaDataDeployer.class);
-
   public OSGiMetaDataDeployer()
   {
     super(OSGiMetaData.class);
@@ -63,13 +59,11 @@
   @Override
   protected OSGiMetaData createMetaData(Manifest manifest) throws Exception
   {
-    OSGiMetaData metaData = null;
-
     Attributes attribs = manifest.getMainAttributes();
-    String symbolicName = attribs.getValue("Bundle-SymbolicName");
+    String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
     if (symbolicName != null)
-      metaData = new OSGiMetaData(symbolicName);
+      return new OSGiMetaData(symbolicName);
 
-    return metaData;
+    return null;
   }
 }

Modified: projects/jboss-osgi/trunk/runtime/deployer/src/main/resources/osgi-deployers-jboss-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/resources/osgi-deployers-jboss-beans.xml	2009-02-25 14:29:00 UTC (rev 84734)
+++ projects/jboss-osgi/trunk/runtime/deployer/src/main/resources/osgi-deployers-jboss-beans.xml	2009-02-25 15:06:53 UTC (rev 84735)
@@ -2,11 +2,6 @@
 
 <deployment xmlns="urn:jboss:bean-deployer:2.0">
 
-  <!-- Locate the single instance of the kernel -->
-  <bean name="jboss.osgi:service=KernelLocator" class="org.jboss.osgi.spi.internal.KernelLocator">
-    <property name="kernel"><inject bean="jboss.kernel:service=Kernel" /></property>
-  </bean>
-
   <!-- The OSGiFramework -->
   <bean name="jboss.osgi:service=Framework" class="org.jboss.osgi.felix.framework.FelixIntegration">
     <property name="felixProperties">


Property changes on: projects/jboss-osgi/trunk/runtime/felix
___________________________________________________________________
Name: svn:mergeinfo
   - 

Modified: projects/jboss-osgi/trunk/runtime/felix/src/main/resources/osgi-jboss-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/runtime/felix/src/main/resources/osgi-jboss-beans.xml	2009-02-25 14:29:00 UTC (rev 84734)
+++ projects/jboss-osgi/trunk/runtime/felix/src/main/resources/osgi-jboss-beans.xml	2009-02-25 15:06:53 UTC (rev 84735)
@@ -3,11 +3,6 @@
 -->
 <deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd" xmlns="urn:jboss:bean-deployer:2.0">
 
-  <!-- Locate the single instance of the kernel -->
-  <bean name="jboss.osgi:service=KernelLocator" class="org.jboss.osgi.spi.internal.KernelLocator">
-    <property name="kernel"><inject bean="jboss.kernel:service=Kernel" /></property>
-  </bean>
-  
   <!-- The OSGiFramework -->
   <bean name="jboss.osgi:service=Framework" class="org.jboss.osgi.felix.framework.FelixIntegration">
     <property name="felixProperties">


Property changes on: projects/jboss-osgi/trunk/runtime/spi
___________________________________________________________________
Name: svn:mergeinfo
   - 

Copied: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/AbstractAttributeProvider.java (from rev 84728, projects/jboss-felix/trunk/modules/spi/src/main/java/org/jboss/osgi/spi/framework/AbstractAttributeProvider.java)
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/AbstractAttributeProvider.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/AbstractAttributeProvider.java	2009-02-25 15:06:53 UTC (rev 84735)
@@ -0,0 +1,49 @@
+/*
+ * 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.spi.framework;
+
+/**
+ * Provide proper attributes/parameters for configuration.
+ *
+ * @author ales.justin at jboss.com
+ */
+public abstract class AbstractAttributeProvider implements AttributeProvider
+{
+   public <T> T getAttribute(String name, Class<T> expectedType)
+   {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+
+      if (expectedType == null)
+         throw new IllegalArgumentException("Null expected type.");
+
+      Object attribute = getAttribute(name);
+      if (attribute != null)
+      {
+         if (expectedType.isInstance(attribute) == false)
+            throw new IllegalArgumentException("Attribute not of expected type [" + expectedType + "]: " + attribute);
+
+         return expectedType.cast(attribute);
+      }
+      return null;
+   }
+}
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/AttributeProvider.java (from rev 84728, projects/jboss-felix/trunk/modules/spi/src/main/java/org/jboss/osgi/spi/framework/AttributeProvider.java)
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/AttributeProvider.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/AttributeProvider.java	2009-02-25 15:06:53 UTC (rev 84735)
@@ -0,0 +1,48 @@
+/*
+ * 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.spi.framework;
+
+/**
+ * Provide proper attributes/parameters for configuration.
+ *
+ * @author ales.justin at jboss.com
+ */
+public interface AttributeProvider
+{
+   /**
+    * Get the attribute.
+    *
+    * @param name the attribute name
+    * @return attribute
+    */
+   Object getAttribute(String name);
+
+   /**
+    * Get the attribute.
+    *
+    * @param <T> exact attribute type
+    * @param name the attribute name
+    * @param expectedType the expected type
+    * @return attribute
+    */
+   <T> T getAttribute(String name, Class<T> expectedType);
+}
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiConfiguration.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiConfiguration.java	2009-02-25 14:29:00 UTC (rev 84734)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiConfiguration.java	2009-02-25 15:06:53 UTC (rev 84735)
@@ -53,6 +53,7 @@
 
   /*
    * Get the OSGi Framework for this configuration
+   *
    * @return The configured instance of a Framework
    */
   public static OSGiFramework getFramework()
@@ -61,12 +62,26 @@
   }
 
   /*
+   * Get the OSGi Framework for this configuration
+   *
+   * @param attributeProvider the attribute provider
+   * @return The configured instance of a Framework
+   */
+  public static OSGiFramework getFramework(AttributeProvider attributeProvider)
+  {
+    return getConfigurationProvider().getFramework(attributeProvider);
+  }
+
+  /*
    * Get a Framework with a given name from this configuration
+   *
+   * @param attributeProvider the attribute provider
+   * @param frameworkName  the framework name
    * @return The configured instance of a Framework
    */
-  public static OSGiFramework getFramework(String frameworkName)
+  public static OSGiFramework getFramework(AttributeProvider attributeProvider, String frameworkName)
   {
-    return getConfigurationProvider().getFramework(frameworkName);
+    return getConfigurationProvider().getFramework(attributeProvider, frameworkName);
   }
 
   /*

Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiConfigurationProvider.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiConfigurationProvider.java	2009-02-25 14:29:00 UTC (rev 84734)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiConfigurationProvider.java	2009-02-25 15:06:53 UTC (rev 84735)
@@ -37,15 +37,29 @@
 {
   /**
    * Get a Framework from this ConfigurationProvider
+   * Note: the instance itself *must* be a AttributeProvider
+   *
    * @return The configured instance of a Framework
+   * @throws IllegalArgumentException if this is not AttributeProvider instance
    */
    OSGiFramework getFramework();
-  
+
   /**
+   * Get a Framework from this ConfigurationProvider
+   *
+   * @param attributeProvider the attribute provider
+   * @return The configured instance of a Framework
+   */
+   OSGiFramework getFramework(AttributeProvider attributeProvider);
+
+  /**
    * Get a Framework with a given name from this ConfigurationProvider
+   *
+   * @param attributeProvider the attribute provider
+   * @param name the framework name
    * @return The configured instance of a Framework
    */
-   OSGiFramework getFramework(String name);
+   OSGiFramework getFramework(AttributeProvider attributeProvider, String name);
   
   /**
    * Configure this provider from the given URL

Deleted: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/internal/KernelLocator.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/internal/KernelLocator.java	2009-02-25 14:29:00 UTC (rev 84734)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/internal/KernelLocator.java	2009-02-25 15:06:53 UTC (rev 84735)
@@ -1,47 +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.spi.internal;
-
-//$Id$
-
-import org.jboss.kernel.Kernel;
-
-/**
- * Locate the single instance of the kernel 
- * 
- * @author Thomas.Diesler at jboss.org
- * @since 12-May-2006
- */
-public class KernelLocator
-{
-   private static Kernel kernel;
-
-   public static Kernel getKernel()
-   {
-      return KernelLocator.kernel;
-   }
-
-   public void setKernel(Kernel kernel)
-   {
-      KernelLocator.kernel = kernel;
-   }
-}
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/internal/MicrocontainerConfigurationProvider.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/internal/MicrocontainerConfigurationProvider.java	2009-02-25 14:29:00 UTC (rev 84734)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/internal/MicrocontainerConfigurationProvider.java	2009-02-25 15:06:53 UTC (rev 84735)
@@ -26,11 +26,15 @@
 import java.io.InputStream;
 import java.net.URL;
 
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
 import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
 import org.jboss.osgi.spi.NotImplementedException;
 import org.jboss.osgi.spi.framework.OSGiConfigurationProvider;
 import org.jboss.osgi.spi.framework.OSGiFramework;
+import org.jboss.osgi.spi.framework.AttributeProvider;
+import org.jboss.osgi.spi.framework.AbstractAttributeProvider;
 
 /**
  * The ConfigurationProvider provides a Framework through a given configuration method
@@ -38,7 +42,7 @@
  * @author thomas.diesler at jboss.com
  * @since 18-Jun-2008
  */
-public class MicrocontainerConfigurationProvider implements OSGiConfigurationProvider
+public class MicrocontainerConfigurationProvider extends AbstractAttributeProvider implements OSGiConfigurationProvider, AttributeProvider
 {
   /* The Framework bean name - jboss.osgi:service=Framework */
   public static final String DEFAULT_BEAN_NAME = "jboss.osgi:service=Framework";
@@ -46,25 +50,28 @@
   public static final String DEFAULT_BEANS_CONFIG = "osgi-jboss-beans.xml";
 
   private Kernel kernel;
-  
+
   public OSGiFramework getFramework()
   {
-    return getFramework(DEFAULT_BEAN_NAME);
+     return getFramework(this);
   }
 
+  public OSGiFramework getFramework(AttributeProvider attributeProvider)
+  {
+    return getFramework(attributeProvider, DEFAULT_BEAN_NAME);
+  }
+
   @SuppressWarnings("deprecation")
-  public OSGiFramework getFramework(String beanName)
+  public OSGiFramework getFramework(AttributeProvider attributeProvider, String beanName)
   {
+    kernel = attributeProvider.getAttribute(KernelConstants.KERNEL_NAME, Kernel.class);
+
     if (kernel == null)
-      kernel = KernelLocator.getKernel();
-    
-    if (kernel == null)
       configure(DEFAULT_BEANS_CONFIG);
-    
-    KernelRegistryEntry entry = kernel.getRegistry().getEntry(beanName);
-    OSGiFramework framework = (OSGiFramework)entry.getTarget();
-    
-    return framework;
+
+    Controller controller = kernel.getController();
+    ControllerContext context = controller.getInstalledContext(beanName); 
+    return (OSGiFramework)context.getTarget();
   }
 
   public void configure(InputStream streamConfig)
@@ -95,4 +102,17 @@
     if (kernel == null)
       throw new IllegalStateException("Cannot obtain kernel, after beans deployment");
   }
+
+   public Object getAttribute(String name)
+   {
+      if (kernel == null)
+         return null;
+
+      if (KernelConstants.KERNEL_NAME.equals(name))
+         return kernel;
+
+      Controller controller = kernel.getController();
+      ControllerContext context = controller.getInstalledContext(name); 
+      return context.getTarget();
+   }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/service/http/src/main/java/org/jboss/osgi/service/http/GenericEndpointServlet.java
===================================================================
--- projects/jboss-osgi/trunk/service/http/src/main/java/org/jboss/osgi/service/http/GenericEndpointServlet.java	2009-02-25 14:29:00 UTC (rev 84734)
+++ projects/jboss-osgi/trunk/service/http/src/main/java/org/jboss/osgi/service/http/GenericEndpointServlet.java	2009-02-25 15:06:53 UTC (rev 84735)
@@ -65,7 +65,7 @@
     super.init(config);
 
     // Get the MBeanServer
-    OSGiFramework framework = OSGiConfiguration.getFramework();
+    OSGiFramework framework = OSGiConfiguration.getFramework(new ServletContextAttributeProvider(config.getServletContext()));
     BundleContext context = framework.getSystemBundleContext();
     ServiceReference sref = context.getServiceReference(MicrocontainerService.class.getName());
     MicrocontainerService service = (MicrocontainerService)context.getService(sref);

Copied: projects/jboss-osgi/trunk/service/http/src/main/java/org/jboss/osgi/service/http/ServletContextAttributeProvider.java (from rev 84728, projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ServletContextAttributeProvider.java)
===================================================================
--- projects/jboss-osgi/trunk/service/http/src/main/java/org/jboss/osgi/service/http/ServletContextAttributeProvider.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/service/http/src/main/java/org/jboss/osgi/service/http/ServletContextAttributeProvider.java	2009-02-25 15:06:53 UTC (rev 84735)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.service.http;
+
+import javax.servlet.ServletContext;
+
+import org.jboss.osgi.spi.framework.AbstractAttributeProvider;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class ServletContextAttributeProvider extends AbstractAttributeProvider
+{
+   private ServletContext context;
+
+   public ServletContextAttributeProvider(ServletContext context)
+   {
+      if (context == null)
+         throw new IllegalArgumentException("Null servlet context.");
+
+      this.context = context;
+   }
+
+   public Object getAttribute(String name)
+   {
+      return context.getAttribute(name);
+   }
+}


Property changes on: projects/jboss-osgi/trunk/testsuite
___________________________________________________________________
Name: svn:ignore
   + target


Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml	2009-02-25 14:29:00 UTC (rev 84734)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml	2009-02-25 15:06:53 UTC (rev 84735)
@@ -104,7 +104,7 @@
 
     <!--
     Name:  no-jboss-bind-address
-    Descr: Skip tests if no jboss.bind address is given
+    Descr: Skip tests if no jboss.bind.address is given
     -->
     <profile>
       <id>no-jboss-bind-address</id>




More information about the jboss-cvs-commits mailing list