]> source.dussan.org Git - archiva.git/commitdiff
extract cassandra configuration in a configuration file
authorOlivier Lamy <olamy@apache.org>
Wed, 26 Mar 2014 22:27:02 +0000 (22:27 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 26 Mar 2014 22:27:02 +0000 (22:27 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1582094 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp/pom.xml
archiva-modules/plugins/metadata-store-cassandra/pom.xml
archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java
archiva-modules/plugins/metadata-store-cassandra/src/main/resources/META-INF/spring-context.xml

index af9aab4870791b8d6ff64697c897b66157079a42..8ec1bb6b1001884bfa08564bff158650780183ad 100644 (file)
             <archiva.devMode>${archiva.devMode}</archiva.devMode>
             <archiva.javascriptLog>${archiva.javascriptLog}</archiva.javascriptLog>
             <archiva.logMissingI18n>${archiva.logMissingI18n}</archiva.logMissingI18n>
-            <!--
-            not needed as we use asyncLogger in configuration
-            <Log4jContextSelector>org.apache.logging.log4j.core.async.AsyncLoggerContextSelector</Log4jContextSelector>
-            -->
-            <cassandraHost>localhost</cassandraHost>
-            <cassandraPort>9160</cassandraPort>
+            <cassandra.host>localhost</cassandra.host>
+            <cassandra.port>9160</cassandra.port>
             <org.apache.sirona.configuration.sirona.properties>${archiva.sirona.configuration}</org.apache.sirona.configuration.sirona.properties>
           </systemProperties>
           <additionalClasspathDirs>
index 8703d93ef795472178401cfdf5598c5f5d61c303..08a8e4d01f9e4e655cb94ec1bc7c0e1c9de9593e 100644 (file)
           <artifactId>maven-surefire-plugin</artifactId>
           <configuration>
             <systemPropertyVariables>
-              <cassandraPort>${cassandraPort}</cassandraPort>
+              <cassandra.port>${cassandraPort}</cassandra.port>
             </systemPropertyVariables>
           </configuration>
         </plugin>
index 9a40693c4103c6310bb1acec7b377036285f8bf3..26ffb080a971ed9110d496af25bc0f67b0bc840e 100644 (file)
@@ -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 );
index e1c2c24bbfc54aea4a0b7bbf88d321113a88d54f..805ef8ce49a876961b6b29ac2611640078c026fb 100644 (file)
   <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