View Javadoc

1   package org.apache.maven.archiva.scheduled;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.ArrayList;
23  import java.util.List;
24  
25  import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
26  import org.apache.maven.archiva.consumers.ConsumerException;
27  import org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer;
28  import org.apache.maven.archiva.model.ArchivaArtifact;
29  import org.slf4j.Logger;
30  import org.slf4j.LoggerFactory;
31  
32  /**
33   * TestDatabaseUnprocessedConsumer 
34   *
35   * @version $Id: TestDatabaseUnprocessedConsumer.java 755300 2009-03-17 16:18:51Z brett $
36   */
37  public class TestDatabaseUnprocessedConsumer
38      extends AbstractMonitoredConsumer
39      implements DatabaseUnprocessedArtifactConsumer
40  {
41      private Logger log = LoggerFactory.getLogger( TestDatabaseUnprocessedConsumer.class );
42      
43      private int countBegin = 0;
44  
45      private int countComplete = 0;
46  
47      private int countProcessed = 0;
48  
49      public void resetCount()
50      {
51          countBegin = 0;
52          countProcessed = 0;
53          countComplete = 0;
54      }
55  
56      public void beginScan()
57      {
58          countBegin++;
59      }
60  
61      public void completeScan()
62      {
63          countComplete++;
64      }
65  
66      public List<String> getIncludedTypes()
67      {
68          List<String> types = new ArrayList<String>();
69          types.add( "pom" );
70          types.add( "jar" );
71          return types;
72      }
73  
74      public void processArchivaArtifact( ArchivaArtifact artifact )
75          throws ConsumerException
76      {
77          log.info( "Processing Artifact: " + artifact );
78          countProcessed++;
79      }
80  
81      public String getDescription()
82      {
83          return "Test Consumer for Database Unprocessed";
84      }
85  
86      public String getId()
87      {
88          return "test-db-unprocessed";
89      }
90  
91      public boolean isPermanent()
92      {
93          return false;
94      }
95  
96      public int getCountBegin()
97      {
98          return countBegin;
99      }
100 
101     public int getCountComplete()
102     {
103         return countComplete;
104     }
105 
106     public int getCountProcessed()
107     {
108         return countProcessed;
109     }
110 }