[jboss-cvs] JBossAS SVN: r84933 - in projects/jboss-osgi/trunk: runtime/felix/src/test/java/org/jboss/test/osgi/felix/microcontainer and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Mar 2 05:16:39 EST 2009


Author: thomas.diesler at jboss.com
Date: 2009-03-02 05:16:38 -0500 (Mon, 02 Mar 2009)
New Revision: 84933

Added:
   projects/jboss-osgi/trunk/runtime/felix/src/main/resources/org.jboss.osgi.spi.framework.OSGiBootstrapProvider
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/AbstractInstanceProvider.java
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/NamedInstanceProvider.java
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrapProvider.java
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/internal/MicrocontainerBootstrapProvider.java
   projects/jboss-osgi/trunk/service/http/src/main/java/org/jboss/osgi/service/http/ServletContextInstanceProvider.java
Removed:
   projects/jboss-osgi/trunk/runtime/felix/src/main/resources/org.jboss.osgi.spi.framework.OSGiConfigurationProvider
   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/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/ServletContextAttributeProvider.java
Modified:
   projects/jboss-osgi/trunk/runtime/felix/src/test/java/org/jboss/test/osgi/felix/microcontainer/ConfiguredServiceTestCase.java
   projects/jboss-osgi/trunk/runtime/felix/src/test/java/org/jboss/test/osgi/felix/microcontainer/ExplicitServiceTestCase.java
   projects/jboss-osgi/trunk/runtime/felix/src/test/java/org/jboss/test/osgi/felix/system/SystemBundleTestCase.java
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTestCase.java
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTestHelper.java
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTestSetup.java
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestCase.java
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestSetup.java
   projects/jboss-osgi/trunk/service/http/src/main/java/org/jboss/osgi/service/http/GenericEndpointServlet.java
   projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/bootstrap/BootstrapTestCase.java
   projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi36/junit/OSGI36TestCase.java
Log:
Refactor OSGiConfiguration to OSGiBootstrap - In container components use injection not lookup

Copied: projects/jboss-osgi/trunk/runtime/felix/src/main/resources/org.jboss.osgi.spi.framework.OSGiBootstrapProvider (from rev 84918, projects/jboss-osgi/trunk/runtime/felix/src/main/resources/org.jboss.osgi.spi.framework.OSGiConfigurationProvider)
===================================================================
--- projects/jboss-osgi/trunk/runtime/felix/src/main/resources/org.jboss.osgi.spi.framework.OSGiBootstrapProvider	                        (rev 0)
+++ projects/jboss-osgi/trunk/runtime/felix/src/main/resources/org.jboss.osgi.spi.framework.OSGiBootstrapProvider	2009-03-02 10:16:38 UTC (rev 84933)
@@ -0,0 +1 @@
+org.jboss.osgi.spi.internal.MicrocontainerBootstrapProvider
\ No newline at end of file

Deleted: projects/jboss-osgi/trunk/runtime/felix/src/main/resources/org.jboss.osgi.spi.framework.OSGiConfigurationProvider
===================================================================
--- projects/jboss-osgi/trunk/runtime/felix/src/main/resources/org.jboss.osgi.spi.framework.OSGiConfigurationProvider	2009-03-02 10:16:32 UTC (rev 84932)
+++ projects/jboss-osgi/trunk/runtime/felix/src/main/resources/org.jboss.osgi.spi.framework.OSGiConfigurationProvider	2009-03-02 10:16:38 UTC (rev 84933)
@@ -1 +0,0 @@
-org.jboss.osgi.spi.internal.MicrocontainerConfigurationProvider
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/runtime/felix/src/test/java/org/jboss/test/osgi/felix/microcontainer/ConfiguredServiceTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/felix/src/test/java/org/jboss/test/osgi/felix/microcontainer/ConfiguredServiceTestCase.java	2009-03-02 10:16:32 UTC (rev 84932)
+++ projects/jboss-osgi/trunk/runtime/felix/src/test/java/org/jboss/test/osgi/felix/microcontainer/ConfiguredServiceTestCase.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -25,8 +25,8 @@
 
 import junit.framework.Test;
 
-import org.jboss.osgi.spi.framework.OSGiConfiguration;
-import org.jboss.osgi.spi.framework.OSGiConfigurationProvider;
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
 import org.jboss.osgi.spi.framework.OSGiFramework;
 import org.jboss.osgi.spi.junit.OSGiTestCase;
 import org.jboss.osgi.spi.junit.OSGiTestSetup;
@@ -50,7 +50,7 @@
       @Override
       protected void setUp() throws Exception
       {
-        OSGiConfigurationProvider provider = OSGiConfiguration.getConfigurationProvider();
+        OSGiBootstrapProvider provider = OSGiBootstrap.getBootstrapProvider();
         provider.configure(getResourceURL("microcontainer/configured-service-test.xml"));
         framework = provider.getFramework();
       }

Modified: projects/jboss-osgi/trunk/runtime/felix/src/test/java/org/jboss/test/osgi/felix/microcontainer/ExplicitServiceTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/felix/src/test/java/org/jboss/test/osgi/felix/microcontainer/ExplicitServiceTestCase.java	2009-03-02 10:16:32 UTC (rev 84932)
+++ projects/jboss-osgi/trunk/runtime/felix/src/test/java/org/jboss/test/osgi/felix/microcontainer/ExplicitServiceTestCase.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -26,8 +26,8 @@
 import junit.framework.Test;
 
 import org.jboss.osgi.service.MicrocontainerService;
-import org.jboss.osgi.spi.framework.OSGiConfiguration;
-import org.jboss.osgi.spi.framework.OSGiConfigurationProvider;
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
 import org.jboss.osgi.spi.framework.OSGiFramework;
 import org.jboss.osgi.spi.junit.OSGiTestCase;
 import org.jboss.osgi.spi.junit.OSGiTestSetup;
@@ -51,7 +51,7 @@
       @Override
       protected void setUp() throws Exception
       {
-        OSGiConfigurationProvider provider = OSGiConfiguration.getConfigurationProvider();
+        OSGiBootstrapProvider provider = OSGiBootstrap.getBootstrapProvider();
         provider.configure(getResourceURL("microcontainer/explicit-service-test.xml"));
         framework = provider.getFramework();
         

Modified: projects/jboss-osgi/trunk/runtime/felix/src/test/java/org/jboss/test/osgi/felix/system/SystemBundleTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/felix/src/test/java/org/jboss/test/osgi/felix/system/SystemBundleTestCase.java	2009-03-02 10:16:32 UTC (rev 84932)
+++ projects/jboss-osgi/trunk/runtime/felix/src/test/java/org/jboss/test/osgi/felix/system/SystemBundleTestCase.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -23,8 +23,8 @@
 
 //$Id$
 
-import org.jboss.osgi.spi.framework.OSGiConfiguration;
-import org.jboss.osgi.spi.framework.OSGiConfigurationProvider;
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
 import org.jboss.osgi.spi.framework.OSGiFramework;
 import org.jboss.osgi.spi.junit.OSGiTestCase;
 import org.osgi.framework.Bundle;
@@ -39,7 +39,7 @@
 {
    public void testSystemBundle()
    {
-      OSGiConfigurationProvider configProvider = OSGiConfiguration.getConfigurationProvider();
+      OSGiBootstrapProvider configProvider = OSGiBootstrap.getBootstrapProvider();
       OSGiFramework framework = configProvider.getFramework();
       Bundle bundle = framework.getSystemBundle();
 

Deleted: 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/AbstractAttributeProvider.java	2009-03-02 10:16:32 UTC (rev 84932)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/AbstractAttributeProvider.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -1,49 +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.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/AbstractInstanceProvider.java (from rev 84918, 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/AbstractInstanceProvider.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/AbstractInstanceProvider.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -0,0 +1,52 @@
+/*
+ * 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;
+
+// $Id: $
+
+/**
+ * Provide a named instance from the configuration.
+ *
+ * @author ales.justin at jboss.com
+ * @author thomas.diesler at jboss.com
+ */
+public abstract class AbstractInstanceProvider implements NamedInstanceProvider
+{
+   public <T> T getInstance(String name, Class<T> expectedType)
+   {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+
+      if (expectedType == null)
+         throw new IllegalArgumentException("Null expected type.");
+
+      Object attribute = getInstance(name);
+      if (attribute != null)
+      {
+         if (expectedType.isInstance(attribute) == false)
+            throw new IllegalArgumentException("Not of expected type [" + expectedType + "]: " + attribute);
+
+         return expectedType.cast(attribute);
+      }
+      return null;
+   }
+}
\ No newline at end of file

Deleted: projects/jboss-osgi/trunk/runtime/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	2009-03-02 10:16:32 UTC (rev 84932)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/AttributeProvider.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -1,48 +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.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

Copied: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/NamedInstanceProvider.java (from rev 84918, projects/jboss-osgi/trunk/runtime/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/NamedInstanceProvider.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/NamedInstanceProvider.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -0,0 +1,51 @@
+/*
+ * 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;
+
+// $Id$
+
+/**
+ * Provide a named instance from the configuration.
+ *
+ * @author ales.justin at jboss.com
+ * @author thomas.diesler at jboss.com
+ */
+public interface NamedInstanceProvider
+{
+   /**
+    * Get a named instance
+    *
+    * @param name the attribute name
+    * @return attribute
+    */
+   Object getInstance(String name);
+
+   /**
+    * Get a named instance for a given type
+    *
+    * @param <T> exact attribute type
+    * @param name the attribute name
+    * @param expectedType the expected type
+    * @return attribute
+    */
+   <T> T getInstance(String name, Class<T> expectedType);
+}
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java (from rev 84918, 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/OSGiBootstrap.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -0,0 +1,99 @@
+/*
+ * 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;
+
+//$Id$
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URL;
+
+/**
+ * The OSGiBootstrap provides an OSGiFramework through a OSGiBootstrapProvider
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 18-Jun-2008
+ */
+public final class OSGiBootstrap
+{
+   // Hide the ctor
+   private OSGiBootstrap()
+   {
+   }
+
+   /**
+    * Get an instance of an OSGiBootstrapProvider. 
+    * </p> 
+    * A OSGiBootstrapProvider is discovered in two stages 
+    * <p/> 
+    * 
+    * <ol> 
+    * <li>Read the bootstrap provider class name from a system property 
+    * <li>Read the bootstrap provider class name from a resource file 
+    * </ol> 
+    * 
+    * In both cases the key is the fully qalified name of the {@link OSGiBootstrapProvider} interface.
+    */
+   public static OSGiBootstrapProvider getBootstrapProvider()
+   {
+      OSGiBootstrapProvider provider;
+
+      // Get the provider name from the System property
+      String providerName = System.getProperty(OSGiBootstrapProvider.class.getName());
+
+      // Get the provider name from the resource file
+      if (providerName == null)
+      {
+         ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+         URL providerURL = ctxLoader.getResource(OSGiBootstrapProvider.class.getName());
+         if (providerURL == null)
+            throw new IllegalStateException("Cannot find resource: " + OSGiBootstrapProvider.class.getName());
+
+         try
+         {
+            providerName = new BufferedReader(new InputStreamReader(providerURL.openStream())).readLine();
+         }
+         catch (Exception e)
+         {
+            throw new IllegalStateException("Cannot read bootstrap provider name from: " + providerURL);
+         }
+      }
+
+      // Verify that we have a provider name
+      if (providerName == null)
+         throw new IllegalStateException("Cannot obtain bootstrap provider");
+
+      // Load the config provider
+      try
+      {
+         ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+         Class<?> providerClass = ctxLoader.loadClass(providerName);
+         provider = (OSGiBootstrapProvider)providerClass.newInstance();
+      }
+      catch (Exception e)
+      {
+         throw new IllegalStateException("Cannot load bootstrap provider: " + providerName);
+      }
+
+      return provider;
+   }
+}
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrapProvider.java (from rev 84918, 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/OSGiBootstrapProvider.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrapProvider.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -0,0 +1,78 @@
+/*
+ * 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;
+
+//$Id$
+
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * An OSGiBootstrapProvider provides an OSGiFramework
+ * <p/>
+ * Implementations would configure the OSGiFramework through some
+ * form of descriptor.
+ * <p/>
+ * Natively, the SPI provides an OSGiBootstrapProvider that is based 
+ * on the Microkernel.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 18-Jun-2008
+ */
+public interface OSGiBootstrapProvider extends NamedInstanceProvider
+{
+   /* The Framework bean name - jboss.osgi:service=Framework */
+   public static final String DEFAULT_FRAMEWORK_NAME = "jboss.osgi:service=Framework";
+   /* The default framework beans: jboss-osgi-bootstrap-beans.xml */
+   public static final String DEFAULT_BOOTSTRAP_BEANS = "jboss-osgi-bootstrap-beans.xml";
+   /* The default framework beans: jboss-osgi-beans.xml */
+   public static final String DEFAULT_FRAMEWORK_BEANS = "jboss-osgi-beans.xml";
+
+   /*
+    * Get the OSGiFramework that registerd with the default name
+    * @return The configured instance of a Framework
+    * @throws IllegalArgumentException if this is not AttributeProvider instance
+    */
+   OSGiFramework getFramework();
+
+   /*
+    * Get an OSGiFramework with a given name from this OSGiBootstrapProvider
+    * @param name the framework name
+    * @return The configured instance of a Framework, or null
+    */
+   OSGiFramework getFramework(String name);
+
+   /*
+    * Configure this provider from the given URL
+    */
+   void configure(URL urlConfig);
+
+   /*
+    * Configure this provider from the resource
+    */
+   void configure(String resourceConfig);
+
+   /*
+    * Configure this provider from the resource
+    */
+   void configure(InputStream streamConfig);
+}
\ No newline at end of file

Deleted: 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-03-02 10:16:32 UTC (rev 84932)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiConfiguration.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -1,99 +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.framework;
-
-//$Id$
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.URL;
-
-/**
- * The OSGiConfiguration provides an OSGiFramework through a OSGiConfigurationProvider
- * 
- * @author thomas.diesler at jboss.com
- * @since 18-Jun-2008
- */
-public final class OSGiConfiguration
-{
-   // Hide the ctor
-   private OSGiConfiguration()
-   {
-   }
-
-   /**
-    * Get an instance of an OSGiConfigurationProvider. 
-    * </p> 
-    * A OSGiConfigurationProvider is discovered in two stages 
-    * <p/> 
-    * 
-    * <ol> 
-    * <li>Read the configuration provider class name from a system property 
-    * <li>Read the configuration provider class name from a resource file 
-    * </ol> 
-    * 
-    * In both cases the key is the fully qalified name of the {@link OSGiConfigurationProvider} interface.
-    */
-   public static OSGiConfigurationProvider getConfigurationProvider()
-   {
-      OSGiConfigurationProvider provider;
-
-      // Get the provider name from the System property
-      String providerName = System.getProperty(OSGiConfigurationProvider.class.getName());
-
-      // Get the provider name from the resource file
-      if (providerName == null)
-      {
-         ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
-         URL providerURL = ctxLoader.getResource(OSGiConfigurationProvider.class.getName());
-         if (providerURL == null)
-            throw new IllegalStateException("Cannot find resource: " + OSGiConfigurationProvider.class.getName());
-
-         try
-         {
-            providerName = new BufferedReader(new InputStreamReader(providerURL.openStream())).readLine();
-         }
-         catch (Exception e)
-         {
-            throw new IllegalStateException("Cannot read configuration provider name from: " + providerURL);
-         }
-      }
-
-      // Verify that we have a provider name
-      if (providerName == null)
-         throw new IllegalStateException("Cannot obtain configuration provider");
-
-      // Load the config provider
-      try
-      {
-         ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
-         Class<?> providerClass = ctxLoader.loadClass(providerName);
-         provider = (OSGiConfigurationProvider)providerClass.newInstance();
-      }
-      catch (Exception e)
-      {
-         throw new IllegalStateException("Cannot load configuration provider: " + providerName);
-      }
-
-      return provider;
-   }
-}
\ No newline at end of file

Deleted: 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-03-02 10:16:32 UTC (rev 84932)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiConfigurationProvider.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -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.spi.framework;
-
-//$Id$
-
-import java.io.InputStream;
-import java.net.URL;
-
-/**
- * An OSGiConfigurationProvider provides an OSGiFramework
- * <p/>
- * Implementations would configure the OSGiFramework through some
- * form of descriptor.
- * <p/>
- * Natively, the SPI provides an OSGiConfigurationProvider that is based 
- * on the Microkernel.
- * 
- * @author thomas.diesler at jboss.com
- * @since 18-Jun-2008
- */
-public interface OSGiConfigurationProvider extends AttributeProvider
-{
-   public static final String DEFAULT_FRAMEWORK_NAME = "jboss.osgi:service=Framework";
-   public static final String DEFAULT_BOOTSTRAP_BEANS = "jboss-osgi-bootstrap-beans.xml";
-   public static final String DEFAULT_FRAMEWORK_BEANS = "jboss-osgi-beans.xml";
-
-   /**
-   * Get the OSGiFramework that registerd with the default name
-   * 
-   * @return The configured instance of a Framework
-   * @throws IllegalArgumentException if this is not AttributeProvider instance
-   */
-   OSGiFramework getFramework();
-
-  /**
-   * Get an OSGiFramework 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(AttributeProvider attributeProvider, String name);
-  
-  /**
-   * Configure this provider from the given URL
-   */
-  void configure(URL urlConfig);
-  
-  /**
-   * Configure this provider from the resource
-   */
-  void configure(String resourceConfig);
-  
-  /**
-   * Configure this provider from the resource
-   */
-  void configure(InputStream streamConfig);
-}
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/internal/MicrocontainerBootstrapProvider.java (from rev 84918, 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/MicrocontainerBootstrapProvider.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/internal/MicrocontainerBootstrapProvider.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -0,0 +1,113 @@
+/*
+ * 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 java.io.InputStream;
+import java.net.URL;
+
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
+import org.jboss.osgi.spi.NotImplementedException;
+import org.jboss.osgi.spi.framework.AbstractInstanceProvider;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.spi.framework.OSGiFramework;
+
+/**
+ * Bootstrap the OSGiFrameworj through the MC
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 18-Jun-2008
+ */
+public class MicrocontainerBootstrapProvider extends AbstractInstanceProvider implements OSGiBootstrapProvider
+{
+   private EmbeddedBeansDeployer deployer = new EmbeddedBeansDeployer();
+   private boolean configured;
+
+   public OSGiFramework getFramework()
+   {
+      return getFramework(DEFAULT_FRAMEWORK_NAME);
+   }
+
+   public OSGiFramework getFramework(String beanName)
+   {
+      OSGiFramework framework = getInstance(beanName, OSGiFramework.class);
+      if (framework == null && configured == false)
+      {
+         configure(DEFAULT_FRAMEWORK_BEANS);
+         framework = getInstance(beanName, OSGiFramework.class);
+      }
+      return framework;
+   }
+
+   public void configure(InputStream streamConfig)
+   {
+      throw new NotImplementedException("Cannot bootstrap JBossMC from InputStream");
+   }
+
+   public void configure(String resourceConfig)
+   {
+      URL urlConfig = Thread.currentThread().getContextClassLoader().getResource(resourceConfig);
+      if (urlConfig == null)
+         throw new IllegalStateException("Cannot find resource: " + resourceConfig);
+
+      configure(urlConfig);
+   }
+
+   public void configure(URL urlConfig)
+   {
+      deployer.deploy(urlConfig);
+      configured = true;
+   }
+
+   public Object getInstance(String name)
+   {
+      Object retObj = null;
+
+      if (configured == false)
+         bootstrapKernel();
+
+      if (KernelConstants.KERNEL_NAME.equals(name))
+      {
+         retObj = deployer.getKernel();
+      }
+      else
+      {
+         Controller controller = deployer.getKernel().getController();
+         ControllerContext context = controller.getInstalledContext(name);
+         if (context != null)
+            retObj = context.getTarget();
+      }
+
+      return retObj;
+   }
+
+   private void bootstrapKernel()
+   {
+      // Deploy the bootstrap beans if DEFAULT_BOOTSTRAP_BEANS is on the classpath
+      URL urlBootstrap = Thread.currentThread().getContextClassLoader().getResource(DEFAULT_BOOTSTRAP_BEANS);
+      if (urlBootstrap != null)
+         deployer.deploy(urlBootstrap);
+   }
+}
\ No newline at end of file

Deleted: 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-03-02 10:16:32 UTC (rev 84932)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/internal/MicrocontainerConfigurationProvider.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -1,114 +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 java.io.InputStream;
-import java.net.URL;
-
-import org.jboss.dependency.spi.Controller;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
-import org.jboss.osgi.spi.NotImplementedException;
-import org.jboss.osgi.spi.framework.AbstractAttributeProvider;
-import org.jboss.osgi.spi.framework.AttributeProvider;
-import org.jboss.osgi.spi.framework.OSGiConfigurationProvider;
-import org.jboss.osgi.spi.framework.OSGiFramework;
-
-/**
- * The ConfigurationProvider provides a Framework through a given configuration method
- * 
- * @author thomas.diesler at jboss.com
- * @since 18-Jun-2008
- */
-public class MicrocontainerConfigurationProvider extends AbstractAttributeProvider implements OSGiConfigurationProvider
-{
-   private EmbeddedBeansDeployer deployer = new EmbeddedBeansDeployer();
-   private boolean configured;
-
-   public OSGiFramework getFramework()
-   {
-      return getFramework(this, DEFAULT_FRAMEWORK_NAME);
-   }
-
-   public OSGiFramework getFramework(AttributeProvider attributeProvider, String beanName)
-   {
-      OSGiFramework framework = attributeProvider.getAttribute(beanName, OSGiFramework.class);
-      if (framework == null && configured == false)
-      {
-         configure(DEFAULT_FRAMEWORK_BEANS);
-         framework = attributeProvider.getAttribute(beanName, OSGiFramework.class);
-      }
-      return framework;
-   }
-
-   public void configure(InputStream streamConfig)
-   {
-      throw new NotImplementedException("Cannot bootstrap JBossMC from InputStream");
-   }
-
-   public void configure(String resourceConfig)
-   {
-      URL urlConfig = Thread.currentThread().getContextClassLoader().getResource(resourceConfig);
-      if (urlConfig == null)
-         throw new IllegalStateException("Cannot find resource: " + resourceConfig);
-
-      configure(urlConfig);
-   }
-
-   public void configure(URL urlConfig)
-   {
-      deployer.deploy(urlConfig);
-      configured = true;
-   }
-
-   public Object getAttribute(String name)
-   {
-      Object retObj = null;
-
-      if (configured == false)
-         bootstrapKernel();
-
-      if (KernelConstants.KERNEL_NAME.equals(name))
-      {
-         retObj = deployer.getKernel();
-      }
-      else
-      {
-         Controller controller = deployer.getKernel().getController();
-         ControllerContext context = controller.getInstalledContext(name);
-         if (context != null)
-            retObj = context.getTarget();
-      }
-
-      return retObj;
-   }
-
-   private void bootstrapKernel()
-   {
-      // Deploy the bootstrap beans if DEFAULT_BOOTSTRAP_BEANS is on the classpath
-      URL urlBootstrap = Thread.currentThread().getContextClassLoader().getResource(DEFAULT_BOOTSTRAP_BEANS);
-      if (urlBootstrap != null)
-         deployer.deploy(urlBootstrap);
-   }
-}
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTestCase.java	2009-03-02 10:16:32 UTC (rev 84932)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTestCase.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -28,7 +28,7 @@
 import javax.management.MBeanServerConnection;
 
 import org.jboss.logging.Logger;
-import org.jboss.osgi.spi.framework.OSGiConfigurationProvider;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
 
 /**
  * An integration test case
@@ -42,25 +42,25 @@
    final Logger log = Logger.getLogger(IntegrationTestCase.class);
 
    private IntegrationTestHelper delegate;
-   private OSGiConfigurationProvider configProvider;
+   private OSGiBootstrapProvider bootProvider;
 
    private IntegrationTestHelper getDelegate()
    {
       if (delegate == null)
       {
-         delegate = new IntegrationTestHelper(getConfigurationProvider());
+         delegate = new IntegrationTestHelper(getBootstrapProvider());
       }
       return delegate;
    }
 
-   public OSGiConfigurationProvider getConfigurationProvider()
+   public OSGiBootstrapProvider getBootstrapProvider()
    {
-      return configProvider;
+      return bootProvider;
    }
 
-   public void setConfigurationProvider(OSGiConfigurationProvider configProvider)
+   public void setBootstrapProvider(OSGiBootstrapProvider configProvider)
    {
-      this.configProvider = configProvider;
+      this.bootProvider = configProvider;
    }
 
    public boolean isRemoteIntegration()

Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTestHelper.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTestHelper.java	2009-03-02 10:16:32 UTC (rev 84932)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTestHelper.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -31,8 +31,8 @@
 
 import org.jboss.deployers.client.spi.DeployerClient;
 import org.jboss.deployers.client.spi.main.MainDeployer;
-import org.jboss.osgi.spi.framework.AttributeProvider;
-import org.jboss.osgi.spi.framework.OSGiConfigurationProvider;
+import org.jboss.osgi.spi.framework.NamedInstanceProvider;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
 
 /**
  * An integration test helper that deals with test deployment/undeployment, etc.
@@ -43,10 +43,10 @@
 public class IntegrationTestHelper extends OSGiTestHelper
 {
    private static MBeanServerConnection server;
-   private OSGiConfigurationProvider configProvider;
+   private OSGiBootstrapProvider configProvider;
    private String integrationTarget;
 
-   public IntegrationTestHelper(OSGiConfigurationProvider configProvider)
+   public IntegrationTestHelper(OSGiBootstrapProvider configProvider)
    {
       this.configProvider = configProvider;
    }
@@ -130,8 +130,8 @@
       }
       else
       {
-         AttributeProvider attProvider = (AttributeProvider)configProvider;
-         DeployerClient deployer = (MainDeployer)attProvider.getAttribute("MainDeployer");
+         NamedInstanceProvider attProvider = (NamedInstanceProvider)configProvider;
+         DeployerClient deployer = (MainDeployer)attProvider.getInstance("MainDeployer");
          return new EmbeddedArchiveDeployer(deployer);
       }
    }

Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTestSetup.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTestSetup.java	2009-03-02 10:16:32 UTC (rev 84932)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTestSetup.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -53,7 +53,7 @@
    {
       if (delegate == null)
       {
-         delegate = new IntegrationTestHelper(getConfigurationProvider());
+         delegate = new IntegrationTestHelper(getBootstrapProvider());
       }
       return delegate;
    }

Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestCase.java	2009-03-02 10:16:32 UTC (rev 84932)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestCase.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -26,8 +26,8 @@
 import java.net.URL;
 
 import org.jboss.logging.Logger;
-import org.jboss.osgi.spi.framework.OSGiConfiguration;
-import org.jboss.osgi.spi.framework.OSGiConfigurationProvider;
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
 import org.jboss.virtual.VFS;
 
 import junit.framework.TestCase;
@@ -44,7 +44,7 @@
    final Logger log = Logger.getLogger(OSGiTestCase.class);
 
    private OSGiTestHelper delegate = new OSGiTestHelper();
-   private OSGiConfigurationProvider configProvider;
+   private OSGiBootstrapProvider bootProvider;
 
    public OSGiTestCase()
    {
@@ -52,23 +52,23 @@
       VFS.init();
    }
 
-   public OSGiConfigurationProvider createConfigurationProvider()
+   public OSGiBootstrapProvider createBootstrapProvider()
    {
-      return OSGiConfiguration.getConfigurationProvider();
+      return OSGiBootstrap.getBootstrapProvider();
    }
 
-   public OSGiConfigurationProvider getConfigurationProvider()
+   public OSGiBootstrapProvider getBootstrapProvider()
    {
-      if (configProvider == null)
+      if (bootProvider == null)
       {
-         configProvider = createConfigurationProvider();
+         bootProvider = createBootstrapProvider();
       }
-      return configProvider;
+      return bootProvider;
    }
 
-   public void setConfigurationProvider(OSGiConfigurationProvider configProvider)
+   public void setBootstrapProvider(OSGiBootstrapProvider configProvider)
    {
-      this.configProvider = configProvider;
+      this.bootProvider = configProvider;
    }
 
    @Override

Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestSetup.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestSetup.java	2009-03-02 10:16:32 UTC (rev 84932)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestSetup.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -26,8 +26,8 @@
 import java.net.URL;
 
 import org.jboss.logging.Logger;
-import org.jboss.osgi.spi.framework.OSGiConfiguration;
-import org.jboss.osgi.spi.framework.OSGiConfigurationProvider;
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
 import org.jboss.virtual.VFS;
 
 import junit.extensions.TestSetup;
@@ -45,7 +45,7 @@
   final Logger log = Logger.getLogger(OSGiTestSetup.class);
 
   private OSGiTestHelper delegate = new OSGiTestHelper();
-  private OSGiConfigurationProvider configProvider;
+  private OSGiBootstrapProvider bootProvider;
   
   public OSGiTestSetup(Class<?> testCase)
   {
@@ -54,23 +54,23 @@
     VFS.init();
   }
 
-  public OSGiConfigurationProvider createConfigurationProvider()
+  public OSGiBootstrapProvider createBootstrapProvider()
   {
-     return OSGiConfiguration.getConfigurationProvider();
+     return OSGiBootstrap.getBootstrapProvider();
   }
 
-  public OSGiConfigurationProvider getConfigurationProvider()
+  public OSGiBootstrapProvider getBootstrapProvider()
   {
-     if (configProvider == null)
+     if (bootProvider == null)
      {
-        configProvider = createConfigurationProvider();
+        bootProvider = createBootstrapProvider();
      }
-     return configProvider;
+     return bootProvider;
   }
 
-  public void setConfigurationProvider(OSGiConfigurationProvider configProvider)
+  public void setBootstrapProvider(OSGiBootstrapProvider bootProvider)
   {
-     this.configProvider = configProvider;
+     this.bootProvider = bootProvider;
   }
 
   @Override

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-03-02 10:16:32 UTC (rev 84932)
+++ projects/jboss-osgi/trunk/service/http/src/main/java/org/jboss/osgi/service/http/GenericEndpointServlet.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -61,8 +61,8 @@
       super.init(config);
 
       // Get the MBeanServer
-      ServletContextAttributeProvider attProvider = new ServletContextAttributeProvider(config.getServletContext());
-      MBeanServer server = attProvider.getAttribute("JMXKernel", JMXKernel.class).getMbeanServer();
+      ServletContextInstanceProvider attProvider = new ServletContextInstanceProvider(config.getServletContext());
+      MBeanServer server = attProvider.getInstance("JMXKernel", JMXKernel.class).getMbeanServer();
 
       try
       {

Deleted: projects/jboss-osgi/trunk/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	2009-03-02 10:16:32 UTC (rev 84932)
+++ projects/jboss-osgi/trunk/service/http/src/main/java/org/jboss/osgi/service/http/ServletContextAttributeProvider.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -1,57 +0,0 @@
-/*
- * 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.dependency.spi.Controller;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
-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)
-   {
-      Kernel kernel = (Kernel)context.getAttribute(KernelConstants.KERNEL_NAME);
-      if (KernelConstants.KERNEL_NAME.equals(name))
-         return kernel;
-         
-      Controller controller = kernel.getController();
-      ControllerContext context = controller.getInstalledContext(name);
-      return (context != null ? context.getTarget() : null);
-   }
-}

Copied: projects/jboss-osgi/trunk/service/http/src/main/java/org/jboss/osgi/service/http/ServletContextInstanceProvider.java (from rev 84918, projects/jboss-osgi/trunk/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/ServletContextInstanceProvider.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/service/http/src/main/java/org/jboss/osgi/service/http/ServletContextInstanceProvider.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -0,0 +1,57 @@
+/*
+ * 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.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
+import org.jboss.osgi.spi.framework.AbstractInstanceProvider;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class ServletContextInstanceProvider extends AbstractInstanceProvider
+{
+   private ServletContext context;
+
+   public ServletContextInstanceProvider(ServletContext context)
+   {
+      if (context == null)
+         throw new IllegalArgumentException("Null servlet context.");
+
+      this.context = context;
+   }
+
+   public Object getInstance(String name)
+   {
+      Kernel kernel = (Kernel)context.getAttribute(KernelConstants.KERNEL_NAME);
+      if (KernelConstants.KERNEL_NAME.equals(name))
+         return kernel;
+         
+      Controller controller = kernel.getController();
+      ControllerContext context = controller.getInstalledContext(name);
+      return (context != null ? context.getTarget() : null);
+   }
+}

Modified: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/bootstrap/BootstrapTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/bootstrap/BootstrapTestCase.java	2009-03-02 10:16:32 UTC (rev 84932)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/bootstrap/BootstrapTestCase.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -24,9 +24,9 @@
 //$Id$
 
 import org.jboss.deployers.client.spi.main.MainDeployer;
-import org.jboss.osgi.spi.framework.AttributeProvider;
-import org.jboss.osgi.spi.framework.OSGiConfiguration;
-import org.jboss.osgi.spi.framework.OSGiConfigurationProvider;
+import org.jboss.osgi.spi.framework.NamedInstanceProvider;
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
 import org.jboss.osgi.spi.framework.OSGiFramework;
 import org.jboss.osgi.spi.junit.OSGiTestCase;
 import org.osgi.framework.Bundle;
@@ -41,7 +41,7 @@
 {
    public void testFrameworkBootstrap() throws Exception
    {
-      OSGiConfigurationProvider configProvider = OSGiConfiguration.getConfigurationProvider();
+      OSGiBootstrapProvider configProvider = OSGiBootstrap.getBootstrapProvider();
       OSGiFramework framework = configProvider.getFramework();
       assertNotNull("Framework not null", framework);
       
@@ -50,24 +50,24 @@
       assertEquals("BundleId == 0", 0, bundle.getBundleId());
       assertEquals("SymbolicName == system.bundle", "system.bundle", bundle.getSymbolicName());
       
-      AttributeProvider attProvider = (AttributeProvider)configProvider;
-      MainDeployer mainDeployer = (MainDeployer)attProvider.getAttribute("MainDeployer");
+      NamedInstanceProvider attProvider = (NamedInstanceProvider)configProvider;
+      MainDeployer mainDeployer = (MainDeployer)attProvider.getInstance("MainDeployer");
       assertNotNull("MainDeployer not null", mainDeployer);
    }
 
    public void testGetConfigurationProvider() throws Exception
    {
-      OSGiConfigurationProvider cp1 = OSGiConfiguration.getConfigurationProvider();
-      OSGiConfigurationProvider cp2 = OSGiConfiguration.getConfigurationProvider();
+      OSGiBootstrapProvider cp1 = OSGiBootstrap.getBootstrapProvider();
+      OSGiBootstrapProvider cp2 = OSGiBootstrap.getBootstrapProvider();
       assertNotSame("Multiple provider instances", cp1, cp2);
    }
 
    public void testConfigureFromResource() throws Exception
    {
-      OSGiConfigurationProvider cp = OSGiConfiguration.getConfigurationProvider();
+      OSGiBootstrapProvider cp = OSGiBootstrap.getBootstrapProvider();
       cp.configure("bootstrap/mock-bootstrap-beans.xml");
       
-      SomeBean bean = (SomeBean)cp.getAttribute("SomeBean");
+      SomeBean bean = (SomeBean)cp.getInstance("SomeBean");
       assertNotNull("Bean not null", bean);
       
       OSGiFramework framework = cp.getFramework();
@@ -79,10 +79,10 @@
 
    public void testConfigureFromURL() throws Exception
    {
-      OSGiConfigurationProvider cp = OSGiConfiguration.getConfigurationProvider();
+      OSGiBootstrapProvider cp = OSGiBootstrap.getBootstrapProvider();
       cp.configure(getResourceURL("bootstrap/mock-bootstrap-beans.xml"));
       
-      SomeBean bean = (SomeBean)cp.getAttribute("SomeBean");
+      SomeBean bean = (SomeBean)cp.getInstance("SomeBean");
       assertNotNull("Bean not null", bean);
       
       OSGiFramework framework = cp.getFramework();

Modified: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi36/junit/OSGI36TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi36/junit/OSGI36TestCase.java	2009-03-02 10:16:32 UTC (rev 84932)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi36/junit/OSGI36TestCase.java	2009-03-02 10:16:38 UTC (rev 84933)
@@ -25,9 +25,9 @@
 
 import junit.framework.Test;
 
-import org.jboss.osgi.spi.framework.AttributeProvider;
-import org.jboss.osgi.spi.framework.OSGiConfiguration;
-import org.jboss.osgi.spi.framework.OSGiConfigurationProvider;
+import org.jboss.osgi.spi.framework.NamedInstanceProvider;
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
 import org.jboss.osgi.spi.jmx.MBeanProxy;
 import org.jboss.osgi.spi.jmx.MBeanProxyException;
 import org.jboss.osgi.spi.junit.IntegrationTestCase;
@@ -51,13 +51,13 @@
       setup = new IntegrationTestSetup(OSGI36TestCase.class, "jbosgi36-bundle.jar, jbosgi36-mbean.jar")
       {
          @Override
-         public OSGiConfigurationProvider createConfigurationProvider()
+         public OSGiBootstrapProvider createBootstrapProvider()
          {
-            OSGiConfigurationProvider configProvider = null;
+            OSGiBootstrapProvider configProvider = null;
             if (isRemoteIntegration() == false)
             {
                // Bootstrap the embedded framework
-               configProvider = OSGiConfiguration.getConfigurationProvider();
+               configProvider = OSGiBootstrap.getBootstrapProvider();
                configProvider.getFramework();
             }
             return configProvider;
@@ -102,9 +102,9 @@
       FooMBean foo;
       if (isRemoteIntegration() == false)
       {
-         OSGiConfigurationProvider configProvider = setup.getConfigurationProvider();
-         AttributeProvider attProvider = (AttributeProvider)configProvider;
-         foo = attProvider.getAttribute("Foo", FooMBean.class);
+         OSGiBootstrapProvider configProvider = setup.getBootstrapProvider();
+         NamedInstanceProvider attProvider = (NamedInstanceProvider)configProvider;
+         foo = attProvider.getInstance("Foo", FooMBean.class);
       }
       else
       {




More information about the jboss-cvs-commits mailing list