[jboss-cvs] JBossAS SVN: r95010 - in projects/jboss-osgi: projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 16 03:51:11 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-10-16 03:51:11 -0400 (Fri, 16 Oct 2009)
New Revision: 95010

Added:
   projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java
   projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixFrameworkWrapper.java
   projects/jboss-osgi/projects/runtime/felix/trunk/src/test/java/org/jboss/test/osgi/felix/OSGiBootstrapTestCase.java
   projects/jboss-osgi/projects/runtime/felix/trunk/src/test/resources/META-INF/
   projects/jboss-osgi/projects/runtime/felix/trunk/src/test/resources/META-INF/services/
   projects/jboss-osgi/projects/runtime/felix/trunk/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider
   projects/jboss-osgi/projects/runtime/felix/trunk/src/test/resources/jboss-osgi-framework.properties
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/BundleContextWrapper.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/BundleWrapper.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkWrapper.java
Modified:
   projects/jboss-osgi/projects/runtime/felix/trunk/pom.xml
   projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBootstrapProvider.java
   projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixIntegration.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkIntegration.java
   projects/jboss-osgi/trunk/pom.xml
Log:
[JBOSGI-183] Initial implementation of OSGi Deployers
Add hooks into Felix integration - WIP

Modified: projects/jboss-osgi/projects/runtime/felix/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/felix/trunk/pom.xml	2009-10-16 07:42:55 UTC (rev 95009)
+++ projects/jboss-osgi/projects/runtime/felix/trunk/pom.xml	2009-10-16 07:51:11 UTC (rev 95010)
@@ -20,18 +20,25 @@
   <artifactId>jboss-osgi-runtime-felix</artifactId>
   <packaging>jar</packaging>
 
-  <version>2.0.1-SNAPSHOT</version>
+  <version>2.0.0-SNAPSHOT</version>
 
   <!-- Parent -->
   <parent>
     <groupId>org.jboss.osgi</groupId>
     <artifactId>jboss-osgi-parent</artifactId>
-    <version>1.0.2</version>
+    <version>1.0.3</version>
   </parent>
 
+  <!-- Subversion -->
+  <scm>
+    <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/felix/trunk</connection>
+    <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/felix/trunk</developerConnection>
+    <url>http://fisheye.jboss.com/qsearch/JBossOSGi</url>
+  </scm>
+
   <properties>
     <version.felix.framework>2.0.0</version.felix.framework>
-    <version.jboss.osgi.spi>1.0.1</version.jboss.osgi.spi>
+    <version.jboss.osgi.spi>1.0.3-SNAPSHOT</version.jboss.osgi.spi>
   </properties>
 
   <!-- Dependencies -->
@@ -46,13 +53,28 @@
       <artifactId>org.apache.felix.framework</artifactId>
       <version>${version.felix.framework}</version>
     </dependency>
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging-log4j</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
-  <!-- Subversion -->
-  <scm>
-    <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/felix/trunk</connection>
-    <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/felix/trunk</developerConnection>
-    <url>http://fisheye.jboss.com/qsearch/JBossOSGi/projects/runtime/felix/trunk</url>
-  </scm>
+  <!-- Build -->
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <systemProperties>
+            <property>
+              <name>log4j.output.dir</name>
+              <value>${project.build.directory}</value>
+            </property>
+          </systemProperties>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 
 </project>

Modified: projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBootstrapProvider.java
===================================================================
--- projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBootstrapProvider.java	2009-10-16 07:42:55 UTC (rev 95009)
+++ projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBootstrapProvider.java	2009-10-16 07:51:11 UTC (rev 95010)
@@ -24,6 +24,7 @@
 //$Id$
 
 import org.jboss.osgi.spi.framework.PropertiesBootstrapProvider;
+import org.osgi.framework.launch.Framework;
 
 /**
  * A bootstrap provider for Felix.
@@ -33,4 +34,16 @@
  */
 public class FelixBootstrapProvider extends PropertiesBootstrapProvider
 {
+   private Framework frameworkWrapper;
+   
+   @Override
+   public Framework getFramework()
+   {
+      if (frameworkWrapper == null)
+      {
+         Framework framework = super.getFramework();
+         frameworkWrapper = new FelixFrameworkWrapper(framework);
+      }
+      return frameworkWrapper;
+   }
 }
\ No newline at end of file

Added: projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java	2009-10-16 07:51:11 UTC (rev 95010)
@@ -0,0 +1,56 @@
+/*
+ * 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.felix;
+
+//$Id$
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.framework.BundleContextWrapper;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+
+/**
+ * The FelixBundleContextWrapper wrapps the BundleContext provided by the Felix implemenation.
+ * 
+ * It provides additional functionality on bundle install.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 15-Oct-2009
+ */
+public class FelixBundleContextWrapper extends BundleContextWrapper
+{
+   // Provide logging
+   final Logger log = Logger.getLogger(FelixBundleContextWrapper.class);
+   
+   public FelixBundleContextWrapper(BundleContext context)
+   {
+      super(context);
+   }
+
+   @Override
+   public Bundle installBundle(String location) throws BundleException
+   {
+      Bundle bundle = super.installBundle(location);
+      return bundle;
+   }
+}
\ No newline at end of file


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

Added: projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixFrameworkWrapper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixFrameworkWrapper.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixFrameworkWrapper.java	2009-10-16 07:51:11 UTC (rev 95010)
@@ -0,0 +1,53 @@
+/*
+ * 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.felix;
+
+//$Id$
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.framework.FrameworkWrapper;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * The FelixFrameworkWrapper wrapps the Framework provided by the Felix implemenation.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 15-Oct-2009
+ */
+class FelixFrameworkWrapper extends FrameworkWrapper
+{
+   // Provide logging
+   final Logger log = Logger.getLogger(FelixFrameworkWrapper.class);
+   
+   FelixFrameworkWrapper(Framework framework)
+   {
+      super(framework);
+   }
+
+   @Override
+   public BundleContext getBundleContext()
+   {
+      BundleContext context = framework.getBundleContext();
+      return new FelixBundleContextWrapper(context);
+   }
+}
\ No newline at end of file


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

Modified: projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixIntegration.java
===================================================================
--- projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixIntegration.java	2009-10-16 07:42:55 UTC (rev 95009)
+++ projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixIntegration.java	2009-10-16 07:51:11 UTC (rev 95010)
@@ -23,10 +23,13 @@
 
 //$Id$
 
+import java.util.Map;
+
 import org.jboss.logging.Logger;
 import org.jboss.osgi.spi.framework.FrameworkIntegration;
 import org.jboss.osgi.spi.util.ServiceLoader;
 import org.osgi.framework.BundleException;
+import org.osgi.framework.launch.Framework;
 import org.osgi.framework.launch.FrameworkFactory;
 
 /**
@@ -40,7 +43,10 @@
    // Provide logging
    final Logger log = Logger.getLogger(FelixIntegration.class);
    
-   public void create()
+   private Framework framework;
+   
+   @Override
+   protected void createFramework(Map<String, Object> properties)
    {
       // Log INFO about this implementation
       log.info(getClass().getPackage().getImplementationTitle());
@@ -58,6 +64,13 @@
       framework = factory.newFramework(properties);
    }
 
+   @Override
+   protected Framework getFramework()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
    public void stop()
    {
       if (framework != null)

Added: projects/jboss-osgi/projects/runtime/felix/trunk/src/test/java/org/jboss/test/osgi/felix/OSGiBootstrapTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/felix/trunk/src/test/java/org/jboss/test/osgi/felix/OSGiBootstrapTestCase.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/felix/trunk/src/test/java/org/jboss/test/osgi/felix/OSGiBootstrapTestCase.java	2009-10-16 07:51:11 UTC (rev 95010)
@@ -0,0 +1,64 @@
+/*
+ * 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.test.osgi.felix;
+
+//$Id$
+
+import static org.junit.Assert.assertEquals;
+
+import org.jboss.osgi.felix.FelixBundleContextWrapper;
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * Test OSGi System bundle access
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 27-Jul-2009
+ */
+public class OSGiBootstrapTestCase 
+{
+   @Test
+   public void testFrameworkLaunch() throws Exception
+   {
+      OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
+      Framework framework = bootProvider.getFramework();
+      
+      assertEquals("BundleId == 0", 0, framework.getBundleId());
+      assertEquals("SymbolicName", "org.apache.felix.framework", framework.getSymbolicName());
+      
+      framework.start();
+      try
+      {
+         BundleContext context = framework.getBundleContext();
+         assertEquals(FelixBundleContextWrapper.class.getName(), context.getClass().getName());
+      }
+      finally
+      {
+         framework.stop();
+         framework.waitForStop(1000);
+      }
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/projects/runtime/felix/trunk/src/test/java/org/jboss/test/osgi/felix/OSGiBootstrapTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/jboss-osgi/projects/runtime/felix/trunk/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider
===================================================================
--- projects/jboss-osgi/projects/runtime/felix/trunk/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/felix/trunk/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider	2009-10-16 07:51:11 UTC (rev 95010)
@@ -0,0 +1 @@
+org.jboss.osgi.felix.FelixBootstrapProvider                     # The Felix bootstrap provider
\ No newline at end of file

Added: projects/jboss-osgi/projects/runtime/felix/trunk/src/test/resources/jboss-osgi-framework.properties
===================================================================
--- projects/jboss-osgi/projects/runtime/felix/trunk/src/test/resources/jboss-osgi-framework.properties	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/felix/trunk/src/test/resources/jboss-osgi-framework.properties	2009-10-16 07:51:11 UTC (rev 95010)
@@ -0,0 +1,24 @@
+#
+# Properties read by the org.jboss.osgi.spi.framework.PropertiesBootstrapProvider
+# 
+# $Id$
+#
+
+# The OSGiFramework implementation 
+org.jboss.osgi.spi.framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
+
+# Properties to configure the Framework
+# org.osgi.framework.storage.clean=onFirstInit
+
+# Framework bootdelegation
+# org.osgi.framework.bootdelegation=org.osgi.service.log
+
+# Extra System Packages
+# org.osgi.framework.system.packages.extra=\
+
+# Bundles that need to be installed with the Framework automatically 
+# org.jboss.osgi.spi.framework.autoInstall=\
+
+# Bundles that need to be started automatically 
+# org.jboss.osgi.spi.framework.autoStart=\
+	
\ No newline at end of file


Property changes on: projects/jboss-osgi/projects/runtime/felix/trunk/src/test/resources/jboss-osgi-framework.properties
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/BundleContextWrapper.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/BundleContextWrapper.java	                        (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/BundleContextWrapper.java	2009-10-16 07:51:11 UTC (rev 95010)
@@ -0,0 +1,174 @@
+/*
+ * 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.File;
+import java.io.InputStream;
+import java.util.Dictionary;
+
+import org.jboss.logging.Logger;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * A generic BundleContext wrapper that delegates all method calls to the underlying 
+ * BundleContext implementation.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 16-Oct-2009
+ */
+public class BundleContextWrapper implements BundleContext
+{
+   // Provide logging
+   final Logger log = Logger.getLogger(BundleContextWrapper.class);
+
+   protected BundleContext context;
+
+   public BundleContextWrapper(BundleContext context)
+   {
+      if (context == null)
+         throw new IllegalArgumentException("Null framework");
+      this.context = context;
+   }
+   
+   public void addBundleListener(BundleListener listener)
+   {
+      context.addBundleListener(listener);
+   }
+
+   public void addFrameworkListener(FrameworkListener listener)
+   {
+      context.addFrameworkListener(listener);
+   }
+
+   public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException
+   {
+      context.addServiceListener(listener, filter);
+   }
+
+   public void addServiceListener(ServiceListener listener)
+   {
+      context.addServiceListener(listener);
+   }
+
+   public Filter createFilter(String filter) throws InvalidSyntaxException
+   {
+      return context.createFilter(filter);
+   }
+
+   public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException
+   {
+      return context.getAllServiceReferences(clazz, filter);
+   }
+
+   public Bundle getBundle()
+   {
+      return context.getBundle();
+   }
+
+   public Bundle getBundle(long id)
+   {
+      return context.getBundle(id);
+   }
+
+   public Bundle[] getBundles()
+   {
+      return context.getBundles();
+   }
+
+   public File getDataFile(String filename)
+   {
+      return context.getDataFile(filename);
+   }
+
+   public String getProperty(String key)
+   {
+      return context.getProperty(key);
+   }
+
+   public Object getService(ServiceReference reference)
+   {
+      return context.getService(reference);
+   }
+
+   public ServiceReference getServiceReference(String clazz)
+   {
+      return context.getServiceReference(clazz);
+   }
+
+   public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException
+   {
+      return context.getServiceReferences(clazz, filter);
+   }
+
+   public Bundle installBundle(String location, InputStream input) throws BundleException
+   {
+      return context.installBundle(location, input);
+   }
+
+   public Bundle installBundle(String location) throws BundleException
+   {
+      return context.installBundle(location);
+   }
+
+   @SuppressWarnings("unchecked")
+   public ServiceRegistration registerService(String clazz, Object service, Dictionary properties)
+   {
+      return context.registerService(clazz, service, properties);
+   }
+
+   @SuppressWarnings("unchecked")
+   public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties)
+   {
+      return context.registerService(clazzes, service, properties);
+   }
+
+   public void removeBundleListener(BundleListener listener)
+   {
+      context.removeBundleListener(listener);
+   }
+
+   public void removeFrameworkListener(FrameworkListener listener)
+   {
+      context.removeFrameworkListener(listener);
+   }
+
+   public void removeServiceListener(ServiceListener listener)
+   {
+      context.removeServiceListener(listener);
+   }
+
+   public boolean ungetService(ServiceReference reference)
+   {
+      return context.ungetService(reference);
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/BundleContextWrapper.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/BundleWrapper.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/BundleWrapper.java	                        (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/BundleWrapper.java	2009-10-16 07:51:11 UTC (rev 95010)
@@ -0,0 +1,197 @@
+/*
+ * 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.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+
+/**
+ * A generic Bundle wrapper that delegates all method calls to the underlying 
+ * Bundle implementation.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 16-Oct-2009
+ */
+public class BundleWrapper implements Bundle
+{
+   // Provide logging
+   final Logger log = Logger.getLogger(BundleWrapper.class);
+
+   protected Bundle bundle;
+
+   public BundleWrapper(Bundle bundle)
+   {
+      if (bundle == null)
+         throw new IllegalArgumentException("Null bundle");
+      this.bundle = bundle;
+   }
+
+   @SuppressWarnings("unchecked")
+   public Enumeration findEntries(String path, String filePattern, boolean recurse)
+   {
+      return bundle.findEntries(path, filePattern, recurse);
+   }
+
+   public BundleContext getBundleContext()
+   {
+      return bundle.getBundleContext();
+   }
+
+   public long getBundleId()
+   {
+      return bundle.getBundleId();
+   }
+
+   public URL getEntry(String path)
+   {
+      return bundle.getEntry(path);
+   }
+
+   @SuppressWarnings("unchecked")
+   public Enumeration getEntryPaths(String path)
+   {
+      return bundle.getEntryPaths(path);
+   }
+
+   @SuppressWarnings("unchecked")
+   public Dictionary getHeaders()
+   {
+      return bundle.getHeaders();
+   }
+
+   @SuppressWarnings("unchecked")
+   public Dictionary getHeaders(String locale)
+   {
+      return bundle.getHeaders(locale);
+   }
+
+   public long getLastModified()
+   {
+      return bundle.getLastModified();
+   }
+
+   public String getLocation()
+   {
+      return bundle.getLocation();
+   }
+
+   public ServiceReference[] getRegisteredServices()
+   {
+      return bundle.getRegisteredServices();
+   }
+
+   public URL getResource(String name)
+   {
+      return bundle.getResource(name);
+   }
+
+   @SuppressWarnings("unchecked")
+   public Enumeration getResources(String name) throws IOException
+   {
+      return bundle.getResources(name);
+   }
+
+   public ServiceReference[] getServicesInUse()
+   {
+      return bundle.getServicesInUse();
+   }
+
+   @SuppressWarnings("unchecked")
+   public Map getSignerCertificates(int signersType)
+   {
+      return bundle.getSignerCertificates(signersType);
+   }
+
+   public int getState()
+   {
+      return bundle.getState();
+   }
+
+   public String getSymbolicName()
+   {
+      return bundle.getSymbolicName();
+   }
+
+   public Version getVersion()
+   {
+      return bundle.getVersion();
+   }
+
+   public boolean hasPermission(Object permission)
+   {
+      return bundle.hasPermission(permission);
+   }
+
+   @SuppressWarnings("unchecked")
+   public Class loadClass(String name) throws ClassNotFoundException
+   {
+      return bundle.loadClass(name);
+   }
+
+   public void start() throws BundleException
+   {
+      bundle.start();
+   }
+
+   public void start(int options) throws BundleException
+   {
+      bundle.start(options);
+   }
+
+   public void stop() throws BundleException
+   {
+      bundle.stop();
+   }
+
+   public void stop(int options) throws BundleException
+   {
+      bundle.stop(options);
+   }
+
+   public void uninstall() throws BundleException
+   {
+      bundle.uninstall();
+   }
+
+   public void update() throws BundleException
+   {
+      bundle.update();
+   }
+
+   public void update(InputStream input) throws BundleException
+   {
+      bundle.update(input);
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/BundleWrapper.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkIntegration.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkIntegration.java	2009-10-16 07:42:55 UTC (rev 95009)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkIntegration.java	2009-10-16 07:51:11 UTC (rev 95010)
@@ -32,30 +32,29 @@
 import org.jboss.logging.Logger;
 import org.jboss.osgi.spi.FrameworkException;
 import org.jboss.osgi.spi.logging.ExportedPackageHelper;
-import org.jboss.osgi.spi.util.ServiceLoader;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.launch.Framework;
-import org.osgi.framework.launch.FrameworkFactory;
 
 /**
- * An abstraction of an OSGi Framework
+ * An abstraction of an OSGi Framework.
  * 
+ * In addition to the standard {@link Framework} this implementation also
+ * supports properties and initial bundle provisioning.
+ * 
  * @author thomas.diesler at jboss.com
  * @since 23-Jan-2009
  */
-public class FrameworkIntegration
+public abstract class FrameworkIntegration
 {
    // Provide logging
    final Logger log = Logger.getLogger(FrameworkIntegration.class);
 
-   protected Map<String, Object> properties = new HashMap<String, Object>();
-   protected List<URL> autoInstall = new ArrayList<URL>();
-   protected List<URL> autoStart = new ArrayList<URL>();
+   private Map<String, Object> properties = new HashMap<String, Object>();
+   private List<URL> autoInstall = new ArrayList<URL>();
+   private List<URL> autoStart = new ArrayList<URL>();
 
-   protected Framework framework;
-
    public Map<String, Object> getProperties()
    {
       return properties;
@@ -86,22 +85,27 @@
       this.autoStart = autoStart;
    }
 
+   /** Overwrite to create the framework */
+   protected abstract void createFramework(Map<String, Object> properties);
+
+   /** Overwrite to provide the framework */
+   protected abstract Framework getFramework();
+   
    public Bundle getBundle()
    {
       assertFrameworkStart();
-      return framework;
+      return getFramework();
    }
 
    public BundleContext getBundleContext()
    {
-      return getBundle().getBundleContext();
+      assertFrameworkStart();
+      return getFramework().getBundleContext();
    }
 
    public void create()
    {
-      // Load the framework instance
-      FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
-      framework = factory.newFramework(properties);
+      createFramework(properties);
    }
 
    public void start()
@@ -112,7 +116,7 @@
       // Start the System Bundle
       try
       {
-         framework.start();
+         getFramework().start();
       }
       catch (BundleException ex)
       {
@@ -120,7 +124,7 @@
       }
       
       // Get system bundle context
-      BundleContext context = framework.getBundleContext();
+      BundleContext context = getFramework().getBundleContext();
       if (context == null)
          throw new FrameworkException("Cannot obtain system context");
 
@@ -176,6 +180,7 @@
 
    public void stop()
    {
+      Framework framework = getFramework();
       if (framework != null)
       {
          try
@@ -198,14 +203,14 @@
 
    private void assertFrameworkCreate()
    {
-      if (framework == null)
+      if (getFramework() == null)
          create();
    }
 
    private void assertFrameworkStart()
    {
       assertFrameworkCreate();
-      if ((framework.getState() & Bundle.ACTIVE) == 0)
+      if ((getFramework().getState() & Bundle.ACTIVE) == 0)
          start();
    }
 }
\ No newline at end of file

Added: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkWrapper.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkWrapper.java	                        (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkWrapper.java	2009-10-16 07:51:11 UTC (rev 95010)
@@ -0,0 +1,208 @@
+/*
+ * 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.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * A generic Framework wrapper that delegates all method calls to the underlying 
+ * Framework implementation.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 16-Oct-2009
+ */
+public class FrameworkWrapper implements Framework
+{
+   // Provide logging
+   final Logger log = Logger.getLogger(FrameworkWrapper.class);
+
+   protected Framework framework;
+
+   public FrameworkWrapper(Framework framework)
+   {
+      if (framework == null)
+         throw new IllegalArgumentException("Null framework");
+      this.framework = framework;
+   }
+
+   @SuppressWarnings("unchecked")
+   public Enumeration findEntries(String arg0, String arg1, boolean arg2)
+   {
+      return framework.findEntries(arg0, arg1, arg2);
+   }
+
+   public BundleContext getBundleContext()
+   {
+      return framework.getBundleContext();
+   }
+
+   public long getBundleId()
+   {
+      return framework.getBundleId();
+   }
+
+   public URL getEntry(String arg0)
+   {
+      return framework.getEntry(arg0);
+   }
+
+   @SuppressWarnings("unchecked")
+   public Enumeration getEntryPaths(String arg0)
+   {
+      return framework.getEntryPaths(arg0);
+   }
+
+   @SuppressWarnings("unchecked")
+   public Dictionary getHeaders()
+   {
+      return framework.getHeaders();
+   }
+
+   @SuppressWarnings("unchecked")
+   public Dictionary getHeaders(String arg0)
+   {
+      return framework.getHeaders(arg0);
+   }
+
+   public long getLastModified()
+   {
+      return framework.getLastModified();
+   }
+
+   public String getLocation()
+   {
+      return framework.getLocation();
+   }
+
+   public ServiceReference[] getRegisteredServices()
+   {
+      return framework.getRegisteredServices();
+   }
+
+   public URL getResource(String arg0)
+   {
+      return framework.getResource(arg0);
+   }
+
+   @SuppressWarnings("unchecked")
+   public Enumeration getResources(String arg0) throws IOException
+   {
+      return framework.getResources(arg0);
+   }
+
+   public ServiceReference[] getServicesInUse()
+   {
+      return framework.getServicesInUse();
+   }
+
+   @SuppressWarnings("unchecked")
+   public Map getSignerCertificates(int arg0)
+   {
+      return framework.getSignerCertificates(arg0);
+   }
+
+   public int getState()
+   {
+      return framework.getState();
+   }
+
+   public String getSymbolicName()
+   {
+      return framework.getSymbolicName();
+   }
+
+   public Version getVersion()
+   {
+      return framework.getVersion();
+   }
+
+   public boolean hasPermission(Object arg0)
+   {
+      return framework.hasPermission(arg0);
+   }
+
+   public void init() throws BundleException
+   {
+      framework.init();
+   }
+
+   @SuppressWarnings("unchecked")
+   public Class loadClass(String arg0) throws ClassNotFoundException
+   {
+      return framework.loadClass(arg0);
+   }
+
+   public void start() throws BundleException
+   {
+      framework.start();
+   }
+
+   public void start(int arg0) throws BundleException
+   {
+      framework.start(arg0);
+   }
+
+   public void stop() throws BundleException
+   {
+      framework.stop();
+   }
+
+   public void stop(int arg0) throws BundleException
+   {
+      framework.stop(arg0);
+   }
+
+   public void uninstall() throws BundleException
+   {
+      framework.uninstall();
+   }
+
+   public void update() throws BundleException
+   {
+      framework.update();
+   }
+
+   public void update(InputStream arg0) throws BundleException
+   {
+      framework.update(arg0);
+   }
+
+   public FrameworkEvent waitForStop(long arg0) throws InterruptedException
+   {
+      return framework.waitForStop(arg0);
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkWrapper.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml	2009-10-16 07:42:55 UTC (rev 95009)
+++ projects/jboss-osgi/trunk/pom.xml	2009-10-16 07:51:11 UTC (rev 95010)
@@ -63,7 +63,7 @@
     <version.jboss.osgi.microcontainer>1.0.2</version.jboss.osgi.microcontainer>
     <version.jboss.osgi.runtime.deployers>1.0.2</version.jboss.osgi.runtime.deployers>
     <version.jboss.osgi.runtime.equinox>3.5</version.jboss.osgi.runtime.equinox>
-    <version.jboss.osgi.runtime.felix>2.0.0</version.jboss.osgi.runtime.felix>
+    <version.jboss.osgi.runtime.felix>2.0.0-SNAPSHOT</version.jboss.osgi.runtime.felix>
     <version.jboss.osgi.runtime.jbossas>1.0.1</version.jboss.osgi.runtime.jbossas>
     <version.jboss.osgi.spi>1.0.3-SNAPSHOT</version.jboss.osgi.spi>
     <version.jboss.osgi.webconsole>1.0.2</version.jboss.osgi.webconsole>




More information about the jboss-cvs-commits mailing list