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
This commit is contained in:
Olivier Lamy 2011-11-07 08:29:35 +00:00
parent 9721429786
commit cef293cf57
15 changed files with 59 additions and 26 deletions

View File

@ -150,7 +150,8 @@
<appserver.base>${project.build.directory}/appserver-base</appserver.base>
<archiva.user.configFileName>${basedir}/target/archiva.xml</archiva.user.configFileName>
<test.resources.path>${project.build.testOutputDirectory}</test.resources.path>
<redback.jdbc.url>jdbc:derby:memory:users-test;create=true</redback.jdbc.url>
<!-- restore when we will be able to use a derby in memory database -->
<!--redback.jdbc.url>jdbc:derby:memory:users-test;create=true</redback.jdbc.url-->
<redback.jdbc.driver.name>org.apache.derby.jdbc.EmbeddedDriver</redback.jdbc.driver.name>
</systemPropertyVariables>
</configuration>

View File

@ -119,8 +119,8 @@
<appserver.base>${project.build.directory}/appserver-base</appserver.base>
<plexus.home>${project.build.directory}/appserver-base</plexus.home>
<derby.system.home>${project.build.directory}/appserver-base</derby.system.home>
<redback.jdbc.url>jdbc:derby:memory:users-test;create=true</redback.jdbc.url>
<redback.jdbc.driver.name>org.apache.derby.jdbc.EmbeddedDriver</redback.jdbc.driver.name>
<redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
<redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name>
<archiva.user.configFileName>${project.build.directory}/archiva.xml</archiva.user.configFileName>
</systemPropertyVariables>
</configuration>

View File

@ -170,8 +170,8 @@
<appserver.base>${project.build.directory}/appserver-base</appserver.base>
<plexus.home>${project.build.directory}/appserver-base</plexus.home>
<derby.system.home>${project.build.directory}/appserver-base</derby.system.home>
<redback.jdbc.url>jdbc:derby:memory:users-test;create=true</redback.jdbc.url>
<redback.jdbc.driver.name>org.apache.derby.jdbc.EmbeddedDriver</redback.jdbc.driver.name>
<redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
<redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name>
</systemPropertyVariables>
</configuration>
</plugin>

View File

@ -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<TemporaryGroupIndex> temporaryGroupIndexes = new CopyOnWriteArrayList<TemporaryGroupIndex>();
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<String> repositoriesIds, boolean packIndex )
throws IndexMergerException
{
@ -148,4 +166,9 @@ public class DefaultIndexMerger
{
return this.temporaryGroupIndexes;
}
public int getDefaultGroupIndexTtl()
{
return this.defaultGroupIndexTtl;
}
}

View File

@ -29,11 +29,12 @@ import java.util.Collection;
*/
public interface IndexMerger
{
/**
* default tmp created group index ttl in minutes
*/
static final int DEFAULT_GROUP_INDEX_TTL = 30;
/**
* system property which contains the value in s for ttl of temporary index groups
*/
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<TemporaryGroupIndex> getTemporaryGroupIndexes();
/**
* @return ttl of temporay group index
*/
int getDefaultGroupIndexTtl();
}

View File

@ -159,8 +159,8 @@
<appserver.base>${project.build.directory}/appserver-base</appserver.base>
<plexus.home>${project.build.directory}/appserver-base</plexus.home>
<derby.system.home>${project.build.directory}/appserver-base</derby.system.home>
<redback.jdbc.url>jdbc:derby:memory:users-test;create=true</redback.jdbc.url>
<redback.jdbc.driver.name>org.apache.derby.jdbc.EmbeddedDriver</redback.jdbc.driver.name>
<redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
<redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name>
</systemPropertyVariables>
</configuration>
</plugin>

View File

@ -213,8 +213,8 @@
<appserver.base>${project.build.directory}/appserver-base</appserver.base>
<plexus.home>${project.build.directory}/appserver-base</plexus.home>
<derby.system.home>${project.build.directory}/appserver-base</derby.system.home>
<redback.jdbc.url>jdbc:derby:memory:users-test;create=true</redback.jdbc.url>
<redback.jdbc.driver.name>org.apache.derby.jdbc.EmbeddedDriver</redback.jdbc.driver.name>
<redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
<redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name>
</systemPropertyVariables>
</configuration>
</plugin>

View File

@ -147,8 +147,8 @@
<appserver.base>${project.build.directory}/appserver-base</appserver.base>
<plexus.home>${project.build.directory}/appserver-base</plexus.home>
<derby.system.home>${project.build.directory}/appserver-base</derby.system.home>
<redback.jdbc.url>jdbc:derby:memory:users-test;create=true</redback.jdbc.url>
<redback.jdbc.driver.name>org.apache.derby.jdbc.EmbeddedDriver</redback.jdbc.driver.name>
<redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
<redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name>
<basedir>${basedir}</basedir>
</systemPropertyVariables>
</configuration>

View File

@ -311,8 +311,8 @@
<archiva.baseRestUrl>${archiva.baseRestUrl}</archiva.baseRestUrl>
<rest.admin.pwd>${rest.admin.pwd}</rest.admin.pwd>
<test.useTomcat>${test.useTomcat}</test.useTomcat>
<redback.jdbc.url>jdbc:derby:memory:users-test;create=true</redback.jdbc.url>
<redback.jdbc.driver.name>org.apache.derby.jdbc.EmbeddedDriver</redback.jdbc.driver.name>
<redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
<redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name>
</systemPropertyVariables>
</configuration>
</plugin>

View File

@ -161,8 +161,8 @@
<configuration>
<systemPropertyVariables>
<derby.system.home>${project.build.directory}/appserver-base</derby.system.home>
<redback.jdbc.url>jdbc:derby:memory:users-test;create=true</redback.jdbc.url>
<redback.jdbc.driver.name>org.apache.derby.jdbc.EmbeddedDriver</redback.jdbc.driver.name>
<redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
<redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name>
</systemPropertyVariables>
</configuration>
</plugin>

View File

@ -579,8 +579,8 @@
<rest.admin.pwd>${rest.admin.pwd}</rest.admin.pwd>
<archiva.user.configFileName>${basedir}/target/archiva.xml</archiva.user.configFileName>
<test.resources.path>${project.build.testOutputDirectory}</test.resources.path>
<redback.jdbc.url>jdbc:derby:memory:users-test;create=true</redback.jdbc.url>
<redback.jdbc.driver.name>org.apache.derby.jdbc.EmbeddedDriver</redback.jdbc.driver.name>
<redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
<redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name>
<basedir>${basedir}</basedir>
</systemPropertyVariables>
</configuration>
@ -648,6 +648,7 @@
<appserver.home>${project.build.directory}/appserver-home</appserver.home>
<derby.system.home>${basedir}/appserver-base/logs</derby.system.home>
<redback.admin.creation.file>${basedir}/target/auto-admin-creation.properties</redback.admin.creation.file>
<java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
</systemProperties>
</configuration>
<dependencies>

View File

@ -199,8 +199,8 @@
<derby.system.home>${project.build.directory}/appserver-base</derby.system.home>
<test.resources.path>${project.build.testOutputDirectory}</test.resources.path>
<archiva.user.configFileName>${project.build.testOutputDirectory}/repository-archiva.xml</archiva.user.configFileName>
<redback.jdbc.url>jdbc:derby:memory:users-test;create=true</redback.jdbc.url>
<redback.jdbc.driver.name>org.apache.derby.jdbc.EmbeddedDriver</redback.jdbc.driver.name>
<redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
<redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name>
</systemPropertyVariables>
<forkMode>${webdav.forkMode}</forkMode>
</configuration>

View File

@ -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" );

View File

@ -169,8 +169,8 @@
<plexus.home>${project.build.directory}/appserver-base</plexus.home>
<java.io.tmpdir>${project.build.testOutputDirectory}</java.io.tmpdir>
<derby.system.home>${project.build.directory}/appserver-base</derby.system.home>
<redback.jdbc.url>jdbc:derby:memory:users-test;create=true</redback.jdbc.url>
<redback.jdbc.driver.name>org.apache.derby.jdbc.EmbeddedDriver</redback.jdbc.driver.name>
<redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
<redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name>
</systemPropertyVariables>
</configuration>
</plugin>

View File

@ -78,6 +78,9 @@
<derbyVersion>10.1.3.1</derbyVersion>
<javaxMailVersion>1.4</javaxMailVersion>
<jettyVersion>7.4.5.v20110725</jettyVersion>
<!-- restore when we will be able to use a derby in memory database -->
<!--redbackTestJdbcUrl>jdbc:derby:memory:users-test;create=true</redbackTestJdbcUrl-->
<redbackTestJdbcDriver>org.apache.derby.jdbc.EmbeddedDriver</redbackTestJdbcDriver>
</properties>
<dependencyManagement>