[jboss-osgi-commits] JBoss-OSGI SVN: r97172 - in projects/jboss-osgi/projects/bundles/husky/trunk: .settings and 2 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Mon Nov 30 11:06:26 EST 2009


Author: thomas.diesler at jboss.com
Date: 2009-11-30 11:06:26 -0500 (Mon, 30 Nov 2009)
New Revision: 97172

Added:
   projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiBundleImpl.java
Modified:
   projects/jboss-osgi/projects/bundles/husky/trunk/.classpath
   projects/jboss-osgi/projects/bundles/husky/trunk/.project
   projects/jboss-osgi/projects/bundles/husky/trunk/.settings/org.eclipse.jdt.core.prefs
   projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java
   projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
   projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java
   projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
   projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
Log:
Delegate OSGiBundle.uninstall() to DeployerService

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/.classpath
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/.classpath	2009-11-30 16:04:13 UTC (rev 97171)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/.classpath	2009-11-30 16:06:26 UTC (rev 97172)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry kind="src" path="src/main/java"/>
-	<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
 	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
 	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
 	<classpathentry kind="output" path="target/classes"/>

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/.project
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/.project	2009-11-30 16:04:13 UTC (rev 97171)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/.project	2009-11-30 16:06:26 UTC (rev 97172)
@@ -6,13 +6,8 @@
 	</projects>
 	<buildSpec>
 		<buildCommand>
-			<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
-			<triggers>full,incremental,</triggers>
+			<name>org.eclipse.jdt.core.javabuilder</name>
 			<arguments>
-				<dictionary>
-					<key>LaunchConfigHandle</key>
-					<value>&lt;project&gt;/.externalToolBuilders/org.eclipse.jdt.core.javabuilder.launch</value>
-				</dictionary>
 			</arguments>
 		</buildCommand>
 		<buildCommand>
@@ -22,7 +17,7 @@
 		</buildCommand>
 	</buildSpec>
 	<natures>
-		<nature>org.eclipse.jdt.core.javanature</nature>
 		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
 	</natures>
 </projectDescription>

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/.settings/org.eclipse.jdt.core.prefs	2009-11-30 16:04:13 UTC (rev 97171)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/.settings/org.eclipse.jdt.core.prefs	2009-11-30 16:06:26 UTC (rev 97172)
@@ -1,5 +1,6 @@
-#Fri May 15 00:24:23 CEST 2009
+#Mon Nov 30 15:53:56 CET 2009
 eclipse.preferences.version=1
 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
 org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
 org.eclipse.jdt.core.compiler.source=1.5

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java	2009-11-30 16:04:13 UTC (rev 97171)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java	2009-11-30 16:06:26 UTC (rev 97172)
@@ -51,6 +51,11 @@
    public abstract Version getVersion();
    
    /**
+    * Returns this bundle's location.
+    */
+   public abstract String getLocation();
+   
+   /**
     * Returns this bundle's Manifest headers and values.
     */
    public abstract Dictionary<String, String> getHeaders();

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java	2009-11-30 16:04:13 UTC (rev 97171)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java	2009-11-30 16:06:26 UTC (rev 97172)
@@ -174,7 +174,7 @@
       throw new IllegalArgumentException("Cannot obtain '" + testArchiveDir + "/" + archive + "'.");
    }
 
-   @SuppressWarnings("unchecked")
+   @SuppressWarnings({ "unchecked", "rawtypes" })
    public InitialContext getInitialContext() throws NamingException
    {
       String port = System.getProperty("jndi.server.port", "1099");

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java	2009-11-30 16:04:13 UTC (rev 97171)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java	2009-11-30 16:06:26 UTC (rev 97172)
@@ -21,13 +21,18 @@
  */
 package org.jboss.osgi.testing.internal;
 
+import java.net.URL;
 import java.util.Dictionary;
 
+import org.jboss.osgi.deployment.deployer.DeployerService;
 import org.jboss.osgi.spi.util.ExportedPackageHelper;
-import org.jboss.osgi.testing.OSGiBundle;
 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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * An OSGi Test Case
@@ -35,14 +40,16 @@
  * @author Thomas.Diesler at jboss.org
  * @since 25-Sep-2008
  */
-public class EmbeddedBundle extends OSGiBundle
+public class EmbeddedBundle extends OSGiBundleImpl
 {
-   private OSGiRuntimeImpl runtime;
+   // Provide logging
+   private final Logger log = LoggerFactory.getLogger(EmbeddedBundle.class);
+   
    private Bundle bundle;
 
    public EmbeddedBundle(OSGiRuntimeImpl runtime, Bundle bundle)
    {
-      this.runtime = runtime;
+      super(runtime);
       this.bundle = bundle;
    }
 
@@ -70,6 +77,12 @@
    }
 
    @Override
+   public String getLocation()
+   {
+      return bundle.getLocation();
+   }
+
+   @Override
    @SuppressWarnings("unchecked")
    public Dictionary<String, String> getHeaders()
    {
@@ -106,7 +119,31 @@
    @Override
    public void uninstall() throws BundleException
    {
-      bundle.uninstall();
-      runtime.unregisterBundle(this);
+      assertNotUninstalled();
+      try
+      {
+         BundleContext context = bundle.getBundleContext();
+         ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
+         if (sref != null)
+         {
+            DeployerService service = (DeployerService)context.getService(sref);
+            service.undeploy(new URL(getLocation()));
+         }
+         else
+         {
+            bundle.uninstall();
+         }
+         getRuntime().unregisterBundle(this);
+         setUninstalled(true);
+      }
+      catch (RuntimeException rte)
+      {
+         throw rte;
+      }
+      catch (Exception ex)
+      {
+         log.error("Cannot uninstall: " + getLocation(), ex);
+      }
    }
+
 }

Added: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiBundleImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiBundleImpl.java	                        (rev 0)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiBundleImpl.java	2009-11-30 16:06:26 UTC (rev 97172)
@@ -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.osgi.testing.internal;
+
+// $Id$
+
+import org.jboss.osgi.testing.OSGiBundle;
+
+/**
+ * An abstract implementation of a {@link OSGiBundle}
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public abstract class OSGiBundleImpl extends OSGiBundle
+{
+   private OSGiRuntimeImpl runtime;
+   private boolean uninstalled;
+   
+   OSGiBundleImpl(OSGiRuntimeImpl runtime)
+   {
+      this.runtime = runtime;
+   }
+
+   OSGiRuntimeImpl getRuntime()
+   {
+      return runtime;
+   }
+
+   boolean isUninstalled()
+   {
+      return uninstalled;
+   }
+
+   void setUninstalled(boolean uninstalled)
+   {
+      this.uninstalled = uninstalled;
+   }
+
+   void assertNotUninstalled()
+   {
+      if (uninstalled == true)
+         throw new IllegalStateException("Bundle already uninstalled: " + getLocation());
+   }
+}


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

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java	2009-11-30 16:04:13 UTC (rev 97171)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java	2009-11-30 16:06:26 UTC (rev 97172)
@@ -165,16 +165,14 @@
       log.debug("End Shutdown");
    }
 
-   protected void deploy(String location) throws Exception
+   protected void deploy(URL archiveURL) throws Exception
    {
-      URL archiveURL = getTestHelper().getTestArchiveURL(location);
       DeployerServiceClient deployer = new DeployerServiceClient(DeployerService.MBEAN_DEPLOYER_SERVICE);
       deployer.deploy(archiveURL);
    }
 
-   protected void undeploy(String location) throws Exception
+   protected void undeploy(URL archiveURL) throws Exception
    {
-      URL archiveURL = getTestHelper().getTestArchiveURL(location);
       DeployerServiceClient deployer = new DeployerServiceClient(DeployerService.MBEAN_DEPLOYER_SERVICE);
       deployer.undeploy(archiveURL);
    }

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java	2009-11-30 16:04:13 UTC (rev 97171)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java	2009-11-30 16:06:26 UTC (rev 97172)
@@ -23,6 +23,7 @@
 
 // $Id$
 
+import java.net.URL;
 import java.util.Dictionary;
 
 import org.jboss.osgi.spi.management.ManagedBundleMBean;
@@ -40,14 +41,12 @@
  * @author Thomas.Diesler at jboss.org
  * @since 25-Sep-2008
  */
-public class RemoteBundle extends OSGiBundle
+public class RemoteBundle extends OSGiBundleImpl
 {
    // Provide logging
    private final Logger log = LoggerFactory.getLogger(RemoteBundle.class);
    
-   private OSGiRuntimeImpl runtime;
    private ManagedBundleMBean bundle;
-   private boolean uninstalled;
    private String location;
 
    private long bundleId;
@@ -56,7 +55,7 @@
    
    public RemoteBundle(OSGiRuntimeImpl runtime, ManagedBundleMBean bundle, String location)
    {
-      this.runtime = runtime;
+      super(runtime);
       this.bundle = bundle;
       this.location = location;
       
@@ -70,7 +69,7 @@
    @Override
    public int getState()
    {
-      return (uninstalled == true ? Bundle.UNINSTALLED : bundle.getState());
+      return (isUninstalled() ? Bundle.UNINSTALLED : bundle.getState());
    }
 
    @Override
@@ -92,6 +91,12 @@
    }
 
    @Override
+   public String getLocation()
+   {
+      return location;
+   }
+
+   @Override
    public Dictionary<String, String> getHeaders()
    {
       assertNotUninstalled();
@@ -125,9 +130,9 @@
       assertNotUninstalled();
       try
       {
-         runtime.undeploy(location);
-         runtime.unregisterBundle(this);
-         uninstalled = true;
+         getRuntime().undeploy(new URL(getLocation()));
+         getRuntime().unregisterBundle(this);
+         setUninstalled(true);
       }
       catch (RuntimeException rte)
       {
@@ -135,13 +140,7 @@
       }
       catch (Exception ex)
       {
-         log.error("Cannot uninstall: " + location, ex);
+         log.error("Cannot uninstall: " + getLocation(), ex);
       }
    }
-
-   private void assertNotUninstalled()
-   {
-      if (uninstalled == true)
-         throw new IllegalStateException("Bundle already uninstalled: " + location);
-   }
 }



More information about the jboss-osgi-commits mailing list