| Method from org.jboss.deployment.scanner.AbstractDeploymentScanner Detail: |
protected void createService() throws Exception {
if (deployer == null)
throw new MissingAttributeException("Deployer");
mainDeployer = (MainDeployerMBean)MBeanProxyExt.create(MainDeployerMBean.class, MainDeployerMBean.OBJECT_NAME, server);
// setup + start scanner thread
scannerThread = new ScannerThread(false);
scannerThread.setDaemon(true);
scannerThread.start();
log.debug("Scanner thread started");
// HACK
//
// install a shutdown hook, as the current system service shutdown
// mechanism will not call this until all other services have stopped.
// we need to know soon, so we can stop scanning to try to avoid
// starting new services when shutting down
final ScannerThread _scannerThread = scannerThread;
shutdownHook = new Thread("DeploymentScanner Shutdown Hook")
{
ScannerThread thread = _scannerThread;
public void run()
{
thread.shutdown();
}
};
try
{
Runtime.getRuntime().addShutdownHook(shutdownHook);
}
catch (Exception e)
{
log.warn("Failed to add shutdown hook", e);
}
}
|
protected void destroyService() throws Exception {
// drop our ref to deployer, so scan will fail
deployer = null;
// shutdown scanner thread
if( scannerThread != null )
{
synchronized( scannerThread )
{
scannerThread.shutdown();
}
}
// HACK
//
// remove the shutdown hook, we don't need it anymore
try
{
Runtime.getRuntime().removeShutdownHook(shutdownHook);
}
catch (Exception ignore)
{
} // who cares really
// help gc
shutdownHook = null;
scannerThread = null;
}
|
public ObjectName getDeployer() {
return ((MBeanProxyInstance)deployer).getMBeanProxyObjectName();
}
|
public long getScanPeriod() {
return scanPeriod;
}
|
public long getStopTimeOut() {
return stopTimeOut;
}
|
public boolean isScanEnabled() {
return scanEnabled;
}
|
abstract public void scan() throws Exception
This is here to work around a bug in the IBM vm that causes an
AbstractMethodError to be thrown when the ScannerThread calls scan. |
public void setDeployer(ObjectName deployerName) {
/////////////////////////////////////////////////////////////////////////
// DeploymentScanner //
/////////////////////////////////////////////////////////////////////////
if (deployerName == null)
throw new NullArgumentException("deployerName");
deployer = (Deployer)
MBeanProxyExt.create(Deployer.class, deployerName, server);
}
|
public void setScanEnabled(boolean flag) {
this.scanEnabled = flag;
}
|
public void setScanPeriod(long period) {
if (period < 0)
throw new IllegalArgumentException("ScanPeriod must be >= 0; have: " + period);
this.scanPeriod = period;
}
|
public void setStopTimeOut(long stopTimeOut) {
this.stopTimeOut = stopTimeOut;
}
|
protected void startService() throws Exception {
synchronized( scannerThread )
{
// scan before we enable the thread, so JBoss version shows up afterwards
scannerThread.doScan();
// enable scanner thread if we are enabled
scannerThread.setEnabled(scanEnabled);
}
}
|
protected void stopService() throws Exception {
// disable scanner thread
if( scannerThread != null )
{
scannerThread.setEnabled(false);
scannerThread.waitForInactive();
}
}
|