mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-26 17:29:12 +01:00
fix some bugs and improve logging
This commit is contained in:
@@ -39,6 +39,8 @@ import java.io.File;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
@@ -47,6 +49,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlRootElement(name = "configuration")
|
||||
public class BackendConfiguration
|
||||
{
|
||||
|
||||
@@ -96,6 +96,10 @@ public class DefaultPluginBackend implements PluginBackend
|
||||
(PluginBackendStore) storeContext.createUnmarshaller().unmarshal(
|
||||
storeFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
pluginStore = new PluginBackendStore();
|
||||
}
|
||||
}
|
||||
catch (JAXBException ex)
|
||||
{
|
||||
|
||||
@@ -95,7 +95,7 @@ public class ScmBackendModule extends ServletModule
|
||||
configurationFile.getPath()));
|
||||
}
|
||||
|
||||
BackendConfiguration configuration = JAXB.unmarshal(baseDirectory,
|
||||
BackendConfiguration configuration = JAXB.unmarshal(configurationFile,
|
||||
BackendConfiguration.class);
|
||||
|
||||
bind(File.class).annotatedWith(Names.named(DIRECTORY_PROPERTY)).toInstance(
|
||||
|
||||
@@ -101,13 +101,18 @@ public class DefaultPluginScanner implements PluginScanner
|
||||
@Override
|
||||
public void scannDirectory(PluginBackend backend, File directory)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("scann directory {}", directory.getPath());
|
||||
}
|
||||
|
||||
File[] files = directory.listFiles();
|
||||
|
||||
for (File file : files)
|
||||
{
|
||||
if (file.isDirectory())
|
||||
{
|
||||
scannDirectory(backend, directory);
|
||||
scannDirectory(backend, file);
|
||||
}
|
||||
else if (file.getName().endsWith(PLUGIN_EXTENSION))
|
||||
{
|
||||
@@ -125,6 +130,11 @@ public class DefaultPluginScanner implements PluginScanner
|
||||
*/
|
||||
private void scannFile(PluginBackend backend, File file)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("scann file {}", file.getPath());
|
||||
}
|
||||
|
||||
JarInputStream inputStream = null;
|
||||
|
||||
try
|
||||
@@ -142,15 +152,17 @@ public class DefaultPluginScanner implements PluginScanner
|
||||
|
||||
if (plugin != null)
|
||||
{
|
||||
if ( logger.isInfoEnabled() )
|
||||
if (logger.isInfoEnabled())
|
||||
{
|
||||
logger.info( "add plugin {} to backend", file.getPath() );
|
||||
logger.info("add plugin {} to backend", file.getPath());
|
||||
}
|
||||
|
||||
backend.addPlugin(plugin.getInformation());
|
||||
}
|
||||
|
||||
break;
|
||||
} else {
|
||||
entry.getCompressedSize();
|
||||
}
|
||||
|
||||
inputStream.closeEntry();
|
||||
|
||||
@@ -73,6 +73,7 @@ public class PluginScannerTimerTask extends TimerTask
|
||||
PluginScannerFactory scannerFactory)
|
||||
{
|
||||
this.backend = backend;
|
||||
this.configuration = configuration;
|
||||
this.scannerFactory = scannerFactory;
|
||||
}
|
||||
|
||||
@@ -92,6 +93,10 @@ public class PluginScannerTimerTask extends TimerTask
|
||||
|
||||
for (File directory : configuration.getDirectories())
|
||||
{
|
||||
if ( logger.isDebugEnabled() )
|
||||
{
|
||||
logger.info("scann directory {}", directory.getPath());
|
||||
}
|
||||
PluginScanner scanner = scannerFactory.createScanner();
|
||||
|
||||
if (configuration.isMultithreaded())
|
||||
|
||||
@@ -69,7 +69,9 @@ public class TimerPluginScannerScheduler implements PluginScannerScheduler
|
||||
BackendConfiguration configuration,
|
||||
PluginScannerFactory scannerFactory)
|
||||
{
|
||||
this.backend = backend;
|
||||
this.configuration = configuration;
|
||||
this.scannerFactory = scannerFactory;
|
||||
timer = new Timer(TIMER_NAME);
|
||||
}
|
||||
|
||||
@@ -92,8 +94,11 @@ public class TimerPluginScannerScheduler implements PluginScannerScheduler
|
||||
@Override
|
||||
public void start()
|
||||
{
|
||||
PluginScannerTimerTask task = new PluginScannerTimerTask(backend, configuration, scannerFactory);
|
||||
timer.schedule(task, configuration.getScannInterval());
|
||||
PluginScannerTimerTask task = new PluginScannerTimerTask(backend,
|
||||
configuration, scannerFactory);
|
||||
|
||||
// wait 5 seconds and start with first run
|
||||
timer.schedule(task, 5000l, configuration.getScannInterval());
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
27
scm-plugin-backend/src/main/resources/logback.xml
Normal file
27
scm-plugin-backend/src/main/resources/logback.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
Document : logback.xml
|
||||
Created on : March 12, 2011, 11:34 AM
|
||||
Author : sdorra
|
||||
Description:
|
||||
Purpose of the document follows.
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!-- encoders are by default assigned the type
|
||||
ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="sonia.scm" level="DEBUG" />
|
||||
|
||||
<root level="WARN">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user