diff options
author | Olivier Lamy <olamy@apache.org> | 2014-03-26 22:27:02 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2014-03-26 22:27:02 +0000 |
commit | 7d1c504705a384185dc53cfa762d91b3fc44bd06 (patch) | |
tree | b20964e92ff2de2626fdd4dd351ba8c95279e90d /archiva-modules/plugins | |
parent | acc72428047d54ba43f802d457afb4f5d10f9c88 (diff) | |
download | archiva-7d1c504705a384185dc53cfa762d91b3fc44bd06.tar.gz archiva-7d1c504705a384185dc53cfa762d91b3fc44bd06.zip |
extract cassandra configuration in a configuration file
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1582094 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/plugins')
3 files changed, 37 insertions, 14 deletions
diff --git a/archiva-modules/plugins/metadata-store-cassandra/pom.xml b/archiva-modules/plugins/metadata-store-cassandra/pom.xml index 8703d93ef..08a8e4d01 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/pom.xml +++ b/archiva-modules/plugins/metadata-store-cassandra/pom.xml @@ -272,7 +272,7 @@ <artifactId>maven-surefire-plugin</artifactId> <configuration> <systemPropertyVariables> - <cassandraPort>${cassandraPort}</cassandraPort> + <cassandra.port>${cassandraPort}</cassandra.port> </systemPropertyVariables> </configuration> </plugin> diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java index 9a40693c4..26ffb080a 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java @@ -33,6 +33,7 @@ import me.prettyprint.hector.api.ddl.ComparatorType; import me.prettyprint.hector.api.factory.HFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Service; @@ -87,23 +88,35 @@ public class DefaultCassandraArchivaManager private String dependencyFamilyName = "dependency"; + @Value("${cassandra.host}") + private String cassandraHost;// = System.getProperty( "cassandra.host", "localhost" ); + + @Value("${cassandra.port}") + private String cassandraPort;// = System.getProperty( "cassandra.port", "9160" ); + + @Value("${cassandra.maxActive}") + private int maxActive;// = Integer.getInteger( "cassandra.maxActive", 20 ); + + @Value("${cassandra.readConsistencyLevel}") + private String readConsistencyLevel;// = + //System.getProperty( "cassandra.readConsistencyLevel", HConsistencyLevel.QUORUM.name() ); + + @Value("${cassandra.writeConsistencyLevel}") + private String writeConsistencyLevel; + //= System.getProperty( "cassandra.writeConsistencyLevel", HConsistencyLevel.QUORUM.name() ); + + @Value("${cassandra.replicationFactor}") + private int replicationFactor;// = Integer.getInteger( "cassandra.replicationFactor", 1 ); + + @Value("${cassandra.keyspace.name}") + private String keyspaceName;// = System.getProperty( "cassandra.keyspace.name", KEYSPACE_NAME ); + + @Value("${cassandra.cluster.name}") + private String clusterName;// = System.getProperty( "cassandra.cluster.name", CLUSTER_NAME ); @PostConstruct public void initialize() { - // FIXME must come from configuration not sys props - String cassandraHost = System.getProperty( "cassandraHost", "localhost" ); - String cassandraPort = System.getProperty( "cassandraPort" ); - int maxActive = Integer.getInteger( "cassandra.maxActive", 20 ); - String readConsistencyLevel = - System.getProperty( "cassandra.readConsistencyLevel", HConsistencyLevel.QUORUM.name() ); - String writeConsistencyLevel = - System.getProperty( "cassandra.readConsistencyLevel", HConsistencyLevel.QUORUM.name() ); - - int replicationFactor = Integer.getInteger( "cassandra.replicationFactor", 1 ); - - String keyspaceName = System.getProperty( "cassandra.keyspace.name", KEYSPACE_NAME ); - String clusterName = System.getProperty( "cassandra.cluster.name", CLUSTER_NAME ); final CassandraHostConfigurator configurator = new CassandraHostConfigurator( cassandraHost + ":" + cassandraPort ); diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/resources/META-INF/spring-context.xml b/archiva-modules/plugins/metadata-store-cassandra/src/main/resources/META-INF/spring-context.xml index e1c2c24bb..805ef8ce4 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/resources/META-INF/spring-context.xml @@ -30,4 +30,14 @@ <context:annotation-config/> <context:component-scan base-package="org.apache.archiva.metadata.repository.cassandra"/> + <context:property-placeholder location="classpath:default-archiva-cassandra.properties" + system-properties-mode="OVERRIDE" + order="2"/> + + <context:property-placeholder location="file:${archiva.cassandra.configuration.file}" + ignore-resource-not-found="true" + ignore-unresolvable="true" + system-properties-mode="OVERRIDE" + order="1"/> + </beans>
\ No newline at end of file |