]> source.dussan.org Git - archiva.git/commitdiff
move scheduled up to top lvl, it could theorically run as a service or daemon and...
authorJesse McConnell <jmcconnell@apache.org>
Thu, 12 Apr 2007 18:56:07 +0000 (18:56 +0000)
committerJesse McConnell <jmcconnell@apache.org>
Thu, 12 Apr 2007 18:56:07 +0000 (18:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches@528087 13f79535-47bb-0310-9956-ffa450edef68

26 files changed:
archiva-jpox-database-refactor/archiva-scheduled/pom.xml [new file with mode: 0644]
archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/ArchivaTaskScheduler.java [new file with mode: 0644]
archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DatabaseTaskJob.java [new file with mode: 0644]
archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java [new file with mode: 0644]
archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/RepositoryTaskJob.java [new file with mode: 0644]
archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaScheduledTaskExecutor.java [new file with mode: 0644]
archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArchivaTask.java [new file with mode: 0644]
archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/DatabaseTask.java [new file with mode: 0644]
archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTask.java [new file with mode: 0644]
archiva-jpox-database-refactor/archiva-scheduled/src/main/resources/META-INF/plexus/components.xml [new file with mode: 0644]
archiva-jpox-database-refactor/archiva-scheduled/src/test/conf/repository-manager.xml [new file with mode: 0644]
archiva-jpox-database-refactor/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaScheduledTaskExecutorTest.java [new file with mode: 0644]
archiva-jpox-database-refactor/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaScheduledTaskExecutorTest.xml [new file with mode: 0644]
archiva-jpox-database-refactor/archiva-web/archiva-scheduled/pom.xml [deleted file]
archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/ArchivaTaskScheduler.java [deleted file]
archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DatabaseTaskJob.java [deleted file]
archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java [deleted file]
archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/RepositoryTaskJob.java [deleted file]
archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaScheduledTaskExecutor.java [deleted file]
archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArchivaTask.java [deleted file]
archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/DatabaseTask.java [deleted file]
archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTask.java [deleted file]
archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/resources/META-INF/plexus/components.xml [deleted file]
archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/test/conf/repository-manager.xml [deleted file]
archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaScheduledTaskExecutorTest.java [deleted file]
archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaScheduledTaskExecutorTest.xml [deleted file]

diff --git a/archiva-jpox-database-refactor/archiva-scheduled/pom.xml b/archiva-jpox-database-refactor/archiva-scheduled/pom.xml
new file mode 100644 (file)
index 0000000..2cd903c
--- /dev/null
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<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">
+  <parent>
+    <groupId>org.apache.maven.archiva</groupId>
+    <artifactId>archiva-base</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>archiva-scheduled</artifactId>
+  <name>Archiva Base :: Scheduled Tasks</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-configuration</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-database</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-repository-layer</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-core-consumers</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-database-consumers</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-lucene-consumers</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-taskqueue</artifactId>
+      <version>1.0-alpha-6</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-quartz</artifactId>
+      <version>1.0-alpha-3</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-component-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-container-default</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus.registry</groupId>
+      <artifactId>plexus-registry-api</artifactId>
+      <version>1.0-alpha-2</version>
+    </dependency>
+    <!-- Test Dependencies -->
+    <dependency>
+      <groupId>org.codehaus.plexus.registry</groupId>
+      <artifactId>plexus-registry-commons</artifactId>
+      <version>1.0-alpha-2</version>
+      <scope>test</scope>
+    </dependency>
+
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>merge</id>
+            <goals>
+              <goal>merge-descriptors</goal>
+            </goals>
+            <configuration>
+              <descriptors>
+                <descriptor>${basedir}/src/main/resources/META-INF/plexus/components.xml</descriptor>
+                <descriptor>${project.build.directory}/generated-resources/plexus/META-INF/plexus/components.xml</descriptor>
+              </descriptors>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/ArchivaTaskScheduler.java b/archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/ArchivaTaskScheduler.java
new file mode 100644 (file)
index 0000000..ffe3c62
--- /dev/null
@@ -0,0 +1,42 @@
+package org.apache.maven.archiva.scheduled;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
+
+/**
+ * The component that takes care of scheduling in the application.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public interface ArchivaTaskScheduler
+{
+    /**
+     * The Plexus component role.
+     */
+    public final static String ROLE = ArchivaTaskScheduler.class.getName();
+
+    public void runDatabaseTasks() throws TaskExecutionException;
+
+    public void runAllRepositoryTasks() throws TaskExecutionException;
+    
+    public void runRepositoryTasks( String repositoryId ) throws TaskExecutionException;
+    
+} 
diff --git a/archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DatabaseTaskJob.java b/archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DatabaseTaskJob.java
new file mode 100644 (file)
index 0000000..6f6a704
--- /dev/null
@@ -0,0 +1,85 @@
+package org.apache.maven.archiva.scheduled;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.scheduled.tasks.ArchivaTask;
+import org.apache.maven.archiva.scheduled.tasks.DatabaseTask;
+import org.codehaus.plexus.scheduler.AbstractJob;
+import org.codehaus.plexus.taskqueue.TaskQueue;
+import org.codehaus.plexus.taskqueue.TaskQueueException;
+import org.quartz.JobDataMap;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+/**
+ * This class is the database job that is executed by the scheduler.
+ */
+public class DatabaseTaskJob
+    extends AbstractJob
+{
+    static final String TASK_KEY = "EXECUTION";
+
+    static final String TASK_QUEUE = "TASK_QUEUE";
+
+    static final String TASK_QUEUE_POLICY = "TASK_QUEUE_POLICY";
+
+    /**
+     * Execute the discoverer and the indexer.
+     *
+     * @param context
+     * @throws org.quartz.JobExecutionException
+     *
+     */
+    public void execute( JobExecutionContext context )
+        throws JobExecutionException
+    {
+        JobDataMap dataMap = context.getJobDetail().getJobDataMap();
+        setJobDataMap( dataMap );
+
+        TaskQueue taskQueue = (TaskQueue) dataMap.get( TASK_QUEUE );
+        String queuePolicy = dataMap.get( TASK_QUEUE_POLICY ).toString();
+
+        ArchivaTask task = new DatabaseTask();
+        task.setName( context.getJobDetail().getName() );
+
+        try
+        {
+            if ( taskQueue.getQueueSnapshot().size() == 0 )
+            {
+                taskQueue.put( task );
+            }
+            else
+            {
+                if ( ArchivaTask.QUEUE_POLICY_WAIT.equals( queuePolicy ) )
+                {
+                    taskQueue.put( task );
+                }
+                else if ( ArchivaTask.QUEUE_POLICY_SKIP.equals( queuePolicy ) )
+                {
+                    // do not queue anymore, policy is to skip
+                }
+            }
+        }
+        catch ( TaskQueueException e )
+        {
+            throw new JobExecutionException( e );
+        }
+    }
+}
diff --git a/archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java b/archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java
new file mode 100644 (file)
index 0000000..2ea5311
--- /dev/null
@@ -0,0 +1,288 @@
+package org.apache.maven.archiva.scheduled;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.RepositoryConfiguration;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.database.ObjectNotFoundException;
+import org.apache.maven.archiva.database.RepositoryDAO;
+import org.apache.maven.archiva.model.ArchivaRepository;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException;
+import org.codehaus.plexus.registry.Registry;
+import org.codehaus.plexus.registry.RegistryListener;
+import org.codehaus.plexus.scheduler.Scheduler;
+import org.codehaus.plexus.taskqueue.TaskQueue;
+import org.codehaus.plexus.taskqueue.TaskQueueException;
+import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
+import org.quartz.CronTrigger;
+import org.quartz.JobDataMap;
+import org.quartz.JobDetail;
+import org.quartz.SchedulerException;
+
+import java.text.ParseException;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Default implementation of a scheduling component for archiva..
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @author <a href="mailto:jmcconnell@apache.org">Jesse McConnell</a>
+ * @plexus.component role="org.apache.maven.archiva.scheduler.ArchivaTaskScheduler"
+ */
+public class DefaultArchivaTaskScheduler
+    extends AbstractLogEnabled
+    implements ArchivaTaskScheduler, Startable, RegistryListener
+{
+    /**
+     * @plexus.requirement
+     */
+    private Scheduler scheduler;
+
+   
+    /**
+     * @plexus.requirement role-hint="archiva-task-queue"
+     */
+    private TaskQueue archivaTaskQueue;
+      
+    /**
+     * @plexus.requirement
+     */
+    private ArchivaConfiguration archivaConfiguration;
+  
+    
+    public static final String DATABASE_DISCOVERER_GROUP = "database-group";
+    
+    public static final String DATABASE_JOB = "database-job";
+    public static final String DATABASE_JOB_TRIGGER = "database-job-trigger";
+   
+    public static final String REPOSITORY_DISCOVERER_GROUP = "repository-group";
+    
+    public static final String REPOSITORY_JOB = "repository-job";
+    public static final String REPOSITORY_JOB_TRIGGER = "repository-job-trigger";
+    
+    public void start()
+        throws StartingException
+    {
+        try
+        {
+               List repositories = archivaConfiguration.getConfiguration().getRepositories();
+               
+               for ( Iterator i = repositories.iterator(); i.hasNext(); )
+               {
+                       RepositoryConfiguration repoConfig = (RepositoryConfiguration)i.next();
+                       
+                       scheduleRepositoryJobs( repoConfig );                   
+               }
+               
+               scheduleDatabaseJobs( );
+        }
+        catch ( SchedulerException e )
+        {
+            throw new StartingException( "Unable to start scheduler: " + e.getMessage(), e );
+        }
+    }
+
+    private void scheduleRepositoryJobs( RepositoryConfiguration repoConfig )
+       throws SchedulerException
+    {
+        if ( repoConfig.getRefreshCronExpression() == null )
+        {
+            getLogger().warn( "Skipping job, no cron expression for " + repoConfig.getId() );
+            return;
+        }
+        
+        // get the cron string for these database scanning jobs
+        String cronString = repoConfig.getRefreshCronExpression();        
+        
+        // setup the unprocessed artifact job
+        JobDetail repositoryJob =
+            new JobDetail( REPOSITORY_JOB + ":" + repoConfig.getId() , REPOSITORY_DISCOVERER_GROUP, RepositoryTaskJob.class );
+
+        JobDataMap dataMap = new JobDataMap();
+        dataMap.put( RepositoryTaskJob.TASK_QUEUE, archivaTaskQueue );
+        dataMap.put( RepositoryTaskJob.TASK_REPOSITORY, repoConfig.getId() );
+        repositoryJob.setJobDataMap( dataMap );
+       
+        try 
+        {
+            CronTrigger trigger =
+                new CronTrigger( REPOSITORY_JOB_TRIGGER + ":" + repoConfig.getId() , REPOSITORY_DISCOVERER_GROUP, cronString );
+        
+            scheduler.scheduleJob( repositoryJob, trigger );
+        }
+        catch ( ParseException e )
+        {
+            getLogger().error( "ParseException in repository scanning cron expression, disabling repository scanning for '" + repoConfig.getId() + "': " + e.getMessage() );
+        }
+             
+    }
+    
+    private void scheduleDatabaseJobs( )
+        throws SchedulerException
+    {        
+        String cronString = archivaConfiguration.getConfiguration().getDatabaseScanning().getCronExpression();
+        
+        // setup the unprocessed artifact job
+        JobDetail databaseJob =
+            new JobDetail( DATABASE_JOB, DATABASE_DISCOVERER_GROUP, DatabaseTaskJob.class );
+
+        JobDataMap dataMap = new JobDataMap();
+        dataMap.put( DatabaseTaskJob.TASK_QUEUE, archivaTaskQueue );
+        databaseJob.setJobDataMap( dataMap );
+       
+        try 
+        {
+            CronTrigger trigger =
+                new CronTrigger( DATABASE_JOB_TRIGGER, DATABASE_DISCOVERER_GROUP, cronString );
+        
+            scheduler.scheduleJob( databaseJob, trigger );
+        }
+        catch ( ParseException e )
+        {
+            getLogger().error( "ParseException in database scanning cron expression, disabling database scanning: " + e.getMessage() );
+        }
+        
+    }
+
+    public void stop()
+        throws StoppingException
+    {
+        try
+        {
+            scheduler.unscheduleJob( DATABASE_JOB, DATABASE_DISCOVERER_GROUP );         
+        }
+        catch ( SchedulerException e )
+        {
+            throw new StoppingException( "Unable to unschedule tasks", e );
+        }
+    }
+
+
+    public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+    {
+        // nothing to do
+    }
+
+    /**
+     * 
+     */
+    public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+    {
+        // cronExpression comes from the database scanning section
+        if ( "cronExpression".equals( propertyName ) )
+        {
+            getLogger().debug( "Restarting the database scheduled task after property change: " + propertyName );
+            
+            try
+            {
+                scheduler.unscheduleJob( DATABASE_JOB, DATABASE_DISCOVERER_GROUP );
+            
+                scheduleDatabaseJobs();
+            }
+            catch ( SchedulerException e )
+            {
+                getLogger().error( "Error restarting the database scanning job after property change." );
+            }
+        }
+        
+        // refreshCronExpression comes from the repositories section
+        // 
+        // currently we have to reschedule all repo jobs because we don't know where the changed one came from
+        if ( "refreshCronExpression".equals( propertyName ) )
+        {
+            List repositories = archivaConfiguration.getConfiguration().getRepositories();
+            
+            for ( Iterator i = repositories.iterator(); i.hasNext(); )
+            {
+                RepositoryConfiguration repoConfig = (RepositoryConfiguration)i.next();
+                
+                if ( repoConfig.getRefreshCronExpression() != null )
+                {
+                    try
+                    {
+                        // unschedule handles jobs that might not exist
+                        scheduler.unscheduleJob( REPOSITORY_JOB + ":" + repoConfig.getId() , REPOSITORY_DISCOVERER_GROUP );
+                        scheduleRepositoryJobs( repoConfig );
+                    }
+                    catch ( SchedulerException e )
+                    {
+                        getLogger().error( "error restarting job: " + REPOSITORY_JOB + ":" + repoConfig.getId() );
+                    }
+                }
+            }
+        }
+    }
+
+    public void runAllRepositoryTasks() throws TaskExecutionException
+    {
+        try
+        {
+            List repositories = archivaConfiguration.getConfiguration().getRepositories();
+            
+            for ( Iterator i = repositories.iterator(); i.hasNext(); )
+            {
+                RepositoryConfiguration repoConfig = (RepositoryConfiguration)i.next();
+                
+                scheduleRepositoryJobs( repoConfig );               
+            }
+            
+        }
+        catch ( SchedulerException e )
+        {
+            throw new TaskExecutionException( "Unable to schedule repository jobs: " + e.getMessage(), e );
+        }
+    }
+
+    public void runDatabaseTasks() throws TaskExecutionException
+    {
+        try
+        {
+            scheduleDatabaseJobs();
+        }
+        catch ( SchedulerException e )
+        {
+            throw new TaskExecutionException( "Unable to schedule repository jobs: " + e.getMessage(), e );
+
+        }
+    }
+
+    public void runRepositoryTasks( String repositoryId ) throws TaskExecutionException
+    {
+        try
+        {
+            RepositoryConfiguration repoConfig = archivaConfiguration.getConfiguration().findRepositoryById( repositoryId );
+            
+            scheduleRepositoryJobs( repoConfig );                         
+        }
+        catch ( SchedulerException e )
+        {
+            throw new TaskExecutionException( "Unable to schedule repository jobs: " + e.getMessage(), e );
+        } 
+    }
+
+    
+    
+}
diff --git a/archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/RepositoryTaskJob.java b/archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/RepositoryTaskJob.java
new file mode 100644 (file)
index 0000000..cfe1488
--- /dev/null
@@ -0,0 +1,87 @@
+package org.apache.maven.archiva.scheduled;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.scheduled.tasks.ArchivaTask;
+import org.apache.maven.archiva.scheduled.tasks.RepositoryTask;
+import org.codehaus.plexus.scheduler.AbstractJob;
+import org.codehaus.plexus.taskqueue.TaskQueue;
+import org.codehaus.plexus.taskqueue.TaskQueueException;
+import org.quartz.JobDataMap;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+/**
+ * This class is the repository job that is executed by the scheduler.
+ */
+public class RepositoryTaskJob
+    extends AbstractJob
+{
+    static final String TASK_KEY = "EXECUTION";
+
+    static final String TASK_QUEUE = "TASK_QUEUE";
+
+    static final String TASK_QUEUE_POLICY = "TASK_QUEUE_POLICY";
+    
+    static final String TASK_REPOSITORY = "TASK_REPOSITORY";
+
+    /**
+     * Execute the discoverer and the indexer.
+     *
+     * @param context
+     * @throws org.quartz.JobExecutionException
+     *
+     */
+    public void execute( JobExecutionContext context )
+        throws JobExecutionException
+    {
+        JobDataMap dataMap = context.getJobDetail().getJobDataMap();
+        setJobDataMap( dataMap );
+
+        TaskQueue taskQueue = (TaskQueue) dataMap.get( TASK_QUEUE );
+        String queuePolicy = dataMap.get( TASK_QUEUE_POLICY ).toString();
+
+        ArchivaTask task = new RepositoryTask();
+        task.setName( context.getJobDetail().getName() );
+
+        try
+        {
+            if ( taskQueue.getQueueSnapshot().size() == 0 )
+            {
+                taskQueue.put( task );
+            }
+            else
+            {
+                if ( ArchivaTask.QUEUE_POLICY_WAIT.equals( queuePolicy ) )
+                {
+                    taskQueue.put( task );
+                }
+                else if ( ArchivaTask.QUEUE_POLICY_SKIP.equals( queuePolicy ) )
+                {
+                    // do not queue anymore, policy is to skip
+                }
+            }
+        }
+        catch ( TaskQueueException e )
+        {
+            throw new JobExecutionException( e );
+        }
+    }
+}
diff --git a/archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaScheduledTaskExecutor.java b/archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaScheduledTaskExecutor.java
new file mode 100644 (file)
index 0000000..af629fd
--- /dev/null
@@ -0,0 +1,194 @@
+package org.apache.maven.archiva.scheduled.executors;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.database.RepositoryDAO;
+import org.apache.maven.archiva.database.updater.DatabaseUpdater;
+import org.apache.maven.archiva.model.ArchivaRepository;
+import org.apache.maven.archiva.repository.RepositoryException;
+import org.apache.maven.archiva.repository.scanner.RepositoryScanner;
+import org.apache.maven.archiva.scheduled.tasks.DatabaseTask;
+import org.apache.maven.archiva.scheduled.tasks.RepositoryTask;
+
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.taskqueue.Task;
+import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
+import org.codehaus.plexus.taskqueue.execution.TaskExecutor;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ * @author <a href="mailto:jmcconnell@apache.org">Jesse McConnell</a>
+ * @version $Id:$
+ * 
+ * @plexus.component role="org.codehaus.plexus.taskqueue.execution.TaskExecutor" 
+ *      role-hint="archiva-task-executor"
+ */
+public class ArchivaScheduledTaskExecutor extends AbstractLogEnabled implements TaskExecutor
+{
+    /**
+     * Configuration store.
+     *
+     * @plexus.requirement
+     */
+    private ArchivaConfiguration archivaConfiguration;
+
+    /**
+     * @plexus.requirement role-hint="jdo"
+     */
+    private DatabaseUpdater databaseUpdater;
+    
+    /**
+     * @plexus.requirement role-hint="jdo"
+     */
+    private RepositoryDAO repositoryDAO;
+    
+    /**
+     * The collection of available consumers.
+     * @plexus.requirement role="org.apache.maven.archiva.consumers.ArchivaArtifactConsumer"
+     */
+    private Map availableConsumers;
+    
+    public void executeTask( Task task ) throws TaskExecutionException
+    {
+        
+        if ( task instanceof DatabaseTask )          
+        {  
+            executeDatabaseTask( (DatabaseTask) task );
+        }
+        else if ( task instanceof RepositoryTask )
+        {
+            executeRepositoryTask( (RepositoryTask) task );
+        }
+        else
+        {
+            throw new TaskExecutionException( "Unknown Task: " + task.toString() );
+        }
+        
+    }
+
+    private void executeDatabaseTask( DatabaseTask task ) throws TaskExecutionException
+    {
+        getLogger().info( "Executing task from queue with job name: " + task.getName() );
+        long time = System.currentTimeMillis();
+
+        
+        try
+        {
+            databaseUpdater.updateAllUnprocessed();
+        }
+        catch ( ArchivaDatabaseException e )
+        {
+            throw new TaskExecutionException( "Error running unprocessed updater", e );
+        }
+       
+        try 
+        {
+            databaseUpdater.updateAllProcessed();
+        }
+        catch ( ArchivaDatabaseException e )
+        {
+            throw new TaskExecutionException( "Error running processed updater", e );
+        }       
+        
+        time = System.currentTimeMillis() - time;
+
+        getLogger().info( "Finished database task in " + time + "ms." );
+        
+    }
+    
+    private void executeRepositoryTask ( RepositoryTask task ) throws TaskExecutionException
+    {
+        getLogger().info( "Executing task from queue with job name: " + task.getName() );
+        
+        long time = System.currentTimeMillis();
+
+        try 
+        {
+            ArchivaRepository arepo = repositoryDAO.getRepository( task.getRepositoryId() );
+                    
+            RepositoryScanner scanner = new RepositoryScanner();
+            
+            scanner.scan( arepo, getActiveConsumerList(), true );
+            
+        }
+        catch ( ArchivaDatabaseException e )
+        {
+            throw new TaskExecutionException( "Database error when executing repository job.", e );
+        }
+        catch ( RepositoryException e )
+        {
+            throw new TaskExecutionException( "Repository error when executing repository job.", e );
+        }
+        
+        
+        time = System.currentTimeMillis() - time;
+
+        getLogger().info( "Finished repository task for " + time + "ms." );
+    }
+    
+    
+    private List getActiveConsumerList()
+    {       
+        List activeConsumers = new ArrayList();
+        
+        List configuredGoodConsumers = archivaConfiguration.getConfiguration().getRepositoryScanning().getGoodConsumers();
+        List configuredBadConsumers = archivaConfiguration.getConfiguration().getRepositoryScanning().getBadConsumers();
+        
+        for ( Iterator i = configuredGoodConsumers.iterator(); i.hasNext(); )
+        {
+            String consumer = (String)i.next();
+            
+            if ( availableConsumers.containsKey( availableConsumers.get( consumer ) )  )
+            {
+                activeConsumers.add( availableConsumers.get( consumer ) );
+            }
+            else
+            {
+                getLogger().warn( "RequestedConsumer [" + consumer + "] does not exist. Skipping in repository scan." );
+            }
+        }
+        
+        for ( Iterator i = configuredBadConsumers.iterator(); i.hasNext(); )
+        {
+            String consumer = (String)i.next();
+            
+            if ( availableConsumers.containsKey( availableConsumers.get( consumer ) )  )
+            {
+                activeConsumers.add( availableConsumers.get( consumer ) );
+            }
+            else
+            {
+                getLogger().warn( "RequestedConsumer [" + consumer + "] does not exist. Skipping in repository scan." );
+            }
+        }
+        
+        return activeConsumers;
+    }
+    
+}
diff --git a/archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArchivaTask.java b/archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArchivaTask.java
new file mode 100644 (file)
index 0000000..642f16b
--- /dev/null
@@ -0,0 +1,68 @@
+package org.apache.maven.archiva.scheduled.tasks;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.codehaus.plexus.taskqueue.Task;
+
+/**
+ * A repository task.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public interface ArchivaTask
+    extends Task
+{
+    public static final String QUEUE_POLICY_WAIT = "wait";
+
+    public static final String QUEUE_POLICY_SKIP = "skip";
+
+    /**
+     * Gets the queue policy for this task.
+     *
+     * @return Queue policy for this task
+     */
+    public String getQueuePolicy();
+
+    /**
+     * Sets the queue policy for this task.
+     *
+     * @param policy
+     */
+    public void setQueuePolicy( String policy );
+
+    /**
+     * Sets the job name to represent a group of similar / identical job tasks.  Can be used to check the
+     * task queue for similar / identical job tasks.
+     */
+    public void setName( String name );
+
+    /**
+     * obtains the name of the task
+     * @return
+     */
+    public String getName();
+
+    public long getMaxExecutionTime();
+
+    public void setMaxExecutionTime( long maxExecutionTime );
+
+
+   
+}
diff --git a/archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/DatabaseTask.java b/archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/DatabaseTask.java
new file mode 100644 (file)
index 0000000..dbd58da
--- /dev/null
@@ -0,0 +1,49 @@
+package org.apache.maven.archiva.scheduled.tasks;
+
+/**
+ * DataRefreshTask - task for discovering changes in the repository 
+ * and updating all associated data. 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id: DataRefreshTask.java 525176 2007-04-03 15:21:33Z joakime $
+ */
+public class DatabaseTask
+    implements ArchivaTask
+{
+   
+    String name;
+    
+    String queuePolicy;
+
+    long maxExecutionTime;
+
+    public long getMaxExecutionTime()
+    {
+        return maxExecutionTime;
+    }
+
+    public void setMaxExecutionTime( long maxExecutionTime )
+    {
+        this.maxExecutionTime = maxExecutionTime;
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    public String getQueuePolicy()
+    {
+        return queuePolicy;
+    }
+
+    public void setQueuePolicy( String queuePolicy )
+    {
+        this.queuePolicy = queuePolicy;
+    }
+}
diff --git a/archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTask.java b/archiva-jpox-database-refactor/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTask.java
new file mode 100644 (file)
index 0000000..fca9173
--- /dev/null
@@ -0,0 +1,60 @@
+package org.apache.maven.archiva.scheduled.tasks;
+
+/**
+ * DataRefreshTask - task for discovering changes in the repository 
+ * and updating all associated data. 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id: DataRefreshTask.java 525176 2007-04-03 15:21:33Z joakime $
+ */
+public class RepositoryTask
+    implements ArchivaTask
+{
+    String repositoryId;
+    
+    String name;
+    
+    String queuePolicy;
+
+    long maxExecutionTime;
+    
+    public String getRepositoryId()
+    {
+        return repositoryId;
+    }
+
+    public void setRepositoryId( String repositoryId )
+    {
+        this.repositoryId = repositoryId;
+    }
+
+    public long getMaxExecutionTime()
+    {
+        return maxExecutionTime;
+    }
+
+    public void setMaxExecutionTime( long maxExecutionTime )
+    {
+        this.maxExecutionTime = maxExecutionTime;
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    public String getQueuePolicy()
+    {
+        return queuePolicy;
+    }
+
+    public void setQueuePolicy( String queuePolicy )
+    {
+        this.queuePolicy = queuePolicy;
+    }
+}
diff --git a/archiva-jpox-database-refactor/archiva-scheduled/src/main/resources/META-INF/plexus/components.xml b/archiva-jpox-database-refactor/archiva-scheduled/src/main/resources/META-INF/plexus/components.xml
new file mode 100644 (file)
index 0000000..245d002
--- /dev/null
@@ -0,0 +1,16 @@
+<components>
+    <component>
+      <role>org.codehaus.plexus.taskqueue.TaskQueue</role>
+      <role-hint>archiva-task-queue</role-hint>
+      <implementation>org.codehaus.plexus.taskqueue.DefaultTaskQueue</implementation>
+      <lifecycle-handler>plexus-configurable</lifecycle-handler>
+      <configuration>
+        <task-entry-evaluators>
+        </task-entry-evaluators>
+        <task-exit-evaluators>
+        </task-exit-evaluators>
+        <task-viability-evaluators>
+        </task-viability-evaluators>
+      </configuration>
+    </component>
+</components>
\ No newline at end of file
diff --git a/archiva-jpox-database-refactor/archiva-scheduled/src/test/conf/repository-manager.xml b/archiva-jpox-database-refactor/archiva-scheduled/src/test/conf/repository-manager.xml
new file mode 100644 (file)
index 0000000..07e9f96
--- /dev/null
@@ -0,0 +1,182 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<configuration>
+  <repositories>
+    <repository>
+      <id>internal</id>
+      <name>Archiva Managed Internal Repository</name>
+      <url>file://${appserver.home}/repositories/internal</url>
+      <layout>default</layout>
+      <releases>true</releases>
+      <snapshots>false</snapshots>
+      <indexed>true</indexed>
+      <refreshCronExpression>0 0 * * ?</refreshCronExpression>
+    </repository>
+    <repository>
+      <id>snapshots</id>
+      <name>Archiva Managed Snapshot Repository</name>
+      <url>file://${appserver.home}/repositories/internal</url>
+      <layout>default</layout>
+      <releases>false</releases>
+      <snapshots>true</snapshots>
+      <indexed>true</indexed>
+      <refreshCronExpression>0 0,30 * * ?</refreshCronExpression>
+    </repository>
+    <repository>
+      <id>central</id>
+      <name>Central Repository</name>
+      <url>http://repo1.maven.org/maven2</url>
+      <layout>default</layout>
+      <releases>true</releases>
+      <snapshots>false</snapshots>
+      <indexed>false</indexed>
+    </repository>
+    <repository>
+      <id>maven2-repository.dev.java.net</id>
+      <name>Java.net Repository for Maven 2</name>
+      <url>https://maven2-repository.dev.java.net/nonav/repository</url>
+      <layout>default</layout>
+      <releases>true</releases>
+      <snapshots>false</snapshots>
+      <indexed>false</indexed>
+    </repository>
+  </repositories>
+
+  <proxyConnectors>
+    <proxyConnector>
+      <sourceRepoId>internal</sourceRepoId>
+      <targetRepoId>central</targetRepoId>
+      <proxyId />
+      <snapshotsPolicy>disabled</snapshotsPolicy>
+      <releasePolicy>never</releasePolicy>
+      <failurePolicy>not-found</failurePolicy>
+    </proxyConnector>
+    <proxyConnector>
+      <sourceRepoId>internal</sourceRepoId>
+      <targetRepoId>maven2-repository.dev.java.net</targetRepoId>
+      <proxyId />
+      <snapshotsPolicy>disabled</snapshotsPolicy>
+      <releasePolicy>never</releasePolicy>
+      <failurePolicy>not-found</failurePolicy>
+      <whiteListPatterns>
+        <whiteListPattern>javax/**</whiteListPattern>
+      </whiteListPatterns>
+    </proxyConnector>
+  </proxyConnectors>
+
+  <networkProxies>
+    <networkProxy>
+      <id>example</id>
+      <protocol>http</protocol>
+      <host>proxy.mycompany.com</host>
+      <port>8080</port>
+      <username>myself</username>
+      <password>mypass</password>
+    </networkProxy>
+  </networkProxies>
+
+  <repositoryScanning>
+    <fileTypes>
+      <fileType>
+        <id>artifacts</id>
+        <patterns>
+          <pattern>**/*.pom</pattern>
+          <pattern>**/*.jar</pattern>
+          <pattern>**/*.ear</pattern>
+          <pattern>**/*.war</pattern>
+          <pattern>**/*.car</pattern>
+          <pattern>**/*.sar</pattern>
+          <pattern>**/*.mar</pattern>
+          <pattern>**/*.rar</pattern>
+          <pattern>**/*.dtd</pattern>
+          <pattern>**/*.tld</pattern>
+          <pattern>**/*.tar.gz</pattern>
+          <pattern>**/*.tar.bz2</pattern>
+          <pattern>**/*.zip</pattern>
+        </patterns>
+      </fileType>
+      <fileType>
+        <id>indexable-content</id>
+        <patterns>
+          <pattern>**/*.txt</pattern>
+          <pattern>**/*.TXT</pattern>
+          <pattern>**/*.block</pattern>
+          <pattern>**/*.config</pattern>
+          <pattern>**/*.pom</pattern>
+          <pattern>**/*.xml</pattern>
+          <pattern>**/*.xsd</pattern>
+          <pattern>**/*.dtd</pattern>
+          <pattern>**/*.tld</pattern>
+        </patterns>
+      </fileType>
+      <fileType>
+        <id>auto-remove</id>
+        <patterns>
+          <pattern>**/*.bak</pattern>
+          <pattern>**/*~</pattern>
+          <pattern>**/*-</pattern>
+        </patterns>
+      </fileType>
+      <fileType>
+        <id>ignored</id>
+        <patterns>
+          <pattern>**/.htaccess</pattern>
+          <pattern>**/KEYS</pattern>
+          <pattern>**/*.rb</pattern>
+          <pattern>**/*.sh</pattern>
+          <pattern>**/.svn/**</pattern>
+          <pattern>**/.DAV/**</pattern>
+        </patterns>
+      </fileType>
+    </fileTypes>
+    <goodConsumers>
+      <goodConsumer>update-db-artifact</goodConsumer>
+      <goodConsumer>create-missing-checksums</goodConsumer>
+      <goodConsumer>update-db-repository-metadata</goodConsumer>
+      <goodConsumer>validate-checksum</goodConsumer>
+      <goodConsumer>validate-signature</goodConsumer>
+      <goodConsumer>index-content</goodConsumer>
+      <goodConsumer>auto-remove</goodConsumer>
+      <goodConsumer>auto-rename</goodConsumer>
+    </goodConsumers>
+    <badConsumers>
+      <badConsumer>update-db-bad-content</badConsumer>
+    </badConsumers>
+  </repositoryScanning>
+
+  <databaseScanning>
+    <cronExpression>0 0 * * ?</cronExpression>
+    <unprocessedConsumers>
+      <unprocessedConsumer>index-artifact</unprocessedConsumer>
+      <unprocessedConsumer>update-db-project</unprocessedConsumer>
+      <unprocessedConsumer>validate-repository-metadata</unprocessedConsumer>
+      <unprocessedConsumer>index-archive-toc</unprocessedConsumer>
+      <unprocessedConsumer>update-db-bytecode-stats</unprocessedConsumer>
+      <unprocessedConsumer>index-public-methods</unprocessedConsumer>
+    </unprocessedConsumers>
+    <processedConsumers>
+      <processedConsumer>not-present-remove-db-artifact</processedConsumer>
+      <processedConsumer>not-present-remove-db-project</processedConsumer>
+      <processedConsumer>not-present-remove-indexed</processedConsumer>
+    </processedConsumers>
+  </databaseScanning>
+
+</configuration>
diff --git a/archiva-jpox-database-refactor/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaScheduledTaskExecutorTest.java b/archiva-jpox-database-refactor/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaScheduledTaskExecutorTest.java
new file mode 100644 (file)
index 0000000..1bdb023
--- /dev/null
@@ -0,0 +1,169 @@
+package org.apache.maven.archiva.scheduled.executors;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.database.RepositoryDAO;
+import org.apache.maven.archiva.model.ArchivaRepository;
+import org.apache.maven.archiva.scheduled.tasks.RepositoryTask;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
+import org.codehaus.plexus.jdo.JdoFactory;
+import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
+import org.codehaus.plexus.taskqueue.execution.TaskExecutor;
+import org.jpox.SchemaTool;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.jdo.JDOHelper;
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+
+/**
+ * IndexerTaskExecutorTest
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id:$
+ */
+public class ArchivaScheduledTaskExecutorTest
+    extends PlexusTestCase
+{
+    private TaskExecutor taskExecutor;
+
+    protected ArchivaDAO dao;
+    
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        DefaultConfigurableJdoFactory jdoFactory = (DefaultConfigurableJdoFactory) lookup( JdoFactory.ROLE, "archiva" );
+        assertEquals( DefaultConfigurableJdoFactory.class.getName(), jdoFactory.getClass().getName() );
+
+        jdoFactory.setPersistenceManagerFactoryClass( "org.jpox.PersistenceManagerFactoryImpl" ); 
+
+        /* derby version
+        File derbyDbDir = new File( "target/plexus-home/testdb" );
+        if ( derbyDbDir.exists() )
+        {
+            FileUtils.deleteDirectory( derbyDbDir );
+        }
+
+        jdoFactory.setDriverName( System.getProperty( "jdo.test.driver", "org.apache.derby.jdbc.EmbeddedDriver" ) );   
+        jdoFactory.setUrl( System.getProperty( "jdo.test.url", "jdbc:derby:" + derbyDbDir.getAbsolutePath() + ";create=true" ) );
+         */   
+
+        jdoFactory.setDriverName( System.getProperty( "jdo.test.driver", "org.hsqldb.jdbcDriver" ) );   
+        jdoFactory.setUrl( System.getProperty( "jdo.test.url", "jdbc:hsqldb:mem:" + getName() ) );
+        
+        jdoFactory.setUserName( System.getProperty( "jdo.test.user", "sa" ) ); 
+
+        jdoFactory.setPassword( System.getProperty( "jdo.test.pass", "" ) ); 
+
+        jdoFactory.setProperty( "org.jpox.transactionIsolation", "READ_COMMITTED" );  
+
+        jdoFactory.setProperty( "org.jpox.poid.transactionIsolation", "READ_COMMITTED" );  
+
+        jdoFactory.setProperty( "org.jpox.autoCreateSchema", "true" );  
+
+        jdoFactory.setProperty( "javax.jdo.option.RetainValues", "true" );
+
+        jdoFactory.setProperty( "javax.jdo.option.RestoreValues", "true" );
+
+        // jdoFactory.setProperty( "org.jpox.autoCreateColumns", "true" );
+
+        jdoFactory.setProperty( "org.jpox.validateTables", "true" );
+
+        jdoFactory.setProperty( "org.jpox.validateColumns", "true" );
+
+        jdoFactory.setProperty( "org.jpox.validateConstraints", "true" );
+
+        Properties properties = jdoFactory.getProperties();
+
+        for ( Iterator it = properties.entrySet().iterator(); it.hasNext(); )
+        {
+            Map.Entry entry = (Map.Entry) it.next();
+
+            System.setProperty( (String) entry.getKey(), (String) entry.getValue() );
+        }
+
+        URL jdoFileUrls[] = new URL[] { getClass()
+            .getResource( "/org/apache/maven/archiva/model/package.jdo" ) }; 
+
+        if ( ( jdoFileUrls == null ) || ( jdoFileUrls[0] == null ) )
+        {
+            fail( "Unable to process test " + getName() + " - missing package.jdo." );
+        }
+
+        File propsFile = null; // intentional
+        boolean verbose = true;
+
+        SchemaTool.deleteSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose );
+        SchemaTool.createSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose, null );
+
+        PersistenceManagerFactory pmf = jdoFactory.getPersistenceManagerFactory();
+
+        assertNotNull( pmf );
+
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        pm.close();
+
+        this.dao = (ArchivaDAO) lookup( ArchivaDAO.class.getName(), "jdo" );
+
+        taskExecutor = (TaskExecutor) lookup( TaskExecutor.class.getName(), "test-archiva-task-executor" );
+    }
+
+    public void testExecutor() throws Exception
+    {
+        RepositoryDAO repoDao = dao.getRepositoryDAO();
+
+        // Create it
+        ArchivaRepository repo =
+            repoDao.createRepository( "testRepo", "Test Repository", "http://localhost:8080/repository/foo" );
+        assertNotNull( repo );
+
+        // Set some mandatory values
+        repo.getModel().setCreationSource( "Test Case" );
+        repo.getModel().setLayoutName( "default" );
+
+        // Save it.
+        ArchivaRepository repoSaved = repoDao.saveRepository( repo );
+        assertNotNull( repoSaved );
+        assertNotNull( repoSaved.getModel() );
+        assertEquals( "testRepo", JDOHelper.getObjectId( repoSaved.getModel() ).toString() );
+
+        RepositoryTask repoTask = new RepositoryTask();
+        
+        repoTask.setName( "testTask" );
+        repoTask.setRepositoryId( "testRepo" );
+        
+        taskExecutor.executeTask( repoTask );
+
+    }
+
+}
diff --git a/archiva-jpox-database-refactor/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaScheduledTaskExecutorTest.xml b/archiva-jpox-database-refactor/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaScheduledTaskExecutorTest.xml
new file mode 100644 (file)
index 0000000..5b212f6
--- /dev/null
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<component-set>
+  <components>
+    <component>
+      <role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role>
+      <role-hint>test-archiva-task-executor</role-hint>
+      <implementation>org.apache.maven.archiva.scheduled.executors.ArchivaScheduledTaskExecutor</implementation>
+      <description></description>
+      <requirements>
+        <requirement>
+          <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
+          <field-name>archivaConfiguration</field-name>
+          <role-hint>test-configuration</role-hint>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.archiva.database.updater.DatabaseUpdater</role>
+          <role-hint>jdo</role-hint>
+          <field-name>databaseUpdater</field-name>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.archiva.database.RepositoryDAO</role>
+          <role-hint>jdo</role-hint>
+          <field-name>repositoryDAO</field-name>
+        </requirement>
+         <requirement>
+          <role>org.apache.maven.archiva.consumers.ArchivaArtifactConsumer</role>
+          <field-name>availableConsumers</field-name>
+        </requirement>
+      </requirements>
+    </component>
+
+    <component>
+      <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
+      <role-hint>test-configuration</role-hint>
+      <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation>
+      <requirements>
+        <requirement>
+          <role>org.codehaus.plexus.registry.Registry</role>
+          <role-hint>configured</role-hint>
+        </requirement>
+      </requirements>
+    </component>
+    
+    <component>
+      <role>org.codehaus.plexus.registry.Registry</role>
+      <role-hint>configured</role-hint>
+      <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation>
+      <configuration>
+        <properties>
+          <system/>
+          <xml fileName="${basedir}/src/test/conf/repository-manager.xml"
+               config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/>
+        </properties>
+      </configuration>
+    </component>
+    
+    <component>
+      <role>org.codehaus.plexus.jdo.JdoFactory</role>
+      <role-hint>archiva</role-hint>
+      <implementation>org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory</implementation>
+      <configuration>
+        <persistenceManagerFactoryClass>org.jpox.PersistenceManagerFactoryImpl</persistenceManagerFactoryClass>
+        <otherProperties>
+          <property>
+            <name>javax.jdo.PersistenceManagerFactoryClass</name>
+            <value>org.jpox.PersistenceManagerFactoryImpl</value>
+          </property>
+        </otherProperties>
+      </configuration>
+    </component>
+  </components>
+</component-set>
diff --git a/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/pom.xml b/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/pom.xml
deleted file mode 100644 (file)
index 2cd903c..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<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">
-  <parent>
-    <groupId>org.apache.maven.archiva</groupId>
-    <artifactId>archiva-base</artifactId>
-    <version>1.0-SNAPSHOT</version>
-  </parent>
-  <modelVersion>4.0.0</modelVersion>
-  <artifactId>archiva-scheduled</artifactId>
-  <name>Archiva Base :: Scheduled Tasks</name>
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.maven.archiva</groupId>
-      <artifactId>archiva-configuration</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven.archiva</groupId>
-      <artifactId>archiva-database</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven.archiva</groupId>
-      <artifactId>archiva-repository-layer</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven.archiva</groupId>
-      <artifactId>archiva-core-consumers</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven.archiva</groupId>
-      <artifactId>archiva-database-consumers</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven.archiva</groupId>
-      <artifactId>archiva-lucene-consumers</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-taskqueue</artifactId>
-      <version>1.0-alpha-6</version>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-quartz</artifactId>
-      <version>1.0-alpha-3</version>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-component-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>commons-lang</groupId>
-      <artifactId>commons-lang</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-container-default</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.plexus.registry</groupId>
-      <artifactId>plexus-registry-api</artifactId>
-      <version>1.0-alpha-2</version>
-    </dependency>
-    <!-- Test Dependencies -->
-    <dependency>
-      <groupId>org.codehaus.plexus.registry</groupId>
-      <artifactId>plexus-registry-commons</artifactId>
-      <version>1.0-alpha-2</version>
-      <scope>test</scope>
-    </dependency>
-
-  </dependencies>
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.codehaus.plexus</groupId>
-        <artifactId>plexus-maven-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>merge</id>
-            <goals>
-              <goal>merge-descriptors</goal>
-            </goals>
-            <configuration>
-              <descriptors>
-                <descriptor>${basedir}/src/main/resources/META-INF/plexus/components.xml</descriptor>
-                <descriptor>${project.build.directory}/generated-resources/plexus/META-INF/plexus/components.xml</descriptor>
-              </descriptors>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-</project>
diff --git a/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/ArchivaTaskScheduler.java b/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/ArchivaTaskScheduler.java
deleted file mode 100644 (file)
index ffe3c62..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.apache.maven.archiva.scheduled;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
-
-/**
- * The component that takes care of scheduling in the application.
- *
- * @author <a href="mailto:brett@apache.org">Brett Porter</a>
- */
-public interface ArchivaTaskScheduler
-{
-    /**
-     * The Plexus component role.
-     */
-    public final static String ROLE = ArchivaTaskScheduler.class.getName();
-
-    public void runDatabaseTasks() throws TaskExecutionException;
-
-    public void runAllRepositoryTasks() throws TaskExecutionException;
-    
-    public void runRepositoryTasks( String repositoryId ) throws TaskExecutionException;
-    
-} 
diff --git a/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DatabaseTaskJob.java b/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DatabaseTaskJob.java
deleted file mode 100644 (file)
index 6f6a704..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-package org.apache.maven.archiva.scheduled;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.archiva.scheduled.tasks.ArchivaTask;
-import org.apache.maven.archiva.scheduled.tasks.DatabaseTask;
-import org.codehaus.plexus.scheduler.AbstractJob;
-import org.codehaus.plexus.taskqueue.TaskQueue;
-import org.codehaus.plexus.taskqueue.TaskQueueException;
-import org.quartz.JobDataMap;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
-
-/**
- * This class is the database job that is executed by the scheduler.
- */
-public class DatabaseTaskJob
-    extends AbstractJob
-{
-    static final String TASK_KEY = "EXECUTION";
-
-    static final String TASK_QUEUE = "TASK_QUEUE";
-
-    static final String TASK_QUEUE_POLICY = "TASK_QUEUE_POLICY";
-
-    /**
-     * Execute the discoverer and the indexer.
-     *
-     * @param context
-     * @throws org.quartz.JobExecutionException
-     *
-     */
-    public void execute( JobExecutionContext context )
-        throws JobExecutionException
-    {
-        JobDataMap dataMap = context.getJobDetail().getJobDataMap();
-        setJobDataMap( dataMap );
-
-        TaskQueue taskQueue = (TaskQueue) dataMap.get( TASK_QUEUE );
-        String queuePolicy = dataMap.get( TASK_QUEUE_POLICY ).toString();
-
-        ArchivaTask task = new DatabaseTask();
-        task.setName( context.getJobDetail().getName() );
-
-        try
-        {
-            if ( taskQueue.getQueueSnapshot().size() == 0 )
-            {
-                taskQueue.put( task );
-            }
-            else
-            {
-                if ( ArchivaTask.QUEUE_POLICY_WAIT.equals( queuePolicy ) )
-                {
-                    taskQueue.put( task );
-                }
-                else if ( ArchivaTask.QUEUE_POLICY_SKIP.equals( queuePolicy ) )
-                {
-                    // do not queue anymore, policy is to skip
-                }
-            }
-        }
-        catch ( TaskQueueException e )
-        {
-            throw new JobExecutionException( e );
-        }
-    }
-}
diff --git a/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java b/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java
deleted file mode 100644 (file)
index 2ea5311..0000000
+++ /dev/null
@@ -1,288 +0,0 @@
-package org.apache.maven.archiva.scheduled;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.RepositoryConfiguration;
-import org.apache.maven.archiva.database.ArchivaDatabaseException;
-import org.apache.maven.archiva.database.ObjectNotFoundException;
-import org.apache.maven.archiva.database.RepositoryDAO;
-import org.apache.maven.archiva.model.ArchivaRepository;
-import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException;
-import org.codehaus.plexus.registry.Registry;
-import org.codehaus.plexus.registry.RegistryListener;
-import org.codehaus.plexus.scheduler.Scheduler;
-import org.codehaus.plexus.taskqueue.TaskQueue;
-import org.codehaus.plexus.taskqueue.TaskQueueException;
-import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
-import org.quartz.CronTrigger;
-import org.quartz.JobDataMap;
-import org.quartz.JobDetail;
-import org.quartz.SchedulerException;
-
-import java.text.ParseException;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Default implementation of a scheduling component for archiva..
- *
- * @author <a href="mailto:brett@apache.org">Brett Porter</a>
- * @author <a href="mailto:jmcconnell@apache.org">Jesse McConnell</a>
- * @plexus.component role="org.apache.maven.archiva.scheduler.ArchivaTaskScheduler"
- */
-public class DefaultArchivaTaskScheduler
-    extends AbstractLogEnabled
-    implements ArchivaTaskScheduler, Startable, RegistryListener
-{
-    /**
-     * @plexus.requirement
-     */
-    private Scheduler scheduler;
-
-   
-    /**
-     * @plexus.requirement role-hint="archiva-task-queue"
-     */
-    private TaskQueue archivaTaskQueue;
-      
-    /**
-     * @plexus.requirement
-     */
-    private ArchivaConfiguration archivaConfiguration;
-  
-    
-    public static final String DATABASE_DISCOVERER_GROUP = "database-group";
-    
-    public static final String DATABASE_JOB = "database-job";
-    public static final String DATABASE_JOB_TRIGGER = "database-job-trigger";
-   
-    public static final String REPOSITORY_DISCOVERER_GROUP = "repository-group";
-    
-    public static final String REPOSITORY_JOB = "repository-job";
-    public static final String REPOSITORY_JOB_TRIGGER = "repository-job-trigger";
-    
-    public void start()
-        throws StartingException
-    {
-        try
-        {
-               List repositories = archivaConfiguration.getConfiguration().getRepositories();
-               
-               for ( Iterator i = repositories.iterator(); i.hasNext(); )
-               {
-                       RepositoryConfiguration repoConfig = (RepositoryConfiguration)i.next();
-                       
-                       scheduleRepositoryJobs( repoConfig );                   
-               }
-               
-               scheduleDatabaseJobs( );
-        }
-        catch ( SchedulerException e )
-        {
-            throw new StartingException( "Unable to start scheduler: " + e.getMessage(), e );
-        }
-    }
-
-    private void scheduleRepositoryJobs( RepositoryConfiguration repoConfig )
-       throws SchedulerException
-    {
-        if ( repoConfig.getRefreshCronExpression() == null )
-        {
-            getLogger().warn( "Skipping job, no cron expression for " + repoConfig.getId() );
-            return;
-        }
-        
-        // get the cron string for these database scanning jobs
-        String cronString = repoConfig.getRefreshCronExpression();        
-        
-        // setup the unprocessed artifact job
-        JobDetail repositoryJob =
-            new JobDetail( REPOSITORY_JOB + ":" + repoConfig.getId() , REPOSITORY_DISCOVERER_GROUP, RepositoryTaskJob.class );
-
-        JobDataMap dataMap = new JobDataMap();
-        dataMap.put( RepositoryTaskJob.TASK_QUEUE, archivaTaskQueue );
-        dataMap.put( RepositoryTaskJob.TASK_REPOSITORY, repoConfig.getId() );
-        repositoryJob.setJobDataMap( dataMap );
-       
-        try 
-        {
-            CronTrigger trigger =
-                new CronTrigger( REPOSITORY_JOB_TRIGGER + ":" + repoConfig.getId() , REPOSITORY_DISCOVERER_GROUP, cronString );
-        
-            scheduler.scheduleJob( repositoryJob, trigger );
-        }
-        catch ( ParseException e )
-        {
-            getLogger().error( "ParseException in repository scanning cron expression, disabling repository scanning for '" + repoConfig.getId() + "': " + e.getMessage() );
-        }
-             
-    }
-    
-    private void scheduleDatabaseJobs( )
-        throws SchedulerException
-    {        
-        String cronString = archivaConfiguration.getConfiguration().getDatabaseScanning().getCronExpression();
-        
-        // setup the unprocessed artifact job
-        JobDetail databaseJob =
-            new JobDetail( DATABASE_JOB, DATABASE_DISCOVERER_GROUP, DatabaseTaskJob.class );
-
-        JobDataMap dataMap = new JobDataMap();
-        dataMap.put( DatabaseTaskJob.TASK_QUEUE, archivaTaskQueue );
-        databaseJob.setJobDataMap( dataMap );
-       
-        try 
-        {
-            CronTrigger trigger =
-                new CronTrigger( DATABASE_JOB_TRIGGER, DATABASE_DISCOVERER_GROUP, cronString );
-        
-            scheduler.scheduleJob( databaseJob, trigger );
-        }
-        catch ( ParseException e )
-        {
-            getLogger().error( "ParseException in database scanning cron expression, disabling database scanning: " + e.getMessage() );
-        }
-        
-    }
-
-    public void stop()
-        throws StoppingException
-    {
-        try
-        {
-            scheduler.unscheduleJob( DATABASE_JOB, DATABASE_DISCOVERER_GROUP );         
-        }
-        catch ( SchedulerException e )
-        {
-            throw new StoppingException( "Unable to unschedule tasks", e );
-        }
-    }
-
-
-    public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
-    {
-        // nothing to do
-    }
-
-    /**
-     * 
-     */
-    public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
-    {
-        // cronExpression comes from the database scanning section
-        if ( "cronExpression".equals( propertyName ) )
-        {
-            getLogger().debug( "Restarting the database scheduled task after property change: " + propertyName );
-            
-            try
-            {
-                scheduler.unscheduleJob( DATABASE_JOB, DATABASE_DISCOVERER_GROUP );
-            
-                scheduleDatabaseJobs();
-            }
-            catch ( SchedulerException e )
-            {
-                getLogger().error( "Error restarting the database scanning job after property change." );
-            }
-        }
-        
-        // refreshCronExpression comes from the repositories section
-        // 
-        // currently we have to reschedule all repo jobs because we don't know where the changed one came from
-        if ( "refreshCronExpression".equals( propertyName ) )
-        {
-            List repositories = archivaConfiguration.getConfiguration().getRepositories();
-            
-            for ( Iterator i = repositories.iterator(); i.hasNext(); )
-            {
-                RepositoryConfiguration repoConfig = (RepositoryConfiguration)i.next();
-                
-                if ( repoConfig.getRefreshCronExpression() != null )
-                {
-                    try
-                    {
-                        // unschedule handles jobs that might not exist
-                        scheduler.unscheduleJob( REPOSITORY_JOB + ":" + repoConfig.getId() , REPOSITORY_DISCOVERER_GROUP );
-                        scheduleRepositoryJobs( repoConfig );
-                    }
-                    catch ( SchedulerException e )
-                    {
-                        getLogger().error( "error restarting job: " + REPOSITORY_JOB + ":" + repoConfig.getId() );
-                    }
-                }
-            }
-        }
-    }
-
-    public void runAllRepositoryTasks() throws TaskExecutionException
-    {
-        try
-        {
-            List repositories = archivaConfiguration.getConfiguration().getRepositories();
-            
-            for ( Iterator i = repositories.iterator(); i.hasNext(); )
-            {
-                RepositoryConfiguration repoConfig = (RepositoryConfiguration)i.next();
-                
-                scheduleRepositoryJobs( repoConfig );               
-            }
-            
-        }
-        catch ( SchedulerException e )
-        {
-            throw new TaskExecutionException( "Unable to schedule repository jobs: " + e.getMessage(), e );
-        }
-    }
-
-    public void runDatabaseTasks() throws TaskExecutionException
-    {
-        try
-        {
-            scheduleDatabaseJobs();
-        }
-        catch ( SchedulerException e )
-        {
-            throw new TaskExecutionException( "Unable to schedule repository jobs: " + e.getMessage(), e );
-
-        }
-    }
-
-    public void runRepositoryTasks( String repositoryId ) throws TaskExecutionException
-    {
-        try
-        {
-            RepositoryConfiguration repoConfig = archivaConfiguration.getConfiguration().findRepositoryById( repositoryId );
-            
-            scheduleRepositoryJobs( repoConfig );                         
-        }
-        catch ( SchedulerException e )
-        {
-            throw new TaskExecutionException( "Unable to schedule repository jobs: " + e.getMessage(), e );
-        } 
-    }
-
-    
-    
-}
diff --git a/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/RepositoryTaskJob.java b/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/RepositoryTaskJob.java
deleted file mode 100644 (file)
index cfe1488..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-package org.apache.maven.archiva.scheduled;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.archiva.scheduled.tasks.ArchivaTask;
-import org.apache.maven.archiva.scheduled.tasks.RepositoryTask;
-import org.codehaus.plexus.scheduler.AbstractJob;
-import org.codehaus.plexus.taskqueue.TaskQueue;
-import org.codehaus.plexus.taskqueue.TaskQueueException;
-import org.quartz.JobDataMap;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
-
-/**
- * This class is the repository job that is executed by the scheduler.
- */
-public class RepositoryTaskJob
-    extends AbstractJob
-{
-    static final String TASK_KEY = "EXECUTION";
-
-    static final String TASK_QUEUE = "TASK_QUEUE";
-
-    static final String TASK_QUEUE_POLICY = "TASK_QUEUE_POLICY";
-    
-    static final String TASK_REPOSITORY = "TASK_REPOSITORY";
-
-    /**
-     * Execute the discoverer and the indexer.
-     *
-     * @param context
-     * @throws org.quartz.JobExecutionException
-     *
-     */
-    public void execute( JobExecutionContext context )
-        throws JobExecutionException
-    {
-        JobDataMap dataMap = context.getJobDetail().getJobDataMap();
-        setJobDataMap( dataMap );
-
-        TaskQueue taskQueue = (TaskQueue) dataMap.get( TASK_QUEUE );
-        String queuePolicy = dataMap.get( TASK_QUEUE_POLICY ).toString();
-
-        ArchivaTask task = new RepositoryTask();
-        task.setName( context.getJobDetail().getName() );
-
-        try
-        {
-            if ( taskQueue.getQueueSnapshot().size() == 0 )
-            {
-                taskQueue.put( task );
-            }
-            else
-            {
-                if ( ArchivaTask.QUEUE_POLICY_WAIT.equals( queuePolicy ) )
-                {
-                    taskQueue.put( task );
-                }
-                else if ( ArchivaTask.QUEUE_POLICY_SKIP.equals( queuePolicy ) )
-                {
-                    // do not queue anymore, policy is to skip
-                }
-            }
-        }
-        catch ( TaskQueueException e )
-        {
-            throw new JobExecutionException( e );
-        }
-    }
-}
diff --git a/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaScheduledTaskExecutor.java b/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaScheduledTaskExecutor.java
deleted file mode 100644 (file)
index af629fd..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-package org.apache.maven.archiva.scheduled.executors;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.database.ArchivaDatabaseException;
-import org.apache.maven.archiva.database.RepositoryDAO;
-import org.apache.maven.archiva.database.updater.DatabaseUpdater;
-import org.apache.maven.archiva.model.ArchivaRepository;
-import org.apache.maven.archiva.repository.RepositoryException;
-import org.apache.maven.archiva.repository.scanner.RepositoryScanner;
-import org.apache.maven.archiva.scheduled.tasks.DatabaseTask;
-import org.apache.maven.archiva.scheduled.tasks.RepositoryTask;
-
-import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.taskqueue.Task;
-import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
-import org.codehaus.plexus.taskqueue.execution.TaskExecutor;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- *
- * @author <a href="mailto:jmcconnell@apache.org">Jesse McConnell</a>
- * @version $Id:$
- * 
- * @plexus.component role="org.codehaus.plexus.taskqueue.execution.TaskExecutor" 
- *      role-hint="archiva-task-executor"
- */
-public class ArchivaScheduledTaskExecutor extends AbstractLogEnabled implements TaskExecutor
-{
-    /**
-     * Configuration store.
-     *
-     * @plexus.requirement
-     */
-    private ArchivaConfiguration archivaConfiguration;
-
-    /**
-     * @plexus.requirement role-hint="jdo"
-     */
-    private DatabaseUpdater databaseUpdater;
-    
-    /**
-     * @plexus.requirement role-hint="jdo"
-     */
-    private RepositoryDAO repositoryDAO;
-    
-    /**
-     * The collection of available consumers.
-     * @plexus.requirement role="org.apache.maven.archiva.consumers.ArchivaArtifactConsumer"
-     */
-    private Map availableConsumers;
-    
-    public void executeTask( Task task ) throws TaskExecutionException
-    {
-        
-        if ( task instanceof DatabaseTask )          
-        {  
-            executeDatabaseTask( (DatabaseTask) task );
-        }
-        else if ( task instanceof RepositoryTask )
-        {
-            executeRepositoryTask( (RepositoryTask) task );
-        }
-        else
-        {
-            throw new TaskExecutionException( "Unknown Task: " + task.toString() );
-        }
-        
-    }
-
-    private void executeDatabaseTask( DatabaseTask task ) throws TaskExecutionException
-    {
-        getLogger().info( "Executing task from queue with job name: " + task.getName() );
-        long time = System.currentTimeMillis();
-
-        
-        try
-        {
-            databaseUpdater.updateAllUnprocessed();
-        }
-        catch ( ArchivaDatabaseException e )
-        {
-            throw new TaskExecutionException( "Error running unprocessed updater", e );
-        }
-       
-        try 
-        {
-            databaseUpdater.updateAllProcessed();
-        }
-        catch ( ArchivaDatabaseException e )
-        {
-            throw new TaskExecutionException( "Error running processed updater", e );
-        }       
-        
-        time = System.currentTimeMillis() - time;
-
-        getLogger().info( "Finished database task in " + time + "ms." );
-        
-    }
-    
-    private void executeRepositoryTask ( RepositoryTask task ) throws TaskExecutionException
-    {
-        getLogger().info( "Executing task from queue with job name: " + task.getName() );
-        
-        long time = System.currentTimeMillis();
-
-        try 
-        {
-            ArchivaRepository arepo = repositoryDAO.getRepository( task.getRepositoryId() );
-                    
-            RepositoryScanner scanner = new RepositoryScanner();
-            
-            scanner.scan( arepo, getActiveConsumerList(), true );
-            
-        }
-        catch ( ArchivaDatabaseException e )
-        {
-            throw new TaskExecutionException( "Database error when executing repository job.", e );
-        }
-        catch ( RepositoryException e )
-        {
-            throw new TaskExecutionException( "Repository error when executing repository job.", e );
-        }
-        
-        
-        time = System.currentTimeMillis() - time;
-
-        getLogger().info( "Finished repository task for " + time + "ms." );
-    }
-    
-    
-    private List getActiveConsumerList()
-    {       
-        List activeConsumers = new ArrayList();
-        
-        List configuredGoodConsumers = archivaConfiguration.getConfiguration().getRepositoryScanning().getGoodConsumers();
-        List configuredBadConsumers = archivaConfiguration.getConfiguration().getRepositoryScanning().getBadConsumers();
-        
-        for ( Iterator i = configuredGoodConsumers.iterator(); i.hasNext(); )
-        {
-            String consumer = (String)i.next();
-            
-            if ( availableConsumers.containsKey( availableConsumers.get( consumer ) )  )
-            {
-                activeConsumers.add( availableConsumers.get( consumer ) );
-            }
-            else
-            {
-                getLogger().warn( "RequestedConsumer [" + consumer + "] does not exist. Skipping in repository scan." );
-            }
-        }
-        
-        for ( Iterator i = configuredBadConsumers.iterator(); i.hasNext(); )
-        {
-            String consumer = (String)i.next();
-            
-            if ( availableConsumers.containsKey( availableConsumers.get( consumer ) )  )
-            {
-                activeConsumers.add( availableConsumers.get( consumer ) );
-            }
-            else
-            {
-                getLogger().warn( "RequestedConsumer [" + consumer + "] does not exist. Skipping in repository scan." );
-            }
-        }
-        
-        return activeConsumers;
-    }
-    
-}
diff --git a/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArchivaTask.java b/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArchivaTask.java
deleted file mode 100644 (file)
index 642f16b..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.apache.maven.archiva.scheduled.tasks;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.codehaus.plexus.taskqueue.Task;
-
-/**
- * A repository task.
- *
- * @author <a href="mailto:brett@apache.org">Brett Porter</a>
- */
-public interface ArchivaTask
-    extends Task
-{
-    public static final String QUEUE_POLICY_WAIT = "wait";
-
-    public static final String QUEUE_POLICY_SKIP = "skip";
-
-    /**
-     * Gets the queue policy for this task.
-     *
-     * @return Queue policy for this task
-     */
-    public String getQueuePolicy();
-
-    /**
-     * Sets the queue policy for this task.
-     *
-     * @param policy
-     */
-    public void setQueuePolicy( String policy );
-
-    /**
-     * Sets the job name to represent a group of similar / identical job tasks.  Can be used to check the
-     * task queue for similar / identical job tasks.
-     */
-    public void setName( String name );
-
-    /**
-     * obtains the name of the task
-     * @return
-     */
-    public String getName();
-
-    public long getMaxExecutionTime();
-
-    public void setMaxExecutionTime( long maxExecutionTime );
-
-
-   
-}
diff --git a/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/DatabaseTask.java b/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/DatabaseTask.java
deleted file mode 100644 (file)
index dbd58da..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.apache.maven.archiva.scheduled.tasks;
-
-/**
- * DataRefreshTask - task for discovering changes in the repository 
- * and updating all associated data. 
- *
- * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
- * @version $Id: DataRefreshTask.java 525176 2007-04-03 15:21:33Z joakime $
- */
-public class DatabaseTask
-    implements ArchivaTask
-{
-   
-    String name;
-    
-    String queuePolicy;
-
-    long maxExecutionTime;
-
-    public long getMaxExecutionTime()
-    {
-        return maxExecutionTime;
-    }
-
-    public void setMaxExecutionTime( long maxExecutionTime )
-    {
-        this.maxExecutionTime = maxExecutionTime;
-    }
-
-    public String getName()
-    {
-        return name;
-    }
-
-    public void setName( String name )
-    {
-        this.name = name;
-    }
-
-    public String getQueuePolicy()
-    {
-        return queuePolicy;
-    }
-
-    public void setQueuePolicy( String queuePolicy )
-    {
-        this.queuePolicy = queuePolicy;
-    }
-}
diff --git a/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTask.java b/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTask.java
deleted file mode 100644 (file)
index fca9173..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.apache.maven.archiva.scheduled.tasks;
-
-/**
- * DataRefreshTask - task for discovering changes in the repository 
- * and updating all associated data. 
- *
- * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
- * @version $Id: DataRefreshTask.java 525176 2007-04-03 15:21:33Z joakime $
- */
-public class RepositoryTask
-    implements ArchivaTask
-{
-    String repositoryId;
-    
-    String name;
-    
-    String queuePolicy;
-
-    long maxExecutionTime;
-    
-    public String getRepositoryId()
-    {
-        return repositoryId;
-    }
-
-    public void setRepositoryId( String repositoryId )
-    {
-        this.repositoryId = repositoryId;
-    }
-
-    public long getMaxExecutionTime()
-    {
-        return maxExecutionTime;
-    }
-
-    public void setMaxExecutionTime( long maxExecutionTime )
-    {
-        this.maxExecutionTime = maxExecutionTime;
-    }
-
-    public String getName()
-    {
-        return name;
-    }
-
-    public void setName( String name )
-    {
-        this.name = name;
-    }
-
-    public String getQueuePolicy()
-    {
-        return queuePolicy;
-    }
-
-    public void setQueuePolicy( String queuePolicy )
-    {
-        this.queuePolicy = queuePolicy;
-    }
-}
diff --git a/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/resources/META-INF/plexus/components.xml b/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/main/resources/META-INF/plexus/components.xml
deleted file mode 100644 (file)
index 245d002..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<components>
-    <component>
-      <role>org.codehaus.plexus.taskqueue.TaskQueue</role>
-      <role-hint>archiva-task-queue</role-hint>
-      <implementation>org.codehaus.plexus.taskqueue.DefaultTaskQueue</implementation>
-      <lifecycle-handler>plexus-configurable</lifecycle-handler>
-      <configuration>
-        <task-entry-evaluators>
-        </task-entry-evaluators>
-        <task-exit-evaluators>
-        </task-exit-evaluators>
-        <task-viability-evaluators>
-        </task-viability-evaluators>
-      </configuration>
-    </component>
-</components>
\ No newline at end of file
diff --git a/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/test/conf/repository-manager.xml b/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/test/conf/repository-manager.xml
deleted file mode 100644 (file)
index 07e9f96..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<configuration>
-  <repositories>
-    <repository>
-      <id>internal</id>
-      <name>Archiva Managed Internal Repository</name>
-      <url>file://${appserver.home}/repositories/internal</url>
-      <layout>default</layout>
-      <releases>true</releases>
-      <snapshots>false</snapshots>
-      <indexed>true</indexed>
-      <refreshCronExpression>0 0 * * ?</refreshCronExpression>
-    </repository>
-    <repository>
-      <id>snapshots</id>
-      <name>Archiva Managed Snapshot Repository</name>
-      <url>file://${appserver.home}/repositories/internal</url>
-      <layout>default</layout>
-      <releases>false</releases>
-      <snapshots>true</snapshots>
-      <indexed>true</indexed>
-      <refreshCronExpression>0 0,30 * * ?</refreshCronExpression>
-    </repository>
-    <repository>
-      <id>central</id>
-      <name>Central Repository</name>
-      <url>http://repo1.maven.org/maven2</url>
-      <layout>default</layout>
-      <releases>true</releases>
-      <snapshots>false</snapshots>
-      <indexed>false</indexed>
-    </repository>
-    <repository>
-      <id>maven2-repository.dev.java.net</id>
-      <name>Java.net Repository for Maven 2</name>
-      <url>https://maven2-repository.dev.java.net/nonav/repository</url>
-      <layout>default</layout>
-      <releases>true</releases>
-      <snapshots>false</snapshots>
-      <indexed>false</indexed>
-    </repository>
-  </repositories>
-
-  <proxyConnectors>
-    <proxyConnector>
-      <sourceRepoId>internal</sourceRepoId>
-      <targetRepoId>central</targetRepoId>
-      <proxyId />
-      <snapshotsPolicy>disabled</snapshotsPolicy>
-      <releasePolicy>never</releasePolicy>
-      <failurePolicy>not-found</failurePolicy>
-    </proxyConnector>
-    <proxyConnector>
-      <sourceRepoId>internal</sourceRepoId>
-      <targetRepoId>maven2-repository.dev.java.net</targetRepoId>
-      <proxyId />
-      <snapshotsPolicy>disabled</snapshotsPolicy>
-      <releasePolicy>never</releasePolicy>
-      <failurePolicy>not-found</failurePolicy>
-      <whiteListPatterns>
-        <whiteListPattern>javax/**</whiteListPattern>
-      </whiteListPatterns>
-    </proxyConnector>
-  </proxyConnectors>
-
-  <networkProxies>
-    <networkProxy>
-      <id>example</id>
-      <protocol>http</protocol>
-      <host>proxy.mycompany.com</host>
-      <port>8080</port>
-      <username>myself</username>
-      <password>mypass</password>
-    </networkProxy>
-  </networkProxies>
-
-  <repositoryScanning>
-    <fileTypes>
-      <fileType>
-        <id>artifacts</id>
-        <patterns>
-          <pattern>**/*.pom</pattern>
-          <pattern>**/*.jar</pattern>
-          <pattern>**/*.ear</pattern>
-          <pattern>**/*.war</pattern>
-          <pattern>**/*.car</pattern>
-          <pattern>**/*.sar</pattern>
-          <pattern>**/*.mar</pattern>
-          <pattern>**/*.rar</pattern>
-          <pattern>**/*.dtd</pattern>
-          <pattern>**/*.tld</pattern>
-          <pattern>**/*.tar.gz</pattern>
-          <pattern>**/*.tar.bz2</pattern>
-          <pattern>**/*.zip</pattern>
-        </patterns>
-      </fileType>
-      <fileType>
-        <id>indexable-content</id>
-        <patterns>
-          <pattern>**/*.txt</pattern>
-          <pattern>**/*.TXT</pattern>
-          <pattern>**/*.block</pattern>
-          <pattern>**/*.config</pattern>
-          <pattern>**/*.pom</pattern>
-          <pattern>**/*.xml</pattern>
-          <pattern>**/*.xsd</pattern>
-          <pattern>**/*.dtd</pattern>
-          <pattern>**/*.tld</pattern>
-        </patterns>
-      </fileType>
-      <fileType>
-        <id>auto-remove</id>
-        <patterns>
-          <pattern>**/*.bak</pattern>
-          <pattern>**/*~</pattern>
-          <pattern>**/*-</pattern>
-        </patterns>
-      </fileType>
-      <fileType>
-        <id>ignored</id>
-        <patterns>
-          <pattern>**/.htaccess</pattern>
-          <pattern>**/KEYS</pattern>
-          <pattern>**/*.rb</pattern>
-          <pattern>**/*.sh</pattern>
-          <pattern>**/.svn/**</pattern>
-          <pattern>**/.DAV/**</pattern>
-        </patterns>
-      </fileType>
-    </fileTypes>
-    <goodConsumers>
-      <goodConsumer>update-db-artifact</goodConsumer>
-      <goodConsumer>create-missing-checksums</goodConsumer>
-      <goodConsumer>update-db-repository-metadata</goodConsumer>
-      <goodConsumer>validate-checksum</goodConsumer>
-      <goodConsumer>validate-signature</goodConsumer>
-      <goodConsumer>index-content</goodConsumer>
-      <goodConsumer>auto-remove</goodConsumer>
-      <goodConsumer>auto-rename</goodConsumer>
-    </goodConsumers>
-    <badConsumers>
-      <badConsumer>update-db-bad-content</badConsumer>
-    </badConsumers>
-  </repositoryScanning>
-
-  <databaseScanning>
-    <cronExpression>0 0 * * ?</cronExpression>
-    <unprocessedConsumers>
-      <unprocessedConsumer>index-artifact</unprocessedConsumer>
-      <unprocessedConsumer>update-db-project</unprocessedConsumer>
-      <unprocessedConsumer>validate-repository-metadata</unprocessedConsumer>
-      <unprocessedConsumer>index-archive-toc</unprocessedConsumer>
-      <unprocessedConsumer>update-db-bytecode-stats</unprocessedConsumer>
-      <unprocessedConsumer>index-public-methods</unprocessedConsumer>
-    </unprocessedConsumers>
-    <processedConsumers>
-      <processedConsumer>not-present-remove-db-artifact</processedConsumer>
-      <processedConsumer>not-present-remove-db-project</processedConsumer>
-      <processedConsumer>not-present-remove-indexed</processedConsumer>
-    </processedConsumers>
-  </databaseScanning>
-
-</configuration>
diff --git a/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaScheduledTaskExecutorTest.java b/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaScheduledTaskExecutorTest.java
deleted file mode 100644 (file)
index 1bdb023..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-package org.apache.maven.archiva.scheduled.executors;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.io.FileUtils;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.database.ArchivaDAO;
-import org.apache.maven.archiva.database.ArchivaDatabaseException;
-import org.apache.maven.archiva.database.RepositoryDAO;
-import org.apache.maven.archiva.model.ArchivaRepository;
-import org.apache.maven.archiva.scheduled.tasks.RepositoryTask;
-import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
-import org.codehaus.plexus.jdo.JdoFactory;
-import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
-import org.codehaus.plexus.taskqueue.execution.TaskExecutor;
-import org.jpox.SchemaTool;
-
-import java.io.File;
-import java.net.URL;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.jdo.JDOHelper;
-import javax.jdo.PersistenceManager;
-import javax.jdo.PersistenceManagerFactory;
-
-/**
- * IndexerTaskExecutorTest
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id:$
- */
-public class ArchivaScheduledTaskExecutorTest
-    extends PlexusTestCase
-{
-    private TaskExecutor taskExecutor;
-
-    protected ArchivaDAO dao;
-    
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-        DefaultConfigurableJdoFactory jdoFactory = (DefaultConfigurableJdoFactory) lookup( JdoFactory.ROLE, "archiva" );
-        assertEquals( DefaultConfigurableJdoFactory.class.getName(), jdoFactory.getClass().getName() );
-
-        jdoFactory.setPersistenceManagerFactoryClass( "org.jpox.PersistenceManagerFactoryImpl" ); 
-
-        /* derby version
-        File derbyDbDir = new File( "target/plexus-home/testdb" );
-        if ( derbyDbDir.exists() )
-        {
-            FileUtils.deleteDirectory( derbyDbDir );
-        }
-
-        jdoFactory.setDriverName( System.getProperty( "jdo.test.driver", "org.apache.derby.jdbc.EmbeddedDriver" ) );   
-        jdoFactory.setUrl( System.getProperty( "jdo.test.url", "jdbc:derby:" + derbyDbDir.getAbsolutePath() + ";create=true" ) );
-         */   
-
-        jdoFactory.setDriverName( System.getProperty( "jdo.test.driver", "org.hsqldb.jdbcDriver" ) );   
-        jdoFactory.setUrl( System.getProperty( "jdo.test.url", "jdbc:hsqldb:mem:" + getName() ) );
-        
-        jdoFactory.setUserName( System.getProperty( "jdo.test.user", "sa" ) ); 
-
-        jdoFactory.setPassword( System.getProperty( "jdo.test.pass", "" ) ); 
-
-        jdoFactory.setProperty( "org.jpox.transactionIsolation", "READ_COMMITTED" );  
-
-        jdoFactory.setProperty( "org.jpox.poid.transactionIsolation", "READ_COMMITTED" );  
-
-        jdoFactory.setProperty( "org.jpox.autoCreateSchema", "true" );  
-
-        jdoFactory.setProperty( "javax.jdo.option.RetainValues", "true" );
-
-        jdoFactory.setProperty( "javax.jdo.option.RestoreValues", "true" );
-
-        // jdoFactory.setProperty( "org.jpox.autoCreateColumns", "true" );
-
-        jdoFactory.setProperty( "org.jpox.validateTables", "true" );
-
-        jdoFactory.setProperty( "org.jpox.validateColumns", "true" );
-
-        jdoFactory.setProperty( "org.jpox.validateConstraints", "true" );
-
-        Properties properties = jdoFactory.getProperties();
-
-        for ( Iterator it = properties.entrySet().iterator(); it.hasNext(); )
-        {
-            Map.Entry entry = (Map.Entry) it.next();
-
-            System.setProperty( (String) entry.getKey(), (String) entry.getValue() );
-        }
-
-        URL jdoFileUrls[] = new URL[] { getClass()
-            .getResource( "/org/apache/maven/archiva/model/package.jdo" ) }; 
-
-        if ( ( jdoFileUrls == null ) || ( jdoFileUrls[0] == null ) )
-        {
-            fail( "Unable to process test " + getName() + " - missing package.jdo." );
-        }
-
-        File propsFile = null; // intentional
-        boolean verbose = true;
-
-        SchemaTool.deleteSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose );
-        SchemaTool.createSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose, null );
-
-        PersistenceManagerFactory pmf = jdoFactory.getPersistenceManagerFactory();
-
-        assertNotNull( pmf );
-
-        PersistenceManager pm = pmf.getPersistenceManager();
-
-        pm.close();
-
-        this.dao = (ArchivaDAO) lookup( ArchivaDAO.class.getName(), "jdo" );
-
-        taskExecutor = (TaskExecutor) lookup( TaskExecutor.class.getName(), "test-archiva-task-executor" );
-    }
-
-    public void testExecutor() throws Exception
-    {
-        RepositoryDAO repoDao = dao.getRepositoryDAO();
-
-        // Create it
-        ArchivaRepository repo =
-            repoDao.createRepository( "testRepo", "Test Repository", "http://localhost:8080/repository/foo" );
-        assertNotNull( repo );
-
-        // Set some mandatory values
-        repo.getModel().setCreationSource( "Test Case" );
-        repo.getModel().setLayoutName( "default" );
-
-        // Save it.
-        ArchivaRepository repoSaved = repoDao.saveRepository( repo );
-        assertNotNull( repoSaved );
-        assertNotNull( repoSaved.getModel() );
-        assertEquals( "testRepo", JDOHelper.getObjectId( repoSaved.getModel() ).toString() );
-
-        RepositoryTask repoTask = new RepositoryTask();
-        
-        repoTask.setName( "testTask" );
-        repoTask.setRepositoryId( "testRepo" );
-        
-        taskExecutor.executeTask( repoTask );
-
-    }
-
-}
diff --git a/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaScheduledTaskExecutorTest.xml b/archiva-jpox-database-refactor/archiva-web/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaScheduledTaskExecutorTest.xml
deleted file mode 100644 (file)
index 5b212f6..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<component-set>
-  <components>
-    <component>
-      <role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role>
-      <role-hint>test-archiva-task-executor</role-hint>
-      <implementation>org.apache.maven.archiva.scheduled.executors.ArchivaScheduledTaskExecutor</implementation>
-      <description></description>
-      <requirements>
-        <requirement>
-          <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
-          <field-name>archivaConfiguration</field-name>
-          <role-hint>test-configuration</role-hint>
-        </requirement>
-        <requirement>
-          <role>org.apache.maven.archiva.database.updater.DatabaseUpdater</role>
-          <role-hint>jdo</role-hint>
-          <field-name>databaseUpdater</field-name>
-        </requirement>
-        <requirement>
-          <role>org.apache.maven.archiva.database.RepositoryDAO</role>
-          <role-hint>jdo</role-hint>
-          <field-name>repositoryDAO</field-name>
-        </requirement>
-         <requirement>
-          <role>org.apache.maven.archiva.consumers.ArchivaArtifactConsumer</role>
-          <field-name>availableConsumers</field-name>
-        </requirement>
-      </requirements>
-    </component>
-
-    <component>
-      <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
-      <role-hint>test-configuration</role-hint>
-      <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation>
-      <requirements>
-        <requirement>
-          <role>org.codehaus.plexus.registry.Registry</role>
-          <role-hint>configured</role-hint>
-        </requirement>
-      </requirements>
-    </component>
-    
-    <component>
-      <role>org.codehaus.plexus.registry.Registry</role>
-      <role-hint>configured</role-hint>
-      <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation>
-      <configuration>
-        <properties>
-          <system/>
-          <xml fileName="${basedir}/src/test/conf/repository-manager.xml"
-               config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/>
-        </properties>
-      </configuration>
-    </component>
-    
-    <component>
-      <role>org.codehaus.plexus.jdo.JdoFactory</role>
-      <role-hint>archiva</role-hint>
-      <implementation>org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory</implementation>
-      <configuration>
-        <persistenceManagerFactoryClass>org.jpox.PersistenceManagerFactoryImpl</persistenceManagerFactoryClass>
-        <otherProperties>
-          <property>
-            <name>javax.jdo.PersistenceManagerFactoryClass</name>
-            <value>org.jpox.PersistenceManagerFactoryImpl</value>
-          </property>
-        </otherProperties>
-      </configuration>
-    </component>
-  </components>
-</component-set>