Author: norman Date: Sun Jan 3 14:07:41 2010 New Revision: 895393 URL: http://svn.apache.org/viewvc?rev=895393&view=rev Log: Fix some bugs after running the spring stuff in production. Now everything works! cleanup
Modified: james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/main/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/main/java/org/apache/james/userrepository/JamesUsersJdbcRepository.java james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/main/java/org/apache/james/userrepository/UsersFileRepository.java james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/test/java/org/apache/james/userrepository/UsersFileRepositoryTest.java james/server/sandbox/active/pure_spring_deployment/core-api/src/main/java/org/apache/james/api/kernel/LoaderService.java james/server/sandbox/active/pure_spring_deployment/core-api/src/main/java/org/apache/james/lifecycle/Configurable.java james/server/sandbox/active/pure_spring_deployment/core-api/src/test/java/org/apache/james/api/kernel/mock/FakeLoader.java james/server/sandbox/active/pure_spring_deployment/core-function/src/main/java/org/apache/james/mailrepository/MailStore.java james/server/sandbox/active/pure_spring_deployment/nntpserver-function/src/main/java/org/apache/james/nntpserver/repository/NNTPSpooler.java james/server/sandbox/active/pure_spring_deployment/remotemanager-function/src/main/java/org/apache/james/remotemanager/RemoteManagerProtocolHandlerFactory.java james/server/sandbox/active/pure_spring_deployment/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/AbstractMappingCmdHandler.java james/server/sandbox/active/pure_spring_deployment/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ListAllMappingsCmdHandler.java james/server/sandbox/active/pure_spring_deployment/socket-shared-library/src/main/java/org/apache/james/socket/shared/ProtocolHandlerChainImpl.java james/server/sandbox/active/pure_spring_deployment/spoolmanager-function/src/main/java/org/apache/james/transport/JamesSpoolManager.java james/server/sandbox/active/pure_spring_deployment/spoolmanager-function/src/main/java/org/apache/james/transport/LinearProcessor.java james/server/sandbox/active/pure_spring_deployment/spoolmanager-function/src/main/java/org/apache/james/transport/StateAwareProcessorList.java james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/config/james/log4j.properties james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/config/james/spring-beans.xml james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/java/org/apache/james/container/spring/lifecycle/AvalonInitializableBeanPostProcessor.java james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/java/org/apache/james/container/spring/lifecycle/CommonsConfigurableBeanPostProcessor.java james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/java/org/apache/james/container/spring/lifecycle/JSR250LoaderService.java Modified: james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/main/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/main/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/main/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java (original) +++ james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/main/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java Sun Jan 3 14:07:41 2010 @@ -232,8 +232,7 @@ * the DataSourceSelector */ @Resource(name="database-connections") - void setDatasources(DataSourceSelector datasources) { - System.out.println("database-connections" + datasources); + public void setDatasources(DataSourceSelector datasources) { m_datasources = datasources; } /** @@ -243,7 +242,7 @@ * the new service */ @Resource(name="filesystem") - void setFileSystem(FileSystem system) { + public void setFileSystem(FileSystem system) { this.fileSystem = system; } Modified: james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/main/java/org/apache/james/userrepository/JamesUsersJdbcRepository.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/main/java/org/apache/james/userrepository/JamesUsersJdbcRepository.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/main/java/org/apache/james/userrepository/JamesUsersJdbcRepository.java (original) +++ james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/main/java/org/apache/james/userrepository/JamesUsersJdbcRepository.java Sun Jan 3 14:07:41 2010 @@ -30,22 +30,11 @@ import java.sql.ResultSet; import java.sql.SQLException; -import javax.annotation.PostConstruct; - /** * A Jdbc-backed UserRepository which handles User instances of the <CODE>DefaultJamesUser</CODE> * class, or any superclass. */ public class JamesUsersJdbcRepository extends AbstractJdbcUsersRepository { - - - // REMOVE ME! - @PostConstruct - @Override - public void init() throws Exception { - super.init(); - } - /** * @see org.apache.james.userrepository.AbstractJdbcUsersRepository#readUserFromResultSet(java.sql.ResultSet) Modified: james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/main/java/org/apache/james/userrepository/UsersFileRepository.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/main/java/org/apache/james/userrepository/UsersFileRepository.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/main/java/org/apache/james/userrepository/UsersFileRepository.java (original) +++ james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/main/java/org/apache/james/userrepository/UsersFileRepository.java Sun Jan 3 14:07:41 2010 @@ -83,7 +83,7 @@ protected void doConfigure( final HierarchicalConfiguration configuration ) throws ConfigurationException { super.doConfigure(configuration); - destination = configuration.getString( "destination/[...@url]" ); + destination = configuration.getString( "destinatio...@url]" ); if (!destination.endsWith(urlSeparator)) { destination += urlSeparator; Modified: james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/test/java/org/apache/james/userrepository/UsersFileRepositoryTest.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/test/java/org/apache/james/userrepository/UsersFileRepositoryTest.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/test/java/org/apache/james/userrepository/UsersFileRepositoryTest.java (original) +++ james/server/sandbox/active/pure_spring_deployment/avalon-user-function/src/test/java/org/apache/james/userrepository/UsersFileRepositoryTest.java Sun Jan 3 14:07:41 2010 @@ -80,7 +80,7 @@ mockStore.add("OBJECT.users", file_Persistent_Object_Repository); res.setStore(mockStore); DefaultConfigurationBuilder configuration = new DefaultConfigurationBuilder("test"); - configuration.addProperty("destination/[...@url]", "file://target/var/users"); + configuration.addProperty("destinatio...@url]", "file://target/var/users"); res.setLog(new SimpleLog("MockLog")); res.configure(configuration); res.init(); Modified: james/server/sandbox/active/pure_spring_deployment/core-api/src/main/java/org/apache/james/api/kernel/LoaderService.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/core-api/src/main/java/org/apache/james/api/kernel/LoaderService.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/core-api/src/main/java/org/apache/james/api/kernel/LoaderService.java (original) +++ james/server/sandbox/active/pure_spring_deployment/core-api/src/main/java/org/apache/james/api/kernel/LoaderService.java Sun Jan 3 14:07:41 2010 @@ -27,6 +27,14 @@ */ public interface LoaderService { + /** + * Inject dependencies to the given object using jsr250. Before the injection is done set the Log and config + * to the object if the right LifeCycle methods are implement and Log / Config is not null + * + * @param obj + * @param logger + * @param config + */ public void injectDependenciesWithLifecycle(Object obj, Log logger, HierarchicalConfiguration config); Modified: james/server/sandbox/active/pure_spring_deployment/core-api/src/main/java/org/apache/james/lifecycle/Configurable.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/core-api/src/main/java/org/apache/james/lifecycle/Configurable.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/core-api/src/main/java/org/apache/james/lifecycle/Configurable.java (original) +++ james/server/sandbox/active/pure_spring_deployment/core-api/src/main/java/org/apache/james/lifecycle/Configurable.java Sun Jan 3 14:07:41 2010 @@ -30,7 +30,8 @@ public interface Configurable { /** - * Configure + * Configure the object. Be aware that no services are injected when this is called. If you need + * to access injected stuff do it in a method annotated with @PostConstruct * * @param config * @throws ConfigurationException Modified: james/server/sandbox/active/pure_spring_deployment/core-api/src/test/java/org/apache/james/api/kernel/mock/FakeLoader.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/core-api/src/test/java/org/apache/james/api/kernel/mock/FakeLoader.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/core-api/src/test/java/org/apache/james/api/kernel/mock/FakeLoader.java (original) +++ james/server/sandbox/active/pure_spring_deployment/core-api/src/test/java/org/apache/james/api/kernel/mock/FakeLoader.java Sun Jan 3 14:07:41 2010 @@ -55,7 +55,8 @@ mappings.put("scheduler", "org.apache.avalon.cornerstone.services.scheduler.TimeScheduler"); mappings.put("database-connections", "org.apache.avalon.cornerstone.services.datasources.DataSourceSelector"); mappings.put("defaultvirtualusertable", "org.apache.james.api.vut.VirtualUserTable"); - + mappings.put("virtualusertablemanagement", "org.apache.james.api.vut.management.VirtualUserTableManagement"); + mappings.put("spoolmanager", "org.apache.james.services.SpoolManager"); mappings.put("matcherpackages", "org.apache.james.transport.MatcherLoader"); mappings.put("mailetpackages", "org.apache.james.transport.MailetLoader"); @@ -65,7 +66,7 @@ mappings.put("spoolmanagement", "org.apache.james.management.SpoolManagementService"); mappings.put("bayesiananalyzermanagement", "org.apache.james.management.BayesianAnalyzerManagementService"); mappings.put("processormanagement", "org.apache.james.management.ProcessorManagementService"); - mappings.put("virtualusertablemanagement", "org.apache.james.api.vut.management.VirtualUserTableManagementService"); + mappings.put("virtualusertablemanagementservice", "org.apache.james.api.vut.management.VirtualUserTableManagementService"); mappings.put("domainlistmanagement", "org.apache.james.management.DomainListManagementService"); mappings.put("nntp-repository", "org.apache.james.nntpserver.repository.NNTPRepository"); } @@ -96,7 +97,6 @@ // Name indicates a service final Object service = get(name); - System.out.println("SERVICE=" + service); if (service == null) { } else { try { Modified: james/server/sandbox/active/pure_spring_deployment/core-function/src/main/java/org/apache/james/mailrepository/MailStore.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/core-function/src/main/java/org/apache/james/mailrepository/MailStore.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/core-function/src/main/java/org/apache/james/mailrepository/MailStore.java (original) +++ james/server/sandbox/active/pure_spring_deployment/core-function/src/main/java/org/apache/james/mailrepository/MailStore.java Sun Jan 3 14:07:41 2010 @@ -73,16 +73,7 @@ private Log logger; - private FileSystem fs; - - private DataSourceSelector datasources; - private LoaderService loader; - - @Resource(name="database-connections") - public void setDatasources(DataSourceSelector datasources) { - this.datasources = datasources; - } public void setLog(Log logger) { @@ -96,17 +87,9 @@ public void configure(HierarchicalConfiguration configuration) throws ConfigurationException{ this.configuration = configuration; } - - /** - * Set the Store to use - * - * @param store the Store - */ - @Resource(name="filesystem") - public void setFileSystem(FileSystem fs) { - this.fs = fs; - } + + @Resource(name="org.apache.james.LoaderService") public void setLoaderService(LoaderService loader) { this.loader = loader; Modified: james/server/sandbox/active/pure_spring_deployment/nntpserver-function/src/main/java/org/apache/james/nntpserver/repository/NNTPSpooler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/nntpserver-function/src/main/java/org/apache/james/nntpserver/repository/NNTPSpooler.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/nntpserver-function/src/main/java/org/apache/james/nntpserver/repository/NNTPSpooler.java (original) +++ james/server/sandbox/active/pure_spring_deployment/nntpserver-function/src/main/java/org/apache/james/nntpserver/repository/NNTPSpooler.java Sun Jan 3 14:07:41 2010 @@ -24,6 +24,8 @@ import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.HierarchicalConfiguration; import org.apache.commons.logging.Log; +import org.apache.james.lifecycle.Configurable; +import org.apache.james.lifecycle.LogEnabled; import org.apache.james.services.FileSystem; import org.apache.james.util.Lock; import org.apache.james.util.io.IOUtil; @@ -45,7 +47,7 @@ * Eats up inappropriate entries. * */ -public class NNTPSpooler { +public class NNTPSpooler implements LogEnabled, Configurable{ private ArticleIDRepository idRepos; @@ -345,12 +347,10 @@ - @Resource(name="org.apache.commons.configuration.Configuration") public void configure(HierarchicalConfiguration config) { this.config = config; } - @Resource(name="org.apache.commons.logging.Log") public void setLog(Log log) { this.logger = log; } Modified: james/server/sandbox/active/pure_spring_deployment/remotemanager-function/src/main/java/org/apache/james/remotemanager/RemoteManagerProtocolHandlerFactory.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/remotemanager-function/src/main/java/org/apache/james/remotemanager/RemoteManagerProtocolHandlerFactory.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/remotemanager-function/src/main/java/org/apache/james/remotemanager/RemoteManagerProtocolHandlerFactory.java (original) +++ james/server/sandbox/active/pure_spring_deployment/remotemanager-function/src/main/java/org/apache/james/remotemanager/RemoteManagerProtocolHandlerFactory.java Sun Jan 3 14:07:41 2010 @@ -25,7 +25,6 @@ import java.util.List; import java.util.Map; -import javax.annotation.PostConstruct; import javax.annotation.Resource; import org.apache.commons.configuration.ConfigurationException; @@ -68,12 +67,6 @@ private MailServer mailServer; - - @PostConstruct - public void init() throws Exception { - super.init(); - } - @SuppressWarnings("unchecked") public void onConfigure(HierarchicalConfiguration configuration) throws ConfigurationException { Modified: james/server/sandbox/active/pure_spring_deployment/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/AbstractMappingCmdHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/AbstractMappingCmdHandler.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/AbstractMappingCmdHandler.java (original) +++ james/server/sandbox/active/pure_spring_deployment/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/AbstractMappingCmdHandler.java Sun Jan 3 14:07:41 2010 @@ -31,7 +31,7 @@ protected final static String REMOVE_MAPPING_ACTION = "REMOVEMAPPING"; protected VirtualUserTableManagementService vutManagement; - @Resource(name = "virtualusertablemanagement") + @Resource(name = "virtualusertablemanagementservice") public final void setVirtualUserTableManagementService(VirtualUserTableManagementService vutManagement) { this.vutManagement = vutManagement; } Modified: james/server/sandbox/active/pure_spring_deployment/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ListAllMappingsCmdHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ListAllMappingsCmdHandler.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ListAllMappingsCmdHandler.java (original) +++ james/server/sandbox/active/pure_spring_deployment/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ListAllMappingsCmdHandler.java Sun Jan 3 14:07:41 2010 @@ -41,7 +41,7 @@ protected VirtualUserTableManagementService vutManagement; - @Resource(name = "virtualusertablemanagement") + @Resource(name = "virtualusertablemanagementservice") public final void setVirtualUserTableManagementService(VirtualUserTableManagementService vutManagement) { this.vutManagement = vutManagement; } Modified: james/server/sandbox/active/pure_spring_deployment/socket-shared-library/src/main/java/org/apache/james/socket/shared/ProtocolHandlerChainImpl.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/socket-shared-library/src/main/java/org/apache/james/socket/shared/ProtocolHandlerChainImpl.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/socket-shared-library/src/main/java/org/apache/james/socket/shared/ProtocolHandlerChainImpl.java (original) +++ james/server/sandbox/active/pure_spring_deployment/socket-shared-library/src/main/java/org/apache/james/socket/shared/ProtocolHandlerChainImpl.java Sun Jan 3 14:07:41 2010 @@ -129,7 +129,6 @@ final Class<?> handlerClass = classLoader.loadClass(className); Object handler = handlerClass.newInstance(); - System.out.println("LOADER=" + loader); loader.injectDependenciesWithLifecycle(handler, getLog(), config); // if it is a commands handler add it to the map with key as command Modified: james/server/sandbox/active/pure_spring_deployment/spoolmanager-function/src/main/java/org/apache/james/transport/JamesSpoolManager.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/spoolmanager-function/src/main/java/org/apache/james/transport/JamesSpoolManager.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/spoolmanager-function/src/main/java/org/apache/james/transport/JamesSpoolManager.java (original) +++ james/server/sandbox/active/pure_spring_deployment/spoolmanager-function/src/main/java/org/apache/james/transport/JamesSpoolManager.java Sun Jan 3 14:07:41 2010 @@ -143,7 +143,7 @@ String processorClass = config.getString("processorClass","org.apache.james.transport.StateAwareProcessorList"); try { processorList = (MailProcessor) Thread.currentThread().getContextClassLoader().loadClass(processorClass).newInstance();; - loaderService.injectDependencies(processorList); + loaderService.injectDependenciesWithLifecycle(processorList, logger, config); } catch (Exception e1) { logger.error("Unable to instantiate spoolmanager processor: "+processorClass, e1); throw new ConfigurationException("Instantiation exception: "+processorClass, e1); Modified: james/server/sandbox/active/pure_spring_deployment/spoolmanager-function/src/main/java/org/apache/james/transport/LinearProcessor.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/spoolmanager-function/src/main/java/org/apache/james/transport/LinearProcessor.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/spoolmanager-function/src/main/java/org/apache/james/transport/LinearProcessor.java (original) +++ james/server/sandbox/active/pure_spring_deployment/spoolmanager-function/src/main/java/org/apache/james/transport/LinearProcessor.java Sun Jan 3 14:07:41 2010 @@ -30,6 +30,7 @@ import java.util.List; import java.util.Locale; +import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.annotation.Resource; import javax.mail.MessagingException; @@ -117,6 +118,8 @@ private Log logger; + private HierarchicalConfiguration processorConf; + /** * Set the spool to be used by this LinearProcessor. * @@ -566,10 +569,15 @@ mailets = new ArrayList<Mailet>(); } - @SuppressWarnings("unchecked") public void configure(HierarchicalConfiguration processorConf) throws ConfigurationException { + this.processorConf = processorConf; + } + + @SuppressWarnings("unchecked") + @PostConstruct + public void init() throws Exception { openProcessorList(); - + final List<HierarchicalConfiguration> mailetConfs = processorConf.configurationsAt( "mailet" ); // Loop through the mailet configuration, load @@ -670,7 +678,6 @@ // able to service mails until this call is made. closeProcessorLists(); } - /** * @see org.apache.james.transport.MailetContainer#getMailetConfigs() */ Modified: james/server/sandbox/active/pure_spring_deployment/spoolmanager-function/src/main/java/org/apache/james/transport/StateAwareProcessorList.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/spoolmanager-function/src/main/java/org/apache/james/transport/StateAwareProcessorList.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/spoolmanager-function/src/main/java/org/apache/james/transport/StateAwareProcessorList.java (original) +++ james/server/sandbox/active/pure_spring_deployment/spoolmanager-function/src/main/java/org/apache/james/transport/StateAwareProcessorList.java Sun Jan 3 14:07:41 2010 @@ -37,7 +37,6 @@ import org.apache.james.api.kernel.LoaderService; import org.apache.james.lifecycle.Configurable; import org.apache.james.lifecycle.LogEnabled; -import org.apache.james.services.SpoolRepository; import org.apache.mailet.Mail; import org.apache.mailet.MailetException; @@ -57,12 +56,6 @@ private HierarchicalConfiguration config; - private MailetLoader mailetLoader; - - private MatcherLoader matcherLoader; - - private SpoolRepository spoolRepos; - private LoaderService loader; public StateAwareProcessorList() { @@ -75,26 +68,12 @@ this.logger = logger; } - - @Resource(name="mailetpackages") - public final void setMailetLoader(MailetLoader mailetLoader) { - this.mailetLoader = mailetLoader; - } - - @Resource(name="matcherpackages") - public final void setMatcherLoader(MatcherLoader matcherLoader) { - this.matcherLoader = matcherLoader; - } - - @Resource(name="spoolrepository") - public final void setSpoolRepository(SpoolRepository spoolRepos) { - this.spoolRepos = spoolRepos; - } @Resource(name="org.apache.james.LoaderService") public final void setLoaderService(LoaderService loader) { this.loader = loader; } + /** * @see org.apache.avalon.framework.activity.Initializable#initialize() */ @@ -115,10 +94,7 @@ processors.put(processorName, processor); - //setupLogger(processor, processorName); - //ContainerUtil.service(processor, compMgr); - //ContainerUtil.configure(processor, processorConf); - + if (logger.isInfoEnabled()) { StringBuffer infoBuffer = new StringBuffer(64) Modified: james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/config/james/log4j.properties URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/config/james/log4j.properties?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/config/james/log4j.properties (original) +++ james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/config/james/log4j.properties Sun Jan 3 14:07:41 2010 @@ -30,6 +30,6 @@ log4j.logger.org.springframework=WARN, CONS, FILE log4j.logger.org.apache.james=DEBUG, CONS, FILE #log4j.logger.james: set from default value WARN to INFO or even DEBUG to see (even) more logging -log4j.logger.james=WARN, CONS, FILE +log4j.logger.james=DEBUG, CONS, FILE log4j.logger=DEBUG, CONS, FILE Modified: james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/config/james/spring-beans.xml URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/config/james/spring-beans.xml?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/config/james/spring-beans.xml (original) +++ james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/config/james/spring-beans.xml Sun Jan 3 14:07:41 2010 @@ -19,22 +19,6 @@ <beans> - - - <!-- - Logging to log4j <bean id="logger" - class="org.apache.james.container.spring.logging.log4j.LoggerToComponentMapper" - init-method="init"> <property name="configurationResource" - value="log4j.properties"/> </bean> Logging to System.out - --> - <!-- - <bean name="logWorker" - class="org.apache.james.container.spring.logging.SystemConsoleLogWorker" - /> <bean name="logger, loggerMap" - class="org.apache.james.container.spring.adaptor.LoggingBridge" > - <property name="logWorker" ref="logWorker" /> </bean> - --> - <!-- replaces strings in configuration values <bean id="stringRemapperConfigurationInterceptor" @@ -92,29 +76,6 @@ /> </bean> --> - <!-- - beans managing bootstrapping and component lifecycle <bean - id="loggerPropagator" - class="org.apache.james.container.spring.lifecycle.LoggerPropagator" > - <property name="loggerFactory" ref="logger"/> </bean> <bean - id="contextPropagator" - class="org.apache.james.container.spring.lifecycle.ContextPropagator" - > <property name="context" ref="avalonContext"/> </bean> <bean - id="servicePropagator" - class="org.apache.james.container.spring.lifecycle.ServicePropagator" - > <property name="serviceManagerFactory" ref="serviceManager"/> - </bean> <bean id="configurationManager" - class="org.apache.james.container.spring.lifecycle.ConfigurationPropagator" - > <property name="configurationProvider" ref="configurationProvider"/> - </bean> <bean id="initializationManager" - class="org.apache.james.container.spring.lifecycle.InitializationPropagator" - /> - --> - - - - - <bean class="org.apache.james.container.spring.lifecycle.AvalonServiceableBeanPostProcessor"> <property name="order" value="2" /> @@ -291,10 +252,8 @@ class="org.apache.james.container.spring.adaptor.FileSystemBridge" /> <!-- The VirtualUserTable Management block --> - <!-- - <bean id="virtualusertablemanagement" - class="org.apache.james.impl.vut.VirtualUserTableManagementService" /> - --> + <bean id="virtualusertablemanagementservice" + class="org.apache.james.impl.vut.VirtualUserTableManagement" /> <!-- VirtualUserTable Store --> <bean id="virtualusertable-store" class="org.apache.james.core.VirtualUserTableStoreImpl" /> Modified: james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/java/org/apache/james/container/spring/lifecycle/AvalonInitializableBeanPostProcessor.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/java/org/apache/james/container/spring/lifecycle/AvalonInitializableBeanPostProcessor.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/java/org/apache/james/container/spring/lifecycle/AvalonInitializableBeanPostProcessor.java (original) +++ james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/java/org/apache/james/container/spring/lifecycle/AvalonInitializableBeanPostProcessor.java Sun Jan 3 14:07:41 2010 @@ -31,6 +31,7 @@ @Override protected void executeLifecycleMethodAfterInit(Initializable bean, String beanname, String lifecyclename) throws Exception { + System.out.println("BEAN=" + beanname + ".initialize()"); bean.initialize(); } @@ -39,8 +40,4 @@ return Initializable.class; } - public int getOrder() { - return 4; - } - } Modified: james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/java/org/apache/james/container/spring/lifecycle/CommonsConfigurableBeanPostProcessor.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/java/org/apache/james/container/spring/lifecycle/CommonsConfigurableBeanPostProcessor.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/java/org/apache/james/container/spring/lifecycle/CommonsConfigurableBeanPostProcessor.java (original) +++ james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/java/org/apache/james/container/spring/lifecycle/CommonsConfigurableBeanPostProcessor.java Sun Jan 3 14:07:41 2010 @@ -36,7 +36,9 @@ protected void executeLifecycleMethodBeforeInit(Configurable bean, String beanname, String lifecyclename) throws Exception { HierarchicalConfiguration beanConfig = provider.getConfigurationForComponent(lifecyclename); - bean.configure(beanConfig); + if(beanConfig != null) { + bean.configure(beanConfig); + } } Modified: james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/java/org/apache/james/container/spring/lifecycle/JSR250LoaderService.java URL: http://svn.apache.org/viewvc/james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/java/org/apache/james/container/spring/lifecycle/JSR250LoaderService.java?rev=895393&r1=895392&r2=895393&view=diff ============================================================================== --- james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/java/org/apache/james/container/spring/lifecycle/JSR250LoaderService.java (original) +++ james/server/sandbox/active/pure_spring_deployment/spring-deployment/src/main/java/org/apache/james/container/spring/lifecycle/JSR250LoaderService.java Sun Jan 3 14:07:41 2010 @@ -18,6 +18,12 @@ ****************************************************************/ package org.apache.james.container.spring.lifecycle; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import javax.annotation.PostConstruct; +import javax.annotation.Resource; + import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.HierarchicalConfiguration; import org.apache.commons.logging.Log; @@ -25,8 +31,6 @@ import org.apache.james.lifecycle.Configurable; import org.apache.james.lifecycle.LogEnabled; import org.springframework.beans.BeansException; -import org.springframework.beans.FatalBeanException; -import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.ConfigurableApplicationContext; @@ -38,16 +42,70 @@ * * */ -...@suppresswarnings("unused") -public class JSR250LoaderService extends CommonAnnotationBeanPostProcessor implements LoaderService { +...@suppresswarnings("serial") +public class JSR250LoaderService extends CommonAnnotationBeanPostProcessor implements LoaderService, ApplicationContextAware { - /* + private ConfigurableApplicationContext applicationContext; + + /* * (non-Javadoc) * @see org.apache.james.api.kernel.LoaderService#injectDependencies(java.lang.Object) */ public void injectDependencies(Object obj) { - postProcessAfterInitialization(obj, obj.getClass().getName()); - } + try { + injectResources(obj); + postConstruct(obj); + } catch (IllegalAccessException e) { + throw new RuntimeException("Unable to handle dependency injection of object " + obj, e); + } catch (InvocationTargetException e) { + throw new RuntimeException("Unable to handle dependency injection of object " + obj, e); + } + } + + + private void postConstruct(Object resource) throws IllegalAccessException, + InvocationTargetException { + Method[] methods = resource.getClass().getMethods(); + for (Method method : methods) { + PostConstruct postConstructAnnotation = method + .getAnnotation(PostConstruct.class); + if (postConstructAnnotation != null) { + Object[] args = {}; + method.invoke(resource, args); + + } + } + } + + private void injectResources(Object resource) { + final Method[] methods = resource.getClass().getMethods(); + for (Method method : methods) { + final Resource resourceAnnotation = method.getAnnotation(Resource.class); + if (resourceAnnotation != null) { + final String name = resourceAnnotation.name(); + if (name == null) { + // Unsupported + } else { + // Name indicates a service + final Object service = applicationContext.getBean(name); + + if (service == null) { + } else { + try { + Object[] args = {service}; + method.invoke(resource, args); + } catch (IllegalAccessException e) { + throw new RuntimeException("Injection failed for object " + resource + " on method " + method + " with resource " + service, e); + } catch (IllegalArgumentException e) { + throw new RuntimeException("Injection failed for object " + resource + " on method " + method + " with resource " + service, e); + } catch (InvocationTargetException e) { + throw new RuntimeException("Injection failed for object " + resource + " on method " + method + " with resource " + service, e); + } + } + } + } + } + } /* * (non-Javadoc) @@ -67,4 +125,8 @@ } injectDependencies(obj); } + + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + this.applicationContext = (ConfigurableApplicationContext) applicationContext; + } } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org