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/10/14 19:10:29 UTC
svn commit: r1022615 - in /james/server/trunk:
domain-library/src/main/java/org/apache/james/domain/JamesDomainList.java
spring-deployment/src/main/config/james/domainlist.xml
spring-deployment/src/main/config/james/spring-beans.xml
Author: norman
Date: Thu Oct 14 17:10:29 2010
New Revision: 1022615
URL: http://svn.apache.org/viewvc?rev=1022615&view=rev
Log:
Let configure the DomainList implementation via domainlist.xml (JAMES-1064)
Added:
james/server/trunk/domain-library/src/main/java/org/apache/james/domain/JamesDomainList.java
Modified:
james/server/trunk/spring-deployment/src/main/config/james/domainlist.xml
james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml
Added: james/server/trunk/domain-library/src/main/java/org/apache/james/domain/JamesDomainList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/domain-library/src/main/java/org/apache/james/domain/JamesDomainList.java?rev=1022615&view=auto
==============================================================================
--- james/server/trunk/domain-library/src/main/java/org/apache/james/domain/JamesDomainList.java (added)
+++ james/server/trunk/domain-library/src/main/java/org/apache/james/domain/JamesDomainList.java Thu Oct 14 17:10:29 2010
@@ -0,0 +1,144 @@
+/****************************************************************
+ * 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.domain;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.james.api.domainlist.DomainList;
+import org.apache.james.api.domainlist.ManageableDomainList;
+import org.apache.james.api.domainlist.ManageableDomainListMBean;
+import org.apache.james.lifecycle.Configurable;
+import org.apache.james.lifecycle.Disposable;
+import org.apache.james.lifecycle.LogEnabled;
+import org.apache.james.services.InstanceFactory;
+
+/**
+ *
+ *
+ */
+public class JamesDomainList implements ManageableDomainList, ManageableDomainListMBean, LogEnabled, Configurable{
+
+ private InstanceFactory instanceFactory;
+ private HierarchicalConfiguration config;
+ private Log log;
+ private DomainList domainList;
+
+ @Resource(name="instanceFactory")
+ public void setInstanceFactory(InstanceFactory instanceFactory) {
+ this.instanceFactory = instanceFactory;
+ }
+
+ @PostConstruct
+ public void init() throws Exception {
+ HierarchicalConfiguration conf = config.configurationAt("domainlist");
+
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ String repName = conf.getString("[@name]", null);
+ String repClass = conf.getString("[@class]");
+
+ if (repName == null) {
+ repName = repClass;
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Starting " + repClass);
+ }
+
+ domainList = (DomainList) instanceFactory.newInstance(loader
+ .loadClass(repClass), log, conf);
+
+ if (log.isInfoEnabled()) {
+ StringBuffer logBuffer = new StringBuffer(64).append("Bean ")
+ .append(repName).append(" started.");
+ log.info(logBuffer.toString());
+ }
+
+ }
+
+ @PreDestroy
+ public void destroy() {
+ if (domainList != null) {
+ if (domainList instanceof Disposable) {
+ ((Disposable) domainList).dispose();
+ }
+ }
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.api.domainlist.ManageableDomainList#addDomain(java.lang.String)
+ */
+ public boolean addDomain(String domain) {
+ if (domainList instanceof ManageableDomainList) {
+ return ((ManageableDomainList) domainList).addDomain(domain);
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.api.domainlist.ManageableDomainList#removeDomain(java.lang.String)
+ */
+ public boolean removeDomain(String domain) {
+ if (domainList instanceof ManageableDomainList) {
+ return ((ManageableDomainList) domainList).removeDomain(domain);
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.api.domainlist.DomainList#containsDomain(java.lang.String)
+ */
+ public boolean containsDomain(String domain) {
+ return domainList.containsDomain(domain);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.api.domainlist.DomainList#getDomains()
+ */
+ public String[] getDomains() {
+ return domainList.getDomains();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.lifecycle.LogEnabled#setLog(org.apache.commons.logging.Log)
+ */
+ public void setLog(Log log) {
+ this.log = log;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.lifecycle.Configurable#configure(org.apache.commons.configuration.HierarchicalConfiguration)
+ */
+ public void configure(HierarchicalConfiguration config) throws ConfigurationException {
+ this.config = config;
+ }
+
+}
Modified: james/server/trunk/spring-deployment/src/main/config/james/domainlist.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/src/main/config/james/domainlist.xml?rev=1022615&r1=1022614&r2=1022615&view=diff
==============================================================================
--- james/server/trunk/spring-deployment/src/main/config/james/domainlist.xml (original)
+++ james/server/trunk/spring-deployment/src/main/config/james/domainlist.xml Thu Oct 14 17:10:29 2010
@@ -17,36 +17,53 @@
specific language governing permissions and limitations
under the License.
-->
-<domainlist>
- <!-- Domainnames identifies the DNS namespace served by this instance of James. -->
- <!-- These domainnames are used for both matcher/mailet processing and SMTP auth -->
- <!-- to determine when a mail is intended for local delivery. -->
- <!-- -->
- <!-- If autodetect is TRUE, James wil attempt to discover its own host name AND -->
- <!-- use any explicitly specified servernames. -->
- <!-- If autodetect is FALSE, James will use only the specified domainnames. -->
- <!-- -->
- <!-- If autodetectIP is not FALSE, James will also allow add the IP address for each servername. -->
- <!-- The automatic IP detection is to support RFC 2821, Sec 4.1.3, address literals. -->
- <!-- -->
- <!-- To override autodetected domainames names simply add explicit domainname elements. -->
- <!-- In most cases this will be necessary. -->
- <!-- By default, the domainname 'localhost' is specified. This can be removed, if required. -->
- <!-- -->
- <!-- Warning: If you are using fetchmail it is important to include the -->
- <!-- fetched domains in the server name list to prevent looping. -->
-
- <!-- comment this if you use JDBCDomainList -->
+
+
+<!-- Domainnames identifies the DNS namespace served by this instance of James. -->
+<!-- These domainnames are used for both matcher/mailet processing and SMTP auth -->
+<!-- to determine when a mail is intended for local delivery. -->
+<!-- -->
+<!-- If autodetect is TRUE, James wil attempt to discover its own host name AND -->
+<!-- use any explicitly specified servernames. -->
+<!-- If autodetect is FALSE, James will use only the specified domainnames. -->
+<!-- -->
+<!-- If autodetectIP is not FALSE, James will also allow add the IP address for each servername. -->
+<!-- The automatic IP detection is to support RFC 2821, Sec 4.1.3, address literals. -->
+<!-- -->
+<!-- To override autodetected domainames names simply add explicit domainname elements. -->
+<!-- In most cases this will be necessary. -->
+<!-- By default, the domainname 'localhost' is specified. This can be removed, if required. -->
+<!-- -->
+<!-- Warning: If you are using fetchmail it is important to include the -->
+<!-- fetched domains in the server name list to prevent looping. -->
+<domainlists>
+
+ <!-- XML based DomainList implementation -->
+ <domainlist class="org.apache.james.domain.XMLDomainList">
<domainnames>
- <domainname>localhost</domainname>
+ <domainname>localhost</domainname>
</domainnames>
-
- <!-- uncomment this if you use JDBCDomainList -->
- <!--
+ <autodetect>true</autodetect>
+ <autodetectIP>true</autodetectIP>
+ </domainlist>
+
+ <!-- JPA implementation for DomainList -->
+ <!--
+ <domainlist class="org.apache.james.domain.JPADomainList">
+ <autodetect>true</autodetect>
+ <autodetectIP>true</autodetectIP>
+ </domainlist>
+ -->
+
+ <!-- JDBC implementation for DomainList. This is deprecated and should not be used. -->
+ <!-- Use JPADomainList if you need a db backend DomainList -->
+ <!--
+ <domainlist class="org.apache.james.domain.JDBCDomainList">
<repositoryPath>db://maildb/domain</repositoryPath>
<sqlFile>file://conf/sqlResources.xml</sqlFile>
- -->
<autodetect>true</autodetect>
<autodetectIP>true</autodetectIP>
-</domainlist>
+ </domainlist>
+ -->
+</domainlists>
\ No newline at end of file
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=1022615&r1=1022614&r2=1022615&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 Thu Oct 14 17:10:29 2010
@@ -257,17 +257,7 @@
<bean id="virtualusertable" name="virtualusertablemanagement" class="org.apache.james.impl.vut.JamesVirtualUserTable" />
<!-- The context domainlist implementation -->
- <bean id="domainlist" name="domainlistmanagement" class="org.apache.james.domain.XMLDomainList" />
-
- <!-- JPA implementation of the domainlist service -->
- <!--
- <bean id="domainlist" name="domainlistmanagement" class="org.apache.james.domain.JPADomainList"/>
- -->
-
- <!-- JDBC implementation of the domainlist service - deprecated, use the JPADomainList -->
- <!--
- <bean id="domainlist" name="domainlistmanagement" class="org.apache.james.domain.JDBCDomainList"/>
- -->
+ <bean id="domainlist" name="domainlistmanagement" class="org.apache.james.domain.JamesDomainList" />
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org