Class DefaultBinding<T>

  • Type Parameters:
    T - type of binding
    All Implemented Interfaces:
    Binding<T>, org.springframework.context.Lifecycle, org.springframework.integration.core.Pausable, org.springframework.integration.support.management.ManageableLifecycle

    public class DefaultBinding<T>
    extends Object
    implements Binding<T>
    Default implementation for a Binding.
    Author:
    Jennifer Hickey, Mark Fisher, Gary Russell, Marius Bogoevici, Oleg Zhurakousky, Myeonghyeon Lee, Soby Chacko
    See Also:
    EnableBinding
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected String group  
      protected org.springframework.context.Lifecycle lifecycle  
      protected String name  
      protected T target  
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultBinding​(String name, String group, T target, org.springframework.context.Lifecycle lifecycle)
      Creates an instance that associates a given name, group and binding target with an optional Lifecycle component, which will be stopped during unbinding.
      DefaultBinding​(String name, T target, org.springframework.context.Lifecycle lifecycle)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void afterUnbind()
      Listener method that executes after unbinding.
      String getBindingName()
      Returns the name of the target for this binding (i.e., channel name).
      String getGroup()  
      String getName()
      Returns the name of the destination for this binding.
      String getState()  
      boolean isPausable()  
      boolean isPaused()
      Will always return false unless overriden.
      boolean isRunning()  
      void pause()
      Pauses the target component represented by this instance if and only if the component implements Pausable interface NOTE: At the time the instance is created the component is already started and active.
      void resume()
      Resumes the target component represented by this instance if and only if the component implements Pausable interface NOTE: At the time the instance is created the component is already started and active.
      void setCompanion​(org.springframework.context.Lifecycle companion)
      Sets the companion Lifecycle.
      void start()
      Stops the target component represented by this instance.
      void stop()
      Starts the target component represented by this instance.
      String toString()  
      void unbind()
      Unbinds the target component represented by this instance and stops any active components.
    • Field Detail

      • name

        protected final String name
      • group

        protected final String group
      • target

        protected final T target
      • lifecycle

        protected final org.springframework.context.Lifecycle lifecycle
    • Constructor Detail

      • DefaultBinding

        public DefaultBinding​(String name,
                              String group,
                              T target,
                              org.springframework.context.Lifecycle lifecycle)
        Creates an instance that associates a given name, group and binding target with an optional Lifecycle component, which will be stopped during unbinding.
        Parameters:
        name - the name of the binding target
        group - the group (only for input targets)
        target - the binding target
        lifecycle - Lifecycle that runs while the binding is active and will be stopped during unbinding
      • DefaultBinding

        public DefaultBinding​(String name,
                              T target,
                              org.springframework.context.Lifecycle lifecycle)
    • Method Detail

      • getName

        public String getName()
        Description copied from interface: Binding
        Returns the name of the destination for this binding.
        Specified by:
        getName in interface Binding<T>
        Returns:
        destination name
      • getBindingName

        public String getBindingName()
        Description copied from interface: Binding
        Returns the name of the target for this binding (i.e., channel name).
        Specified by:
        getBindingName in interface Binding<T>
        Returns:
        binding name
      • getGroup

        public String getGroup()
      • getState

        public String getState()
      • isRunning

        public boolean isRunning()
        Specified by:
        isRunning in interface Binding<T>
        Specified by:
        isRunning in interface org.springframework.context.Lifecycle
        Specified by:
        isRunning in interface org.springframework.integration.support.management.ManageableLifecycle
        Returns:
        'true' if the target component represented by this instance is running.
      • isPausable

        public boolean isPausable()
      • isPaused

        public boolean isPaused()
        Description copied from interface: Binding
        Will always return false unless overriden.
        Specified by:
        isPaused in interface Binding<T>
        Specified by:
        isPaused in interface org.springframework.integration.core.Pausable
      • start

        public void start()
        Description copied from interface: Binding
        Stops the target component represented by this instance. NOTE: At the time the instance is created the component is already started. This operation is typically used by actuator to re-bind/re-start.
        Specified by:
        start in interface Binding<T>
        Specified by:
        start in interface org.springframework.context.Lifecycle
        Specified by:
        start in interface org.springframework.integration.support.management.ManageableLifecycle
        See Also:
        BindingsEndpoint
      • stop

        public void stop()
        Description copied from interface: Binding
        Starts the target component represented by this instance. NOTE: At the time the instance is created the component is already started. This operation is typically used by actuator to re-bind/re-start.
        Specified by:
        stop in interface Binding<T>
        Specified by:
        stop in interface org.springframework.context.Lifecycle
        Specified by:
        stop in interface org.springframework.integration.support.management.ManageableLifecycle
        See Also:
        BindingsEndpoint
      • pause

        public void pause()
        Description copied from interface: Binding
        Pauses the target component represented by this instance if and only if the component implements Pausable interface NOTE: At the time the instance is created the component is already started and active. This operation is typically used by actuator to pause/resume.
        Specified by:
        pause in interface Binding<T>
        Specified by:
        pause in interface org.springframework.integration.core.Pausable
        See Also:
        BindingsEndpoint
      • resume

        public void resume()
        Description copied from interface: Binding
        Resumes the target component represented by this instance if and only if the component implements Pausable interface NOTE: At the time the instance is created the component is already started and active. This operation is typically used by actuator to pause/resume.
        Specified by:
        resume in interface Binding<T>
        Specified by:
        resume in interface org.springframework.integration.core.Pausable
        See Also:
        BindingsEndpoint
      • unbind

        public void unbind()
        Description copied from interface: Binding
        Unbinds the target component represented by this instance and stops any active components. Implementations must be idempotent. After this method is invoked, the target is not expected to receive any messages; this instance should be discarded, and a new Binding should be created instead.
        Specified by:
        unbind in interface Binding<T>
      • afterUnbind

        protected void afterUnbind()
        Listener method that executes after unbinding. Subclasses can implement their own behaviour on unbinding by overriding this method.
      • setCompanion

        public void setCompanion​(org.springframework.context.Lifecycle companion)
        Sets the companion Lifecycle. In most cases, when dealing with message producer (e.g., Supplier), performing any lifecycle operation on it does nothing as we may need to also perform the same operation on its companion object (e.g., SourcePollingChannelAdapter)
        Parameters:
        companion - instance of companion Lifecycle object