[jboss-cvs] JBossAS SVN: r95001 - in projects/jboss-osgi: projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 16 00:09:45 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-10-16 00:09:45 -0400 (Fri, 16 Oct 2009)
New Revision: 95001
Modified:
projects/jboss-osgi/projects/bundles/hotdeploy/trunk/pom.xml
projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentScannerService.java
projects/jboss-osgi/trunk/pom.xml
Log:
Remove bootstrap dependency on deployment API
Modified: projects/jboss-osgi/projects/bundles/hotdeploy/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/hotdeploy/trunk/pom.xml 2009-10-16 03:54:25 UTC (rev 95000)
+++ projects/jboss-osgi/projects/bundles/hotdeploy/trunk/pom.xml 2009-10-16 04:09:45 UTC (rev 95001)
@@ -40,11 +40,17 @@
<!-- Properties -->
<properties>
<version.jboss.osgi.common>1.0.2</version.jboss.osgi.common>
+ <version.jboss.osgi.spi>1.0.3-SNAPSHOT</version.jboss.osgi.spi>
<version.osgi>r4v42</version.osgi>
</properties>
<!-- Dependencies -->
<dependencies>
+ <dependency>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-spi</artifactId>
+ <version>${version.jboss.osgi.spi}</version>
+ </dependency>
<!-- Bundle dependencies -->
<dependency>
@@ -82,12 +88,13 @@
<Private-Package>org.jboss.osgi.hotdeploy.internal</Private-Package>
<Import-Package>
javax.management,
- org.jboss.osgi.common.log;version="1.0",
- org.jboss.osgi.spi.service;version="1.0",
- org.jboss.osgi.spi.util;version="1.0",
+ org.jboss.osgi.common.log;version=1.0,
+ org.jboss.osgi.spi.service;version=1.0,
+ org.jboss.osgi.spi.util;version=1.0,
org.osgi.framework,
org.osgi.service.log,
- org.osgi.util.tracker
+ org.osgi.util.tracker,
+ org.slf4j;version=1.5,
</Import-Package>
</instructions>
</configuration>
Modified: projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java 2009-10-16 03:54:25 UTC (rev 95000)
+++ projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java 2009-10-16 04:09:45 UTC (rev 95001)
@@ -31,12 +31,9 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
-import org.jboss.osgi.common.log.LogServiceTracker;
import org.jboss.osgi.spi.service.DeployerService;
import org.jboss.osgi.spi.service.DeploymentScannerService;
import org.jboss.osgi.spi.util.BundleDeployment;
@@ -46,7 +43,8 @@
import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
-import org.osgi.service.log.LogService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The DeploymentScanner service
@@ -56,24 +54,22 @@
*/
public class DeploymentScannerImpl implements DeploymentScannerService
{
- private LogServiceTracker log;
+ private Logger log = LoggerFactory.getLogger(DeploymentScannerImpl.class);
private BundleContext context;
private long scanInterval;
private File scanLocation;
private long scanCount;
+ private long beforeStart;
private long lastChange;
private DeployerService deployer;
private ScannerThread scannerThread;
private List<BundleDeployment> lastScan = new ArrayList<BundleDeployment>();
- private Set<ScanListener> listeners = new LinkedHashSet<ScanListener>();
private Map<String, BundleDeployment> deploymentCache = new HashMap<String, BundleDeployment>();
- private boolean traceBundles = false;
public DeploymentScannerImpl(BundleContext context)
{
- this.log = new LogServiceTracker(context);
this.context = context;
// Get the DeployerService
@@ -110,7 +106,7 @@
if (scandir.startsWith(osgiHome))
scandir = "..." + scandir.substring(osgiHome.length());
- log.log(LogService.LOG_INFO, "Start DeploymentScanner: [scandir=" + scandir + ",interval=" + scanInterval + "ms]");
+ log.info("Start DeploymentScanner: [scandir=" + scandir + ",interval=" + scanInterval + "ms]");
scannerThread = new ScannerThread(context, this);
lastChange = System.currentTimeMillis();
scannerThread.start();
@@ -120,33 +116,17 @@
{
if (scannerThread != null)
{
- log.log(LogService.LOG_INFO, "Stop DeploymentScanner");
+ log.info("Stop DeploymentScanner");
scannerThread.stopScan();
scannerThread = null;
}
}
- public void addScanListener(ScanListener listener)
- {
- listeners.add(listener);
- }
-
- public void removeScanListener(ScanListener listener)
- {
- listeners.remove(listener);
- }
-
public void scan()
{
- // Use a copy so listeners can remove themselves from within the callback
- List<ScanListener> scanListeners = new ArrayList<ScanListener>(listeners);
- for (ScanListener listener : scanListeners)
- listener.beforeScan(this);
-
List<BundleDeployment> currScan = Arrays.asList(getBundleDeployments());
- if (traceBundles)
- logBundleDeployments("Current Scan", currScan);
+ logBundleDeployments("Current Scan", currScan);
int oldDiff = processOldDeployments(currScan);
int newDiff = processNewDeployments(currScan);
@@ -157,16 +137,20 @@
lastScan = currScan;
scanCount++;
- for (ScanListener listener : scanListeners)
- listener.afterScan(this);
+ float diff = (lastChange - beforeStart) / 1000f;
+ if (scanCount == 1)
+ log.info("JBossOSGi Runtime started in " + diff + "sec");
}
private void logBundleDeployments(String message, List<BundleDeployment> bundleDeps)
{
- System.out.println(message);
- for (BundleDeployment dep : bundleDeps)
+ if (log.isTraceEnabled())
{
- System.out.println(" " + dep);
+ log.trace(message);
+ for (BundleDeployment dep : bundleDeps)
+ {
+ log.trace(" " + dep);
+ }
}
}
@@ -196,8 +180,7 @@
}
}
- if (traceBundles)
- logBundleDeployments("OLD diff", diff);
+ logBundleDeployments("OLD diff", diff);
// Undeploy the bundles through the DeployerService
try
@@ -207,7 +190,7 @@
}
catch (Exception ex)
{
- log.log(LogService.LOG_ERROR, "Cannot undeploy bundles", ex);
+ log.error("Cannot undeploy bundles", ex);
}
return diff.size();
@@ -226,8 +209,7 @@
}
}
- if (traceBundles)
- logBundleDeployments("NEW diff", diff);
+ logBundleDeployments("NEW diff", diff);
// Deploy the bundles through the DeployerService
if (diff.size() > 0)
@@ -239,7 +221,7 @@
}
catch (Exception ex)
{
- log.log(LogService.LOG_ERROR, "Cannot deploy bundles", ex);
+ log.error("Cannot deploy bundles", ex);
}
}
@@ -252,7 +234,7 @@
File[] listFiles = scanLocation.listFiles();
if (listFiles == null)
- log.log(LogService.LOG_WARNING, "Cannot list files in: " + scanLocation);
+ log.warn("Cannot list files in: " + scanLocation);
if (listFiles != null)
{
@@ -272,7 +254,7 @@
}
catch (BundleException ex)
{
- log.log(LogService.LOG_WARNING, "Cannot obtain bundle deployment for: " + file);
+ log.warn("Cannot obtain bundle deployment for: " + file);
}
}
bundles.add(dep);
@@ -286,6 +268,7 @@
private void initScanner(BundleContext context)
{
scanInterval = 2000;
+ beforeStart = System.currentTimeMillis();
String interval = context.getProperty(PROPERTY_SCAN_INTERVAL);
if (interval != null)
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-10-16 03:54:25 UTC (rev 95000)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-10-16 04:09:45 UTC (rev 95001)
@@ -38,15 +38,11 @@
import java.util.Properties;
import org.jboss.logging.Logger;
-import org.jboss.osgi.spi.service.DeploymentScannerService;
-import org.jboss.osgi.spi.service.DeploymentScannerService.ScanListener;
import org.jboss.osgi.spi.util.ServiceLoader;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
-import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
-import org.osgi.framework.ServiceReference;
import org.osgi.framework.launch.Framework;
/**
@@ -211,7 +207,6 @@
public void run()
{
// Start the framework
- final long beforeStart = System.currentTimeMillis();
try
{
framework.start();
@@ -220,38 +215,7 @@
{
throw new IllegalStateException("Cannot start framework", ex);
}
- final long afterStart = System.currentTimeMillis();
- // Report how long it took to boot and do the first scan
- BundleContext context = framework.getBundleContext();
- ServiceReference sref = context.getServiceReference(DeploymentScannerService.class.getName());
- if (sref != null)
- {
- DeploymentScannerService scannerService = (DeploymentScannerService)context.getService(sref);
- ScanListener listener = new ScanListener()
- {
- public void beforeScan(DeploymentScannerService service)
- {
- // do nothing
- }
-
- public void afterScan(DeploymentScannerService service)
- {
- long lastChange = service.getLastChange();
- if (lastChange > afterStart)
- {
- float diff = (lastChange - beforeStart) / 1000f;
- log.info("JBossOSGi Runtime started in " + diff + "sec");
- }
- service.removeScanListener(this);
- }
- };
- scannerService.addScanListener(listener);
- }
-
- float diff = (afterStart - beforeStart) / 1000f;
- log.info("JBossOSGi Runtime booted in " + diff + "sec");
-
Reader br = new InputStreamReader(System.in);
try
{
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentScannerService.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentScannerService.java 2009-10-16 03:54:25 UTC (rev 95000)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentScannerService.java 2009-10-16 04:09:45 UTC (rev 95001)
@@ -77,31 +77,4 @@
* Returns the array of bundles currently known to the deployemtn scanner.
*/
BundleDeployment[] getBundleDeployments();
-
- /**
- * Add a scan listener to this service
- */
- void addScanListener(ScanListener listener);
-
- /**
- * Remove the scan listener from this service
- */
- void removeScanListener(ScanListener listener);
-
- /**
- * A ScanListener can be registered with the {@link DeploymentScannerService}
- * to monitor the progress of deployed bundles
- */
- interface ScanListener
- {
- /**
- * Called before every scan
- */
- void beforeScan(DeploymentScannerService service);
-
- /**
- * Called after every scan
- */
- void afterScan(DeploymentScannerService service);
- }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2009-10-16 03:54:25 UTC (rev 95000)
+++ projects/jboss-osgi/trunk/pom.xml 2009-10-16 04:09:45 UTC (rev 95001)
@@ -55,7 +55,7 @@
<version.jboss.osgi.common>1.0.2</version.jboss.osgi.common>
<version.jboss.osgi.common.core>2.2.13.GA</version.jboss.osgi.common.core>
<version.jboss.osgi.framework>1.0.0.Alpha2</version.jboss.osgi.framework>
- <version.jboss.osgi.hotdeploy>1.0.2</version.jboss.osgi.hotdeploy>
+ <version.jboss.osgi.hotdeploy>1.0.3-SNAPSHOT</version.jboss.osgi.hotdeploy>
<version.jboss.osgi.husky>1.0.1</version.jboss.osgi.husky>
<version.jboss.osgi.jaxb>2.1.10.SP2</version.jboss.osgi.jaxb>
<version.jboss.osgi.jmx>1.0.1</version.jboss.osgi.jmx>
More information about the jboss-cvs-commits
mailing list