diff options
author | Olivier Lamy <olamy@apache.org> | 2014-03-28 11:43:24 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2014-03-28 11:43:24 +0000 |
commit | bef128817d76a8aac1fa575df8197f8af5a62921 (patch) | |
tree | 8eef57af1b1bc9ac655d485aa267b88787f93c28 /archiva-modules | |
parent | d4aee19ee6b233bff720ac573106565a2d0976b7 (diff) | |
download | archiva-bef128817d76a8aac1fa575df8197f8af5a62921.tar.gz archiva-bef128817d76a8aac1fa575df8197f8af5a62921.zip |
move the factory bean to the api
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1582713 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules')
20 files changed, 70 insertions, 39 deletions
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 2708e39ac..97f911ff3 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 @@ -160,6 +160,7 @@ <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> + <archiva.repositorySessionFactory.id>test</archiva.repositorySessionFactory.id> </systemPropertyVariables> </configuration> </plugin> diff --git a/archiva-modules/archiva-base/archiva-indexer/pom.xml b/archiva-modules/archiva-base/archiva-indexer/pom.xml index a8756505f..922123c4b 100644 --- a/archiva-modules/archiva-base/archiva-indexer/pom.xml +++ b/archiva-modules/archiva-base/archiva-indexer/pom.xml @@ -219,6 +219,7 @@ <derby.system.home>${project.build.directory}/appserver-base</derby.system.home> <redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url> <redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name> + <archiva.repositorySessionFactory.id>mock</archiva.repositorySessionFactory.id> </systemPropertyVariables> </configuration> </plugin> diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/mock/MockRepositorySessionFactory.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/mock/MockRepositorySessionFactory.java index 2acbcb57c..0fd0ae27b 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/mock/MockRepositorySessionFactory.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/mock/MockRepositorySessionFactory.java @@ -38,7 +38,7 @@ import java.util.List; /** * @author Olivier Lamy */ -@Service( "RepositorySessionFactory#mock" ) +@Service( "repositorySessionFactory#mock" ) public class MockRepositorySessionFactory implements RepositorySessionFactory { diff --git a/archiva-modules/archiva-base/archiva-proxy/pom.xml b/archiva-modules/archiva-base/archiva-proxy/pom.xml index c074ff4e5..fd8fbb8fe 100644 --- a/archiva-modules/archiva-base/archiva-proxy/pom.xml +++ b/archiva-modules/archiva-base/archiva-proxy/pom.xml @@ -250,6 +250,7 @@ <derby.system.home>${project.build.directory}/appserver-base</derby.system.home> <redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url> <redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name> + <archiva.repositorySessionFactory.id>test</archiva.repositorySessionFactory.id> </systemPropertyVariables> </configuration> </plugin> diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java index f836043ff..38a421ac1 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java @@ -23,7 +23,7 @@ import org.springframework.stereotype.Service; * specific language governing permissions and limitations * under the License. */ -@Service("repositorySessionFactory") +@Service("repositorySessionFactory#test") public class TestRepositorySessionFactory implements RepositorySessionFactory { 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 e4d7e444c..d18a9b739 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 @@ -287,6 +287,7 @@ <derby.system.home>${project.build.directory}/appserver-base</derby.system.home> <redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url> <redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name> + <archiva.repositorySessionFactory.id>mock</archiva.repositorySessionFactory.id> </systemPropertyVariables> </configuration> </plugin> diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/MockRepositorySessionFactory.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/MockRepositorySessionFactory.java index 7be9d6cb7..199f0e288 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/MockRepositorySessionFactory.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/MockRepositorySessionFactory.java @@ -38,7 +38,7 @@ import java.util.List; /** * @author Olivier Lamy */ -@Service( "RepositorySessionFactory#mock" ) +@Service( "repositorySessionFactory#mock" ) public class MockRepositorySessionFactory implements RepositorySessionFactory { diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml index 18e2e6642..6f6c3ed34 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml @@ -236,6 +236,7 @@ <redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url> <redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name> <basedir>${basedir}</basedir> + <archiva.repositorySessionFactory.id>mock</archiva.repositorySessionFactory.id> </systemPropertyVariables> </configuration> </plugin> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/mock/MockRepositorySessionFactory.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/mock/MockRepositorySessionFactory.java index 85c01299a..5776681d5 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/mock/MockRepositorySessionFactory.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/mock/MockRepositorySessionFactory.java @@ -38,7 +38,7 @@ import java.util.List; /** * @author Olivier Lamy */ -@Service( "RepositorySessionFactory#mock" ) +@Service( "repositorySessionFactory#mock" ) public class MockRepositorySessionFactory implements RepositorySessionFactory { diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml index b3dad9ce1..b152f2fec 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml @@ -171,6 +171,15 @@ </excludes> </configuration> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <systemPropertyVariables> + <archiva.repositorySessionFactory.id>test</archiva.repositorySessionFactory.id> + </systemPropertyVariables> + </configuration> + </plugin> </plugins> </pluginManagement> </build> diff --git a/archiva-modules/archiva-web/archiva-security/pom.xml b/archiva-modules/archiva-web/archiva-security/pom.xml index c1e99c861..4c59752f3 100644 --- a/archiva-modules/archiva-web/archiva-security/pom.xml +++ b/archiva-modules/archiva-web/archiva-security/pom.xml @@ -243,6 +243,7 @@ <derby.system.home>${project.build.directory}/appserver-base</derby.system.home> <redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url> <redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name> + <archiva.repositorySessionFactory.id>file</archiva.repositorySessionFactory.id> </systemPropertyVariables> </configuration> </plugin> diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/META-INF/spring-context.xml index a948d74aa..06cf58a64 100755 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/META-INF/spring-context.xml @@ -40,7 +40,8 @@ <constructor-arg ref="jcr-config"/> </bean> - <bean id="jcr-config" class="org.apache.archiva.metadata.repository.jcr.ArchivaJcrRepositoryConfig" factory-method="create"> + <bean id="jcr-config" class="org.apache.archiva.metadata.repository.jcr.ArchivaJcrRepositoryConfig" factory-method="create" + lazy-init="true"> <constructor-arg value="${appserver.base}/conf/repository.xml"/> <constructor-arg value="${appserver.base}/data/jcr"/> </bean> diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml index 155d08000..254bf6206 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml @@ -37,12 +37,6 @@ <alias name="authorizer#rbac" alias="authorizer#default"/> <alias name="repositoryStatisticsManager#default" alias="repositoryStatisticsManager"/> - <!-- so can be override with -Darchiva.repositorySessionFactory.id= jcr or cassandra or file --> - <bean name="repositorySessionFactory" class="org.apache.archiva.web.startup.RepositorySessionFactoryBean"> - <constructor-arg> - <util:properties location="classpath:archiva-runtime.properties" local-override="true"/> - </constructor-arg> - </bean> <alias name="environmentCheck#archiva-locked-admin-check" alias="environmentCheck#locked-admin-check"/> <alias name="userManager#archiva" alias="userManager#default"/> diff --git a/archiva-modules/archiva-web/archiva-webdav/pom.xml b/archiva-modules/archiva-web/archiva-webdav/pom.xml index 2166fa7c3..ed1d56fd8 100644 --- a/archiva-modules/archiva-web/archiva-webdav/pom.xml +++ b/archiva-modules/archiva-web/archiva-webdav/pom.xml @@ -308,6 +308,7 @@ <archiva.user.configFileName>${project.build.testOutputDirectory}/repository-archiva.xml</archiva.user.configFileName> <redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url> <redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name> + <archiva.repositorySessionFactory.id>beer</archiva.repositorySessionFactory.id> </systemPropertyVariables> <forkMode>${webdav.forkMode}</forkMode> </configuration> diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java index 224f7ec23..93a4e5ce5 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java @@ -21,7 +21,7 @@ package org.apache.archiva.metadata.repository; import org.springframework.stereotype.Service; -@Service +@Service("repositorySessionFactory#beer") public class TestRepositorySessionFactory implements RepositorySessionFactory { diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/RepositorySessionFactoryBean.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/RepositorySessionFactoryBean.java index 855b8b89a..e182104f1 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/RepositorySessionFactoryBean.java +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/RepositorySessionFactoryBean.java @@ -1,4 +1,4 @@ -package org.apache.archiva.web.startup; +package org.apache.archiva.metadata.repository; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -19,7 +19,6 @@ package org.apache.archiva.web.startup; * under the License. */ -import org.apache.archiva.metadata.repository.RepositorySessionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.config.AbstractFactoryBean; @@ -36,16 +35,22 @@ public class RepositorySessionFactoryBean private Logger logger = LoggerFactory.getLogger( getClass() ); - //@Value( "repositorySessionFactory#${archiva.repositorySessionFactory.id}" ) - //private String beanName; + private static final String BEAN_ID_SYS_PROPS = "archiva.repositorySessionFactory.id"; private Properties properties; + private String id; + public RepositorySessionFactoryBean( Properties properties ) { this.properties = properties; // we can override with system props - this.properties.putAll( System.getProperties() ); + String value = System.getProperty( BEAN_ID_SYS_PROPS ); + if ( value != null ) + { + this.properties.put( BEAN_ID_SYS_PROPS, value ); + } + id = properties.getProperty( BEAN_ID_SYS_PROPS ); } @Override @@ -58,13 +63,22 @@ public class RepositorySessionFactoryBean protected RepositorySessionFactory createInstance() throws Exception { - String id = properties.getProperty( "archiva.repositorySessionFactory.id" ); RepositorySessionFactory repositorySessionFactory = getBeanFactory().getBean( "repositorySessionFactory#" + id, RepositorySessionFactory.class ); logger.info( "create RepositorySessionFactory instance of {}", repositorySessionFactory.getClass().getName() ); return repositorySessionFactory; } + public String getId() + { + return id; + } + + public void setId( String id ) + { + this.id = id; + } + public Properties getProperties() { return properties; diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/resources/META-INF/spring-context.xml b/archiva-modules/metadata/metadata-repository-api/src/main/resources/META-INF/spring-context.xml index 6e1dc2489..e7c511811 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/metadata/metadata-repository-api/src/main/resources/META-INF/spring-context.xml @@ -21,14 +21,22 @@ <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" + xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context-3.0.xsd" + http://www.springframework.org/schema/context/spring-context-3.0.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd" default-lazy-init="true"> <context:annotation-config/> <context:component-scan base-package="org.apache.archiva.metadata.repository"/> + <!-- so can be override with -Darchiva.repositorySessionFactory.id= jcr or cassandra or file --> + <bean name="repositorySessionFactory" class="org.apache.archiva.metadata.repository.RepositorySessionFactoryBean"> + <constructor-arg> + <util:properties location="classpath:archiva-runtime.properties" local-override="true"/> + </constructor-arg> + </bean> </beans>
\ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/archiva-runtime.properties b/archiva-modules/metadata/metadata-repository-api/src/main/resources/archiva-runtime.properties index ad69475d7..d41614e69 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/archiva-runtime.properties +++ b/archiva-modules/metadata/metadata-repository-api/src/main/resources/archiva-runtime.properties @@ -16,5 +16,5 @@ # specific language governing permissions and limitations # under the License. # - +#default value archiva.repositorySessionFactory.id=jcr
\ No newline at end of file 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 26ffb080a..0c6a967eb 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 @@ -31,6 +31,8 @@ import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition; import me.prettyprint.hector.api.ddl.ColumnIndexType; import me.prettyprint.hector.api.ddl.ComparatorType; import me.prettyprint.hector.api.factory.HFactory; +import org.apache.archiva.metadata.repository.RepositorySessionFactoryBean; +import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; @@ -89,35 +91,40 @@ public class DefaultCassandraArchivaManager private String dependencyFamilyName = "dependency"; @Value("${cassandra.host}") - private String cassandraHost;// = System.getProperty( "cassandra.host", "localhost" ); + private String cassandraHost; @Value("${cassandra.port}") - private String cassandraPort;// = System.getProperty( "cassandra.port", "9160" ); + private String cassandraPort; @Value("${cassandra.maxActive}") - private int maxActive;// = Integer.getInteger( "cassandra.maxActive", 20 ); + private int maxActive; @Value("${cassandra.readConsistencyLevel}") - private String readConsistencyLevel;// = - //System.getProperty( "cassandra.readConsistencyLevel", HConsistencyLevel.QUORUM.name() ); + private String readConsistencyLevel; @Value("${cassandra.writeConsistencyLevel}") private String writeConsistencyLevel; - //= System.getProperty( "cassandra.writeConsistencyLevel", HConsistencyLevel.QUORUM.name() ); @Value("${cassandra.replicationFactor}") - private int replicationFactor;// = Integer.getInteger( "cassandra.replicationFactor", 1 ); + private int replicationFactor; @Value("${cassandra.keyspace.name}") - private String keyspaceName;// = System.getProperty( "cassandra.keyspace.name", KEYSPACE_NAME ); + private String keyspaceName; @Value("${cassandra.cluster.name}") - private String clusterName;// = System.getProperty( "cassandra.cluster.name", CLUSTER_NAME ); + private String clusterName; + + @Inject + private RepositorySessionFactoryBean repositorySessionFactoryBean; @PostConstruct public void initialize() { - + // skip initialisation if not cassandra + if ( !StringUtils.equals( repositorySessionFactoryBean.getId(), "cassandra" ) ) + { + return; + } final CassandraHostConfigurator configurator = new CassandraHostConfigurator( cassandraHost + ":" + cassandraPort ); configurator.setMaxActive( maxActive ); diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java index 2f41d4d6f..4ae693ccf 100644 --- a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java +++ b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java @@ -51,20 +51,11 @@ public class JcrRepositorySessionFactory @Inject private ApplicationContext applicationContext; - /** - * - */ private Map<String, MetadataFacetFactory> metadataFacetFactories; - /** - * - */ @Inject private Repository repository; - /** - * - */ @Inject private MetadataResolver metadataResolver; |