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 pg...@apache.org on 2002/08/23 08:09:42 UTC
cvs commit: jakarta-james/src/conf james-config.xml
pgoldstein 2002/08/22 23:09:42
Modified: src/java/org/apache/james James.java
src/conf james-config.xml
Log:
Changes to support autodetecting of IP addresses.
Altered handling of default postmaster address.
Added comments.
Rearranged lifecycle methods to match lifecycle order.
Removed tabs.
Revision Changes Path
1.28 +65 -15 jakarta-james/src/java/org/apache/james/James.java
Index: James.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/James.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- James.java 19 Aug 2002 18:57:07 -0000 1.27
+++ James.java 23 Aug 2002 06:09:42 -0000 1.28
@@ -63,6 +63,12 @@
Initializable, MailServer, MailetContext, Component {
private final static String VERSION = Constants.SOFTWARE_NAME + " " + Constants.SOFTWARE_VERSION;
+
+ /**
+ * Whether 'deep debugging' is turned on.
+ *
+ * TODO: Shouldn't this be false by default?
+ */
private final static boolean DEEP_DEBUG = true;
private DefaultComponentManager compMgr; //Components shared
@@ -108,6 +114,7 @@
/**
* A hash table of server attributes
+ * These are the MailetContext attributes
*/
private Hashtable attributes = new Hashtable();
@@ -129,16 +136,6 @@
}
/**
- * Pass the <code>Configuration</code> to the instance.
- *
- * @param configuration the class configurations.
- * @throws ConfigurationException if an error occurs
- */
- public void configure(Configuration conf) {
- this.conf = conf;
- }
-
- /**
* Pass the <code>ComponentManager</code> to the <code>composer</code>.
* The instance uses the specified <code>ComponentManager</code> to
* acquire the components it needs for execution.
@@ -153,6 +150,16 @@
}
/**
+ * Pass the <code>Configuration</code> to the instance.
+ *
+ * @param configuration the class configurations.
+ * @throws ConfigurationException if an error occurs
+ */
+ public void configure(Configuration conf) {
+ this.conf = conf;
+ }
+
+ /**
* Initialize the component. Initialization includes
* allocating any resources required throughout the
* components lifecycle.
@@ -197,7 +204,7 @@
getLogger().info("Local host is: " + hostName);
// Get the domains and hosts served by this instance
- serverNames = new Vector();
+ serverNames = new HashSet();
Configuration serverConf = conf.getChild("servernames");
if (serverConf.getAttributeAsBoolean("autodetect") && (!hostName.equals("localhost"))) {
serverNames.add(hostName.toLowerCase(Locale.US));
@@ -206,7 +213,28 @@
final Configuration[] serverNameConfs =
conf.getChild( "servernames" ).getChildren( "servername" );
for ( int i = 0; i < serverNameConfs.length; i++ ) {
- serverNames.add( serverNameConfs[i].getValue());
+ serverNames.add( serverNameConfs[i].getValue().toLowerCase(Locale.US));
+
+ if (serverConf.getAttributeAsBoolean("autodetectIP", true)) {
+ try {
+ /* This adds the IP address(es) for each host to support
+ * support <us...@address-literal> - RFC 2821, sec 4.1.3.
+ * It might be proper to use the actual IP addresses
+ * available on this server, but we can't do that
+ * without NetworkInterface from JDK 1.4. Because of
+ * Virtual Hosting considerations, we may need to modify
+ * this to keep hostname and IP associated, rather than
+ * just both in the set.
+ */
+ InetAddress[] addrs = InetAddress.getAllByName(serverNameConfs[i].getValue());
+ for (int j = 0; j < addrs.length ; j++) {
+ serverNames.add(addrs[j].getHostAddress());
+ }
+ }
+ catch(Exception genericException) {
+ getLogger().error("Cannot get IP address(es) for " + serverNameConfs[i].getValue());
+ }
+ }
}
if (serverNames.isEmpty()) {
throw new ConfigurationException( "Fatal configuration error: no servernames specified!");
@@ -222,7 +250,22 @@
// Get postmaster
- String postMasterAddress = conf.getChild("postmaster").getValue("root@localhost");
+ String postMasterAddress = conf.getChild("postmaster").getValue("postmaster");
+ // if there is no @domain part, then add the first one from the
+ // list of supported domains that isn't localhost. If that
+ // doesn't work, use the hostname, even if it is localhost.
+ if (postMasterAddress.indexOf('@') < 0) {
+ String domainName = null; // the domain to use
+ // loop through candidate domains until we find one or exhaust the list
+ for ( int i = 0; domainName == null && i < serverNameConfs.length ; i++ ) {
+ String serverName = serverNameConfs[i].getValue().toLowerCase(Locale.US);
+ if (!("localhost".equals(serverName))) {
+ domainName = serverName; // ok, not localhost, so use it
+ }
+ }
+ // if we found a suitable domain, use it. Otherwise fallback to the host name.
+ postMasterAddress = postMasterAddress + "@" + (domainName != null ? domainName : hostName);
+ }
this.postmaster = new MailAddress( postMasterAddress );
context.put( Constants.POSTMASTER, postmaster );
@@ -457,6 +500,13 @@
//Methods for MailetContext
+ /**
+ * <p>Get the prioritized list of mail servers for a given host.</p>
+ *
+ * <p>TODO: This needs to be made a more specific ordered subtype of Collection.</p>
+ *
+ * @param host
+ */
public Collection getMailServers(String host) {
DNSServer dnsServer = null;
try {
1.28 +16 -14 jakarta-james/src/conf/james-config.xml
Index: james-config.xml
===================================================================
RCS file: /home/cvs/jakarta-james/src/conf/james-config.xml,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- james-config.xml 29 Jul 2002 13:47:39 -0000 1.27
+++ james-config.xml 23 Aug 2002 06:09:42 -0000 1.28
@@ -25,10 +25,12 @@
<!-- CONFIRM? -->
<!-- servernames identifies the DNS namespace served by this instance of James.
- If autodetect is TRUE, James wil attempt to discover its own name AND use any specified servernames.
- If autodetect is FALSE, James will use only the specified servernames.
- By default, the servername 'localhost' is specified. This can be removed, if required. -->
- <servernames autodetect="TRUE">
+ If autodetect is TRUE, James wil attempt to discover its own name AND use any specified servernames.
+ If autodetect is FALSE, James will use only the specified servernames.
+ 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.
+ By default, the servername 'localhost' is specified. This can be removed, if required. -->
+ <servernames autodetect="TRUE" autodetectIP="TRUE">
<!--<servername>To override autodetected server names uncomment this. </servername> -->
<servername>localhost</servername>
</servernames>
@@ -253,9 +255,9 @@
<smtpserver>
<port>25</port>
- <!-- uncomment this if you want to bind to a specific inetaddress -->
+ <!-- uncomment this if you want to bind to a specific inetaddress -->
<!--<bind> </bind>-->
- <!-- uncomment this if you want to use TLS (SSL) on this port -->
+ <!-- uncomment this if you want to use TLS (SSL) on this port -->
<!--<useTLS>true</useTLS>-->
<handler>
@@ -465,13 +467,13 @@
<!-- Configure database connections here. These connections are referred to by name elsewhere in the config file -->
<!-- CHECKME! To allow James to use a database, configure the database connection here -->
<data-sources>
-
- <!-- James is distributed with a built in relevant copy of the mm.mysql JDBC -->
- <!-- driver no additional driver is needed for mysql. Read the mm.mysql LGPL -->
- <!-- licence at apps\james\SAR-INF\lib\mm.mysql.LICENCE -->
-
- <!-- JDBC driver .jar libraries for other RDBMS can be placed in ~james/lib/ -->
-
+
+ <!-- James is distributed with a built in relevant copy of the mm.mysql JDBC -->
+ <!-- driver no additional driver is needed for mysql. Read the mm.mysql LGPL -->
+ <!-- licence at apps\james\SAR-INF\lib\mm.mysql.LICENCE -->
+
+ <!-- JDBC driver .jar libraries for other RDBMS can be placed in ~james/lib/ -->
+
<!-- Example, connecting to a MySQL database called "mail" on localhost-->
<!--<data-source name="maildb" class="org.apache.james.util.mordred.JdbcDataSource">
<driver>org.gjt.mm.mysql.Driver</driver>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>