You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2010/01/24 20:08:34 UTC
svn commit: r902621 - in /james/server/trunk: ./ avalon-user-function/
avalon-user-function/src/main/java/org/apache/james/userrepository/
avalon-user-function/src/main/java/org/apache/james/vut/
avalon-user-function/src/test/java/org/apache/james/user...
Author: norman
Date: Sun Jan 24 19:08:32 2010
New Revision: 902621
URL: http://svn.apache.org/viewvc?rev=902621&view=rev
Log:
Replace DataSourceSelector / DataSourceComponent with own DataSourceSelector service and DataSource. Reuse the spring configured datasource (JAMES-960)
Added:
james/server/trunk/core-api/src/main/java/org/apache/james/services/DataSourceSelector.java
james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/SpringDataSourceSelector.java
Removed:
james/server/trunk/core-function/src/main/java/org/apache/james/util/dbcp/
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/test/mock/DummyDataSourceSelector.java
Modified:
james/server/trunk/avalon-user-function/pom.xml
james/server/trunk/avalon-user-function/src/main/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java
james/server/trunk/avalon-user-function/src/main/java/org/apache/james/vut/JDBCVirtualUserTable.java
james/server/trunk/avalon-user-function/src/test/java/org/apache/james/userrepository/DefaultUsersJdbcRepositoryTest.java
james/server/trunk/avalon-user-function/src/test/java/org/apache/james/vut/JDBCVirtualUserTableTest.java
james/server/trunk/core-function/pom.xml
james/server/trunk/core-function/src/main/java/org/apache/james/domain/JDBCDomainList.java
james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/JDBCMailRepository.java
james/server/trunk/core-function/src/test/java/org/apache/james/domain/JDBCDomainListTest.java
james/server/trunk/core-function/src/test/java/org/apache/james/mailrepository/JDBCMailRepositoryTest.java
james/server/trunk/core-library/pom.xml
james/server/trunk/core-library/src/test/java/org/apache/james/test/util/Util.java
james/server/trunk/mailets-function/pom.xml
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysisFeeder.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCListserv.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCVirtualUserTable.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java
james/server/trunk/management-library/pom.xml
james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/BayesianAnalyzerManagement.java
james/server/trunk/pom.xml
james/server/trunk/smtpserver-function/pom.xml
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/JDBCGreylistHandler.java
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AsyncSMTPServerTest.java
james/server/trunk/spring-deployment/pom.xml
james/server/trunk/spring-deployment/src/main/config/james/james-config.xml
james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml
Modified: james/server/trunk/avalon-user-function/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/avalon-user-function/pom.xml?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/avalon-user-function/pom.xml (original)
+++ james/server/trunk/avalon-user-function/pom.xml Sun Jan 24 19:08:32 2010
@@ -74,14 +74,6 @@
<groupId>org.apache.avalon.cornerstone.store</groupId>
<artifactId>cornerstone-store-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.excalibur.components</groupId>
- <artifactId>excalibur-datasource</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.avalon.cornerstone.datasources</groupId>
- <artifactId>cornerstone-datasources-api</artifactId>
- </dependency>
<dependency>
<groupId>org.apache.james</groupId>
@@ -107,11 +99,14 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.avalon.cornerstone.datasources</groupId>
- <artifactId>cornerstone-datasources-impl</artifactId>
+
+
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
Modified: james/server/trunk/avalon-user-function/src/main/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/avalon-user-function/src/main/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/avalon-user-function/src/main/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java (original)
+++ james/server/trunk/avalon-user-function/src/main/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java Sun Jan 24 19:08:32 2010
@@ -19,12 +19,11 @@
package org.apache.james.userrepository;
-import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
-import org.apache.avalon.excalibur.datasource.DataSourceComponent;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.james.api.user.User;
import org.apache.james.impl.jamesuser.AbstractUsersRepository;
+import org.apache.james.services.DataSourceSelector;
import org.apache.james.services.FileSystem;
import org.apache.james.util.sql.JDBCUtil;
import org.apache.james.util.sql.SqlResources;
@@ -45,6 +44,7 @@
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
+import javax.sql.DataSource;
/**
* An abstract base class for creating UserRepository implementations
@@ -80,7 +80,7 @@
private DataSourceSelector m_datasources;
- private DataSourceComponent m_datasource;
+ private DataSource m_datasource;
// Fetches all Users from the db.
private String m_getUsersSql;
@@ -276,8 +276,7 @@
};
// Get the data-source required.
- m_datasource = (DataSourceComponent) m_datasources
- .select(m_datasourceName);
+ m_datasource = m_datasources.getDataSource(m_datasourceName);
// Test the connection to the database, by getting the DatabaseMetaData.
Connection conn = openConnection();
Modified: james/server/trunk/avalon-user-function/src/main/java/org/apache/james/vut/JDBCVirtualUserTable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/avalon-user-function/src/main/java/org/apache/james/vut/JDBCVirtualUserTable.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/avalon-user-function/src/main/java/org/apache/james/vut/JDBCVirtualUserTable.java (original)
+++ james/server/trunk/avalon-user-function/src/main/java/org/apache/james/vut/JDBCVirtualUserTable.java Sun Jan 24 19:08:32 2010
@@ -36,14 +36,14 @@
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
+import javax.sql.DataSource;
-import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
-import org.apache.avalon.excalibur.datasource.DataSourceComponent;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.james.api.vut.management.InvalidMappingException;
import org.apache.james.impl.vut.AbstractVirtualUserTable;
import org.apache.james.impl.vut.VirtualUserTableUtil;
+import org.apache.james.services.DataSourceSelector;
import org.apache.james.services.FileSystem;
import org.apache.james.util.sql.JDBCUtil;
import org.apache.james.util.sql.SqlResources;
@@ -54,7 +54,7 @@
public class JDBCVirtualUserTable extends AbstractVirtualUserTable {
private DataSourceSelector datasources = null;
- private DataSourceComponent dataSourceComponent = null;
+ private DataSource dataSourceComponent = null;
private String tableName = "VirtualUserTable";
private String dataSourceName = null;
@@ -136,7 +136,7 @@
@PostConstruct
public void init() throws Exception {
- setDataSourceComponent((DataSourceComponent) datasources.select(dataSourceName));
+ setDataSource(datasources.getDataSource(dataSourceName));
StringBuffer logBuffer = null;
if (getLogger().isDebugEnabled()) {
@@ -218,7 +218,7 @@
};
- public void setDataSourceComponent(DataSourceComponent dataSourceComponent) {
+ public void setDataSource(DataSource dataSourceComponent) {
this.dataSourceComponent = dataSourceComponent;
}
Modified: james/server/trunk/avalon-user-function/src/test/java/org/apache/james/userrepository/DefaultUsersJdbcRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/avalon-user-function/src/test/java/org/apache/james/userrepository/DefaultUsersJdbcRepositoryTest.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/avalon-user-function/src/test/java/org/apache/james/userrepository/DefaultUsersJdbcRepositoryTest.java (original)
+++ james/server/trunk/avalon-user-function/src/test/java/org/apache/james/userrepository/DefaultUsersJdbcRepositoryTest.java Sun Jan 24 19:08:32 2010
@@ -19,15 +19,14 @@
package org.apache.james.userrepository;
-import org.apache.avalon.cornerstone.blocks.datasources.DefaultDataSourceSelector;
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.james.api.user.UsersRepository;
+import org.apache.james.services.DataSourceSelector;
import org.apache.james.test.mock.james.MockFileSystem;
import org.apache.james.test.util.Util;
-import org.apache.james.util.ConfigurationAdapter;
import java.util.Iterator;
@@ -57,7 +56,7 @@
*/
protected void configureAbstractJdbcUsersRepository(AbstractJdbcUsersRepository res, String tableString) throws Exception, ConfigurationException {
res.setFileSystem(new MockFileSystem());
- DefaultDataSourceSelector dataSourceSelector = Util.getDataSourceSelector();
+ DataSourceSelector dataSourceSelector = Util.getDataSourceSelector();
res.setDatasources(dataSourceSelector );
Modified: james/server/trunk/avalon-user-function/src/test/java/org/apache/james/vut/JDBCVirtualUserTableTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/avalon-user-function/src/test/java/org/apache/james/vut/JDBCVirtualUserTableTest.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/avalon-user-function/src/test/java/org/apache/james/vut/JDBCVirtualUserTableTest.java (original)
+++ james/server/trunk/avalon-user-function/src/test/java/org/apache/james/vut/JDBCVirtualUserTableTest.java Sun Jan 24 19:08:32 2010
@@ -21,32 +21,28 @@
package org.apache.james.vut;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.configuration.DefaultConfiguration;
-import org.apache.avalon.framework.service.ServiceException;
+import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.james.api.vut.management.InvalidMappingException;
import org.apache.james.impl.vut.AbstractVirtualUserTable;
import org.apache.james.test.mock.james.MockFileSystem;
-import org.apache.james.test.mock.util.AttrValConfiguration;
import org.apache.james.test.util.Util;
-import org.apache.james.util.ConfigurationAdapter;
public class JDBCVirtualUserTableTest extends AbstractVirtualUserTableTest {
/**
* @see org.apache.james.vut.AbstractVirtualUserTableTest#getVirtalUserTable()
*/
- protected AbstractVirtualUserTable getVirtalUserTable() throws ServiceException, ConfigurationException, Exception {
+ protected AbstractVirtualUserTable getVirtalUserTable() throws Exception {
JDBCVirtualUserTable mr = new JDBCVirtualUserTable();
mr.setLog(new SimpleLog("MockLog"));
mr.setDataSourceSelector(Util.getDataSourceSelector());
mr.setDNSService(setUpDNSServer());
mr.setFileSystem(new MockFileSystem());
- DefaultConfiguration defaultConfiguration = new DefaultConfiguration("ReposConf");
- defaultConfiguration.setAttribute("destinationURL","db://maildb/VirtualUserTable");
- defaultConfiguration.addChild(new AttrValConfiguration("sqlFile","file://conf/sqlResources.xml"));
- mr.configure(new ConfigurationAdapter(defaultConfiguration));
+ DefaultConfigurationBuilder defaultConfiguration = new DefaultConfigurationBuilder();
+ defaultConfiguration.addProperty("[@destinationURL]","db://maildb/VirtualUserTable");
+ defaultConfiguration.addProperty("sqlFile","file://conf/sqlResources.xml");
+ mr.configure(defaultConfiguration);
mr.init();
return mr;
}
Added: james/server/trunk/core-api/src/main/java/org/apache/james/services/DataSourceSelector.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-api/src/main/java/org/apache/james/services/DataSourceSelector.java?rev=902621&view=auto
==============================================================================
--- james/server/trunk/core-api/src/main/java/org/apache/james/services/DataSourceSelector.java (added)
+++ james/server/trunk/core-api/src/main/java/org/apache/james/services/DataSourceSelector.java Sun Jan 24 19:08:32 2010
@@ -0,0 +1,33 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.services;
+
+import javax.sql.DataSource;
+
+public interface DataSourceSelector {
+
+ /**
+ * Return datasource for the given name or null if none can be found
+ *
+ * @param name
+ * @return ds
+ */
+ public DataSource getDataSource(String name);
+}
Modified: james/server/trunk/core-function/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/core-function/pom.xml?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/core-function/pom.xml (original)
+++ james/server/trunk/core-function/pom.xml Sun Jan 24 19:08:32 2010
@@ -74,14 +74,7 @@
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.avalon.cornerstone.datasources</groupId>
- <artifactId>cornerstone-datasources-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.excalibur.components</groupId>
- <artifactId>excalibur-datasource</artifactId>
- </dependency>
+
<dependency>
<groupId>org.apache.avalon.cornerstone.store</groupId>
<artifactId>cornerstone-store-api</artifactId>
@@ -118,11 +111,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.avalon.cornerstone.datasources</groupId>
- <artifactId>cornerstone-datasources-impl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>test</scope>
Modified: james/server/trunk/core-function/src/main/java/org/apache/james/domain/JDBCDomainList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-function/src/main/java/org/apache/james/domain/JDBCDomainList.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/core-function/src/main/java/org/apache/james/domain/JDBCDomainList.java (original)
+++ james/server/trunk/core-function/src/main/java/org/apache/james/domain/JDBCDomainList.java Sun Jan 24 19:08:32 2010
@@ -34,12 +34,12 @@
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
+import javax.sql.DataSource;
-import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
-import org.apache.avalon.excalibur.datasource.DataSourceComponent;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.james.services.DataSourceSelector;
import org.apache.james.services.FileSystem;
import org.apache.james.util.sql.JDBCUtil;
import org.apache.james.util.sql.SqlResources;
@@ -50,7 +50,7 @@
public class JDBCDomainList extends AbstractDomainList {
private DataSourceSelector datasources;
- private DataSourceComponent dataSourceComponent;
+ private DataSource dataSourceComponent;
private FileSystem fileSystem;
private String tableName = null;
@@ -74,7 +74,7 @@
this.configuration = (HierarchicalConfiguration)configuration;
}
- public void setDataSourceComponent(DataSourceComponent dataSourceComponent) {
+ public void setDataSource(DataSource dataSourceComponent) {
this.dataSourceComponent = dataSourceComponent;
}
@@ -147,7 +147,7 @@
public void init() throws Exception {
configure();
- setDataSourceComponent((DataSourceComponent) datasources.select(dataSourceName));
+ setDataSource(datasources.getDataSource(dataSourceName));
StringBuffer logBuffer = null;
if (getLogger().isDebugEnabled()) {
Modified: james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/JDBCMailRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/JDBCMailRepository.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/JDBCMailRepository.java (original)
+++ james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/JDBCMailRepository.java Sun Jan 24 19:08:32 2010
@@ -21,15 +21,14 @@
package org.apache.james.mailrepository;
-import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
import org.apache.avalon.cornerstone.services.store.StreamRepository;
-import org.apache.avalon.excalibur.datasource.DataSourceComponent;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.james.core.MailImpl;
import org.apache.james.core.MimeMessageCopyOnWriteProxy;
import org.apache.james.core.MimeMessageWrapper;
+import org.apache.james.services.DataSourceSelector;
import org.apache.james.services.FileSystem;
import org.apache.james.util.sql.JDBCUtil;
import org.apache.james.util.sql.SqlResources;
@@ -40,6 +39,7 @@
import javax.annotation.Resource;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
+import javax.sql.DataSource;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -110,7 +110,7 @@
/**
* The JDBC datasource that provides the JDBC connection
*/
- protected DataSourceComponent datasource;
+ protected DataSource datasource;
/**
* The name of the datasource used by this repository
@@ -282,7 +282,7 @@
}
};
// Get the data-source required.
- datasource = (DataSourceComponent)datasources.select(datasourceName);
+ datasource = datasources.getDataSource(datasourceName);
// Test the connection to the database, by getting the DatabaseMetaData.
Connection conn = datasource.getConnection();
Modified: james/server/trunk/core-function/src/test/java/org/apache/james/domain/JDBCDomainListTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-function/src/test/java/org/apache/james/domain/JDBCDomainListTest.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/core-function/src/test/java/org/apache/james/domain/JDBCDomainListTest.java (original)
+++ james/server/trunk/core-function/src/test/java/org/apache/james/domain/JDBCDomainListTest.java Sun Jan 24 19:08:32 2010
@@ -28,16 +28,17 @@
import java.sql.ResultSet;
import java.sql.SQLException;
+import javax.sql.DataSource;
+
import junit.framework.TestCase;
-import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
-import org.apache.avalon.excalibur.datasource.DataSourceComponent;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.james.api.dnsservice.AbstractDNSServer;
import org.apache.james.api.dnsservice.DNSService;
+import org.apache.james.services.DataSourceSelector;
import org.apache.james.test.mock.james.MockFileSystem;
import org.apache.james.test.util.Util;
import org.apache.james.util.sql.JDBCUtil;
@@ -46,11 +47,11 @@
private String repos = "db://maildb/";
private String table = "costumTable";
private DataSourceSelector dataSource;
- private DataSourceComponent data;
+ private DataSource data;
public void setUp() throws Exception {
dataSource = Util.getDataSourceSelector();
- data = (DataSourceComponent) dataSource.select("maildb");
+ data = dataSource.getDataSource("maildb");
sqlQuery("create table " + table + " (domain VARCHAR (255))");
}
Modified: james/server/trunk/core-function/src/test/java/org/apache/james/mailrepository/JDBCMailRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-function/src/test/java/org/apache/james/mailrepository/JDBCMailRepositoryTest.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/core-function/src/test/java/org/apache/james/mailrepository/JDBCMailRepositoryTest.java (original)
+++ james/server/trunk/core-function/src/test/java/org/apache/james/mailrepository/JDBCMailRepositoryTest.java Sun Jan 24 19:08:32 2010
@@ -20,10 +20,10 @@
package org.apache.james.mailrepository;
-import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.james.mailrepository.filepair.File_Persistent_Stream_Repository;
+import org.apache.james.services.DataSourceSelector;
import org.apache.james.services.MailRepository;
import org.apache.james.test.mock.avalon.MockStore;
import org.apache.james.test.mock.james.MockFileSystem;
Modified: james/server/trunk/core-library/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/core-library/pom.xml?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/core-library/pom.xml (original)
+++ james/server/trunk/core-library/pom.xml Sun Jan 24 19:08:32 2010
@@ -78,11 +78,6 @@
</dependency>
<dependency>
- <groupId>org.apache.excalibur.components</groupId>
- <artifactId>excalibur-datasource</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-mailet-base</artifactId>
<classifier>tests</classifier>
@@ -99,9 +94,10 @@
<artifactId>james-server-user-api</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.avalon.cornerstone.datasources</groupId>
- <artifactId>cornerstone-datasources-impl</artifactId>
+
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Modified: james/server/trunk/core-library/src/test/java/org/apache/james/test/util/Util.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-library/src/test/java/org/apache/james/test/util/Util.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/core-library/src/test/java/org/apache/james/test/util/Util.java (original)
+++ james/server/trunk/core-library/src/test/java/org/apache/james/test/util/Util.java Sun Jan 24 19:08:32 2010
@@ -19,17 +19,16 @@
package org.apache.james.test.util;
-import org.apache.avalon.cornerstone.blocks.datasources.DefaultDataSourceSelector;
-import org.apache.avalon.excalibur.datasource.JdbcDataSource;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.DefaultConfiguration;
+import org.apache.commons.dbcp.BasicDataSource;
import org.apache.derby.jdbc.EmbeddedDriver;
-import org.apache.james.test.mock.avalon.MockLogger;
-import org.apache.james.test.mock.util.AttrValConfiguration;
+import org.apache.james.services.DataSourceSelector;
+
import java.io.IOException;
import java.net.ServerSocket;
+import javax.sql.DataSource;
+
/**
* some utilities for James unit testing
*/
@@ -83,33 +82,30 @@
return PORT_LAST_USED;
}
- public static Configuration getValuedConfiguration(String name, String value) {
- DefaultConfiguration defaultConfiguration = new DefaultConfiguration(name);
- defaultConfiguration.setValue(value);
- return defaultConfiguration;
- }
/**
* @return
* @throws Exception
*/
- public static DefaultDataSourceSelector getDataSourceSelector() throws Exception {
- DefaultDataSourceSelector dataSourceSelector = new DefaultDataSourceSelector();
- dataSourceSelector.enableLogging(new MockLogger());
- DefaultConfiguration dc = new DefaultConfiguration("database-connections");
- DefaultConfiguration ds = new DefaultConfiguration("data-source");
- ds.setAttribute("name","maildb");
- ds.setAttribute("class",JdbcDataSource.class.getName());
-
- ds.addChild(new AttrValConfiguration("driver",EmbeddedDriver.class.getName()));
- ds.addChild(new AttrValConfiguration("dburl","jdbc:derby:target/testdb;create=true"));
- ds.addChild(new AttrValConfiguration("user","james"));
- ds.addChild(new AttrValConfiguration("password","james"));
-
- ds.addChild(new AttrValConfiguration("max","20"));
- dc.addChild(ds);
- dataSourceSelector.configure(dc);
- dataSourceSelector.initialize();
+ public static DataSourceSelector getDataSourceSelector() throws Exception {
+ DataSourceSelector dataSourceSelector = new DataSourceSelector() {
+
+ public DataSource getDataSource(String name) {
+ if (name.equals("maildb")) {
+ BasicDataSource ds = new BasicDataSource();
+ ds.setDriverClassName(EmbeddedDriver.class.getName());
+ ds.setUrl("jdbc:derby:target/testdb;create=true");
+ ds.setUsername("james");
+ ds.setPassword("james");
+ return ds;
+ }
+ return null;
+ }
+
+ };
+
return dataSourceSelector;
}
+
+
}
Modified: james/server/trunk/mailets-function/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/pom.xml?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/mailets-function/pom.xml (original)
+++ james/server/trunk/mailets-function/pom.xml Sun Jan 24 19:08:32 2010
@@ -106,15 +106,7 @@
<groupId>org.apache.avalon.cornerstone.store</groupId>
<artifactId>cornerstone-store-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.excalibur.components</groupId>
- <artifactId>excalibur-datasource</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.avalon.cornerstone.datasources</groupId>
- <artifactId>cornerstone-datasources-api</artifactId>
- </dependency>
-
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java Sun Jan 24 19:08:32 2010
@@ -32,9 +32,9 @@
import javax.annotation.Resource;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
+import javax.sql.DataSource;
-import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
-import org.apache.avalon.excalibur.datasource.DataSourceComponent;
+import org.apache.james.services.DataSourceSelector;
import org.apache.james.util.bayesian.JDBCBayesianAnalyzer;
import org.apache.james.util.sql.JDBCUtil;
import org.apache.mailet.Mail;
@@ -126,7 +126,7 @@
}
};
- private DataSourceComponent datasource;
+ private DataSource datasource;
private String repositoryPath;
private static final String MAIL_ATTRIBUTE_NAME = "org.apache.james.spam.probability";
@@ -245,7 +245,7 @@
String datasourceName = repositoryPath.substring(stindex);
- datasource = (DataSourceComponent) selector.select(datasourceName);
+ datasource = selector.getDataSource(datasourceName);
} catch (Exception e) {
throw new MessagingException("Can't get datasource", e);
}
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysisFeeder.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysisFeeder.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysisFeeder.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysisFeeder.java Sun Jan 24 19:08:32 2010
@@ -31,9 +31,9 @@
import javax.mail.Header;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
+import javax.sql.DataSource;
-import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
-import org.apache.avalon.excalibur.datasource.DataSourceComponent;
+import org.apache.james.services.DataSourceSelector;
import org.apache.james.util.bayesian.JDBCBayesianAnalyzer;
import org.apache.james.util.sql.JDBCUtil;
import org.apache.mailet.Mail;
@@ -124,7 +124,7 @@
}
};
- private DataSourceComponent datasource;
+ private DataSource datasource;
private String repositoryPath;
private String feedType;
@@ -203,7 +203,7 @@
String datasourceName = repositoryPath.substring(stindex);
- datasource = (DataSourceComponent) selector.select(datasourceName);
+ datasource = selector.getDataSource(datasourceName);
} catch (Exception e) {
throw new MessagingException("Can't get datasource", e);
}
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java Sun Jan 24 19:08:32 2010
@@ -21,8 +21,7 @@
package org.apache.james.transport.mailets;
-import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
-import org.apache.avalon.excalibur.datasource.DataSourceComponent;
+import org.apache.james.services.DataSourceSelector;
import org.apache.james.util.sql.JDBCUtil;
import org.apache.mailet.base.GenericMailet;
import org.apache.mailet.Mail;
@@ -32,6 +31,7 @@
import javax.annotation.Resource;
import javax.mail.MessagingException;
import javax.mail.internet.ParseException;
+import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
@@ -56,7 +56,7 @@
*/
public class JDBCAlias extends GenericMailet {
- protected DataSourceComponent datasource;
+ protected DataSource datasource;
protected String query = null;
private DataSourceSelector selector;
@@ -95,7 +95,7 @@
try {
// Get the data-source required.
- datasource = (DataSourceComponent)selector.select(datasourceName);
+ datasource = selector.getDataSource(datasourceName);
conn = datasource.getConnection();
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCListserv.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCListserv.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCListserv.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCListserv.java Sun Jan 24 19:08:32 2010
@@ -21,8 +21,7 @@
package org.apache.james.transport.mailets;
-import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
-import org.apache.avalon.excalibur.datasource.DataSourceComponent;
+import org.apache.james.services.DataSourceSelector;
import org.apache.james.util.sql.JDBCUtil;
import org.apache.mailet.MailAddress;
import org.apache.mailet.MailetException;
@@ -30,6 +29,7 @@
import javax.annotation.Resource;
import javax.mail.MessagingException;
import javax.mail.internet.ParseException;
+import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
@@ -59,7 +59,7 @@
*/
public class JDBCListserv extends GenericListserv {
- protected DataSourceComponent datasource;
+ protected DataSource datasource;
protected String listservID = null;
protected String listservTable = null;
protected String membersTable = null;
@@ -128,7 +128,7 @@
try {
// Get the data-source required.
- datasource = (DataSourceComponent)selector.select(datasourceName);
+ datasource = selector.getDataSource(datasourceName);
conn = datasource.getConnection();
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCVirtualUserTable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCVirtualUserTable.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCVirtualUserTable.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCVirtualUserTable.java Sun Jan 24 19:08:32 2010
@@ -21,15 +21,15 @@
package org.apache.james.transport.mailets;
-import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
-import org.apache.avalon.excalibur.datasource.DataSourceComponent;
import org.apache.james.impl.vut.VirtualUserTableUtil;
+import org.apache.james.services.DataSourceSelector;
import org.apache.james.util.sql.JDBCUtil;
import org.apache.mailet.MailAddress;
import org.apache.mailet.MailetException;
import javax.annotation.Resource;
import javax.mail.MessagingException;
+import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
@@ -92,7 +92,7 @@
*/
public class JDBCVirtualUserTable extends AbstractVirtualUserTable
{
- protected DataSourceComponent datasource;
+ protected DataSource datasource;
/**
* The query used by the mailet to get the alias mapping
@@ -134,7 +134,7 @@
try {
// Get the data-source required.
- datasource = (DataSourceComponent)selector.select(datasourceName);
+ datasource = selector.getDataSource(datasourceName);
conn = datasource.getConnection();
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java Sun Jan 24 19:08:32 2010
@@ -21,10 +21,9 @@
package org.apache.james.transport.mailets;
-import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
-import org.apache.avalon.excalibur.datasource.DataSourceComponent;
import org.apache.james.api.user.JamesUser;
import org.apache.james.api.user.UsersRepository;
+import org.apache.james.services.DataSourceSelector;
import org.apache.james.util.sql.JDBCUtil;
import org.apache.james.util.sql.SqlResources;
import org.apache.mailet.base.GenericMailet;
@@ -41,6 +40,7 @@
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
+import javax.sql.DataSource;
import java.io.File;
import java.io.IOException;
@@ -126,7 +126,7 @@
/** The date format object used to generate RFC 822 compliant date headers. */
private RFC822DateFormat rfc822DateFormat = new RFC822DateFormat();
- private DataSourceComponent datasource;
+ private DataSource datasource;
/** The user repository for this mail server. Contains all the users with inboxes
* on this server.
@@ -239,7 +239,7 @@
// Get the data-source required.
int stindex = repositoryPath.indexOf("://") + 3;
String datasourceName = repositoryPath.substring(stindex);
- datasource = (DataSourceComponent) selector.select(datasourceName);
+ datasource = selector.getDataSource(datasourceName);
} catch (Exception e) {
throw new MessagingException("Can't get datasource", e);
}
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java Sun Jan 24 19:08:32 2010
@@ -21,10 +21,9 @@
package org.apache.james.transport.matchers;
-import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
-import org.apache.avalon.excalibur.datasource.DataSourceComponent;
import org.apache.james.api.user.JamesUser;
import org.apache.james.api.user.UsersRepository;
+import org.apache.james.services.DataSourceSelector;
import org.apache.james.transport.mailets.WhiteListManager;
import org.apache.james.util.sql.JDBCUtil;
import org.apache.james.util.sql.SqlResources;
@@ -34,6 +33,7 @@
import javax.annotation.Resource;
import javax.mail.MessagingException;
+import javax.sql.DataSource;
import java.io.File;
import java.sql.Connection;
@@ -65,7 +65,7 @@
private String selectByPK;
- private DataSourceComponent datasource;
+ private DataSource datasource;
/** The user repository for this mail server. Contains all the users with inboxes
* on this server.
@@ -138,7 +138,7 @@
// Get the data-source required.
int stindex = repositoryPath.indexOf("://") + 3;
String datasourceName = repositoryPath.substring(stindex);
- datasource = (DataSourceComponent) selector.select(datasourceName);
+ datasource = selector.getDataSource(datasourceName);
} catch (Exception e) {
throw new MessagingException("Can't get datasource", e);
}
Modified: james/server/trunk/management-library/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/management-library/pom.xml?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/management-library/pom.xml (original)
+++ james/server/trunk/management-library/pom.xml Sun Jan 24 19:08:32 2010
@@ -60,14 +60,7 @@
<groupId>org.apache.avalon.framework</groupId>
<artifactId>avalon-framework-impl</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.avalon.cornerstone.datasources</groupId>
- <artifactId>cornerstone-datasources-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.excalibur.components</groupId>
- <artifactId>excalibur-datasource</artifactId>
- </dependency>
+
<dependency>
<groupId>org.apache.avalon.cornerstone.store</groupId>
<artifactId>cornerstone-store-api</artifactId>
Modified: james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/BayesianAnalyzerManagement.java
URL: http://svn.apache.org/viewvc/james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/BayesianAnalyzerManagement.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/BayesianAnalyzerManagement.java (original)
+++ james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/BayesianAnalyzerManagement.java Sun Jan 24 19:08:32 2010
@@ -35,11 +35,10 @@
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
+import javax.sql.DataSource;
import net.fortuna.mstor.data.MboxFile;
-import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
-import org.apache.avalon.excalibur.datasource.DataSourceComponent;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.commons.logging.Log;
@@ -47,6 +46,7 @@
import org.apache.james.management.BayesianAnalyzerManagementException;
import org.apache.james.management.BayesianAnalyzerManagementMBean;
import org.apache.james.management.BayesianAnalyzerManagementService;
+import org.apache.james.services.DataSourceSelector;
import org.apache.james.services.FileSystem;
import org.apache.james.util.bayesian.JDBCBayesianAnalyzer;
@@ -61,7 +61,7 @@
private final static String HAM = "HAM";
private final static String SPAM = "SPAM";
private DataSourceSelector selector;
- private DataSourceComponent component;
+ private DataSource component;
private String repos;
private String sqlFileUrl;
private FileSystem fileSystem;
@@ -80,7 +80,7 @@
@PostConstruct
public void init() throws Exception {
if (repos != null) {
- setDataSourceComponent((DataSourceComponent) selector.select(repos));
+ setDataSource(selector.getDataSource(repos));
File sqlFile = fileSystem.getFile(sqlFileUrl);
analyzer.initSqlQueries(component.getConnection(), sqlFile.getAbsolutePath());
}
@@ -119,7 +119,7 @@
*
* @param component The DataSourceComponent
*/
- public void setDataSourceComponent(DataSourceComponent component) {
+ public void setDataSource(DataSource component) {
this.component = component;
}
Modified: james/server/trunk/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/pom.xml?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/pom.xml (original)
+++ james/server/trunk/pom.xml Sun Jan 24 19:08:32 2010
@@ -793,62 +793,6 @@
</dependency>
<dependency>
- <groupId>org.apache.avalon.cornerstone.datasources</groupId>
- <artifactId>cornerstone-datasources-api</artifactId>
- <version>2.2.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.excalibur.components</groupId>
- <artifactId>excalibur-datasource</artifactId>
- <version>2.2.2</version>
- <exclusions>
- <exclusion>
- <artifactId>excalibur-pool-instrumented</artifactId>
- <groupId>org.apache.excalibur.components</groupId>
- </exclusion>
- <exclusion>
- <artifactId>excalibur-component</artifactId>
- <groupId>org.apache.excalibur.components</groupId>
- </exclusion>
- <exclusion>
- <artifactId>excalibur-testcase</artifactId>
- <groupId>org.apache.excalibur.components</groupId>
- </exclusion>
- <exclusion>
- <artifactId>excalibur-fortress</artifactId>
- <groupId>org.apache.excalibur.components</groupId>
- </exclusion>
- <exclusion>
- <artifactId>excalibur-fortress-container-api</artifactId>
- <groupId>org.apache.excalibur.components</groupId>
- </exclusion>
- <exclusion>
- <artifactId>excalibur-logger</artifactId>
- <groupId>org.apache.excalibur.components</groupId>
- </exclusion>
- <exclusion>
- <artifactId>hsqldb</artifactId>
- <groupId>hsqldb</groupId>
- </exclusion>
- <exclusion>
- <artifactId>excalibur-fortress-meta</artifactId>
- <groupId>org.apache.excalibur.components</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.avalon.cornerstone.datasources</groupId>
- <artifactId>cornerstone-datasources-impl</artifactId>
- <version>2.2.2</version>
- <scope>runtime</scope>
- <exclusions>
- <exclusion>
- <artifactId>d-haven-managed-pool</artifactId>
- <groupId>d-haven-managed-pool</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
<groupId>org.apache.avalon.cornerstone.store</groupId>
<artifactId>cornerstone-store-api</artifactId>
<version>2.2.2</version>
Modified: james/server/trunk/smtpserver-function/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/pom.xml?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/pom.xml (original)
+++ james/server/trunk/smtpserver-function/pom.xml Sun Jan 24 19:08:32 2010
@@ -84,10 +84,7 @@
<artifactId>${javax.activation.artifactId}</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.avalon.cornerstone.datasources</groupId>
- <artifactId>cornerstone-datasources-api</artifactId>
- </dependency>
+
<dependency>
<groupId>org.apache.avalon.cornerstone.store</groupId>
<artifactId>cornerstone-store-api</artifactId>
@@ -105,10 +102,7 @@
<groupId>org.apache.avalon.framework</groupId>
<artifactId>avalon-framework-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.excalibur.components</groupId>
- <artifactId>excalibur-datasource</artifactId>
- </dependency>
+
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-jspf</artifactId>
Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/JDBCGreylistHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/JDBCGreylistHandler.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/JDBCGreylistHandler.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/JDBCGreylistHandler.java Sun Jan 24 19:08:32 2010
@@ -34,9 +34,8 @@
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
+import javax.sql.DataSource;
-import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
-import org.apache.avalon.excalibur.datasource.DataSourceComponent;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.HierarchicalConfiguration;
@@ -45,6 +44,7 @@
import org.apache.james.api.dnsservice.DNSService;
import org.apache.james.api.dnsservice.util.NetMatcher;
import org.apache.james.lifecycle.LogEnabled;
+import org.apache.james.services.DataSourceSelector;
import org.apache.james.services.FileSystem;
import org.apache.james.smtpserver.protocol.SMTPSession;
import org.apache.james.smtpserver.protocol.core.fastfail.AbstractGreylistHandler;
@@ -69,7 +69,7 @@
private DataSourceSelector datasources = null;
- private DataSourceComponent datasource = null;
+ private DataSource datasource = null;
private FileSystem fileSystem = null;
@@ -288,7 +288,7 @@
* @param datasource
* the datasource
*/
- public void setDataSource(DataSourceComponent datasource) {
+ public void setDataSource(DataSource datasource) {
this.datasource = datasource;
}
@@ -382,13 +382,13 @@
* @throws ServiceException
* @throws SQLException
*/
- private DataSourceComponent initDataSource(String repositoryPath)
+ private DataSource initDataSource(String repositoryPath)
throws ServiceException, SQLException {
int stindex = repositoryPath.indexOf("://") + 3;
String datasourceName = repositoryPath.substring(stindex);
- return (DataSourceComponent) datasources.select(datasourceName);
+ return datasources.getDataSource(datasourceName);
}
/**
Modified: james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AsyncSMTPServerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AsyncSMTPServerTest.java?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AsyncSMTPServerTest.java (original)
+++ james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AsyncSMTPServerTest.java Sun Jan 24 19:08:32 2010
@@ -38,7 +38,6 @@
import junit.framework.TestCase;
-import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
import org.apache.avalon.cornerstone.services.store.Store;
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.commons.logging.impl.SimpleLog;
@@ -52,7 +51,6 @@
import org.apache.james.services.MailServer;
import org.apache.james.smtpserver.integration.SMTPServerDNSServiceAdapter;
import org.apache.james.smtpserver.mina.AsyncSMTPServer;
-import org.apache.james.test.mock.DummyDataSourceSelector;
import org.apache.james.test.mock.DummyVirtualUserTableStore;
import org.apache.james.test.mock.avalon.MockStore;
import org.apache.james.test.mock.james.MockFileSystem;
@@ -225,7 +223,6 @@
dnsAdapter.setDNSService(m_dnsServer);
m_serviceManager.put("org.apache.james.smtpserver.protocol.DNSService", dnsAdapter);
m_serviceManager.put(VirtualUserTableStore.ROLE, new DummyVirtualUserTableStore());
- m_serviceManager.put(DataSourceSelector.ROLE, new DummyDataSourceSelector());
SMTPServerDNSServiceAdapter dnsAdapter = new SMTPServerDNSServiceAdapter();
dnsAdapter.setDNSService(m_dnsServer);
m_serviceManager.put("org.apache.james.smtpserver.protocol.DNSService", dnsAdapter);
Modified: james/server/trunk/spring-deployment/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/pom.xml?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/spring-deployment/pom.xml (original)
+++ james/server/trunk/spring-deployment/pom.xml Sun Jan 24 19:08:32 2010
@@ -348,11 +348,6 @@
<scope>runtime</scope>
</dependency>
- <dependency>
- <groupId>org.apache.avalon.cornerstone.datasources</groupId>
- <artifactId>cornerstone-datasources-impl</artifactId>
- <scope>runtime</scope>
- </dependency>
<dependency>
<groupId>org.apache.derby</groupId>
Modified: james/server/trunk/spring-deployment/src/main/config/james/james-config.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/src/main/config/james/james-config.xml?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/spring-deployment/src/main/config/james/james-config.xml (original)
+++ james/server/trunk/spring-deployment/src/main/config/james/james-config.xml Sun Jan 24 19:08:32 2010
@@ -1397,89 +1397,4 @@
<sqlFile>file://conf/sqlResources.xml</sqlFile>
</table>
</virtualusertable-store>
-
- <!-- The database-connections block -->
- <database-connections>
- <!-- These connections are referred to by name elsewhere in the config file -->
-<!-- CHECKME! -->
- <!-- To allow James to use a database you must configure the database connection here. -->
- <!-- If you are not using a database, you can leave this section unchanged. -->
- <!-- These connections are referred to by name in URLs elsewhere in the config file. -->
- <!--
- James has previously used an in-house connection pool, Mordred.
- Mordred is being deprecated in favor of Jakarta Commons DBCP.
- To use DBCP: org.apache.james.util.dbcp.JdbcDataSource
- To use Mordred: org.apache.james.util.mordred.JdbcDataSource
-
- Change it back, of course, to use Mordred.
-
- NOTE: DBCP is configured to recover from a database server outage.
- This, alone, may be reason for you to give it a try.
- -->
-
- <!-- Out of the box default configuration uses Apache Derby as the default -->
- <!-- database, which is easy to embed - but we support all the major SQL -->
- <!-- databases - just reconfigure your JDBC configuration -->
- <!-- -->
- <data-source name="maildb" class="org.apache.james.util.dbcp.JdbcDataSource">
- <driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
- <dburl>jdbc:derby:../var/derbydb;create=true</dburl>
- <user></user>
- <password></password>
- <poolPreparedStatements>true</poolPreparedStatements>
- <max>20</max>
- </data-source>
- <!-- -->
-
- <!-- JDBC driver .jar libraries for other RDBMS can be placed in ~james/lib/ -->
-
- <!-- You can download latest Connector/J from -->
- <!-- http://dev.mysql.com/downloads/connector/j/3.1.html -->
- <!-- -->
- <!-- Example, connecting to a MySQL database called "mail" on localhost-->
- <!-- -->
- <!-- The max value is the maximum number of concurrent connections James will -->
- <!-- open to this database-->
- <!-- If you see "SQLException: Giving up... no connections available." in your -->
- <!-- log files or bounced mail you should increase this value -->
- <!--
- <data-source name="maildb" class="org.apache.james.util.dbcp.JdbcDataSource">
- <driver>com.mysql.jdbc.Driver</driver>
- <dburl>jdbc:mysql://127.0.0.1/mail?autoReconnect=true</dburl>
- <user>username</user>
- <password>password</password>
- <max>20</max>
- </data-source>
- -->
-
- <!-- Example, connecting to a Microsoft MSSQL database called "mail" on localhost-->
- <!-- -->
- <!-- The max value is the maximum number of concurrent connections James will -->
- <!-- open to this database-->
- <!-- If you see "SQLException: Giving up... no connections available." in your -->
- <!-- log files or bounced mail you should increase this value -->
- <!--
- <data-source name="maildb" class="org.apache.james.util.dbcp.JdbcDataSource">
- <driver>com.inet.tds.TdsDriver</driver>
- <dburl>jdbc:inetdae7:127.0.0.1?database=James</dburl>
- <user>sa_james</user>
- <password>blahblah</password>
- <max>20</max>
- </data-source>
- -->
-
- <!-- Here is a configuration for hsqldb (formerly HypersonicSQL) -->
- <!-- You can download the db from http://www.hsqldb.org/ . Just put the -->
- <!-- hsqldb.jar in the lib directory and uncomment the following block -->
- <!--
- <data-source name="maildb" class="org.apache.james.util.dbcp.JdbcDataSource">
- <driver>org.hsqldb.jdbcDriver</driver>
- <dburl>jdbc:hsqldb:target/data/hsqldb</dburl>
- <user>sa</user>
- <password></password>
- <max>20</max>
- </data-source>
- -->
-
- </database-connections>
</config>
Modified: james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml?rev=902621&r1=902620&r2=902621&view=diff
==============================================================================
--- james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml (original)
+++ james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml Sun Jan 24 19:08:32 2010
@@ -270,15 +270,15 @@
<constructor-arg index="2" ref="entityManagerFactory"/>
</bean>
- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+ <bean id="maildb" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" />
- <property name="url" value="jdbc:derby:../var/mailboxmanager-derbydb;create=true" />
+ <property name="url" value="jdbc:derby:../var/derbydb;create=true" />
<property name="username" value="app" />
<property name="password" value="app" />
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- <property name="dataSource" ref="dataSource"/>
+ <property name="dataSource" ref="maildb"/>
<property name="jpaVendorAdapter" ref="vendorAdapter"/>
</bean>
@@ -300,6 +300,6 @@
</bean>
<!-- The DataSourceSelector block -->
- <bean id="database-connections" class="org.apache.avalon.cornerstone.blocks.datasources.DefaultDataSourceSelector" destroy-method="dispose" />
+ <bean id="database-connections" class="org.apache.james.container.spring.SpringDataSourceSelector"/>
</beans>
\ No newline at end of file
Added: james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/SpringDataSourceSelector.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/SpringDataSourceSelector.java?rev=902621&view=auto
==============================================================================
--- james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/SpringDataSourceSelector.java (added)
+++ james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/SpringDataSourceSelector.java Sun Jan 24 19:08:32 2010
@@ -0,0 +1,58 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+package org.apache.james.container.spring;
+
+import javax.sql.DataSource;
+
+import org.apache.james.services.DataSourceSelector;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ * Spring based implementation of DataSourceSelector. It use the given name to return the bean which
+ * map to it.
+ *
+ *
+ */
+public class SpringDataSourceSelector implements DataSourceSelector, ApplicationContextAware{
+
+ private ApplicationContext context;
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.services.DataSourceSelector#getDataSource(java.lang.String)
+ */
+ public DataSource getDataSource(String name) {
+ Object object = context.getBean(name);
+ if (object instanceof DataSource) {
+ return (DataSource) object;
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
+ */
+ public void setApplicationContext(ApplicationContext context) throws BeansException {
+ this.context = context;
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org