WIP: Spring-Upgrade auf 2.2.0
authorKai Moritz <kai@juplo.de>
Tue, 29 Oct 2019 08:49:28 +0000 (09:49 +0100)
committerKai Moritz <kai@juplo.de>
Tue, 29 Oct 2019 16:39:14 +0000 (17:39 +0100)
pom.xml
src/main/java/de/juplo/facebook/errors/FacebookErrorsSpringSocialAutoConfiguration.java [deleted file]

diff --git a/pom.xml b/pom.xml
index 3a8720d..705cb06 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -58,8 +58,6 @@
 
     <sonatypeOssDistMgmtSnapshotsUrl>https://oss.sonatype.org/content/repositories/snapshots/</sonatypeOssDistMgmtSnapshotsUrl>
 
-    <spring-social-facebook.version>2.0.3.RELEASE</spring-social-facebook.version>
-
   </properties>
 
 
       <artifactId>spring-boot-autoconfigure</artifactId>
       <optional>true</optional>
     </dependency>
-    <dependency>
-      <groupId>org.springframework.social</groupId>
-      <artifactId>spring-social-facebook</artifactId>
-      <version>${spring-social-facebook.version}</version>
-      <optional>true</optional>
-    </dependency>
 
     <!-- Needed for the mapping of error responses -->
     <dependency>
diff --git a/src/main/java/de/juplo/facebook/errors/FacebookErrorsSpringSocialAutoConfiguration.java b/src/main/java/de/juplo/facebook/errors/FacebookErrorsSpringSocialAutoConfiguration.java
deleted file mode 100644 (file)
index 49a3101..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-package de.juplo.facebook.errors;
-
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.BeanCreationException;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.BeanPostProcessor;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
-import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
-import org.springframework.boot.autoconfigure.social.FacebookAutoConfiguration;
-import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.social.facebook.api.Facebook;
-import org.springframework.social.facebook.api.impl.FacebookTemplate;
-import org.springframework.web.client.ResponseErrorHandler;
-import org.springframework.web.client.RestTemplate;
-
-
-
-/**
- * Automatic configuration for Srping-Social-Facebook
- *
- * @author Kai Moritz
- */
-@Configuration
-@ConditionalOnClass(value = FacebookTemplate.class)
-@AutoConfigureAfter({
-  WebMvcAutoConfiguration.class,
-  FacebookAutoConfiguration.class
-  })
-public class FacebookErrorsSpringSocialAutoConfiguration
-{
-  private static final Logger LOG =
-      LoggerFactory.getLogger(FacebookErrorsSpringSocialAutoConfiguration.class);
-
-
-  @Bean
-  static public BeanPostProcessor errorHandlerInjectorSpringSocial()
-  {
-    LOG.info("Configuring GraphApiErrorHandler for handling error-messages");
-    return new BeanPostProcessor()
-    {
-      @Override
-      public Object postProcessBeforeInitialization(
-          Object bean,
-          String beanName
-          )
-          throws
-          BeansException
-      {
-        return bean;
-      }
-
-      @Override
-      public Object postProcessAfterInitialization(
-          Object bean,
-          String beanName
-          )
-          throws
-          BeansException
-      {
-        if (bean instanceof Facebook)
-        {
-          try
-          {
-            Facebook facebook = (Facebook) bean;
-            RestTemplate template = (RestTemplate) facebook.restOperations();
-            ResponseErrorHandler handler = template.getErrorHandler();
-            template.setErrorHandler(new GraphApiErrorHandler(handler));
-            // Be sure, that the potential exception is triggered before!
-            LOG.debug("Injecting GraphApiErrorHandler in {}", facebook);
-          }
-          catch (BeanCreationException e)
-          {
-            /**
-             * This exception is called, if the BeanPostProcessor is called
-             * with a scoped bean, while the according scope is not
-             * accessible.
-             * This happens during initialization and can safely be ignored,
-             * because we only have to inject the handler for beans, that are
-             * actually usable.
-             */
-          }
-        }
-
-        return bean;
-      }
-    };
-  }
-
-  @Bean
-  static public BeanDefinitionRegistryPostProcessor test()
-  {
-    return new BeanDefinitionRegistryPostProcessor()
-    {
-      @Override
-      public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException
-      {
-        for(String name : registry.getBeanDefinitionNames())
-        {
-          BeanDefinition bean = registry.getBeanDefinition(name);
-          LOG.info("{}: {} - {} / {}", name, bean.getBeanClassName(), bean.getFactoryBeanName(), bean);
-        }
-      }
-
-      @Override
-      public void postProcessBeanFactory(ConfigurableListableBeanFactory factory) throws BeansException
-      {
-        for(String name : factory.getBeanNamesForType(Facebook.class))
-        {
-          BeanDefinition bean = factory.getBeanDefinition(name);
-          LOG.info("{}{}", name, factory.isFactoryBean(name) ? " (factory)" : "");
-        }
-      }
-    };
-  }
-}
\ No newline at end of file