org.springframework.web.socket.server.standard

## Class ServerEndpointExporter

- java.lang.Object
- - org.springframework.web.socket.server.standard.ServerEndpointExporter

- All Implemented Interfaces:
    Aware, BeanPostProcessor, InitializingBean, ApplicationContextAware

      public class ServerEndpointExporter
      extends Object
      implements InitializingBean, BeanPostProcessor, ApplicationContextAware

  Detects beans of type `ServerEndpointConfig` and registers with the standard Java WebSocket runtime. Also detects beans annotated with `ServerEndpoint` and registers them as well. Although not required, it is likely annotated endpoints should have their `configurator` property set to `SpringConfigurator`.

  When this class is used, by declaring it in Spring configuration, it should be possible to turn off a Servlet container's scan for WebSocket endpoints. This can be done with the help of the `<absolute-ordering>` element in web.xml.

  Since:
    4.0
  Author:
    Rossen Stoyanchev
  See Also:
    `ServerEndpointRegistration`, `SpringConfigurator`, `ServletServerContainerFactoryBean`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServerEndpointExporter()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterPropertiesSet()` Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
    `protected javax.websocket.server.ServerContainer` | `getServerContainer()`
    `Object` | `postProcessAfterInitialization(Object bean, String beanName)` Apply this BeanPostProcessor to the given new bean instance after any bean initialization callbacks (like InitializingBean's `afterPropertiesSet` or a custom init-method).
    `Object` | `postProcessBeforeInitialization(Object bean, String beanName)` Apply this BeanPostProcessor to the given new bean instance before any bean initialization callbacks (like InitializingBean's `afterPropertiesSet` or a custom init-method).
    `void` | `setAnnotatedEndpointClasses(Class<?>... annotatedEndpointClasses)` Explicitly list annotated endpoint types that should be registered on startup.
    `void` | `setApplicationContext(ApplicationContext applicationContext)` Set the ApplicationContext that this object runs in.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ServerEndpointExporter

          public ServerEndpointExporter()

  - ### Method Detail

    - #### setAnnotatedEndpointClasses

          public void setAnnotatedEndpointClasses(Class<?>... annotatedEndpointClasses)

      Explicitly list annotated endpoint types that should be registered on startup. This can be done if you wish to turn off a Servlet container's scan for endpoints, which goes through all 3rd party jars in the, and rely on Spring configuration instead.
      Parameters:
        `annotatedEndpointClasses` - `ServerEndpoint`-annotated types

    - #### setApplicationContext

          public void setApplicationContext(ApplicationContext applicationContext)

      Description copied from interface: `ApplicationContextAware`
      Set the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.

      Invoked after population of normal bean properties but before an init callback such as `InitializingBean.afterPropertiesSet()` or a custom init-method. Invoked after `ResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader)`, `ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)` and `MessageSourceAware`, if applicable.

      Specified by:
        `setApplicationContext` in interface `ApplicationContextAware`
      Parameters:
        `applicationContext` - the ApplicationContext object to be used by this object
      See Also:
        `BeanInitializationException`

    - #### getServerContainer

          protected javax.websocket.server.ServerContainer getServerContainer()

    - #### afterPropertiesSet

          public void afterPropertiesSet()
                                  throws Exception

      Description copied from interface: `InitializingBean`
      Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

      This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

      Specified by:
        `afterPropertiesSet` in interface `InitializingBean`
      Throws:
        `Exception` - in the event of misconfiguration (such as failure to set an essential property) or if initialization fails.

    - #### postProcessAfterInitialization

          public Object postProcessAfterInitialization(Object bean,
                                                       String beanName)
                                                throws BeansException

      Description copied from interface: `BeanPostProcessor`
      Apply this BeanPostProcessor to the given new bean instance after any bean initialization callbacks (like InitializingBean's `afterPropertiesSet` or a custom init-method). The bean will already be populated with property values. The returned bean instance may be a wrapper around the original.

      In case of a FactoryBean, this callback will be invoked for both the FactoryBean instance and the objects created by the FactoryBean (as of Spring 2.0). The post-processor can decide whether to apply to either the FactoryBean or created objects or both through corresponding `bean instanceof FactoryBean` checks.

      This callback will also be invoked after a short-circuiting triggered by a `InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation(java.lang.Class<?>, java.lang.String)` method, in contrast to all other BeanPostProcessor callbacks.

      Specified by:
        `postProcessAfterInitialization` in interface `BeanPostProcessor`
      Parameters:
        `bean` - the new bean instance
        `beanName` - the name of the bean
      Returns:
        the bean instance to use, either the original or a wrapped one; if `null`, no subsequent BeanPostProcessors will be invoked
      Throws:
        `BeansException` - in case of errors
      See Also:
        `InitializingBean.afterPropertiesSet()`, `FactoryBean`

    - #### postProcessBeforeInitialization

          public Object postProcessBeforeInitialization(Object bean,
                                                        String beanName)
                                                 throws BeansException

      Description copied from interface: `BeanPostProcessor`
      Apply this BeanPostProcessor to the given new bean instance before any bean initialization callbacks (like InitializingBean's `afterPropertiesSet` or a custom init-method). The bean will already be populated with property values. The returned bean instance may be a wrapper around the original.
      Specified by:
        `postProcessBeforeInitialization` in interface `BeanPostProcessor`
      Parameters:
        `bean` - the new bean instance
        `beanName` - the name of the bean
      Returns:
        the bean instance to use, either the original or a wrapped one; if `null`, no subsequent BeanPostProcessors will be invoked
      Throws:
        `BeansException` - in case of errors
      See Also:
        `InitializingBean.afterPropertiesSet()`