All,
Attached is a patch that removes the dependency on the Phoenix BlockContext class. Rather than using the getBaseDirectory method of the BlockContext, we simply call get on the base Context interface with the appropriate key. The Avalon folks are still working on straightening all of this out, but this patch is a little adjustment in the interm. See the comments in AvalonContextConstants for further discussion. As always, comments, critiques, and questions are welcome. --Peter
AvalonContextConstants.java
Description: java/
JDBCMailRepository.java
Description: java/
NNTPUtil.java
Description: java/
AbstractJdbcUsersRepository.java
Description: java/
Index: jakarta-james/src/java/org/apache/james/mailrepository/JDBCMailRepository.java
===================================================================
RCS file:
/home/cvs/jakarta-james/src/java/org/apache/james/mailrepository/JDBCMailRepository.java,v
retrieving revision 1.21
diff -u -r1.21 JDBCMailRepository.java
--- jakarta-james/src/java/org/apache/james/mailrepository/JDBCMailRepository.java
12 Aug 2002 07:41:36 -0000 1.21
+++ jakarta-james/src/java/org/apache/james/mailrepository/JDBCMailRepository.java
+ 12 Aug 2002 18:53:59 -0000
@@ -24,7 +24,7 @@
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.phoenix.BlockContext;
+import org.apache.james.context.AvalonContextConstants;
import org.apache.james.core.MailImpl;
import org.apache.james.core.MimeMessageWrapper;
import org.apache.james.services.MailRepository;
@@ -246,8 +246,24 @@
// Initialise the sql strings.
String fileName = sqlFileName.substring("file://".length());
if (!(fileName.startsWith("/"))) {
- fileName = ((BlockContext)context).getBaseDirectory() +
- File.separator + fileName;
+ String baseDirectory = "";
+ try {
+ File applicationHome =
+ (File)context.get(AvalonContextConstants.APPLICATION_HOME);
+ baseDirectory = applicationHome.toString();
+ } catch (ContextException ce) {
+ getLogger().fatalError("Encountered exception when resolving
+application home in Avalon context.", ce);
+ throw ce;
+ } catch (ClassCastException cce) {
+ getLogger().fatalError("Application home object stored in Avalon
+context was not of type java.io.File.", cce);
+ throw cce;
+ }
+ StringBuffer fileNameBuffer =
+ new StringBuffer(128)
+ .append(baseDirectory)
+ .append(File.separator)
+ .append(fileName);
+ fileName = fileNameBuffer.toString();
}
File sqlFile = (new File(fileName)).getCanonicalFile();
Index: jakarta-james/src/java/org/apache/james/nntpserver/repository/NNTPUtil.java
===================================================================
RCS file:
/home/cvs/jakarta-james/src/java/org/apache/james/nntpserver/repository/NNTPUtil.java,v
retrieving revision 1.7
diff -u -r1.7 NNTPUtil.java
--- jakarta-james/src/java/org/apache/james/nntpserver/repository/NNTPUtil.java 7 Aug
2002 23:38:48 -0000 1.7
+++ jakarta-james/src/java/org/apache/james/nntpserver/repository/NNTPUtil.java 12 Aug
+2002 18:53:59 -0000
@@ -15,7 +15,7 @@
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.logger.Logger;
-import org.apache.avalon.phoenix.BlockContext;
+import org.apache.james.context.AvalonContextConstants;
import org.apache.james.nntpserver.NNTPException;
import java.io.File;
@@ -47,8 +47,22 @@
}
fileName = fileName.substring(prefixLength);
if (!(fileName.startsWith("/"))) {
- fileName = ((BlockContext)context).getBaseDirectory() +
- File.separator + fileName;
+ String baseDirectory = "";
+ try {
+ File applicationHome =
+ (File)context.get(AvalonContextConstants.APPLICATION_HOME);
+ baseDirectory = applicationHome.toString();
+ } catch (ContextException ce) {
+ throw new ConfigurationException("Encountered exception when
+resolving application home in Avalon context.", ce);
+ } catch (ClassCastException cce) {
+ throw new ConfigurationException("Application home object stored in
+Avalon context was not of type java.io.File.", cce);
+ }
+ StringBuffer fileNameBuffer =
+ new StringBuffer(128)
+ .append(baseDirectory)
+ .append(File.separator)
+ .append(fileName);
+ fileName = fileNameBuffer.toString();
}
File f = new File(fileName);
if ( f.exists() && f.isFile() )
Index:
jakarta-james/src/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java
===================================================================
RCS file:
/home/cvs/jakarta-james/src/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java,v
retrieving revision 1.7
diff -u -r1.7 AbstractJdbcUsersRepository.java
---
jakarta-james/src/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java
12 Aug 2002 07:41:36 -0000 1.7
+++
+jakarta-james/src/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java
+ 12 Aug 2002 18:54:00 -0000
@@ -21,7 +21,7 @@
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.phoenix.BlockContext;
+import org.apache.james.context.AvalonContextConstants;
import org.apache.james.services.User;
import org.apache.james.util.JDBCUtil;
import org.apache.james.util.SqlResources;
@@ -232,8 +232,24 @@
// Initialise the sql strings.
String fileName = m_sqlFileName.substring("file://".length());
if (!(fileName.startsWith("/"))) {
- fileName = ((BlockContext)context).getBaseDirectory() +
- File.separator + fileName;
+ String baseDirectory = "";
+ try {
+ File applicationHome =
+ (File)context.get(AvalonContextConstants.APPLICATION_HOME);
+ baseDirectory = applicationHome.toString();
+ } catch (ContextException ce) {
+ getLogger().fatalError("Encountered exception when resolving
+application home in Avalon context.", ce);
+ throw ce;
+ } catch (ClassCastException cce) {
+ getLogger().fatalError("Application home object stored in Avalon
+context was not of type java.io.File.", cce);
+ throw cce;
+ }
+ StringBuffer fileNameBuffer =
+ new StringBuffer(128)
+ .append(baseDirectory)
+ .append(File.separator)
+ .append(fileName);
+ fileName = fileNameBuffer.toString();
}
File sqlFile = (new File(fileName)).getCanonicalFile();
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
