[jboss-cvs] JBossAS SVN: r89471 - in projects/jboss-osgi/trunk: bundles and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed May 27 11:31:37 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-05-27 11:31:37 -0400 (Wed, 27 May 2009)
New Revision: 89471

Added:
   projects/jboss-osgi/trunk/bundles/hotdeploy/
   projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/
   projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/BundleInfo.java
   projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/DeploymentScanner.java
   projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/
   projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerHelper.java
   projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java
   projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/HotDeployActivator.java
   projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/ScannerThread.java
Removed:
   projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/logging/
Modified:
   projects/jboss-osgi/trunk/blueprint/pom.xml
   projects/jboss-osgi/trunk/bundles/hotdeploy/pom.xml
   projects/jboss-osgi/trunk/bundles/jndi/pom.xml
   projects/jboss-osgi/trunk/bundles/pom.xml
   projects/jboss-osgi/trunk/testsuite/pom.xml
Log:
Add hot deployment

Modified: projects/jboss-osgi/trunk/blueprint/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/blueprint/pom.xml	2009-05-27 15:27:22 UTC (rev 89470)
+++ projects/jboss-osgi/trunk/blueprint/pom.xml	2009-05-27 15:31:37 UTC (rev 89471)
@@ -50,7 +50,7 @@
 
     <!--
       Name: framework-knopflerfish
-      Descr: Setup for Equinox framework integration testing
+      Descr: Setup for Knopflerfish framework integration testing
     -->
     <profile>
       <id>framework-knopflerfish</id>

Copied: projects/jboss-osgi/trunk/bundles/hotdeploy (from rev 89459, projects/jboss-osgi/trunk/bundles/logging)

Modified: projects/jboss-osgi/trunk/bundles/hotdeploy/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundles/logging/pom.xml	2009-05-27 09:46:37 UTC (rev 89459)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/pom.xml	2009-05-27 15:31:37 UTC (rev 89471)
@@ -2,13 +2,13 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
-  <name>JBossOSGi Bundles - Logging</name>
+  <name>JBossOSGi Bundles - HotDeployment</name>
 
   <groupId>org.jboss.osgi.bundles</groupId>
-  <artifactId>jboss-osgi-logging</artifactId>
+  <artifactId>jboss-osgi-hotdeploy</artifactId>
   <packaging>bundle</packaging>
 
-  <version>1.0.0.Beta2</version>
+  <version>1.0.0</version>
   
   <!-- Parent -->
   <parent>
@@ -19,9 +19,11 @@
 
   <!-- Dependencies -->
   <dependencies>
+    
+    <!-- Bundle dependencies -->
     <dependency>
-      <groupId>org.jboss.logging</groupId>
-      <artifactId>jboss-logging-spi</artifactId>
+      <groupId>org.jboss.osgi.bundles</groupId>
+      <artifactId>jboss-osgi-common</artifactId>
       <scope>provided</scope>
     </dependency>
     
@@ -47,10 +49,13 @@
         <configuration>
           <instructions>
             <Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
-            <Bundle-Activator>org.jboss.osgi.service.logging.LoggingActivator</Bundle-Activator>
-            <Private-Package>org.jboss.osgi.service.logging</Private-Package>
+            <Bundle-Activator>org.jboss.osgi.service.hotdeploy.internal.HotDeployActivator</Bundle-Activator>
+            <Private-Package>org.jboss.osgi.service.hotdeploy.internal</Private-Package>
+            <Export-Package>
+              org.jboss.osgi.service.hotdeploy;version=${version}
+            </Export-Package>
             <Import-Package>
-               org.jboss.logging,
+               org.jboss.osgi.common.log,
                org.osgi.framework,
                org.osgi.service.log,
                org.osgi.util.tracker

Added: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/BundleInfo.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/BundleInfo.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/BundleInfo.java	2009-05-27 15:31:37 UTC (rev 89471)
@@ -0,0 +1,111 @@
+/*
+ * 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.service.hotdeploy;
+
+import java.net.URL;
+
+import org.osgi.framework.Bundle;
+
+//$Id$
+
+/**
+ * An abstraction of a bundle in the scan folder
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 27-May-2009
+ */
+public class BundleInfo
+{
+   public enum State
+   {
+      NEW, INSTALLED, ACTIVE, UNINSTALLED
+   };
+
+   private URL location;
+   private String symbolicName;
+   private State state;
+
+   public BundleInfo(URL bundleURL, String symbolicName, Bundle bundle)
+   {
+      this.symbolicName = symbolicName;
+      this.location = bundleURL;
+      this.state = State.NEW;
+
+      if (bundle != null)
+      {
+         int bundleState = bundle.getState();
+         switch (bundleState)
+         {
+            case Bundle.INSTALLED:
+            case Bundle.RESOLVED:
+            case Bundle.STARTING:
+            case Bundle.STOPPING:
+               state = State.INSTALLED;
+               break;
+               
+            case Bundle.ACTIVE:
+               state = State.ACTIVE;
+               break;
+               
+            case Bundle.UNINSTALLED:
+               state = State.UNINSTALLED;
+               break;
+         }
+      }
+   }
+
+   public URL getLocation()
+   {
+      return location;
+   }
+
+   public State getState()
+   {
+      return state;
+   }
+
+   public String getSymbolicName()
+   {
+      return symbolicName;
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if ((obj instanceof BundleInfo) == false)
+         return false;
+      
+      BundleInfo other = (BundleInfo)obj;
+      return symbolicName.equals(other.symbolicName);
+   }
+
+   @Override
+   public int hashCode()
+   {
+      return toString().hashCode();
+   }
+
+   public String toString()
+   {
+      return "[" + state + "," + symbolicName + "]";
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/BundleInfo.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/DeploymentScanner.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/DeploymentScanner.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/DeploymentScanner.java	2009-05-27 15:31:37 UTC (rev 89471)
@@ -0,0 +1,73 @@
+/*
+ * 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.service.hotdeploy;
+
+//$Id$
+
+import java.net.URL;
+
+/**
+ * The DeploymentScanner service 
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 27-May-2009
+ */
+public interface DeploymentScanner
+{
+   /**
+    * The property that names the scan location: org.jboss.osgi.hotdeploy.scan
+    */
+   String PROPERTY_SCAN_LOCATION = "org.jboss.osgi.hotdeploy.scan";
+   
+   /**
+    * The property to defines the scan interval: org.jboss.osgi.hotdeploy.interval
+    */
+   String PROPERTY_SCAN_INTERVAL = "org.jboss.osgi.hotdeploy.interval";
+   
+   /**
+    * Get the scan location URL.
+    *  
+    * This is can be specified by setting the {@link PROPERTY_SCAN_LOCATION} property. 
+    */
+   URL getScanLocation();
+   
+   /**
+    * The number of scans since the service started 
+    */
+   long getScanCount();
+   
+   /**
+    * The number of milliseconds between scans
+    * Defaults to 2000ms 
+    */
+   long getScanInterval();
+   
+   /**
+    * Run a directory scan
+    */
+   void scan();
+   
+   /**
+    * Returns the array of bundles currently known to the deployemtn scanner. 
+    */
+   BundleInfo[] getBundles();
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/DeploymentScanner.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerHelper.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerHelper.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerHelper.java	2009-05-27 15:31:37 UTC (rev 89471)
@@ -0,0 +1,153 @@
+/*
+ * 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.service.hotdeploy.internal;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.jboss.osgi.common.log.LogServiceTracker;
+import org.jboss.osgi.service.hotdeploy.BundleInfo;
+import org.jboss.osgi.service.hotdeploy.DeploymentScanner;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.service.log.LogService;
+
+/**
+ * A DeploymentScanner helper
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 27-May-2009
+ */
+public class DeploymentScannerHelper
+{
+   private LogServiceTracker log;
+   private BundleContext context;
+   private DeploymentScanner scanner;
+   private List<BundleInfo> lastScan;
+
+   public DeploymentScannerHelper(BundleContext context, DeploymentScanner scanner)
+   {
+      this.log = new LogServiceTracker(context);
+      this.context = context;
+      this.scanner = scanner;
+      
+      this.lastScan = Arrays.asList(scanner.getBundles());
+   }
+
+   public void scan()
+   {
+      List<BundleInfo> currScan = Arrays.asList(scanner.getBundles());
+      
+      processNewDeployments(currScan);
+      processOldDeployments(currScan);
+
+      lastScan = currScan;
+   }
+
+   static Bundle getInstalledBundle(BundleContext context, String symbolicName)
+   {
+      Bundle bundle = null;
+
+      for (Bundle aux : context.getBundles())
+      {
+         if (aux.getSymbolicName().equals(symbolicName))
+         {
+            bundle = aux;
+            break;
+         }
+      }
+
+      return bundle;
+   }
+
+   private void processNewDeployments(List<BundleInfo> currScan)
+   {
+      List<BundleInfo> diff = new ArrayList<BundleInfo>();
+
+      // Detect NEW bundles that are not in the last scan  
+      for (BundleInfo info : currScan)
+      {
+         if (lastScan.contains(info) == false)
+            diff.add(info);
+      }
+
+      for (BundleInfo info : diff)
+      {
+         if (info.getState() == BundleInfo.State.NEW)
+         {
+            Bundle bundle = null;
+            try
+            {
+               log.log(LogService.LOG_INFO, "Install: " + info.getSymbolicName());
+               bundle = context.installBundle(info.getLocation().toExternalForm());
+            }
+            catch (BundleException ex)
+            {
+               log.log(LogService.LOG_ERROR, "Cannot install bundle", ex);
+            }
+
+            if (bundle != null)
+            {
+               try
+               {
+                  log.log(LogService.LOG_INFO, "Start: " + info.getSymbolicName());
+                  bundle.start();
+               }
+               catch (BundleException ex)
+               {
+                  log.log(LogService.LOG_ERROR, "Cannot start bundle", ex);
+               }
+            }
+         }
+      }
+   }
+
+   private void processOldDeployments(List<BundleInfo> currScan)
+   {
+      List<BundleInfo> diff = new ArrayList<BundleInfo>();
+
+      // Detect OLD bundles that are not in the current scan  
+      for (BundleInfo info : lastScan)
+      {
+         if (currScan.contains(info) == false)
+            diff.add(info);
+      }
+
+      for (BundleInfo info : diff)
+      {
+         Bundle bundle = getInstalledBundle(context, info.getSymbolicName());
+         try
+         {
+            log.log(LogService.LOG_INFO, "Uninstall: " + info.getSymbolicName());
+            bundle.uninstall();
+         }
+         catch (BundleException ex)
+         {
+            log.log(LogService.LOG_ERROR, "Cannot uninstall bundle", ex);
+         }
+      }
+   }
+}
\ No newline at end of file


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

Added: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java	2009-05-27 15:31:37 UTC (rev 89471)
@@ -0,0 +1,195 @@
+/*
+ * 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.service.hotdeploy.internal;
+
+//$Id$
+
+import static org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.jboss.osgi.service.hotdeploy.BundleInfo;
+import org.jboss.osgi.service.hotdeploy.DeploymentScanner;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The DeploymentScanner service
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 27-May-2009
+ */
+public class DeploymentScannerImpl implements DeploymentScanner
+{
+   private BundleContext context;
+
+   private long scanInterval;
+   private File scanLocation;
+   private long scanCount;
+
+   private ScannerThread scannerThread;
+   private DeploymentScannerHelper scanHelper;
+
+   public DeploymentScannerImpl(BundleContext context)
+   {
+      this.context = context;
+
+      initScanner(context);
+   }
+
+   public void start()
+   {
+      scanHelper = new DeploymentScannerHelper(context, this);
+      scannerThread = new ScannerThread(context, this);
+      scannerThread.start();
+   }
+
+   public void stop()
+   {
+      if (scannerThread != null)
+      {
+         scannerThread.stopScan();
+         scannerThread = null;
+      }
+   }
+
+   public void scan()
+   {
+      scanHelper.scan();
+      scanCount++;
+   }
+
+   public BundleInfo[] getBundles()
+   {
+      List<BundleInfo> bundles = new ArrayList<BundleInfo>();
+      for (File file : scanLocation.listFiles())
+      {
+         String symbolicName = getSymbolicName(file);
+         Bundle bundle = DeploymentScannerHelper.getInstalledBundle(context, symbolicName);
+         BundleInfo bundleInfo = new BundleInfo(toURL(file), symbolicName, bundle);
+         bundles.add(bundleInfo);
+      }
+      BundleInfo[] arr = new BundleInfo[bundles.size()];
+      return bundles.toArray(arr);
+   }
+
+   public long getScanCount()
+   {
+      return scanCount;
+   }
+
+   public long getScanInterval()
+   {
+      return scanInterval;
+   }
+
+   public URL getScanLocation()
+   {
+      return toURL(scanLocation.getAbsolutePath());
+   }
+
+   private void initScanner(BundleContext context)
+   {
+      scanInterval = 2000;
+      
+      String interval = context.getProperty(PROPERTY_SCAN_INTERVAL);
+      if (interval != null)
+         scanInterval = new Long(interval);
+      
+      String scanLoc = context.getProperty(PROPERTY_SCAN_LOCATION);
+      if (scanLoc == null)
+         throw new IllegalStateException("Cannot obtain value for property: '" + PROPERTY_SCAN_LOCATION + "'");
+
+      // Check if the prop is already an URL
+      try
+      {
+         URL scanURL = new URL(scanLoc);
+         scanLocation = new File(scanURL.getPath());
+      }
+      catch (MalformedURLException ex)
+      {
+         // ignore
+      }
+
+      // Check if the prop is an existing dir
+      File scanFile = new File(scanLoc);
+      if (scanFile.exists() == false)
+         throw new IllegalStateException("Scan location does not exist: " + scanLoc);
+
+      // Check if the scan location is a directory
+      if (scanFile.isDirectory() == false)
+         throw new IllegalStateException("Scan location is not a directory: " + scanLoc);
+
+      scanLocation = scanFile;
+   }
+
+   private String getSymbolicName(File file)
+   {
+      try
+      {
+         JarFile jarFile = new JarFile(file);
+         Manifest manifest = jarFile.getManifest();
+         Attributes attribs = manifest.getMainAttributes();
+         String symbolicName = attribs.getValue(BUNDLE_SYMBOLICNAME);
+         if (symbolicName == null)
+            throw new IllegalStateException("Cannot obtain '" + BUNDLE_SYMBOLICNAME + "' from: " + file);
+
+         return symbolicName;
+      }
+      catch (IOException ex)
+      {
+         throw new IllegalStateException("Cannot obtain '" + BUNDLE_SYMBOLICNAME + "' from: " + file, ex);
+      }
+   }
+
+   private URL toURL(File file)
+   {
+      try
+      {
+         return file.toURL();
+      }
+      catch (MalformedURLException ex)
+      {
+         throw new IllegalArgumentException("Invalid URL: " + file);
+      }
+   }
+
+   private URL toURL(String urlStr)
+   {
+      try
+      {
+         return new URL(urlStr);
+      }
+      catch (MalformedURLException ex)
+      {
+         throw new IllegalArgumentException("Invalid URL: " + urlStr);
+      }
+   }
+}
\ No newline at end of file


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

Copied: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/HotDeployActivator.java (from rev 89459, projects/jboss-osgi/trunk/bundles/logging/src/main/java/org/jboss/osgi/service/logging/LoggingActivator.java)
===================================================================
--- projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/HotDeployActivator.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/HotDeployActivator.java	2009-05-27 15:31:37 UTC (rev 89471)
@@ -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.service.hotdeploy.internal;
+
+//$Id$
+
+import org.jboss.osgi.service.hotdeploy.DeploymentScanner;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The {@link DeploymentScanner} service activator
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 27-May-2009
+ */
+public class HotDeployActivator implements BundleActivator
+{
+   private DeploymentScannerImpl service;
+   
+   public void start(BundleContext context)
+   {
+      service = new DeploymentScannerImpl(context);
+      context.registerService(DeploymentScanner.class.getName(), service, null);
+      
+      service.start();
+   }
+
+   public void stop(BundleContext context)
+   {
+      if (service != null)
+      {
+         service.stop();
+         service = null;
+      }
+   }
+}
\ No newline at end of file

Added: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/ScannerThread.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/ScannerThread.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/ScannerThread.java	2009-05-27 15:31:37 UTC (rev 89471)
@@ -0,0 +1,79 @@
+/*
+ * 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.service.hotdeploy.internal;
+
+//$Id$
+
+import org.jboss.osgi.common.log.LogServiceTracker;
+import org.jboss.osgi.service.hotdeploy.DeploymentScanner;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+/**
+ * A simple scanner thread
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 27-May-2009
+ */
+public class ScannerThread extends Thread
+{
+   private LogService log;
+   
+   private DeploymentScanner scanner;
+   private boolean active = true;
+
+   public ScannerThread(BundleContext context, DeploymentScanner scanner)
+   {
+      this.log = new LogServiceTracker(context);
+      this.scanner = scanner;
+   }
+
+   @Override
+   public void run()
+   {
+      try
+      {
+         while (active == true)
+         {
+            sleep(scanner.getScanInterval());
+            try
+            {
+               scanner.scan();
+            }
+            catch (RuntimeException ex)
+            {
+               log.log(LogService.LOG_ERROR, "Hot deployment error", ex);
+            }
+         }
+      }
+      catch (InterruptedException ex)
+      {
+         // ignore
+      }
+   }
+
+   public void stopScan()
+   {
+      active = false;
+      interrupt();
+   }
+}
\ No newline at end of file


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

Modified: projects/jboss-osgi/trunk/bundles/jndi/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundles/jndi/pom.xml	2009-05-27 15:27:22 UTC (rev 89470)
+++ projects/jboss-osgi/trunk/bundles/jndi/pom.xml	2009-05-27 15:31:37 UTC (rev 89471)
@@ -42,7 +42,7 @@
       <scope>provided</scope>
     </dependency>
     
-    <!-- Bundles -->
+    <!-- Bundle dependencies -->
     <dependency>
       <groupId>org.jboss.osgi.bundles</groupId>
       <artifactId>jboss-osgi-common</artifactId>

Modified: projects/jboss-osgi/trunk/bundles/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundles/pom.xml	2009-05-27 15:27:22 UTC (rev 89470)
+++ projects/jboss-osgi/trunk/bundles/pom.xml	2009-05-27 15:31:37 UTC (rev 89471)
@@ -21,6 +21,7 @@
     <!-- jboss-osgi -->  
     <module>common</module>
     <module>logging</module>
+    <module>hotdeploy</module>
     <module>jmx</module>
     <module>jndi</module>
     <module>microcontainer</module>

Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml	2009-05-27 15:27:22 UTC (rev 89470)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml	2009-05-27 15:31:37 UTC (rev 89471)
@@ -202,7 +202,7 @@
 
     <!--
       Name: framework-knopflerfish
-      Descr: Setup for Equinox framework integration testing
+      Descr: Setup for Knopflerfish framework integration testing
     -->
     <profile>
       <id>framework-knopflerfish</id>




More information about the jboss-cvs-commits mailing list