james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1050353 - in /james/server/trunk: container-spring/src/main/config/james/context/ container-spring/src/main/java/org/apache/james/container/spring/ container-spring/src/main/java/org/apache/james/container/spring/lifecycle/ nio-netty/src/m...
Date Fri, 17 Dec 2010 11:29:43 GMT
Author: norman
Date: Fri Dec 17 11:29:43 2010
New Revision: 1050353

URL: http://svn.apache.org/viewvc?rev=1050353&view=rev
Log:
The ProtocolHandlerChain is now managed and handled by the spring container. This makes more
sense and is not such a hack as before. 

Added:
    james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/SpringProtocolHandlerChain.java
      - copied, changed from r1049974, james/server/trunk/nio-netty/src/main/java/org/apache/james/server/JamesProtocolHandlerChain.java
Modified:
    james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
    james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/ConfigurationProvider.java
    james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/LogProvider.java
    james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/SpringConfigurationProvider.java
    james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/SpringLogProvider.java
    james/server/trunk/nio-netty/src/main/java/org/apache/james/server/JamesProtocolHandlerChain.java
    james/server/trunk/osgi/src/main/java/org/apache/james/container/osgi/OsgiConfigurationProvider.java
    james/server/trunk/osgi/src/main/java/org/apache/james/container/osgi/OsgiLogProvider.java

Modified: james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml?rev=1050353&r1=1050352&r2=1050353&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
(original)
+++ james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
Fri Dec 17 11:29:43 2010
@@ -45,10 +45,6 @@
     <bean id="configurationProvider" class="org.apache.james.container.spring.lifecycle.SpringConfigurationProvider">
         <property name="configurationMappings">
             <map>
-                <entry key="lmtpProtocolHandlerChain" value="lmtpserver"/>
-                <entry key="smtpProtocolHandlerChain" value="smtpserver"/>
-                <entry key="pop3ProtocolHandlerChain" value="pop3server"/>
-                <entry key="remoteProtocolHandlerChain" value="remotemanager"/>
                 <entry key="mailProcessor" value="mailetcontainer"/>
                 <entry key="mailspooler" value="mailetcontainer"/>
                 <entry key="mailetloader" value="mailetcontainer"/>
@@ -68,10 +64,6 @@
     <bean id="logProvider" class="org.apache.james.container.spring.lifecycle.SpringLogProvider">
         <property name="logMappings">
             <map>
-                <entry key="lmtpProtocolHandlerChain" value="lmtpserver"/>
-                <entry key="smtpProtocolHandlerChain" value="smtpserver"/>
-                <entry key="pop3ProtocolHandlerChain" value="pop3server"/>
-                <entry key="remoteProtocolHandlerChain" value="remoteManager"/>
                 <entry key="mailProcessor" value="mailetcontainer"/>
                 <entry key="mailspooler" value="mailetcontainer"/>
                 <entry key="mailetloader" value="mailetcontainer"/>
@@ -159,8 +151,9 @@
     <bean id="remotemanager" class="org.apache.james.remotemanager.netty.RemoteManager"
>
         <property name="protocolHandlerChain" ref="remoteProtocolHandlerChain"/>
     </bean>
-    <bean id="remoteProtocolHandlerChain" class="org.apache.james.server.JamesProtocolHandlerChain">
+    <bean id="remoteProtocolHandlerChain" class="org.apache.james.container.spring.SpringProtocolHandlerChain">
         <property name="coreHandlersPackage" value="org.apache.james.remotemanager.core.CoreCmdHandlerLoader"/>
+        <property name="beanName" value="remotemanager"/>
     </bean>
 
     <!-- 
@@ -169,8 +162,9 @@
     <bean id="smtpserver" class="org.apache.james.smtpserver.netty.SMTPServer">
         <property name="protocolHandlerChain" ref="smtpProtocolHandlerChain"/>
     </bean>
-    <bean id="smtpProtocolHandlerChain" class="org.apache.james.server.JamesProtocolHandlerChain">
+    <bean id="smtpProtocolHandlerChain" class="org.apache.james.container.spring.SpringProtocolHandlerChain">
         <property name="coreHandlersPackage" value="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+        <property name="beanName" value="smtpserver"/>
     </bean>
 
     <!-- 
@@ -179,10 +173,11 @@
     <bean id="lmtpserver" class="org.apache.james.lmtpserver.netty.LMTPServer">
         <property name="protocolHandlerChain" ref="lmtpProtocolHandlerChain"/>
     </bean>
-    <bean id="lmtpProtocolHandlerChain" class="org.apache.james.server.JamesProtocolHandlerChain">
+    <bean id="lmtpProtocolHandlerChain" class="org.apache.james.container.spring.SpringProtocolHandlerChain">
         <property name="coreHandlersPackage" value="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/>
+        <property name="beanName" value="lmtpserver"/>
     </bean>
-    
+
     <!-- 
       Fetchmail
      -->
@@ -194,8 +189,9 @@
     <bean id="pop3server"  class="org.apache.james.pop3server.netty.POP3Server" >
         <property name="protocolHandlerChain" ref="pop3ProtocolHandlerChain"/>
     </bean>
-    <bean id="pop3ProtocolHandlerChain" class="org.apache.james.server.JamesProtocolHandlerChain">
+    <bean id="pop3ProtocolHandlerChain" class="org.apache.james.container.spring.SpringProtocolHandlerChain">
         <property name="coreHandlersPackage" value="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/>
+        <property name="beanName" value="lmtpserver"/>
     </bean>
 
     <!-- 

Copied: james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/SpringProtocolHandlerChain.java
(from r1049974, james/server/trunk/nio-netty/src/main/java/org/apache/james/server/JamesProtocolHandlerChain.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/SpringProtocolHandlerChain.java?p2=james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/SpringProtocolHandlerChain.java&p1=james/server/trunk/nio-netty/src/main/java/org/apache/james/server/JamesProtocolHandlerChain.java&r1=1049974&r2=1050353&rev=1050353&view=diff
==============================================================================
--- james/server/trunk/nio-netty/src/main/java/org/apache/james/server/JamesProtocolHandlerChain.java
(original)
+++ james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/SpringProtocolHandlerChain.java
Fri Dec 17 11:29:43 2010
@@ -16,205 +16,209 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.server;
+package org.apache.james.container.spring;
 
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 
-import javax.annotation.PostConstruct;
-import javax.annotation.Resource;
 
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.ConfigurationUtils;
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.commons.configuration.HierarchicalConfiguration;
 import org.apache.commons.logging.Log;
-import org.apache.james.lifecycle.api.Configurable;
-import org.apache.james.lifecycle.api.LogEnabled;
+import org.apache.james.container.spring.lifecycle.ConfigurationProvider;
+import org.apache.james.container.spring.lifecycle.LogProvider;
 import org.apache.james.protocols.api.ExtensibleHandler;
 import org.apache.james.protocols.api.HandlersPackage;
 import org.apache.james.protocols.api.ProtocolHandlerChain;
 import org.apache.james.protocols.api.WiringException;
-import org.apache.james.resolver.api.InstanceFactory;
-
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
 
 /**
- * ProtocolHandlerchain implementation which instance all the configured handlers
- * 
  *
+ * {@link ProtocolHandlerChain} implementation which will parse a configuration file and
register all configured handlers in the Spring {@link ConfigurableListableBeanFactory} instance
+ * Here the @class attribute of the handler configuration will be used as bean name prefixed
with the value of {@link #setBeanName(String)} + :
+ * 
+ * 
+ * This implementation take also care of wire the {@link ExtensibleHandler} for which it
is responsible
+ * 
+ * 
  */
 @SuppressWarnings("unchecked")
-public class JamesProtocolHandlerChain implements ProtocolHandlerChain, Configurable, LogEnabled
{
-  
-    private Log log;
-    private String coreHandlersPackage;
-    private LinkedList handlers = new LinkedList();
-    private HierarchicalConfiguration config;
-    private InstanceFactory factory;
-
+public class SpringProtocolHandlerChain implements ProtocolHandlerChain, BeanFactoryPostProcessor,
BeanPostProcessor {
 
-    public void setCoreHandlersPackage(String coreHandlersPackage) {
-        this.coreHandlersPackage = coreHandlersPackage;
-    }
-   
-    @Resource(name="instanceFactory")
-    public void setInstanceFactory(InstanceFactory factory) {
-        this.factory = factory;
-    }
+    private String coreHandlersPackage;
+    private List<String> handlers = new LinkedList<String>();
+    private String beanname;
+    private ConfigurableListableBeanFactory beanFactory;
     
     
-    @PostConstruct
-    public void init() throws Exception {
-        HierarchicalConfiguration handlerchainConfig = config.configurationAt("handler.handlerchain");
-        if (handlerchainConfig.getString("[@coreHandlersPackage]") == null)
-            handlerchainConfig.addProperty("[@coreHandlersPackage]", coreHandlersPackage);
-        
-        loadHandlers(handlerchainConfig);     
-        
-        wireExtensibleHandlers();
+    public void setBeanName(String beanname) {
+        this.beanname = beanname;
     }
-    
-    /**
-     * ExtensibleHandler wiring
-     * 
-     * @throws WiringException 
-     */
-    private void wireExtensibleHandlers() throws WiringException {
-        for (int a = 0; a < handlers.size(); a++) {
-            final Object obj = handlers.get(a);
-            if (obj instanceof ExtensibleHandler) {
-                final ExtensibleHandler extensibleHandler = (ExtensibleHandler) obj;
-                final List<Class<?>> markerInterfaces = extensibleHandler.getMarkerInterfaces();
-                for (int i = 0; i < markerInterfaces.size(); i++) {
-                    final Class<?> markerInterface = markerInterfaces.get(i);
-                    final List<?> extensions = getHandlers(markerInterface);
-                    extensibleHandler.wireExtensions(markerInterface, extensions);
-                }
-            }
-
-        }
 
+    public void setCoreHandlersPackage(String coreHandlersPackage) {
+        this.coreHandlersPackage = coreHandlersPackage;
     }
-    
-    /**
-     * Load and add the classes to the handler map
-     * 
-     * @param classLoader The classLoader to use
-     * @param className The class name 
-     * @param config The configuration 
-     * @throws ConfigurationException Get thrown on error
-     */
-    private void loadClass(String className, org.apache.commons.configuration.HierarchicalConfiguration
config) throws Exception {
-        Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
-        Object obj = factory.newInstance(clazz, log, config);
-
-
-        // if it is a commands handler add it to the map with key as command
-        // name
-        if (obj instanceof HandlersPackage) {
-
-            List<String> c = ((HandlersPackage) obj).getHandlers();
-
-            for (Iterator<String> i = c.iterator(); i.hasNext(); ) {
-                String cName = i.next();
-
-                HierarchicalConfiguration cmdConf = addHandler(cName);
-
-                loadClass(cName, cmdConf);
-            }
-
-        } else {
-            handlers.add(obj);
-            
-            if (log.isInfoEnabled()) {
-                log.info("Added Handler: " + className);
-            }
-
-        }
 
-    }
-    
     /**
-     * Return a DefaultConfiguration build on the given command name and classname
+     * Return a DefaultConfiguration build on the given command name and
+     * classname
      * 
-     * @param cmdName The command name
-     * @param className The class name
+     * @param cmdName
+     *            The command name
+     * @param className
+     *            The class name
      * @return DefaultConfiguration
-     * @throws ConfigurationException 
+     * @throws ConfigurationException
      */
     private HierarchicalConfiguration addHandler(String className) throws ConfigurationException
{
         HierarchicalConfiguration hConf = new DefaultConfigurationBuilder();
-        hConf.addProperty("handler.[@class]", className);
+        hConf.addProperty("[@class]", className);
         return hConf;
     }
-    
-    
-    /* (non-Javadoc)
-     * @see org.apache.james.socket.shared.ProtocolHandlerChain#getHandlers(java.lang.Class)
+
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.ProtocolHandlerChain#getHandlers(java.lang.Class)
      */
     public <T> LinkedList<T> getHandlers(Class<T> type) {
         LinkedList<T> classHandlers = new LinkedList<T>();
-        Iterator hList = handlers.iterator();
-        while (hList.hasNext()) {
-            Object obj = hList.next();
-            if (type.isInstance(obj)) {
-                classHandlers.add((T)obj);
+        String[] names = beanFactory.getBeanNamesForType(type);
+
+        for (int i = 0; i < names.length; i++) {
+            String name = names[i];
+            // check if the handler is registered in the handler chain
+            if (handlers.contains(name)) {
+                classHandlers.add(beanFactory.getBean(name, type));
             }
         }
+        
         return classHandlers;
     }
 
+
     /**
-     * loads the various handlers from the configuration
-     * 
-     * @param configuration
-     *            configuration under handlerchain node
+     * Lookup the {@link HierarchicalConfiguration} for the beanname which was configured
via {@link #setBeanName(String)} and parse it for handlers which should be 
+     * registered in the {@link ConfigurableListableBeanFactory}. 
      */
-    private void loadHandlers(HierarchicalConfiguration commonsConf) throws Exception {
+    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws
BeansException {
+        this.beanFactory = beanFactory;
+        ConfigurationProvider confProvider = beanFactory.getBean(ConfigurationProvider.class);
+        LogProvider logProvider = beanFactory.getBean(LogProvider.class);
+        
+        try {
+            Log log = logProvider.getLog(beanname);
+            HierarchicalConfiguration config = confProvider.getConfiguration(beanname);
+            HierarchicalConfiguration handlerchainConfig = config.configurationAt("handler.handlerchain");
+            List<org.apache.commons.configuration.HierarchicalConfiguration> children
= handlerchainConfig.configurationsAt("handler");
+
+            // check if the coreHandlersPackage was specified inte hconfig if not add the
default 
+            if (handlerchainConfig.getString("[@coreHandlersPackage]") == null)
+                handlerchainConfig.addProperty("[@coreHandlersPackage]", coreHandlersPackage);
+
+            String coreCmdName = handlerchainConfig.getString("[@coreHandlersPackage]");
 
-            List<org.apache.commons.configuration.HierarchicalConfiguration> children
= ((HierarchicalConfiguration) commonsConf).configurationsAt("handler");
+            
+            BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
 
-            String coreCmdName = commonsConf.getString("[@coreHandlersPackage]");
-            // load the core handlers
-            loadClass(coreCmdName,
-                    addHandler(coreCmdName));
+            String coreCmdBeanName = getBeanName(coreCmdName);
 
-            // load the configured handlers
-            if (children != null && children.isEmpty() == false) {
+            // now register the HandlerPackage 
+            BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(coreCmdName).setLazyInit(false).getBeanDefinition();
+            registry.registerBeanDefinition(coreCmdBeanName, def);
+            HandlersPackage handlersPackage = beanFactory.getBean(coreCmdBeanName, HandlersPackage.class);
 
-                for (int i = 0; i < children.size(); i++) {
-                    org.apache.commons.configuration.HierarchicalConfiguration hConf = children.get(i);
-                    String className = hConf.getString("[@class]");
+            List<String> c = handlersPackage.getHandlers();
 
-                    if (className != null) {
-                        // ignore base handlers.
-                        if (!className.equals(coreCmdName)) {
+            for (Iterator<String> i = c.iterator(); i.hasNext();) {
+                String cName = i.next();
 
-                            // load the handler
-                            loadClass(className, hConf);
-                        }
+                try {
+                    HierarchicalConfiguration cmdConf = addHandler(cName);
+                    children.add(cmdConf);
+                } catch (ConfigurationException e) {
+                    throw new FatalBeanException("Unable to create configuration for handler
" + cName, e);
+                }
+            }
+
+            for (int i = 0; i < children.size(); i++) {
+                HierarchicalConfiguration hConf = children.get(i);
+                String className = hConf.getString("[@class]", null);
+
+                if (className != null) {
+                    // ignore base handlers.
+                    if (!className.equals(coreCmdName)) {
+
+                        String handlerBeanName = getBeanName(className);
+
+                        // register the log and configuration for it
+                        logProvider.registerLog(handlerBeanName, log);
+                        confProvider.registerConfiguration(handlerBeanName, hConf);
+
+                        // now register the BeanDefinition on the context and store the beanname
for later usage
+                        BeanDefinition handlerDef = BeanDefinitionBuilder.genericBeanDefinition(className).getBeanDefinition();
+                        registry.registerBeanDefinition(handlerBeanName, handlerDef);
+                        
+                        handlers.add(handlerBeanName);
                     }
+                } else {
+                    throw new FatalBeanException("Missing @class attribute in configuration:
" + ConfigurationUtils.toString(hConf));
                 }
-               
             }
-        
+            
+            
+        } catch (ConfigurationException e) {
+            throw new FatalBeanException("Unable to load configuration for bean " + beanname,
e);
+        }
+
     }
-    
 
-  
-    /*
-     * (non-Javadoc)
-     * @see org.apache.james.lifecycle.Configurable#configure(org.apache.commons.configuration.HierarchicalConfiguration)
+    private String getBeanName(String name) {
+        return beanname + ":" + name;
+    }
+
+
+    /**
+     * Check if the bean was registered within the instance and if so see if it is an {@link
ExtensibleHandler} implementation
+     * 
+     * If thats the case it will do all the needed wiring 
      */
-    public void configure(HierarchicalConfiguration config) throws ConfigurationException
{
-        this.config = config;
+    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException
{
+        
+        // check if ths instance is responsible for the bean and if so if the bean is an
instance of ExtensibleHandler
+        if (handlers.contains(beanName) && bean instanceof ExtensibleHandler) {
+            final ExtensibleHandler extensibleHandler = (ExtensibleHandler) bean;
+            final List<Class<?>> markerInterfaces = extensibleHandler.getMarkerInterfaces();
+            for (int i = 0; i < markerInterfaces.size(); i++) {
+                final Class<?> markerInterface = markerInterfaces.get(i);
+                final List<?> extensions = getHandlers(markerInterface);
+                try {
+                    // ok now time for try the wiring
+                    extensibleHandler.wireExtensions(markerInterface, extensions);
+                } catch (WiringException e) {
+                    throw new FatalBeanException("Unable to wire the handler " + bean + "
with name " + beanName, e);
+                }
+            }
+        }
+        
+        return bean;
     }
-    
-    /*
-     * (non-Javadoc)
-     * @see org.apache.james.lifecycle.LogEnabled#setLog(org.apache.commons.logging.Log)
+
+    /**
+     * Nothing todo so just return the bean
      */
-    public void setLog(Log log) {
-        this.log = log;
+    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
{
+        return bean;
     }
 }
\ No newline at end of file

Modified: james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/ConfigurationProvider.java
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/ConfigurationProvider.java?rev=1050353&r1=1050352&r2=1050353&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/ConfigurationProvider.java
(original)
+++ james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/ConfigurationProvider.java
Fri Dec 17 11:29:43 2010
@@ -36,4 +36,12 @@ public interface ConfigurationProvider {
      * @throws ConfigurationException
      */
     public HierarchicalConfiguration getConfiguration(String beanName) throws ConfigurationException;
+    
+    /**
+     * Register a {@link HierarchicalConfiguration} for a bean name
+     * 
+     * @param beanName
+     * @param conf
+     */
+    public void registerConfiguration(String beanName, HierarchicalConfiguration conf);
 }

Modified: james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/LogProvider.java
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/LogProvider.java?rev=1050353&r1=1050352&r2=1050353&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/LogProvider.java
(original)
+++ james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/LogProvider.java
Fri Dec 17 11:29:43 2010
@@ -34,4 +34,12 @@ public interface LogProvider {
      * @return log
      */
     public Log getLog(String beanName);
+    
+    /**
+     * Register a {@link Log} for a beanName. The registered Log will get returned by {@link
#getLog(String)}
+     * 
+     * @param beanName
+     * @param log
+     */
+    public void registerLog(String beanName, Log log);
 }

Modified: james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/SpringConfigurationProvider.java
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/SpringConfigurationProvider.java?rev=1050353&r1=1050352&r2=1050353&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/SpringConfigurationProvider.java
(original)
+++ james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/SpringConfigurationProvider.java
Fri Dec 17 11:29:43 2010
@@ -38,30 +38,30 @@ import org.springframework.core.io.Resou
  */
 public class SpringConfigurationProvider implements ConfigurationProvider, ResourceLoaderAware,
InitializingBean {
 
-	private ResourceLoader loader;
-	private Map<String,HierarchicalConfiguration> confMap = new HashMap<String,HierarchicalConfiguration>();
-    private Map<String,String> resources;
-
-
-
-	/**
-	 * Return the configuration prefix to load the config. In this case its
-	 * file://conf/
-	 * 
-	 * @return prefix
-	 */
-	protected String getConfigPrefix() {
-		return "file://conf/";
-	}
-	
-	/*
-	 * (non-Javadoc)
-	 * @see org.springframework.context.ResourceLoaderAware#setResourceLoader(org.springframework.core.io.ResourceLoader)
-	 */
-	public void setResourceLoader(ResourceLoader loader) {
-		this.loader = loader;
-	}
+    private ResourceLoader loader;
+    private Map<String, HierarchicalConfiguration> confMap = new HashMap<String,
HierarchicalConfiguration>();
+    private Map<String, String> resources;
+
+    /**
+     * Return the configuration prefix to load the config. In this case its
+     * file://conf/
+     * 
+     * @return prefix
+     */
+    protected String getConfigPrefix() {
+        return "file://conf/";
+    }
 
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.springframework.context.ResourceLoaderAware#setResourceLoader(org
+     * .springframework.core.io.ResourceLoader)
+     */
+    public void setResourceLoader(ResourceLoader loader) {
+        this.loader = loader;
+    }
     
     private XMLConfiguration getConfig(Resource r) throws ConfigurationException, IOException
{
         XMLConfiguration config = new XMLConfiguration();
@@ -85,8 +85,10 @@ public class SpringConfigurationProvider
     }
 
 
+
     /*
-     * 
+     * (non-Javadoc)
+     * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
      */
     public void afterPropertiesSet() throws Exception {
         if (resources != null) {
@@ -95,11 +97,15 @@ public class SpringConfigurationProvider
             while (it.hasNext()) {
                 String key = it.next();
                 String value = resources.get(key);
-                confMap.put(key,getConfiguration(value));
+                registerConfiguration(key,getConfiguration(value));
             }
         }
     }
 
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.container.spring.lifecycle.ConfigurationProvider#getConfiguration(java.lang.String)
+     */
     public HierarchicalConfiguration getConfiguration(String name) throws ConfigurationException
{
         HierarchicalConfiguration conf = confMap.get(name);
         if (conf != null) {
@@ -117,4 +123,12 @@ public class SpringConfigurationProvider
         throw new ConfigurationException("Unable to load configuration for component " +
name);
     }
 
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.container.spring.lifecycle.ConfigurationProvider#registerConfiguration(java.lang.String,
org.apache.commons.configuration.HierarchicalConfiguration)
+     */
+    public void registerConfiguration(String beanName, HierarchicalConfiguration conf) {
+        confMap.put(beanName,conf);
+    }
+
 }

Modified: james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/SpringLogProvider.java
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/SpringLogProvider.java?rev=1050353&r1=1050352&r2=1050353&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/SpringLogProvider.java
(original)
+++ james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/lifecycle/SpringLogProvider.java
Fri Dec 17 11:29:43 2010
@@ -33,24 +33,27 @@ import org.springframework.beans.factory
  */
 public class SpringLogProvider implements LogProvider, InitializingBean {
 
-    private final Map<String,Log> logMap = new HashMap<String,Log>();
+    private final Map<String, Log> logMap = new HashMap<String, Log>();
     private Map<String, String> logs;
     private final static String PREFIX = "james.";
 
-	/**
-	 * Use {@link Log4JLogger} to create the Log
-	 * 
-	 * @param loggerName
-	 * @return log
-	 */
-	protected Log createLog(String loggerName) {
-		return new Log4JLogger(loggerName);
-	}
-	
-	/*
-	 * (non-Javadoc)
-	 * @see org.apache.james.container.spring.Registry#registerForComponent(java.lang.String,
java.lang.Object)
-	 */
+    /**
+     * Use {@link Log4JLogger} to create the Log
+     * 
+     * @param loggerName
+     * @return log
+     */
+    protected Log createLog(String loggerName) {
+        return new Log4JLogger(loggerName);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.james.container.spring.Registry#registerForComponent(java.
+     * lang.String, java.lang.Object)
+     */
     public void registerForComponent(String name, Log log) {
         logMap.put(name, log);
     }
@@ -69,12 +72,15 @@ public class SpringLogProvider implement
             while(it.hasNext()) {
                 String key = it.next();
                 String value = logs.get(key);
-                
-                logMap.put(key, new Log4JLogger(PREFIX + value));
+                registerLog(key, new Log4JLogger(PREFIX + value));
             }
         }
     }
 
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.container.spring.lifecycle.LogProvider#getLog(java.lang.String)
+     */
     public Log getLog(String name) {
         Log log = logMap.get(name);
         if (log != null) {
@@ -83,4 +89,12 @@ public class SpringLogProvider implement
             return createLog(PREFIX + name);
         }
     }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.container.spring.lifecycle.LogProvider#registerLog(java.lang.String,
org.apache.commons.logging.Log)
+     */
+    public void registerLog(String beanName, Log log) {
+        logMap.put(beanName, log);
+    }
 }

Modified: james/server/trunk/nio-netty/src/main/java/org/apache/james/server/JamesProtocolHandlerChain.java
URL: http://svn.apache.org/viewvc/james/server/trunk/nio-netty/src/main/java/org/apache/james/server/JamesProtocolHandlerChain.java?rev=1050353&r1=1050352&r2=1050353&view=diff
==============================================================================
--- james/server/trunk/nio-netty/src/main/java/org/apache/james/server/JamesProtocolHandlerChain.java
(original)
+++ james/server/trunk/nio-netty/src/main/java/org/apache/james/server/JamesProtocolHandlerChain.java
Fri Dec 17 11:29:43 2010
@@ -42,6 +42,7 @@ import org.apache.james.resolver.api.Ins
  * ProtocolHandlerchain implementation which instance all the configured handlers
  * 
  *
+ * TODO: Move this to test package as it is the only place where it get used
  */
 @SuppressWarnings("unchecked")
 public class JamesProtocolHandlerChain implements ProtocolHandlerChain, Configurable, LogEnabled
{

Modified: james/server/trunk/osgi/src/main/java/org/apache/james/container/osgi/OsgiConfigurationProvider.java
URL: http://svn.apache.org/viewvc/james/server/trunk/osgi/src/main/java/org/apache/james/container/osgi/OsgiConfigurationProvider.java?rev=1050353&r1=1050352&r2=1050353&view=diff
==============================================================================
--- james/server/trunk/osgi/src/main/java/org/apache/james/container/osgi/OsgiConfigurationProvider.java
(original)
+++ james/server/trunk/osgi/src/main/java/org/apache/james/container/osgi/OsgiConfigurationProvider.java
Fri Dec 17 11:29:43 2010
@@ -51,4 +51,9 @@ public class OsgiConfigurationProvider i
         
     }
 
+    public void registerConfiguration(String beanName, HierarchicalConfiguration conf) {
+        // TODO Auto-generated method stub
+        
+    }
+
 }

Modified: james/server/trunk/osgi/src/main/java/org/apache/james/container/osgi/OsgiLogProvider.java
URL: http://svn.apache.org/viewvc/james/server/trunk/osgi/src/main/java/org/apache/james/container/osgi/OsgiLogProvider.java?rev=1050353&r1=1050352&r2=1050353&view=diff
==============================================================================
--- james/server/trunk/osgi/src/main/java/org/apache/james/container/osgi/OsgiLogProvider.java
(original)
+++ james/server/trunk/osgi/src/main/java/org/apache/james/container/osgi/OsgiLogProvider.java
Fri Dec 17 11:29:43 2010
@@ -37,4 +37,9 @@ public class OsgiLogProvider implements 
         return LogFactory.getLog(beanName);
     }
 
+    public void registerLog(String beanName, Log log) {
+        // TODO Auto-generated method stub
+        
+    }
+
 }



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


Mime
View raw message