Author: eric
Date: Mon Dec 27 13:59:21 2010
New Revision: 1053068
URL: http://svn.apache.org/viewvc?rev=1053068&view=rev
Log:
Move abstract classes to upper package - remame AbstractBeanFactoryAware to
AbstractBeanFactory - Simple Code format/javadoc.
Added:
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/AbstractBeanFactory.java
- copied, changed from r1053066,
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/AbstractBeanFactoryAware.java
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/AbstractLifecycleBeanPostProcessor.java
- copied, changed from r1053066,
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/postprocessor/AbstractLifecycleBeanPostProcessor.java
Removed:
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/AbstractBeanFactoryAware.java
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/postprocessor/AbstractLifecycleBeanPostProcessor.java
Modified:
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/mailetcontainer/MailetLoaderBeanFactory.java
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/mailetcontainer/MatcherLoaderBeanFactory.java
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/mailrepositorystore/MailRepositoryStoreBeanFactory.java
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/ProtocolHandlerChainFactoryPostProcessor.java
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/postprocessor/ConfigurableBeanPostProcessor.java
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/postprocessor/LogEnabledBeanPostProcessor.java
Copied:
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/AbstractBeanFactory.java
(from r1053066,
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/AbstractBeanFactoryAware.java)
URL:
http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/AbstractBeanFactory.java?p2=james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/AbstractBeanFactory.java&p1=james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/AbstractBeanFactoryAware.java&r1=1053066&r2=1053068&rev=1053068&view=diff
==============================================================================
---
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/AbstractBeanFactoryAware.java
(original)
+++
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/AbstractBeanFactory.java
Mon Dec 27 13:59:21 2010
@@ -16,14 +16,19 @@
* specific language governing permissions and limitations *
* under the License. *
****************************************************************/
-package org.apache.james.container.spring.bean.factory;
+package org.apache.james.container.spring.bean;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-public abstract class AbstractBeanFactoryAware implements BeanFactoryAware {
+/**
+ * Simple abstract base class which BeanFactory, FactoryBeanPostProcessors
+ * and BeanPostProcessors implementations should
+ * extend if they want to access the context's beanFactory.
+ */
+public abstract class AbstractBeanFactory implements BeanFactoryAware {
private ConfigurableListableBeanFactory beanFactory;
Copied:
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/AbstractLifecycleBeanPostProcessor.java
(from r1053066,
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/postprocessor/AbstractLifecycleBeanPostProcessor.java)
URL:
http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/AbstractLifecycleBeanPostProcessor.java?p2=james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/AbstractLifecycleBeanPostProcessor.java&p1=james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/postprocessor/AbstractLifecycleBeanPostProcessor.java&r1=1053066&r2=1053068&rev=1053068&view=diff
==============================================================================
---
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/postprocessor/AbstractLifecycleBeanPostProcessor.java
(original)
+++
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/AbstractLifecycleBeanPostProcessor.java
Mon Dec 27 13:59:21 2010
@@ -16,9 +16,8 @@
* specific language governing permissions and limitations *
* under the License. *
****************************************************************/
-package org.apache.james.container.spring.bean.postprocessor;
+package org.apache.james.container.spring.bean;
-import org.apache.james.container.spring.bean.factory.AbstractBeanFactoryAware;
import org.springframework.beans.BeansException;
import org.springframework.beans.FatalBeanException;
import org.springframework.beans.factory.config.BeanPostProcessor;
@@ -26,45 +25,15 @@ import org.springframework.core.Ordered;
import org.springframework.core.PriorityOrdered;
/**
- * Abstract base class which BeanPostProcessors should extend if they provide
an
- * LifeCycle handling
+ * Abstract base class which BeanPostProcessors should
+ * extend if they provide an LifeCycle handling.
*
* @param <T>
*/
-public abstract class AbstractLifecycleBeanPostProcessor<T> extends
AbstractBeanFactoryAware implements BeanPostProcessor, PriorityOrdered {
+public abstract class AbstractLifecycleBeanPostProcessor<T> extends
AbstractBeanFactory implements BeanPostProcessor, PriorityOrdered {
private int order = Ordered.HIGHEST_PRECEDENCE;
- /**
- * Return the class which mark the lifecycle.
- *
- * @return interfaceClass
- */
- protected abstract Class<T> getLifeCycleInterface();
-
- /**
- * Method which gets executed if the bean implement the LifeCycleInterface.
- * Override this if you wish perform any action. Default is todo nothing
- *
- * @param bean
- * the actual bean
- * @param beanname
- * then name of the bean
- * @throws Exception
- */
- protected abstract void executeLifecycleMethodBeforeInit(T bean, String
beanname) throws Exception;
-
- /**
- * Method which gets executed if the bean implement the LifeCycleInterface.
- * Override this if you wish perform any action. Default is todo nothing
- *
- * @param bean the actual bean
- * @param beanname then name of the bean
- * @param componentName the component name
- * @throws Exception
- */
- protected abstract void executeLifecycleMethodAfterInit(T bean, String
beanname) throws Exception;
-
/*
* (non-Javadoc)
*
@@ -75,7 +44,9 @@ public abstract class AbstractLifecycleB
try {
Class<T> lClass = getLifeCycleInterface();
if (lClass.isInstance(bean)) {
- // check if the bean is registered in the context. If not it
was create by the InstanceFactory and so there is no need to execute the
callback
+ // Check if the bean is registered in the context.
+ // If not it was created by the container and so there
+ // is no need to execute the callback.
if (getBeanFactory().containsBeanDefinition(name)) {
executeLifecycleMethodBeforeInit((T) bean, name);
}
@@ -96,7 +67,9 @@ public abstract class AbstractLifecycleB
try {
Class<T> lClass = getLifeCycleInterface();
if (lClass.isInstance(bean)) {
- // check if the bean is registered in the context. If not it
was create by the InstanceFactory and so there is no need to execute the
callback
+ // Check if the bean is registered in the context.
+ // If not it was created by the container and so there is no
+ // need to execute the callback.
if (getBeanFactory().containsBeanDefinition(name)) {
executeLifecycleMethodAfterInit((T) bean, name);
}
@@ -108,6 +81,34 @@ public abstract class AbstractLifecycleB
}
/**
+ * Return the class which mark the lifecycle.
+ *
+ * @return interfaceClass
+ */
+ protected abstract Class<T> getLifeCycleInterface();
+
+ /**
+ * Method which gets executed if the bean implement the LifeCycleInterface.
+ * Override this if you wish perform any action. Default is todo nothing
+ *
+ * @param bean the actual bean
+ * @param beanname then name of the bean
+ * @throws Exception
+ */
+ protected abstract void executeLifecycleMethodBeforeInit(T bean, String
beanname) throws Exception;
+
+ /**
+ * Method which gets executed if the bean implement the LifeCycleInterface.
+ * Override this if you wish perform any action. Default is todo nothing
+ *
+ * @param bean the actual bean
+ * @param beanname then name of the bean
+ * @param componentName the component name
+ * @throws Exception
+ */
+ protected abstract void executeLifecycleMethodAfterInit(T bean, String
beanname) throws Exception;
+
+ /**
* @param order
*/
public void setOrder(int order) {
Modified:
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/mailetcontainer/MailetLoaderBeanFactory.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/mailetcontainer/MailetLoaderBeanFactory.java?rev=1053068&r1=1053067&r2=1053068&view=diff
==============================================================================
---
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/mailetcontainer/MailetLoaderBeanFactory.java
(original)
+++
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/mailetcontainer/MailetLoaderBeanFactory.java
Mon Dec 27 13:59:21 2010
@@ -20,7 +20,7 @@ package org.apache.james.container.sprin
import javax.mail.MessagingException;
-import org.apache.james.container.spring.bean.factory.AbstractBeanFactoryAware;
+import org.apache.james.container.spring.bean.AbstractBeanFactory;
import org.apache.james.mailetcontainer.api.MailetLoader;
import org.apache.mailet.Mailet;
import org.apache.mailet.MailetConfig;
@@ -33,7 +33,7 @@ import org.springframework.beans.factory
* The Mailets are not registered in the factory after loading them!
*
*/
-public class MailetLoaderBeanFactory extends AbstractBeanFactoryAware
implements MailetLoader {
+public class MailetLoaderBeanFactory extends AbstractBeanFactory implements
MailetLoader {
/*
* (non-Javadoc)
Modified:
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/mailetcontainer/MatcherLoaderBeanFactory.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/mailetcontainer/MatcherLoaderBeanFactory.java?rev=1053068&r1=1053067&r2=1053068&view=diff
==============================================================================
---
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/mailetcontainer/MatcherLoaderBeanFactory.java
(original)
+++
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/mailetcontainer/MatcherLoaderBeanFactory.java
Mon Dec 27 13:59:21 2010
@@ -20,7 +20,7 @@ package org.apache.james.container.sprin
import javax.mail.MessagingException;
-import org.apache.james.container.spring.bean.factory.AbstractBeanFactoryAware;
+import org.apache.james.container.spring.bean.AbstractBeanFactory;
import org.apache.james.mailetcontainer.api.MatcherLoader;
import org.apache.mailet.MailetException;
import org.apache.mailet.Matcher;
@@ -33,7 +33,7 @@ import org.springframework.beans.factory
* The Matchers are not registered in the factory after loading them!
*
*/
-public class MatcherLoaderBeanFactory extends AbstractBeanFactoryAware
implements MatcherLoader {
+public class MatcherLoaderBeanFactory extends AbstractBeanFactory implements
MatcherLoader {
/*
* (non-Javadoc)
Modified:
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/mailrepositorystore/MailRepositoryStoreBeanFactory.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/mailrepositorystore/MailRepositoryStoreBeanFactory.java?rev=1053068&r1=1053067&r2=1053068&view=diff
==============================================================================
---
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/mailrepositorystore/MailRepositoryStoreBeanFactory.java
(original)
+++
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factory/mailrepositorystore/MailRepositoryStoreBeanFactory.java
Mon Dec 27 13:59:21 2010
@@ -31,7 +31,7 @@ import org.apache.commons.configuration.
import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.commons.logging.Log;
-import org.apache.james.container.spring.bean.factory.AbstractBeanFactoryAware;
+import org.apache.james.container.spring.bean.AbstractBeanFactory;
import org.apache.james.lifecycle.api.Configurable;
import org.apache.james.lifecycle.api.LogEnabled;
import org.apache.james.mailrepository.api.MailRepository;
@@ -41,9 +41,8 @@ import org.springframework.beans.factory
/**
* Provides a registry of mail repositories. A mail repository is uniquely
* identified by its destinationURL, type and model.
- *
*/
-public class MailRepositoryStoreBeanFactory extends AbstractBeanFactoryAware
implements MailRepositoryStore, LogEnabled, Configurable {
+public class MailRepositoryStoreBeanFactory extends AbstractBeanFactory
implements MailRepositoryStore, LogEnabled, Configurable {
/**
* Map of [destinationURL + type]->Repository
@@ -105,11 +104,8 @@ public class MailRepositoryStoreBeanFact
* <p>This is presumably synchronized to prevent corruption of the
* internal registry.</p>
*
- * @param repConf the Configuration object used to register the
- * repository
- *
- * @throws ConfigurationException if an error occurs accessing the
- * Configuration object
+ * @param repConf the Configuration object used to register the repository
+ * @throws ConfigurationException if an error occurs accessing the
Configuration object
*/
@SuppressWarnings("unchecked")
public synchronized void registerRepository(HierarchicalConfiguration
repConf) throws ConfigurationException {
@@ -170,8 +166,7 @@ public class MailRepositoryStoreBeanFact
* @param hint the Configuration object used to look up the repository
* @return the selected repository
* @throws MailRepostoryStoreException if any error occurs while parsing
the
- * Configuration or retrieving the
- * MailRepository
+ * Configuration or retrieving the MailRepository
*/
public synchronized MailRepository select(String destination) throws
MailRepostoryStoreException {
Modified:
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/ProtocolHandlerChainFactoryPostProcessor.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/ProtocolHandlerChainFactoryPostProcessor.java?rev=1053068&r1=1053067&r2=1053068&view=diff
==============================================================================
---
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/ProtocolHandlerChainFactoryPostProcessor.java
(original)
+++
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/ProtocolHandlerChainFactoryPostProcessor.java
Mon Dec 27 13:59:21 2010
@@ -42,77 +42,27 @@ import org.springframework.beans.factory
/**
*
- * {...@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
+ * {...@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 abstract class ProtocolHandlerChainFactoryPostProcessor implements
ProtocolHandlerChain, BeanFactoryPostProcessor {
+ private ConfigurableListableBeanFactory beanFactory;
+
private String coreHandlersPackage;
private List<String> handlers = new LinkedList<String>();
private String beanname;
- private ConfigurableListableBeanFactory beanFactory;
-
- public void setBeanName(String beanname) {
- this.beanname = beanname;
- }
-
- public void setCoreHandlersPackage(String coreHandlersPackage) {
- this.coreHandlersPackage = coreHandlersPackage;
- }
-
- /**
- * Return a DefaultConfiguration build on the given command name and
- * classname
- *
- * @param cmdName The command name
- * @param className The class name
- * @return DefaultConfiguration
- * @throws ConfigurationException
- */
- private HierarchicalConfiguration addHandler(String className) throws
ConfigurationException {
- HierarchicalConfiguration hConf = new DefaultConfigurationBuilder();
- hConf.addProperty("[...@class]", className);
- return hConf;
- }
-
-
- /*
- * (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>();
- 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;
- }
-
- /**
- * Returns the Handlers List.
- *
- * @return
- */
- public List<String> getHandlers() {
- return handlers;
- }
-
/**
* Lookup the {...@link HierarchicalConfiguration} for the beanname which
was
* configured via {...@link #setBeanName(String)} and parse it for
handlers which should be
@@ -194,6 +144,57 @@ public abstract class ProtocolHandlerCha
}
+ public void setCoreHandlersPackage(String coreHandlersPackage) {
+ this.coreHandlersPackage = coreHandlersPackage;
+ }
+
+ /**
+ * Return a DefaultConfiguration build on the given command name and
+ * classname.
+ *
+ * @param cmdName The command name
+ * @param className The class name
+ * @return DefaultConfiguration
+ * @throws ConfigurationException
+ */
+ private HierarchicalConfiguration addHandler(String className) throws
ConfigurationException {
+ HierarchicalConfiguration hConf = new DefaultConfigurationBuilder();
+ hConf.addProperty("[...@class]", className);
+ return hConf;
+ }
+
+ /**
+ * Returns the Handlers List.
+ *
+ * @return
+ */
+ public List<String> getHandlers() {
+ return handlers;
+ }
+
+ /*
+ * (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>();
+ 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;
+ }
+
+ public void setBeanName(String beanname) {
+ this.beanname = beanname;
+ }
+
private String getBeanName(String name) {
return beanname + ":" + name;
}
Modified:
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/postprocessor/ConfigurableBeanPostProcessor.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/postprocessor/ConfigurableBeanPostProcessor.java?rev=1053068&r1=1053067&r2=1053068&view=diff
==============================================================================
---
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/postprocessor/ConfigurableBeanPostProcessor.java
(original)
+++
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/postprocessor/ConfigurableBeanPostProcessor.java
Mon Dec 27 13:59:21 2010
@@ -19,6 +19,7 @@
package org.apache.james.container.spring.bean.postprocessor;
import org.apache.commons.configuration.HierarchicalConfiguration;
+import
org.apache.james.container.spring.bean.AbstractLifecycleBeanPostProcessor;
import
org.apache.james.container.spring.provider.configuration.ConfigurationProvider;
import org.apache.james.lifecycle.api.Configurable;
@@ -46,7 +47,7 @@ public class ConfigurableBeanPostProcess
@Override
protected void executeLifecycleMethodAfterInit(Configurable bean, String
beanname) throws Exception {
- // Do nothing
+ // Do nothing.
}
}
Modified:
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/postprocessor/LogEnabledBeanPostProcessor.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/postprocessor/LogEnabledBeanPostProcessor.java?rev=1053068&r1=1053067&r2=1053068&view=diff
==============================================================================
---
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/postprocessor/LogEnabledBeanPostProcessor.java
(original)
+++
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/postprocessor/LogEnabledBeanPostProcessor.java
Mon Dec 27 13:59:21 2010
@@ -18,6 +18,7 @@
****************************************************************/
package org.apache.james.container.spring.bean.postprocessor;
+import
org.apache.james.container.spring.bean.AbstractLifecycleBeanPostProcessor;
import org.apache.james.container.spring.provider.log.LogProvider;
import org.apache.james.lifecycle.api.LogEnabled;
@@ -44,7 +45,7 @@ public class LogEnabledBeanPostProcessor
@Override
protected void executeLifecycleMethodAfterInit(LogEnabled bean, String
beanname) throws Exception {
- // Do nothing
+ // Do nothing.
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]