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 jo...@apache.org on 2006/12/14 09:18:51 UTC

svn commit: r487125 [1/4] - in /james/server/sandbox/spring-integration: ./ src/main/java/org/apache/james/container/spring/adaptor/ src/main/java/org/apache/james/container/spring/lifecycle/ src/main/java/org/apache/james/container/spring/processor/ s...

Author: joachim
Date: Thu Dec 14 00:18:49 2006
New Revision: 487125

URL: http://svn.apache.org/viewvc?view=rev&rev=487125
Log:
- did not run regression tests for 2.3 but should work
- configuration for trunk JAMES-724
- exclude beans from Propagator/Processor
- ServiceManager hints with individual instance
- BeanPostProcessor implementations for correct lifecycle
- FileSystem stub
- lots of work ahead :-)

Added:
    james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/
    james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/AbstractProcessor.java
    james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ConfigurationProcessor.java
    james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ContextProcessor.java
    james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/InitializationProcessor.java
    james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/LoggerProcessor.java
    james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ServiceProcessor.java
    james/server/sandbox/spring-integration/src/trunk/
    james/server/sandbox/spring-integration/src/trunk/config/
    james/server/sandbox/spring-integration/src/trunk/config/james-assembly.xml
    james/server/sandbox/spring-integration/src/trunk/config/james-config.xml
    james/server/sandbox/spring-integration/src/trunk/config/james-fetchmail.xml
    james/server/sandbox/spring-integration/src/trunk/config/james-listmanager.xml
    james/server/sandbox/spring-integration/src/trunk/config/james-liststores.xml
    james/server/sandbox/spring-integration/src/trunk/config/james-server.xml
    james/server/sandbox/spring-integration/src/trunk/config/james-smtphandlerchain.xml
    james/server/sandbox/spring-integration/src/trunk/config/mailboxManagerSqlResources.xml
    james/server/sandbox/spring-integration/src/trunk/config/miResources.xml
    james/server/sandbox/spring-integration/src/trunk/config/spring-config.xml
    james/server/sandbox/spring-integration/src/trunk/config/sqlResources.xml
    james/server/sandbox/spring-integration/src/trunk/java/
    james/server/sandbox/spring-integration/src/trunk/java/org/
    james/server/sandbox/spring-integration/src/trunk/java/org/apache/
    james/server/sandbox/spring-integration/src/trunk/java/org/apache/james/
    james/server/sandbox/spring-integration/src/trunk/java/org/apache/james/container/
    james/server/sandbox/spring-integration/src/trunk/java/org/apache/james/container/spring/
    james/server/sandbox/spring-integration/src/trunk/java/org/apache/james/container/spring/adaptor/
    james/server/sandbox/spring-integration/src/trunk/java/org/apache/james/container/spring/adaptor/FileSystemBridge.java
Modified:
    james/server/sandbox/spring-integration/HOW-TO.txt
    james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerBridge.java
    james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/AbstractPropagator.java
    james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ConfigurationPropagator.java
    james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ServicePropagator.java

Modified: james/server/sandbox/spring-integration/HOW-TO.txt
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/HOW-TO.txt?view=diff&rev=487125&r1=487124&r2=487125
==============================================================================
--- james/server/sandbox/spring-integration/HOW-TO.txt (original)
+++ james/server/sandbox/spring-integration/HOW-TO.txt Thu Dec 14 00:18:49 2006
@@ -11,7 +11,7 @@
 from {James_Server}/build/lib: james-2.3.0.jar mailet-2.3.jar mailet-api-2.3.jar
 from {James_Server}/phoenix-bin/lib: all files
 from {James_Server}/phoenix-bin/tools/lib: spice-configkit-1.1.2.jar
-from the Spring Framework 2.0 distribution: spring.jar
+from the Spring Framework 2.0 distribution: spring.jar and commons-loggin.jar
 
 1.2 Using your own James configuration
 

Modified: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerBridge.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerBridge.java?view=diff&rev=487125&r1=487124&r2=487125
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerBridge.java (original)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerBridge.java Thu Dec 14 00:18:49 2006
@@ -29,49 +29,107 @@
 /**
  * provides a Avalon-style service manager to all James components
  */
-public class ServiceManagerBridge implements ServiceManager, ApplicationContextAware {
+public class ServiceManagerBridge implements ApplicationContextAware {
 
-    private ApplicationContext applicationContext;
+	private ApplicationContext applicationContext;
 
-    public Object lookup(String componentIdentifier) throws ServiceException {
-        Object component = lookupByClassname(componentIdentifier);
-        if (component == null) component = lookupByBeanname(componentIdentifier);
-
-        if (component == null) throw new ServiceException("could not resolve dependency " + componentIdentifier); // adhere to avalon service manager contract
-        return component;
-    }
-
-    private Object lookupByClassname(String componentIdentifier) {
-        Class lookupClass = null;
-        try {
-            lookupClass = Class.forName(componentIdentifier);
-        } catch (ClassNotFoundException e) {
-            return null;
-        }
-        Map beansOfType = applicationContext.getBeansOfType(lookupClass);
-        if (beansOfType.size() > 1) throw new RuntimeException("not yet supported");
-        if (beansOfType.size() == 0) return null; // try other method
-        Object bean = beansOfType.values().iterator().next();
-        return bean;
-    }
-
-    private Object lookupByBeanname(String componentIdentifier) {
-        return applicationContext.getBean(componentIdentifier);
-    }
-
-    public boolean hasService(String componentIdentifier) {
-        try {
-            return null != lookup(componentIdentifier);
-        } catch (ServiceException e) {
-            return false;
-        }
-    }
-
-    public void release(Object object) {
-        throw new IllegalStateException("not yet implemented");
-    }
-
-    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
-        this.applicationContext = applicationContext;
-    }
+	private Map beanBlockInfos;
+
+	private class ServiceManagerInstance implements ServiceManager {
+
+		private Map beanBlockInfo;
+		
+		public ServiceManagerInstance(Map beanBlockInfo) {
+			this.beanBlockInfo=beanBlockInfo;
+		}
+
+		public Object lookup(String componentIdentifier)
+				throws ServiceException {
+			Object component = lookupByClassname(componentIdentifier);
+			if (component == null)
+				component = lookupByBeanname(componentIdentifier);
+
+			if (component == null)
+				throw new ServiceException("could not resolve dependency "
+						+ componentIdentifier); // adhere to avalon service
+												// manager contract
+			return component;
+		}
+
+		private Object lookupByClassname(String className) {
+			
+			String beanName = getBeanName(className);
+			
+			if (beanName!=null) {
+				System.out.println("Lookup configured "+beanName);
+				return lookupByBeanname(beanName);
+			}
+			
+			Class lookupClass = null;
+			try {
+				lookupClass = Class.forName(className);
+			} catch (ClassNotFoundException e) {
+				return null;
+			}
+			
+			Map beansOfType = applicationContext.getBeansOfType(lookupClass);
+			if (beansOfType.size() > 1) {
+				System.err.println("not yet supported");
+				Thread.dumpStack();
+				System.exit(1);
+				throw new RuntimeException("not yet supported");
+			}
+			if (beansOfType.size() == 0)
+				return null; // try other method
+			Object bean = beansOfType.values().iterator().next();
+			return bean;
+		}
+
+		public boolean hasService(String componentIdentifier) {
+			try {
+				return null != lookup(componentIdentifier);
+			} catch (ServiceException e) {
+				return false;
+			}
+		}
+
+		public void release(Object object) {
+			throw new IllegalStateException("not yet implemented");
+		}
+		
+		protected String getBeanName(String className) {
+			String beanName = null;
+			if (beanBlockInfo!=null) {
+				
+				beanName= (String) beanBlockInfo.get(className);
+				System.out.println("We have a blockInfo! " +className+"  -> "+beanName);
+			} 
+			return beanName;
+		}
+	}
+	
+	private Object lookupByBeanname(String componentIdentifier) {
+		return applicationContext.getBean(componentIdentifier);
+	}
+
+	public void setApplicationContext(ApplicationContext applicationContext)
+			throws BeansException {
+		this.applicationContext = applicationContext;
+	}
+
+	public ServiceManager getInstance(String beanName) {
+		return new ServiceManagerInstance(getBeanBlockInfo(beanName));
+	}
+	
+	protected Map getBeanBlockInfo(String beanName) {
+		Map blockInfo = null;
+		if (beanBlockInfos!=null) {
+			blockInfo= (Map) beanBlockInfos.get(beanName);
+		} 
+		return blockInfo;
+	}
+
+	public void setBeanBlockInfos(Map beanBlockInfos) {
+		this.beanBlockInfos = beanBlockInfos;
+	}
 }

Modified: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/AbstractPropagator.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/AbstractPropagator.java?view=diff&rev=487125&r1=487124&r2=487125
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/AbstractPropagator.java (original)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/AbstractPropagator.java Thu Dec 14 00:18:49 2006
@@ -18,6 +18,8 @@
  ****************************************************************/
 package org.apache.james.container.spring.lifecycle;
 
+import java.util.Collection;
+
 import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
 import org.springframework.beans.factory.BeanFactoryUtils;
 import org.springframework.beans.BeansException;
@@ -27,19 +29,27 @@
  */
 public abstract class AbstractPropagator {
 
-    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
+    private Collection excludeBeans;
+
+	public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
 
         Class lifecycleInterface = getLifecycleInterface();
         String[] beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(configurableListableBeanFactory, lifecycleInterface);
         for (int i = 0; i < beanNames.length; i++) {
             String beanName = beanNames[i];
-
-            Object bean = configurableListableBeanFactory.getBean(beanName);
-            invokeLifecycleWorker(beanName, bean);
+            if (excludeBeans == null || !excludeBeans.contains(beanName)) {
+	            Object bean = configurableListableBeanFactory.getBean(beanName);
+	            invokeLifecycleWorker(beanName, bean);
+            }
         }
     }
+    
+    public void setExcludeBeans(Collection excludeBeans) {
+    	this.excludeBeans=excludeBeans;
+    }
 
     protected abstract Class getLifecycleInterface();
 
     protected abstract void invokeLifecycleWorker(String beanName, Object bean);
+
 }

Modified: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ConfigurationPropagator.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ConfigurationPropagator.java?view=diff&rev=487125&r1=487124&r2=487125
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ConfigurationPropagator.java (original)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ConfigurationPropagator.java Thu Dec 14 00:18:49 2006
@@ -68,9 +68,10 @@
              }
              configurable.configure(componentConfiguration);
          } catch (ConfigurationException e) {
-             //throw new RuntimeException("could not configure component of type " + configurable.getClass(), e);
-         } catch (Exception e) {
-             //throw new RuntimeException("could not configure component of type " + serviceable.getClass(), e);
+             throw new RuntimeException("could not configure component of type " + configurable.getClass(), e);
          }
+//         catch (Exception e) {
+//             throw new RuntimeException("could not configure component of type " + serviceable.getClass(), e);
+//         }
      }
 }

Modified: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ServicePropagator.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ServicePropagator.java?view=diff&rev=487125&r1=487124&r2=487125
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ServicePropagator.java (original)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ServicePropagator.java Thu Dec 14 00:18:49 2006
@@ -29,7 +29,7 @@
     protected void invokeLifecycleWorker(String beanName, Object bean) {
         Serviceable serviceable = (Serviceable) bean;
         try {
-            serviceable.service(serviceManager);
+            serviceable.service(serviceManager.getInstance(beanName));
         } catch (ServiceException e) {
             throw new RuntimeException("could not successfully run service method on component of type " + serviceable.getClass(), e);
         }

Added: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/AbstractProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/AbstractProcessor.java?view=auto&rev=487125
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/AbstractProcessor.java (added)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/AbstractProcessor.java Thu Dec 14 00:18:49 2006
@@ -0,0 +1,48 @@
+/****************************************************************
+ * 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.processor;
+
+import java.util.Collection;
+
+import org.springframework.beans.BeansException;
+
+/**
+ * basis for iterating over all spring beans having some specific implementation 
+ */
+public abstract class AbstractProcessor {
+
+    private Collection excludeBeans;
+
+    
+    public void setExcludeBeans(Collection excludeBeans) {
+    	this.excludeBeans=excludeBeans;
+    }
+    
+    protected boolean isIncluded(String beanName) {
+    	if (excludeBeans!=null) {
+    		return !excludeBeans.contains(beanName);
+    	} else {
+    		return true;
+    	}
+    }
+
+	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+		return bean;
+	}
+}

Added: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ConfigurationProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ConfigurationProcessor.java?view=auto&rev=487125
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ConfigurationProcessor.java (added)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ConfigurationProcessor.java Thu Dec 14 00:18:49 2006
@@ -0,0 +1,78 @@
+/****************************************************************
+ * 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.processor;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.james.container.spring.adaptor.ConfigurationProvider;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.core.Ordered;
+
+/**
+ * calls configure() for all avalon components
+ */
+public class ConfigurationProcessor extends AbstractProcessor implements
+		BeanPostProcessor, Ordered {
+	
+	private Configuration configuration;
+
+	private boolean isConfigurationEmpty(Configuration componentConfiguration) {
+		return (componentConfiguration.getChildren() == null || componentConfiguration
+				.getChildren().length == 0)
+				&& (componentConfiguration.getAttributeNames() == null || componentConfiguration
+						.getAttributeNames().length == 0);
+	}
+
+	public int getOrder() {
+		return 3;
+	}
+
+	public Object postProcessBeforeInitialization(Object bean, String beanName)
+			throws BeansException {
+		if (bean instanceof Configurable && isIncluded(beanName)) {
+			Configurable configurable = (Configurable) bean;
+			try {
+				Configuration componentConfiguration = configuration
+						.getChild(beanName);
+				if (isConfigurationEmpty(componentConfiguration)) {
+					// heuristic: try lowercase
+					componentConfiguration = configuration.getChild(beanName
+							.toLowerCase());
+				}
+				if (isConfigurationEmpty(componentConfiguration)) {
+					System.out.println("configuraton empty for bean "
+							+ beanName);
+				}
+				configurable.configure(componentConfiguration);
+			} catch (ConfigurationException e) {
+				throw new RuntimeException(
+						"could not configure component of type "
+								+ configurable.getClass(), e);
+			}
+		}
+		return bean;
+	}
+
+	public void setConfigurationProvider(
+			ConfigurationProvider configurationProvider) {
+		configuration = configurationProvider.getConfiguration();
+	}
+}

Added: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ContextProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ContextProcessor.java?view=auto&rev=487125
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ContextProcessor.java (added)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ContextProcessor.java Thu Dec 14 00:18:49 2006
@@ -0,0 +1,63 @@
+/****************************************************************
+ * 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.processor;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.core.Ordered;
+
+/**
+ * calls contextualize() for all avalon components
+ */
+public class ContextProcessor extends AbstractProcessor implements BeanPostProcessor, Ordered {
+    
+	private Context context;
+
+    protected void invokeLifecycleWorker(String beanName, Object bean) {
+        Contextualizable contextualizable = (Contextualizable) bean;
+        try {
+            contextualizable.contextualize(context);
+        } catch (ContextException e) {
+            throw new RuntimeException("could not successfully run contextualize method on component of type " + contextualizable.getClass(), e);
+        }
+    }
+
+    public int getOrder() {
+        return 1;
+    }
+    
+    public void setContext(Context context) {
+    	this.context=context;
+    }
+
+	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+		if (bean instanceof Contextualizable && isIncluded(beanName)) {
+	        Contextualizable contextualizable = (Contextualizable) bean;
+	        try {
+	            contextualizable.contextualize(context);
+	        } catch (ContextException e) {
+	            throw new RuntimeException("could not successfully run contextualize method on component of type " + contextualizable.getClass(), e);
+	        }			
+		}
+		return bean;
+	}
+}

Added: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/InitializationProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/InitializationProcessor.java?view=auto&rev=487125
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/InitializationProcessor.java (added)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/InitializationProcessor.java Thu Dec 14 00:18:49 2006
@@ -0,0 +1,47 @@
+/****************************************************************
+ * 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.processor;
+
+import org.apache.avalon.framework.activity.Initializable;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.core.Ordered;
+
+/**
+ * calls initialize() for all avalon components
+ */
+public class InitializationProcessor extends AbstractProcessor implements BeanPostProcessor, Ordered {
+
+    public int getOrder() {
+        return 4;
+    }
+
+	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+		if (bean instanceof Initializable && isIncluded(beanName)) {
+	        Initializable initializable = (Initializable) bean;
+	        try {
+	            initializable.initialize();
+	        } catch (Exception e) {
+	            throw new RuntimeException("could not initialize component of type " + initializable.getClass(), e);
+	        }			
+		}
+		return bean;
+	}
+
+}

Added: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/LoggerProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/LoggerProcessor.java?view=auto&rev=487125
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/LoggerProcessor.java (added)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/LoggerProcessor.java Thu Dec 14 00:18:49 2006
@@ -0,0 +1,50 @@
+/****************************************************************
+ * 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.processor;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.james.container.spring.logging.LoggerToComponentMapper;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.core.Ordered;
+
+/**
+ * propagates Loggers for all avalon components
+ */
+public class LoggerProcessor extends AbstractProcessor implements BeanPostProcessor, Ordered {
+    
+	private LoggerToComponentMapper loggerToComponentMapper;
+
+    public int getOrder() {
+        return 0;
+    }
+    
+    public void setLoggerToComponentMapper(LoggerToComponentMapper loggerToComponentMapper) {
+    	this.loggerToComponentMapper=loggerToComponentMapper;
+    }
+
+	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+		if (bean instanceof LogEnabled && isIncluded(beanName)) {
+	        LogEnabled logEnabled = (LogEnabled) bean;
+	        logEnabled.enableLogging(loggerToComponentMapper.getComponentLogger(beanName));	
+		}
+		return bean;
+	}
+
+}

Added: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ServiceProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ServiceProcessor.java?view=auto&rev=487125
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ServiceProcessor.java (added)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ServiceProcessor.java Thu Dec 14 00:18:49 2006
@@ -0,0 +1,36 @@
+package org.apache.james.container.spring.processor;
+
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.james.container.spring.adaptor.ServiceManagerBridge;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.core.Ordered;
+
+/**
+ * calls service() for all avalon components
+ */
+public class ServiceProcessor extends AbstractProcessor implements BeanPostProcessor, Ordered {
+
+    private ServiceManagerBridge serviceManagerBridge;
+
+    public int getOrder() {
+        return 2;
+    }
+
+	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+		if (bean instanceof Serviceable && isIncluded(beanName)) {
+	        Serviceable serviceable = (Serviceable) bean;
+	        try {
+	            serviceable.service(serviceManagerBridge.getInstance(beanName));
+	        } catch (ServiceException e) {
+	            throw new RuntimeException("could not successfully run service method on component of type " + serviceable.getClass(), e);
+	        }			
+		}
+		return bean;
+	}
+	
+	public void setServiceManagerBridge(ServiceManagerBridge serviceManagerBridge) {
+		this.serviceManagerBridge=serviceManagerBridge;
+	}
+}

Added: james/server/sandbox/spring-integration/src/trunk/config/james-assembly.xml
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/trunk/config/james-assembly.xml?view=auto&rev=487125
==============================================================================
--- james/server/sandbox/spring-integration/src/trunk/config/james-assembly.xml (added)
+++ james/server/sandbox/spring-integration/src/trunk/config/james-assembly.xml Thu Dec 14 00:18:49 2006
@@ -0,0 +1,326 @@
+<?xml version="1.0"?>
+
+<assembly>
+
+  <!-- The list of blocks being run in this Phoenix server. -->
+  <!-- -->
+  <!-- Each block element has a name attribute that is unique -->
+  <!-- among the blocks. It also has a class attribute that -->
+  <!-- specifies the class providing that block-->
+  <!-- -->
+  <!-- The block element may have one or more provide sub-elements. -->
+  <!-- Each provide element represents another block on which this -->
+  <!-- block depends.  Phoenix will calculate a dependency chain when it -->
+  <!-- reads this file, and will load and start the blocks in the order -->
+  <!-- specified by that chain.  Each provide element has a name attribute, -->
+  <!-- which matches the name of a block defined in this file.  It also -->
+  <!-- has a role attribute.  This attribute is the string by which the -->
+  <!-- enclosing block will identify the required block. -->
+  <!-- -->
+
+  <!-- The James block  -->
+  <block name="James" class="org.apache.james.James" >
+
+    <!-- Specify which components will provide the services required by this
+    block. The roles are specified in the code and the .xinfo file. The names
+    here must match the names specified for a Block in this xml file.   -->
+    <provide name="dnsserver" role="org.apache.james.services.DNSServer"/>
+    <provide name="mailstore" role="org.apache.avalon.cornerstone.services.store.Store"/>
+    <provide name="users-store" role="org.apache.james.services.UsersStore"/>
+    <provide name="localusersrepository" role="org.apache.james.services.UsersRepository"/>
+    <provide name="spoolrepository" role="org.apache.james.services.SpoolRepository"/>
+    <provide name="filesystem" role="org.apache.james.services.FileSystem" />
+    <provide name="domainlist" role="org.apache.james.services.DomainList" />
+    <provide name="sockets"
+             role="org.apache.avalon.cornerstone.services.sockets.SocketManager"/>
+    <provide name="scheduler"
+             role="org.apache.avalon.cornerstone.services.scheduler.TimeScheduler"/>
+    <provide name="database-connections"
+             role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector" />
+  </block>
+
+    
+  <block name="mailboxmanager" class="org.apache.james.mailboxmanager.impl.DefaultMailboxManagerProvider">
+      <provide name="filesystem" role="org.apache.james.services.FileSystem" />
+      <provide name="mailboxmanager-mailstore" role="org.apache.avalon.cornerstone.services.store.Store" />      
+  </block>  
+
+  <block name="mailboxmanager-mailstore" class="org.apache.james.mailboxmanager.mailstore.MyAvalonMailStore" >
+    <provide name="database-connections"
+             role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector" />
+    <provide name="filesystem" role="org.apache.james.services.FileSystem" />     
+  </block>      
+ 
+   
+  <!-- The James Spool Manager block  -->
+  <block name="spoolmanager" class="org.apache.james.transport.JamesSpoolManager" >
+    <provide name="spoolrepository" role="org.apache.james.services.SpoolRepository"/>
+    <provide name="matcherpackages" role="org.apache.james.services.MatcherLoader"/>
+    <provide name="mailetpackages" role="org.apache.james.services.MailetLoader"/>
+  </block>
+
+  <block name="matcherpackages" class="org.apache.james.transport.JamesMatcherLoader" >
+    <provide name="James" role="org.apache.mailet.MailetContext"/>
+    <provide name="filesystem" role="org.apache.james.services.FileSystem" />
+  </block>
+
+  <block name="mailetpackages" class="org.apache.james.transport.JamesMailetLoader" >
+    <provide name="James" role="org.apache.mailet.MailetContext"/>
+    <provide name="filesystem" role="org.apache.james.services.FileSystem" />
+  </block>
+
+  <block name="dnsserver" class="org.apache.james.dnsserver.DNSServer" />
+
+  <!-- The Spool Management block  -->
+  <block name="spoolmanagement" class="org.apache.james.management.SpoolManagement" >
+      <provide name="mailstore" role="org.apache.avalon.cornerstone.services.store.Store"/>
+  </block>
+  
+  <block name="processormanagement" class="org.apache.james.management.ProcessorManagement" >
+      <provide name="spoolmanager" role="org.apache.james.services.SpoolManager"/>
+  </block>
+
+  <block name="bayesiananalyzermanagement" class="org.apache.james.management.BayesianAnalyzerManagement" >
+      <provide name="database-connections"
+             role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector" />
+    <provide name="filesystem" role="org.apache.james.services.FileSystem" />
+  </block>
+
+  <block name="remotemanager" class="org.apache.james.remotemanager.RemoteManager" >
+    <provide name="mailstore" role="org.apache.avalon.cornerstone.services.store.Store"/>
+    <provide name="users-store" role="org.apache.james.services.UsersStore"/>
+    <provide name="localusersrepository" role="org.apache.james.services.UsersRepository"/>
+    <provide name="sockets"
+             role="org.apache.avalon.cornerstone.services.sockets.SocketManager"/>
+    <provide name="connections"
+             role="org.apache.james.services.JamesConnectionManager"/>
+    <provide name="James" role="org.apache.james.services.MailServer"/>
+    <provide name="thread-manager"
+             role="org.apache.avalon.cornerstone.services.threads.ThreadManager" />
+    <provide name="spoolmanagement" 
+             role="org.apache.james.services.SpoolManagementService"/>
+    <provide name="bayesiananalyzermanagement"
+             role="org.apache.james.services.BayesianAnalyzerManagementService"/>
+    <provide name="dnsserver" role="org.apache.james.services.DNSServer"/>
+    <provide name="processormanagement" role="org.apache.james.services.ProcessorManagementService"/>
+    <provide name="virtualusertablemanagement" role="org.apache.james.services.VirtualUserTableManagementService"/>
+    <provide name="domainlistmanagement" role="org.apache.james.services.DomainListManagementService"/>
+</block>
+
+  <!-- The User Management block  -->
+  <block name="usermanagement" class="org.apache.james.management.UserManagement" >
+    <provide name="localusersrepository" role="org.apache.james.services.UsersRepository"/>
+    <provide name="users-store" role="org.apache.james.services.UsersStore"/>
+  </block>
+    
+    <!-- IMAP Server -->
+  <block name="imap-connections"
+         class="org.apache.james.util.connection.SimpleConnectionManager" >
+    <provide name="thread-manager"
+             role="org.apache.avalon.cornerstone.services.threads.ThreadManager" />
+  </block>  
+    
+  <block name="imapserver" class="org.apache.james.imapserver.ImapServer" >
+    <provide name="localusersrepository" role="org.apache.james.services.UsersRepository"/>
+    <provide name="sockets"
+             role="org.apache.avalon.cornerstone.services.sockets.SocketManager"/>
+    <provide name="imap-connections"
+             role="org.apache.james.services.JamesConnectionManager"/>
+    <provide name="James" role="org.apache.james.services.MailServer"/>
+    <provide name="thread-manager"
+             role="org.apache.avalon.cornerstone.services.threads.ThreadManager" />
+    <provide name="mailboxmanager"
+             role="org.apache.james.mailboxmanager.manager.MailboxManagerProvider" />    
+    <provide name="dnsserver" role="org.apache.james.services.DNSServer"/>    
+  </block>      
+    
+  <!-- POP3 Server -->
+  <block name="pop3server" class="org.apache.james.pop3server.POP3Server" >
+    <provide name="localusersrepository" role="org.apache.james.services.UsersRepository"/>
+    <provide name="sockets"
+             role="org.apache.avalon.cornerstone.services.sockets.SocketManager"/>
+    <provide name="connections"
+             role="org.apache.james.services.JamesConnectionManager"/>
+    <provide name="James" role="org.apache.james.services.MailServer"/>
+    <provide name="thread-manager"
+             role="org.apache.avalon.cornerstone.services.threads.ThreadManager" />
+    <provide name="dnsserver" role="org.apache.james.services.DNSServer"/>
+  </block>
+
+  <!-- SMTP Server -->
+  <block name="smtpserver" class="org.apache.james.smtpserver.SMTPServer" >
+    <provide name="James" role="org.apache.mailet.MailetContext"/>
+    <provide name="localusersrepository" role="org.apache.james.services.UsersRepository"/>
+    <provide name="dnsserver" role="org.apache.james.services.DNSServer"/>
+    <provide name="sockets"
+             role="org.apache.avalon.cornerstone.services.sockets.SocketManager"/>
+    <provide name="connections"
+             role="org.apache.james.services.JamesConnectionManager"/>
+    <provide name="James" role="org.apache.james.services.MailServer"/>
+    <provide name="thread-manager"
+             role="org.apache.avalon.cornerstone.services.threads.ThreadManager" />
+    <provide name="database-connections"
+             role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector" />
+    <provide name="filesystem" role="org.apache.james.services.FileSystem" />
+    <provide name="defaultvirtualusertable"
+             role="org.apache.james.services.VirtualUserTable" />
+  </block>
+
+  <!-- NNTP Server -->
+  <block name="nntpserver" class="org.apache.james.nntpserver.NNTPServer" >
+    <provide name="localusersrepository" role="org.apache.james.services.UsersRepository"/>
+    <provide name="sockets"
+             role="org.apache.avalon.cornerstone.services.sockets.SocketManager"/>
+    <provide name="connections"
+             role="org.apache.james.services.JamesConnectionManager"/>
+    <provide name="nntp-repository"
+             role="org.apache.james.nntpserver.repository.NNTPRepository"/>
+    <provide name="thread-manager"
+             role="org.apache.avalon.cornerstone.services.threads.ThreadManager" />
+    <provide name="dnsserver" role="org.apache.james.services.DNSServer"/>
+  </block>
+
+  <!-- NNTP Repository -->
+  <block name="nntp-repository" class="org.apache.james.nntpserver.repository.NNTPRepositoryImpl">
+    <provide name="filesystem" role="org.apache.james.services.FileSystem" />
+  </block>
+
+  <!-- FetchMail Service -->
+  <block name="fetchmail" class="org.apache.james.fetchmail.FetchScheduler" >
+    <provide name="scheduler"
+             role="org.apache.avalon.cornerstone.services.scheduler.TimeScheduler"/> 
+    <provide name="James" role="org.apache.james.services.MailServer"/>      
+    <provide name="localusersrepository" role="org.apache.james.services.UsersRepository"/>
+    <provide name="dnsserver" role="org.apache.james.services.DNSServer"/>
+  </block>
+
+  <!-- The High Level Storage block -->
+    
+  <block name="mailstore" class="org.apache.james.core.AvalonMailStore" >
+    <provide name="database-connections"
+             role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector" />
+    <provide name="mailboxmanager"
+             role="org.apache.james.mailboxmanager.manager.MailboxManagerProvider" />  
+    <provide name="filesystem" role="org.apache.james.services.FileSystem" />     
+  </block>  
+        
+  <!-- The main SpoolRepository -->
+  <block name="spoolrepository" class="org.apache.james.mailrepository.MailStoreSpoolRepository" >
+    <provide name="mailstore"
+             role="org.apache.avalon.cornerstone.services.store.Store" />
+  </block>
+
+  <!-- The User Storage block -->
+  <block name="users-store" class="org.apache.james.core.AvalonUsersStore" >
+    <!-- Configure file based user store here, defaults should be fine -->
+    <provide name="mailstore"
+             role="org.apache.avalon.cornerstone.services.store.Store"/>
+    <provide name="database-connections"
+             role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector" />
+    <provide name="filesystem" role="org.apache.james.services.FileSystem" />
+  </block>
+
+  <!-- This is needed to link the smtpserver to the local user repository -->
+  <!-- LocalJamesUsersRepository is used for backward compatibility with James 2.3.0 -->
+  <!-- This is needed to support <usernames> configuraion inside James -->
+  <!-- If backward compatibility is not need the LocalUsersRepository implementaion -->
+  <!-- could be safely used -->
+  <block name="localusersrepository" class="org.apache.james.core.LocalJamesUsersRepository">
+    <provide name="users-store"
+             role="org.apache.james.services.UsersStore"/>
+  </block>
+
+  <!-- The context FileSystem implementation -->
+  <block name="filesystem" class="org.apache.james.context.AvalonFileSystem">
+  </block>
+  
+  <!-- The VirtualUserTable Management block  -->
+  <block name="virtualusertablemanagement" class="org.apache.james.management.VirtualUserTableManagement" >
+    <provide name="virtualusertable-store" role="org.apache.james.services.VirtualUserTableStore"/>
+    <provide name="defaultvirtualusertable" role="org.apache.james.services.VirtualUserTableManagement" />
+  </block>
+  
+  <!-- VirtualUserTable Store -->
+  <block name="virtualusertable-store" class="org.apache.james.core.AvalonVirtualUserTableStore">
+    <provide name="database-connections"
+             role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector"/>
+    <provide name="filesystem" role="org.apache.james.services.FileSystem"/>
+    <provide name="dnsserver" role="org.apache.james.services.DNSServer"/>
+  </block>
+  
+  <block name="defaultvirtualusertable" class="org.apache.james.core.DefaultVirtualUserTable">
+    <provide name="virtualusertable-store"
+             role="org.apache.james.services.VirtualUserTableStore"/>
+  </block>
+  
+  
+  <!-- ######################################################################## -->
+  <!-- The context domainlist implementation -->
+  <block name="domainlist" class="org.apache.james.domain.XMLDomainList">
+      <provide name="dnsserver" role="org.apache.james.services.DNSServer"/>
+  </block>
+  
+  <!--  JDBC implementation of the domainlist service-->
+  <!--
+  <block name="domainlist" class="org.apache.james.domain.JDBCDomainList">
+      <provide name="database-connections"
+             role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector"/>
+      <provide name="filesystem" role="org.apache.james.services.FileSystem"/>
+      <provide name="dnsserver" role="org.apache.james.services.DNSServer"/>
+  </block>
+  -->
+  
+  <!-- JDBC VirtualUserTable implementation of the domainlist service -->
+  <!--
+  <block name="domainlist" class="org.apache.james.vut.JDBCVirtualUserTable">
+    <provide name="database-connections"
+             role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector"/>
+    <provide name="filesystem" role="org.apache.james.services.FileSystem"/>
+    <provide name="dnsserver" role="org.apache.james.services.DNSServer"/>
+  </block>
+  -->
+  
+  <!-- XML VirtualUserTable implementation of the domainlist service -->
+  <!--
+  <block name="domainlist" class="org.apache.james.vut.XMLVirtualUserTable">
+      <provide name="dnsserver" role="org.apache.james.services.DNSServer"/>
+  </block>
+  -->
+  <!-- #################################################################### -->
+  
+  <block name="domainlistmanagement" class="org.apache.james.management.DomainListManagement">
+    <provide name="domainlist"
+             role="org.apache.james.services.DomainList"/>
+  </block>
+  
+  <!-- Configuration for Cornerstone Blocks only after here
+       NOTHING BELOW THIS SHOULD NEED CHANGING,
+       (unless you want secure sockets (TLS)) -->
+
+  <!-- The Connection Manager block -->
+  <block name="connections"
+         class="org.apache.james.util.connection.SimpleConnectionManager" >
+    <provide name="thread-manager"
+             role="org.apache.avalon.cornerstone.services.threads.ThreadManager" />
+  </block>
+
+  <!-- The Socket Manager block -->
+  <block name="sockets"
+         class="org.apache.avalon.cornerstone.blocks.sockets.DefaultSocketManager"/>
+
+  <!-- The Time Scheduler block -->
+  <block name="scheduler"
+         class="org.apache.avalon.cornerstone.blocks.scheduler.DefaultTimeScheduler" >
+    <provide name="thread-manager"
+             role="org.apache.avalon.cornerstone.services.threads.ThreadManager" />
+  </block>
+
+  <!-- The DataSourceSelector block -->
+  <block name="database-connections"
+         class="org.apache.avalon.cornerstone.blocks.datasources.DefaultDataSourceSelector" />
+
+  <!-- The ThreadManager block -->
+  <block name="thread-manager"
+         class="org.apache.avalon.cornerstone.blocks.threads.DefaultThreadManager" />
+
+</assembly>



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org