This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 07cda85c81ca8d486b996fbb4adb0c95a20840cb Author: Benoit Tellier <[email protected]> AuthorDate: Fri Mar 20 14:05:35 2020 +0700 JAMES-3122 Remove LogEnabled deprecated API --- CHANGELOG.md | 3 +- .../org/apache/james/lifecycle/api/LogEnabled.java | 41 ------- .../lifecycle/LogEnabledBeanPostProcessor.java | 52 --------- .../container/spring/lifecycle/LogProvider.java | 47 -------- .../spring/lifecycle/LogProviderImpl.java | 120 --------------------- .../lifecycle/LogProviderManagementMBean.java | 39 ------- .../OsgiLifecycleBeanFactoryPostProcessor.java | 90 ---------------- .../META-INF/org/apache/james/spring-server.xml | 3 +- .../resources/META-INF/spring/loaders-context.xml | 10 -- upgrade-instructions.md | 16 +++ 10 files changed, 19 insertions(+), 402 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e5d8c1..ff57fdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,7 +65,8 @@ of tasks being currently executed. - JAMES-3016 RemoteDelivery now doesn't enable `allow8bitmime` property by default. This parameter could cause body content alteration leading to DKIM invalid DKIM signatures to be positioned. Thanks to Sergey B. for the report. -More details about the property is at [java mail doc](https://javaee.github.io/javamail/docs/api/com/sun/mail/smtp/package-summary.html) +More details about the property is at [java mail doc](https://javaee.github.io/javamail/docs/api/com/sun/mail/smtp/package-summary.html) + - JAMES-3122 LogEnabled API in Spring product had been removed for Log4J2 adoption for Java 9+ runtime compatibility. ### Third party softwares - The distributed James server product (relying on Guice, Cassandra, ElasticSearch, RabbitMQ and optionally Swift) now needs at least RabbitMQ 3.8. diff --git a/server/container/lifecycle-api/src/main/java/org/apache/james/lifecycle/api/LogEnabled.java b/server/container/lifecycle-api/src/main/java/org/apache/james/lifecycle/api/LogEnabled.java deleted file mode 100644 index d829441..0000000 --- a/server/container/lifecycle-api/src/main/java/org/apache/james/lifecycle/api/LogEnabled.java +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - ****************************************************************/ - -package org.apache.james.lifecycle.api; - -import org.slf4j.Logger; - -/** - * Indicates that a services requires general logging. Note that this log should - * only be used for general service operations. A context sensitive log should - * be preferred where that is available within the context of a call. - * - * @deprecated Prefer using SLF4J LoggingFactory to get a Logger in each class - */ -@Deprecated -public interface LogEnabled { - - /** - * Sets the service log. - * - * @param log - * not null - */ - void setLog(Logger log); -} diff --git a/server/container/spring/src/main/java/org/apache/james/container/spring/lifecycle/LogEnabledBeanPostProcessor.java b/server/container/spring/src/main/java/org/apache/james/container/spring/lifecycle/LogEnabledBeanPostProcessor.java deleted file mode 100644 index 6402211..0000000 --- a/server/container/spring/src/main/java/org/apache/james/container/spring/lifecycle/LogEnabledBeanPostProcessor.java +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - ****************************************************************/ -package org.apache.james.container.spring.lifecycle; - -import org.apache.james.lifecycle.api.LogEnabled; - -/** - * Inject Commons Log to beans which implement LogEnabled. - * - * @deprecated Prefer using SLF4J LoggingFactory to get a Logger in each class - */ -@Deprecated -public class LogEnabledBeanPostProcessor extends AbstractLifecycleBeanPostProcessor<LogEnabled> { - - private LogProvider provider; - - public void setLogProvider(LogProvider provider) { - this.provider = provider; - } - - @Override - protected Class<LogEnabled> getLifeCycleInterface() { - return LogEnabled.class; - } - - @Override - protected void executeLifecycleMethodBeforeInit(LogEnabled bean, String beanname) throws Exception { - bean.setLog(provider.getLog(beanname)); - } - - @Override - protected void executeLifecycleMethodAfterInit(LogEnabled bean, String beanname) throws Exception { - // Do nothing. - } - -} diff --git a/server/container/spring/src/main/java/org/apache/james/container/spring/lifecycle/LogProvider.java b/server/container/spring/src/main/java/org/apache/james/container/spring/lifecycle/LogProvider.java deleted file mode 100644 index 5826257..0000000 --- a/server/container/spring/src/main/java/org/apache/james/container/spring/lifecycle/LogProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - ****************************************************************/ -package org.apache.james.container.spring.lifecycle; - -import org.slf4j.Logger; - -/** - * Provide {@link Logger} instances for Beans - * - * @deprecated Prefer using SLF4J LoggingFactory to get a Logger in each class - */ -@Deprecated -public interface LogProvider { - - /** - * Return the Log for the bean with the given name - * - * @param beanName - * @return log - */ - Logger getLog(String beanName); - - /** - * Register a {@link Logger} for a beanName. The registered Log will get - * returned by {@link #getLog(String)} - * - * @param beanName - * @param log - */ - void registerLog(String beanName, Logger log); -} diff --git a/server/container/spring/src/main/java/org/apache/james/container/spring/lifecycle/LogProviderImpl.java b/server/container/spring/src/main/java/org/apache/james/container/spring/lifecycle/LogProviderImpl.java deleted file mode 100644 index d2adee1..0000000 --- a/server/container/spring/src/main/java/org/apache/james/container/spring/lifecycle/LogProviderImpl.java +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - ****************************************************************/ -package org.apache.james.container.spring.lifecycle; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.log4j.Level; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; - -/** - * Provide a Log object for components - * - * @deprecated Prefer using SLF4J LoggingFactory to get a Logger in each class - */ -@Deprecated -public class LogProviderImpl implements LogProvider, InitializingBean, LogProviderManagementMBean { - - private final ConcurrentHashMap<String, Logger> logMap = new ConcurrentHashMap<>(); - private Map<String, String> logs; - private static final String PREFIX = "james."; - - /** - * Use {@link Logger} to create the Log - * - * @param loggerName - * @return log - */ - protected Logger createLog(String loggerName) { - return LoggerFactory.getLogger(loggerName); - } - - public void setLogMappings(Map<String, String> logs) { - this.logs = logs; - } - - @Override - public void afterPropertiesSet() throws Exception { - if (logs != null) { - for (String key : logs.keySet()) { - String value = logs.get(key); - registerLog(key, createLog(PREFIX + value)); - } - } - } - - @Override - public Logger getLog(String name) { - logMap.putIfAbsent(name, createLog(PREFIX + name)); - return logMap.get(name); - } - - @Override - public void registerLog(String beanName, Logger log) { - logMap.put(beanName, log); - } - - @Override - public List<String> getSupportedLogLevels() { - return Arrays.asList("DEBUG", "INFO", "WARN", "ERROR", "OFF"); - } - - @Override - public Map<String, String> getLogLevels() { - TreeMap<String, String> levels = new TreeMap<>(); - for (String name : logMap.keySet()) { - String level = getLogLevel(name); - if (level != null) { - levels.put(name, level); - } - } - return levels; - - } - - @Override - public String getLogLevel(String component) { - Logger log = logMap.get(component); - if (log == null) { - throw new IllegalArgumentException("No Log for component " + component); - } - org.apache.log4j.Logger logger = org.apache.log4j.Logger.getRootLogger(); - if (logger == null || logger.getLevel() == null) { - return null; - } - Level level = logger.getLevel(); - return level.toString(); - } - - @Override - public void setLogLevel(String component, String loglevel) { - if (!getSupportedLogLevels().contains(loglevel)) { - throw new IllegalArgumentException("Not supported loglevel given"); - } else { - ((org.apache.log4j.Logger) logMap.get(component)).setLevel(Level.toLevel(loglevel)); - } - } - -} diff --git a/server/container/spring/src/main/java/org/apache/james/container/spring/lifecycle/LogProviderManagementMBean.java b/server/container/spring/src/main/java/org/apache/james/container/spring/lifecycle/LogProviderManagementMBean.java deleted file mode 100644 index 605396c..0000000 --- a/server/container/spring/src/main/java/org/apache/james/container/spring/lifecycle/LogProviderManagementMBean.java +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - ****************************************************************/ -package org.apache.james.container.spring.lifecycle; - -import java.util.List; -import java.util.Map; - -/** - * Allow to change loglevel via JMX - * @deprecated static configuration via SLF4J implementation configuration file is advised - */ -@Deprecated -public interface LogProviderManagementMBean { - - List<String> getSupportedLogLevels(); - - Map<String, String> getLogLevels(); - - String getLogLevel(String component); - - void setLogLevel(String component, String loglevel); - -} diff --git a/server/container/spring/src/main/java/org/apache/james/container/spring/lifecycle/osgi/OsgiLifecycleBeanFactoryPostProcessor.java b/server/container/spring/src/main/java/org/apache/james/container/spring/lifecycle/osgi/OsgiLifecycleBeanFactoryPostProcessor.java deleted file mode 100644 index 7fd8dca..0000000 --- a/server/container/spring/src/main/java/org/apache/james/container/spring/lifecycle/osgi/OsgiLifecycleBeanFactoryPostProcessor.java +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - ****************************************************************/ -package org.apache.james.container.spring.lifecycle.osgi; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; - -import org.apache.james.container.spring.lifecycle.ConfigurableBeanPostProcessor; -import org.apache.james.container.spring.lifecycle.ConfigurationProvider; -import org.apache.james.container.spring.lifecycle.LogEnabledBeanPostProcessor; -import org.apache.james.container.spring.lifecycle.LogProvider; -import org.osgi.framework.BundleContext; -import org.osgi.framework.BundleException; -import org.osgi.framework.InvalidSyntaxException; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.osgi.extender.OsgiBeanFactoryPostProcessor; - - -@SuppressWarnings("deprecation") -public class OsgiLifecycleBeanFactoryPostProcessor implements OsgiBeanFactoryPostProcessor { - - - private ConfigurationProvider confProvider; - private LogProvider logProvider; - - public void setConfigurationProvider(ConfigurationProvider confProvider) { - this.confProvider = confProvider; - } - - public void setLogProvider(LogProvider logProvider) { - this.logProvider = logProvider; - } - - - @Override - public void postProcessBeanFactory(BundleContext context, ConfigurableListableBeanFactory factory) throws BeansException, InvalidSyntaxException, BundleException { - // We need to set the beanfactory by hand. This MAY be a bug in spring-dm but I'm not sure yet - LogEnabledBeanPostProcessor loggingProcessor = new LogEnabledBeanPostProcessor(); - loggingProcessor.setBeanFactory(factory); - loggingProcessor.setLogProvider(logProvider); - loggingProcessor.setOrder(0); - factory.addBeanPostProcessor(loggingProcessor); - - OSGIResourceAnnotationBeanPostProcessor resourceProcessor = new OSGIResourceAnnotationBeanPostProcessor(); - resourceProcessor.setBeanClassLoader(factory.getBeanClassLoader()); - resourceProcessor.setBeanFactory(factory); - resourceProcessor.setBundleContext(context); - resourceProcessor.setTimeout(60 * 1000); - factory.addBeanPostProcessor(resourceProcessor); - - OSGIPersistenceUnitAnnotationBeanPostProcessor persistenceProcessor = new OSGIPersistenceUnitAnnotationBeanPostProcessor(); - persistenceProcessor.setBeanClassLoader(factory.getBeanClassLoader()); - persistenceProcessor.setBeanFactory(factory); - persistenceProcessor.setBundleContext(context); - persistenceProcessor.setTimeout(60 * 1000); - factory.addBeanPostProcessor(persistenceProcessor); - - ConfigurableBeanPostProcessor configurationProcessor = new ConfigurableBeanPostProcessor(); - configurationProcessor.setBeanFactory(factory); - configurationProcessor.setConfigurationProvider(confProvider); - configurationProcessor.setOrder(2); - factory.addBeanPostProcessor(configurationProcessor); - - InitDestroyAnnotationBeanPostProcessor annotationProcessor = new InitDestroyAnnotationBeanPostProcessor(); - annotationProcessor.setInitAnnotationType(PostConstruct.class); - annotationProcessor.setDestroyAnnotationType(PreDestroy.class); - factory.addBeanPostProcessor(annotationProcessor); - - - } - -} diff --git a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml index b4a0753..92461ad 100644 --- a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml +++ b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml @@ -259,7 +259,6 @@ <!-- <entry key="org.apache.james:type=component,name=james23importer" value-ref="james23importermanagement"/> --> - <entry key="org.apache.james:type=container,name=logprovider" value-ref="logprovider"/> <entry key="org.apache.james:type=component,name=quotamanagerbean" value-ref="quotamanagermanagement"/> <entry key="org.apache.james:type=component,name=reindexerbean" value-ref="reindexermanagement"/> <entry key="org.apache.james:type=component,name=sievemanagerbean" value-ref="sievemanagerbean"/> @@ -268,7 +267,7 @@ <property name="assembler"> <bean class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler"> <property name="managedInterfaces" - value="org.apache.james.fetchmail.FetchSchedulerMBean,org.apache.james.domainlist.api.DomainListManagementMBean,org.apache.james.dnsservice.api.DNSServiceMBean,org.apache.james.rrt.api.RecipientRewriteTableManagementMBean,org.apache.james.user.api.UsersRepositoryManagementMBean,org.apache.james.adapter.mailbox.MailboxManagerManagementMBean,org.apache.james.adapter.mailbox.MailboxCopierManagementMBean,org.apache.james.mailetcontainer.api.jmx.MailSpoolerMBean,org. [...] + value="org.apache.james.fetchmail.FetchSchedulerMBean,org.apache.james.domainlist.api.DomainListManagementMBean,org.apache.james.dnsservice.api.DNSServiceMBean,org.apache.james.rrt.api.RecipientRewriteTableManagementMBean,org.apache.james.user.api.UsersRepositoryManagementMBean,org.apache.james.adapter.mailbox.MailboxManagerManagementMBean,org.apache.james.adapter.mailbox.MailboxCopierManagementMBean,org.apache.james.mailetcontainer.api.jmx.MailSpoolerMBean,org. [...] </bean> </property> </bean> diff --git a/server/container/spring/src/main/resources/META-INF/spring/loaders-context.xml b/server/container/spring/src/main/resources/META-INF/spring/loaders-context.xml index 5f7b850..ccfc959 100644 --- a/server/container/spring/src/main/resources/META-INF/spring/loaders-context.xml +++ b/server/container/spring/src/main/resources/META-INF/spring/loaders-context.xml @@ -23,16 +23,6 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <!-- - Spring "Bean-Post-Processor" for LogEnabled interface. - --> - <bean class="org.apache.james.container.spring.lifecycle.LogEnabledBeanPostProcessor"> - <property name="logProvider" ref="logprovider"/> - <property name="order" value="0"/> - </bean> - <bean id="logprovider" class="org.apache.james.container.spring.lifecycle.LogProviderImpl"> - </bean> - - <!-- Configuration "Bean-Factory-Post-Processor" responsible to register beans from James specific configuration files --> diff --git a/upgrade-instructions.md b/upgrade-instructions.md index 0853760..f634df0 100644 --- a/upgrade-instructions.md +++ b/upgrade-instructions.md @@ -31,6 +31,22 @@ Change list: - [UidValidity and JPA or Cassandra](#uid-validity-and-jpa-or-cassandra) - [Differentiation between domain alias and domain mapping](#differentiation-between-domain-alias-and-domain-mapping) - [ProtocolSession storng typing](#protocolsession-storng-typing) + - [LogEnabled removal](#logenabled-removal) + +### LogEnabled removal + +Date 20/03/2020 + +SHA-1 XXX + +JIRA: https://issues.apache.org/jira/browse/JAMES-3122 + +Concerned product: Spring + +As Log4J 1.x is not compatible with Java 9+ runtime, we adopted Log4J2 as a logging solution for the Spring product. + +As a consequence, the deprecated `LogEnabled` API will be removed. We recommend extension developers to obtain their +Logger instance using the SLF4J `LoggerFactory` class instead. ### ProtocolSession storng typing --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
