Class AbstractEndpoint
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,Lifecycle
,Phased
,SmartLifecycle
,ExpressionCapable
,NamedComponent
,ManageableLifecycle
,ManageableSmartLifecycle
- Direct Known Subclasses:
AbstractPollingEndpoint
,EventDrivenConsumer
,GatewayProxyFactoryBean
,MessageProducerSupport
,MessagingGatewaySupport
,ReactiveStreamsConsumer
@IntegrationManagedResource public abstract class AbstractEndpoint extends IntegrationObjectSupport implements ManageableSmartLifecycle, DisposableBean
The base class for Message Endpoint implementations.
This class implements Lifecycle and provides an autoStartup
property. If true
, the endpoint will start automatically upon
initialization. Otherwise, it will require an explicit invocation of its
start()
method. The default value is true
.
To require explicit startup, provide a value of false
to the setAutoStartup(boolean)
method.
- Author:
- Mark Fisher, Kris Jacyna, Gary Russell, Artem Bilan, Trung Pham
-
Field Summary
Fields Modifier and Type Field Description protected Condition
lifecycleCondition
protected ReentrantLock
lifecycleLock
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
-
Constructor Summary
Constructors Constructor Description AbstractEndpoint()
-
Method Summary
Modifier and Type Method Description void
destroy()
protected abstract void
doStart()
Subclasses must implement this method with the start behavior.protected abstract void
doStop()
Subclasses must implement this method with the stop behavior.protected void
doStop(Runnable callback)
Stop the component and invoke callback.int
getPhase()
String
getRole()
boolean
isActive()
boolean
isAutoStartup()
boolean
isRunning()
protected void
onInit()
Subclasses may implement this for initialization logic.void
setAutoStartup(boolean autoStartup)
void
setPhase(int phase)
void
setRole(String role)
Specify the role for the endpoint.void
start()
void
stop()
void
stop(Runnable callback)
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getComponentType, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
-
Field Details
-
Constructor Details
-
AbstractEndpoint
public AbstractEndpoint()
-
-
Method Details
-
setAutoStartup
public void setAutoStartup(boolean autoStartup) -
setPhase
public void setPhase(int phase) -
setRole
Specify the role for the endpoint. Such endpoints can be started/stopped as a group.- Parameters:
role
- the role for this endpoint.- Since:
- 5.0
- See Also:
SmartLifecycle
,SmartLifecycleRoleController
-
getRole
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classIntegrationObjectSupport
-
destroy
public void destroy()- Specified by:
destroy
in interfaceDisposableBean
-
isAutoStartup
public final boolean isAutoStartup()- Specified by:
isAutoStartup
in interfaceSmartLifecycle
-
getPhase
public final int getPhase()- Specified by:
getPhase
in interfacePhased
- Specified by:
getPhase
in interfaceSmartLifecycle
-
isRunning
public final boolean isRunning()- Specified by:
isRunning
in interfaceLifecycle
- Specified by:
isRunning
in interfaceManageableLifecycle
-
start
public final void start()- Specified by:
start
in interfaceLifecycle
- Specified by:
start
in interfaceManageableLifecycle
-
stop
public final void stop()- Specified by:
stop
in interfaceLifecycle
- Specified by:
stop
in interfaceManageableLifecycle
-
stop
- Specified by:
stop
in interfaceSmartLifecycle
-
doStop
Stop the component and invoke callback.- Parameters:
callback
- the Runnable to invoke.
-
isActive
public boolean isActive() -
doStart
protected abstract void doStart()Subclasses must implement this method with the start behavior. This method will be invoked while holding thelifecycleLock
. -
doStop
protected abstract void doStop()Subclasses must implement this method with the stop behavior. This method will be invoked while holding thelifecycleLock
.
-