mirror of https://github.com/apache/archiva.git
PR: MRM-114
Submitted by: Pete Marvin King Extended AbstractLogEnabled to get the Logger object that is used by the DiscovererJob. git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@410716 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cf102ca5ba
commit
9b278ded3b
|
@ -98,9 +98,10 @@ public class DiscovererJob
|
||||||
public void execute( JobExecutionContext context )
|
public void execute( JobExecutionContext context )
|
||||||
throws JobExecutionException
|
throws JobExecutionException
|
||||||
{
|
{
|
||||||
getLogger().info( "Start execution of DiscovererJob.." );
|
|
||||||
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
|
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
|
||||||
|
|
||||||
|
setJobDataMap( dataMap );
|
||||||
|
getLogger().info( "[DiscovererJob] Start execution of DiscovererJob.." );
|
||||||
//configuration values specified in properties file
|
//configuration values specified in properties file
|
||||||
String indexPath = (String) dataMap.get( MAP_INDEXPATH );
|
String indexPath = (String) dataMap.get( MAP_INDEXPATH );
|
||||||
ArtifactRepository defaultRepository = (ArtifactRepository) dataMap.get( MAP_DEFAULT_REPOSITORY );
|
ArtifactRepository defaultRepository = (ArtifactRepository) dataMap.get( MAP_DEFAULT_REPOSITORY );
|
||||||
|
@ -129,8 +130,8 @@ public class DiscovererJob
|
||||||
convertSnapshots );
|
convertSnapshots );
|
||||||
indexPom( models, indexPath, defaultRepository );
|
indexPom( models, indexPath, defaultRepository );
|
||||||
|
|
||||||
List metadataList = defaultMetadataDiscoverer.discoverMetadata(
|
List metadataList = defaultMetadataDiscoverer.discoverMetadata( new File( defaultRepository
|
||||||
new File( defaultRepository.getBasedir() ), blacklistedPatterns );
|
.getBasedir() ), blacklistedPatterns );
|
||||||
indexMetadata( metadataList, indexPath, new File( defaultRepository.getBasedir() ) );
|
indexMetadata( metadataList, indexPath, new File( defaultRepository.getBasedir() ) );
|
||||||
}
|
}
|
||||||
else if ( dataMap.get( MAP_LAYOUT ).equals( "legacy" ) )
|
else if ( dataMap.get( MAP_LAYOUT ).equals( "legacy" ) )
|
||||||
|
@ -197,8 +198,8 @@ public class DiscovererJob
|
||||||
throws RepositoryIndexException, MalformedURLException
|
throws RepositoryIndexException, MalformedURLException
|
||||||
{
|
{
|
||||||
String repoDir = repositoryBase.toURL().toString();
|
String repoDir = repositoryBase.toURL().toString();
|
||||||
ArtifactRepository repository =
|
ArtifactRepository repository = repoFactory
|
||||||
repoFactory.createArtifactRepository( "repository", repoDir, layout, null, null );
|
.createArtifactRepository( "repository", repoDir, layout, null, null );
|
||||||
|
|
||||||
MetadataRepositoryIndex metadataIndex = indexFactory.createMetadataRepositoryIndex( indexPath, repository );
|
MetadataRepositoryIndex metadataIndex = indexFactory.createMetadataRepositoryIndex( indexPath, repository );
|
||||||
for ( Iterator iter = metadataList.iterator(); iter.hasNext(); )
|
for ( Iterator iter = metadataList.iterator(); iter.hasNext(); )
|
||||||
|
|
|
@ -16,30 +16,32 @@ package org.apache.maven.repository.manager.web.job;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||||
import org.apache.maven.artifact.repository.DefaultArtifactRepositoryFactory;
|
import org.apache.maven.artifact.repository.DefaultArtifactRepositoryFactory;
|
||||||
import org.apache.maven.repository.discovery.ArtifactDiscoverer;
|
import org.apache.maven.repository.discovery.ArtifactDiscoverer;
|
||||||
import org.apache.maven.repository.discovery.MetadataDiscoverer;
|
import org.apache.maven.repository.discovery.MetadataDiscoverer;
|
||||||
import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
|
import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
|
||||||
|
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||||
import org.codehaus.plexus.scheduler.Scheduler;
|
import org.codehaus.plexus.scheduler.Scheduler;
|
||||||
import org.quartz.CronTrigger;
|
import org.quartz.CronTrigger;
|
||||||
import org.quartz.JobDataMap;
|
import org.quartz.JobDataMap;
|
||||||
import org.quartz.JobDetail;
|
import org.quartz.JobDetail;
|
||||||
import org.quartz.SchedulerException;
|
import org.quartz.SchedulerException;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class sets the job to be executed in the plexus-quartz scheduler
|
* This class sets the job to be executed in the plexus-quartz scheduler
|
||||||
*
|
*
|
||||||
* @plexus.component role="org.apache.maven.repository.manager.web.job.DiscovererScheduler"
|
* @plexus.component role="org.apache.maven.repository.manager.web.job.DiscovererScheduler"
|
||||||
*/
|
*/
|
||||||
public class DiscovererScheduler
|
public class DiscovererScheduler
|
||||||
|
extends AbstractLogEnabled
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @plexus.requirement
|
* @plexus.requirement
|
||||||
|
@ -91,6 +93,7 @@ public class DiscovererScheduler
|
||||||
props = config.getProperties();
|
props = config.getProperties();
|
||||||
JobDetail jobDetail = new JobDetail( "discovererJob", "DISCOVERER", DiscovererJob.class );
|
JobDetail jobDetail = new JobDetail( "discovererJob", "DISCOVERER", DiscovererJob.class );
|
||||||
JobDataMap dataMap = new JobDataMap();
|
JobDataMap dataMap = new JobDataMap();
|
||||||
|
dataMap.put( DiscovererJob.LOGGER, getLogger() );
|
||||||
dataMap.put( DiscovererJob.MAP_INDEXPATH, props.getProperty( "index.path" ) );
|
dataMap.put( DiscovererJob.MAP_INDEXPATH, props.getProperty( "index.path" ) );
|
||||||
dataMap.put( DiscovererJob.MAP_BLACKLIST, props.getProperty( "blacklist.patterns" ) );
|
dataMap.put( DiscovererJob.MAP_BLACKLIST, props.getProperty( "blacklist.patterns" ) );
|
||||||
dataMap.put( DiscovererJob.MAP_DEFAULT_REPOSITORY, getDefaultRepository() );
|
dataMap.put( DiscovererJob.MAP_DEFAULT_REPOSITORY, getDefaultRepository() );
|
||||||
|
@ -105,8 +108,7 @@ public class DiscovererScheduler
|
||||||
dataMap.put( DiscovererJob.MAP_REPO_FACTORY, repoFactory );
|
dataMap.put( DiscovererJob.MAP_REPO_FACTORY, repoFactory );
|
||||||
jobDetail.setJobDataMap( dataMap );
|
jobDetail.setJobDataMap( dataMap );
|
||||||
|
|
||||||
CronTrigger trigger =
|
CronTrigger trigger = new CronTrigger( "DiscovererTrigger", "DISCOVERER", props.getProperty( "cron.expression" ) );
|
||||||
new CronTrigger( "DiscovererTrigger", "DISCOVERER", props.getProperty( "cron.expression" ) );
|
|
||||||
scheduler.scheduleJob( jobDetail, trigger );
|
scheduler.scheduleJob( jobDetail, trigger );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue