From: Olivier Lamy Date: Wed, 26 Mar 2014 22:27:02 +0000 (+0000) Subject: extract cassandra configuration in a configuration file X-Git-Tag: archiva-2.1.0~164 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7d1c504705a384185dc53cfa762d91b3fc44bd06;p=archiva.git extract cassandra configuration in a configuration file git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1582094 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-webapp/pom.xml b/archiva-modules/archiva-web/archiva-webapp/pom.xml index af9aab487..8ec1bb6b1 100644 --- a/archiva-modules/archiva-web/archiva-webapp/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp/pom.xml @@ -1003,12 +1003,8 @@ ${archiva.devMode} ${archiva.javascriptLog} ${archiva.logMissingI18n} - - localhost - 9160 + localhost + 9160 ${archiva.sirona.configuration} 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 @@ maven-surefire-plugin - ${cassandraPort} + ${cassandraPort} 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 @@ + + + + \ No newline at end of file