From cef293cf574359cda04473e4010ee3c1b7059ee8 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 7 Nov 2011 08:29:35 +0000 Subject: [PATCH] move jdbc test url and jdbc test driver to properties to be able to change that in one place git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1198646 13f79535-47bb-0310-9956-ffa450edef68 --- .../resources/archetype-resources/pom.xml | 3 ++- .../archiva-core-consumers/pom.xml | 4 ++-- .../archiva-base/archiva-indexer/pom.xml | 4 ++-- .../indexer/merger/DefaultIndexMerger.java | 23 +++++++++++++++++++ .../archiva/indexer/merger/IndexMerger.java | 11 ++++++--- .../archiva-base/archiva-proxy/pom.xml | 4 ++-- .../archiva-repository-admin-default/pom.xml | 4 ++-- .../archiva-scheduler-indexing/pom.xml | 4 ++-- .../archiva-rest-services/pom.xml | 4 ++-- .../archiva-web/archiva-security/pom.xml | 4 ++-- .../archiva-web/archiva-webapp/pom.xml | 5 ++-- .../archiva-web/archiva-webdav/pom.xml | 4 ++-- .../webdav/ArchivaDavResourceFactory.java | 2 +- .../archiva-xmlrpc-services/pom.xml | 4 ++-- pom.xml | 3 +++ 15 files changed, 58 insertions(+), 25 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/pom.xml index 08c3752ed..ec49d4a95 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/pom.xml @@ -150,7 +150,8 @@ ${project.build.directory}/appserver-base ${basedir}/target/archiva.xml ${project.build.testOutputDirectory} - jdbc:derby:memory:users-test;create=true + + org.apache.derby.jdbc.EmbeddedDriver diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml index 4222dfc0d..0367aa66d 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml @@ -119,8 +119,8 @@ ${project.build.directory}/appserver-base ${project.build.directory}/appserver-base ${project.build.directory}/appserver-base - jdbc:derby:memory:users-test;create=true - org.apache.derby.jdbc.EmbeddedDriver + ${redbackTestJdbcUrl} + ${redbackTestJdbcDriver} ${project.build.directory}/archiva.xml diff --git a/archiva-modules/archiva-base/archiva-indexer/pom.xml b/archiva-modules/archiva-base/archiva-indexer/pom.xml index ec70560dc..426f6d34e 100644 --- a/archiva-modules/archiva-base/archiva-indexer/pom.xml +++ b/archiva-modules/archiva-base/archiva-indexer/pom.xml @@ -170,8 +170,8 @@ ${project.build.directory}/appserver-base ${project.build.directory}/appserver-base ${project.build.directory}/appserver-base - jdbc:derby:memory:users-test;create=true - org.apache.derby.jdbc.EmbeddedDriver + ${redbackTestJdbcUrl} + ${redbackTestJdbcDriver} diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java index 045d2c28d..11b0814c2 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java @@ -24,6 +24,7 @@ import org.apache.archiva.common.plexusbridge.MavenIndexerUtils; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.math.NumberUtils; import org.apache.maven.index.NexusIndexer; import org.apache.maven.index.context.IndexingContext; import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException; @@ -34,6 +35,7 @@ import org.slf4j.LoggerFactory; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; +import javax.annotation.PostConstruct; import javax.inject.Inject; import java.io.File; import java.io.IOException; @@ -50,6 +52,11 @@ public class DefaultIndexMerger implements IndexMerger { + /** + * default tmp created group index ttl in minutes + */ + static final int DEFAULT_GROUP_INDEX_TTL = 30; + private Logger log = LoggerFactory.getLogger( getClass() ); @Inject @@ -63,6 +70,8 @@ public class DefaultIndexMerger private List temporaryGroupIndexes = new CopyOnWriteArrayList(); + private int defaultGroupIndexTtl; + @Inject public DefaultIndexMerger( PlexusSisuBridge plexusSisuBridge, MavenIndexerUtils mavenIndexerUtils ) throws PlexusSisuBridgeException @@ -72,6 +81,15 @@ public class DefaultIndexMerger indexPacker = plexusSisuBridge.lookup( IndexPacker.class, "default" ); } + @PostConstruct + public void intialize() + { + String ttlStr = + System.getProperty( IndexMerger.TMP_GROUP_INDEX_SYS_KEY, Integer.toString( DEFAULT_GROUP_INDEX_TTL ) ); + this.defaultGroupIndexTtl = NumberUtils.toInt( ttlStr, DEFAULT_GROUP_INDEX_TTL ); + + } + public IndexingContext buildMergedIndex( Collection repositoriesIds, boolean packIndex ) throws IndexMergerException { @@ -148,4 +166,9 @@ public class DefaultIndexMerger { return this.temporaryGroupIndexes; } + + public int getDefaultGroupIndexTtl() + { + return this.defaultGroupIndexTtl; + } } diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java index 999d85bd5..4dbe2a819 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java @@ -29,11 +29,12 @@ import java.util.Collection; */ public interface IndexMerger { + /** - * default tmp created group index ttl in minutes + * system property which contains the value in s for ttl of temporary index groups */ - static final int DEFAULT_GROUP_INDEX_TTL = 30; - + static final String TMP_GROUP_INDEX_SYS_KEY = "archiva.tmp.group.index.ttl"; + /** * @param repositoriesIds repositories Ids to merge content * @param packIndex will generate a downloadable index @@ -47,5 +48,9 @@ public interface IndexMerger Collection getTemporaryGroupIndexes(); + /** + * @return ttl of temporay group index + */ + int getDefaultGroupIndexTtl(); } diff --git a/archiva-modules/archiva-base/archiva-proxy/pom.xml b/archiva-modules/archiva-base/archiva-proxy/pom.xml index 3cf6f60bd..62e485ed2 100644 --- a/archiva-modules/archiva-base/archiva-proxy/pom.xml +++ b/archiva-modules/archiva-base/archiva-proxy/pom.xml @@ -159,8 +159,8 @@ ${project.build.directory}/appserver-base ${project.build.directory}/appserver-base ${project.build.directory}/appserver-base - jdbc:derby:memory:users-test;create=true - org.apache.derby.jdbc.EmbeddedDriver + ${redbackTestJdbcUrl} + ${redbackTestJdbcDriver} diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml index b01764f23..4e4524e2d 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml @@ -213,8 +213,8 @@ ${project.build.directory}/appserver-base ${project.build.directory}/appserver-base ${project.build.directory}/appserver-base - jdbc:derby:memory:users-test;create=true - org.apache.derby.jdbc.EmbeddedDriver + ${redbackTestJdbcUrl} + ${redbackTestJdbcDriver} diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml index 50375e7ab..11d084e00 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml @@ -147,8 +147,8 @@ ${project.build.directory}/appserver-base ${project.build.directory}/appserver-base ${project.build.directory}/appserver-base - jdbc:derby:memory:users-test;create=true - org.apache.derby.jdbc.EmbeddedDriver + ${redbackTestJdbcUrl} + ${redbackTestJdbcDriver} ${basedir} diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml index 06a428e70..b2bae3f29 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml @@ -311,8 +311,8 @@ ${archiva.baseRestUrl} ${rest.admin.pwd} ${test.useTomcat} - jdbc:derby:memory:users-test;create=true - org.apache.derby.jdbc.EmbeddedDriver + ${redbackTestJdbcUrl} + ${redbackTestJdbcDriver} diff --git a/archiva-modules/archiva-web/archiva-security/pom.xml b/archiva-modules/archiva-web/archiva-security/pom.xml index cb9709f3e..99ac1d7a2 100644 --- a/archiva-modules/archiva-web/archiva-security/pom.xml +++ b/archiva-modules/archiva-web/archiva-security/pom.xml @@ -161,8 +161,8 @@ ${project.build.directory}/appserver-base - jdbc:derby:memory:users-test;create=true - org.apache.derby.jdbc.EmbeddedDriver + ${redbackTestJdbcUrl} + ${redbackTestJdbcDriver} diff --git a/archiva-modules/archiva-web/archiva-webapp/pom.xml b/archiva-modules/archiva-web/archiva-webapp/pom.xml index a8e5b31db..47ce9fd60 100644 --- a/archiva-modules/archiva-web/archiva-webapp/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp/pom.xml @@ -579,8 +579,8 @@ ${rest.admin.pwd} ${basedir}/target/archiva.xml ${project.build.testOutputDirectory} - jdbc:derby:memory:users-test;create=true - org.apache.derby.jdbc.EmbeddedDriver + ${redbackTestJdbcUrl} + ${redbackTestJdbcDriver} ${basedir} @@ -648,6 +648,7 @@ ${project.build.directory}/appserver-home ${basedir}/appserver-base/logs ${basedir}/target/auto-admin-creation.properties + ${project.build.directory} diff --git a/archiva-modules/archiva-web/archiva-webdav/pom.xml b/archiva-modules/archiva-web/archiva-webdav/pom.xml index 6047ef797..3b6b83bcd 100644 --- a/archiva-modules/archiva-web/archiva-webdav/pom.xml +++ b/archiva-modules/archiva-web/archiva-webdav/pom.xml @@ -199,8 +199,8 @@ ${project.build.directory}/appserver-base ${project.build.testOutputDirectory} ${project.build.testOutputDirectory}/repository-archiva.xml - jdbc:derby:memory:users-test;create=true - org.apache.derby.jdbc.EmbeddedDriver + ${redbackTestJdbcUrl} + ${redbackTestJdbcDriver} ${webdav.forkMode} diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java index a4341ced0..de71e9d15 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java @@ -1215,7 +1215,7 @@ public class ArchivaDavResourceFactory if ( tmp != null && tmp.getDirectory() != null && tmp.getDirectory().exists() ) { - if ( System.currentTimeMillis() - tmp.getCreationTime() > ( IndexMerger.DEFAULT_GROUP_INDEX_TTL * 60 + if ( System.currentTimeMillis() - tmp.getCreationTime() > ( indexMerger.getDefaultGroupIndexTtl() * 60 * 1000 ) ) { log.debug( "tmp group index is too old so delete it" ); diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml index 901eb48c8..3a01a683d 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml @@ -169,8 +169,8 @@ ${project.build.directory}/appserver-base ${project.build.testOutputDirectory} ${project.build.directory}/appserver-base - jdbc:derby:memory:users-test;create=true - org.apache.derby.jdbc.EmbeddedDriver + ${redbackTestJdbcUrl} + ${redbackTestJdbcDriver} diff --git a/pom.xml b/pom.xml index d94192e81..61c2267d4 100644 --- a/pom.xml +++ b/pom.xml @@ -78,6 +78,9 @@ 10.1.3.1 1.4 7.4.5.v20110725 + + + org.apache.derby.jdbc.EmbeddedDriver -- 2.39.5