public abstract class ServiceImp extends java.lang.Object implements Service
Implementation of default / common behaviour for Service
s.
Includes basic implementation of MessageEventGenerator
which
returns the fully qualified name of the class.
Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
log |
CONFIRMATION_ID_KEY
Constructor and Description |
---|
ServiceImp()
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
changeState(ComponentState newState)
Updates the state for the component
ComponentState . |
void |
close()
Closes the component.
|
protected abstract void |
closeService() |
boolean |
continueOnFailure()
If true containers should continue and apply the next configured
Service even if this Service throws an
Exception . |
java.lang.String |
createName()
Create a name for any
MleMarker that is generated. |
java.lang.String |
createQualifier()
Create a qualifier for any
MleMarker that is generated. |
java.lang.Boolean |
getContinueOnFail() |
java.lang.Boolean |
getIsConfirmation()
Deprecated.
since 3.6.2 No-one has ever produced a confirmation service. This will be removed.
|
java.lang.Boolean |
getIsTrackingEndpoint() |
java.lang.String |
getLookupName()
Returns the exact name to bind this object to our
Context . |
java.lang.String |
getUniqueId()
Get the unique-id that is associated with this component.
|
void |
init()
Initialises the component.
|
protected abstract void |
initService() |
boolean |
isBranching()
Returns true if the implementation supports branching.
|
boolean |
isConfirmation()
Returns true if this event is a confirmation, otherwise false.
|
boolean |
isTrackingEndpoint()
Returns true if this should be considered an 'end-point' for tracking
purposes, otherwise false.
|
void |
requestClose()
Request this component is closed.
|
void |
requestInit()
Request this component is init'd.
|
void |
requestStart()
Request this component is started.
|
void |
requestStop()
Request this component is stopped.
|
protected static void |
rethrowServiceException(java.lang.Throwable e)
Deprecated.
|
ComponentState |
retrieveComponentState()
Returns the last record
ComponentState . |
void |
setContinueOnFail(java.lang.Boolean b)
whether or not this service is configured to continue on failure.
|
void |
setIsConfirmation(java.lang.Boolean b)
Deprecated.
since 3.6.2 No-one has ever produced a confirmation service. This will be removed.
|
void |
setIsTrackingEndpoint(java.lang.Boolean b)
whether or not this service is is a tracking endpoint.
|
void |
setLookupName(java.lang.String lookupName)
Specify the lookup name (if required) when adding this service as a shared component.
|
void |
setUniqueId(java.lang.String s)
Sets the unique identifier for this
Service . |
void |
start()
Starts the component.
|
void |
stop()
Stop the component
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
prepare
public ServiceImp()
Creates a new instance. Default unique ID is autogenerated using GuidGenerator.getUUID()
.
public final void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
init
in interface ComponentLifecycle
CoreException
- wrapping any underlying Exception
sprotected abstract void initService() throws CoreException
CoreException
public final void close()
ComponentLifecycle
A closed component should release any connections it uses, etc. and clean up completely.
Throwing a RuntimeException
may cause unintended consequences
close
in interface ComponentLifecycle
protected abstract void closeService()
public void stop()
ComponentLifecycle
A stopped component is not expected to be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling stop will pause message delivery. Throwing a
RuntimeException
may cause unintended consequences
stop
in interface ComponentLifecycle
public void start() throws CoreException
ComponentLifecycle
Once a component is started it should be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling start will begin message delivery.
start
in interface ComponentLifecycle
CoreException
- wrapping any underlying Exception
spublic java.lang.String createName()
MessageEventGenerator
MleMarker
that is generated.
The default implementation is to return the classname of the component in question.
* @return the name for anyMleMarker
that is generated.createName
in interface MessageEventGenerator
public java.lang.String createQualifier()
MessageEventGenerator
MleMarker
that is generated.
The default implementation is to return the unique-id of the component in question, or the empty string if not configured
createQualifier
in interface MessageEventGenerator
MleMarker
that is generated.public java.lang.String getUniqueId()
AdaptrisComponent
getUniqueId
in interface AdaptrisComponent
public void setUniqueId(java.lang.String s)
Service
Sets the unique identifier for this Service
. These unique
identifiers are optional but maybe required by some implementations of
ServiceCollection
.
setUniqueId
in interface Service
s
- this Service
's unique identifierpublic boolean isBranching()
Service
Returns true if the implementation supports branching.
isBranching
in interface Service
BranchingServiceCollection
public boolean continueOnFailure()
Service
If true containers should continue and apply the next configured
Service
even if this Service
throws an
Exception
.
continueOnFailure
in interface Service
public java.lang.Boolean getContinueOnFail()
continueOnFailure()
public void setContinueOnFail(java.lang.Boolean b)
b
- true/false, default if not specified is false.public java.lang.Boolean getIsTrackingEndpoint()
public void setIsTrackingEndpoint(java.lang.Boolean b)
b
- true/false, default if not specified is false.@Deprecated @Removal(version="3.9.0") public java.lang.Boolean getIsConfirmation()
@Deprecated @Removal(version="3.9.0") public void setIsConfirmation(java.lang.Boolean b)
b
- true/false, default if not specified is false.public boolean isTrackingEndpoint()
MessageEventGenerator
Returns true if this should be considered an 'end-point' for tracking purposes, otherwise false.
isTrackingEndpoint
in interface MessageEventGenerator
public boolean isConfirmation()
MessageEventGenerator
Returns true if this event is a confirmation, otherwise false.
isConfirmation
in interface MessageEventGenerator
@Deprecated @Removal(version="3.9.0") protected static void rethrowServiceException(java.lang.Throwable e) throws ServiceException
ExceptionHelper.wrapServiceException(Throwable)
or
ExceptionHelper.rethrowServiceException(Throwable)
instead.ServiceException
public void changeState(ComponentState newState)
Updates the state for the component ComponentState
.
changeState
in interface StateManagedComponent
public ComponentState retrieveComponentState()
Returns the last record ComponentState
.
retrieveComponentState
in interface StateManagedComponent
ComponentState
public void requestInit() throws CoreException
Request this component is init'd.
requestInit
in interface StateManagedComponent
CoreException
- wrapping any underlying Exceptionspublic void requestStart() throws CoreException
Request this component is started.
requestStart
in interface StateManagedComponent
CoreException
- wrapping any underlying Exceptionspublic void requestStop()
Request this component is stopped.
requestStop
in interface StateManagedComponent
public void requestClose()
Request this component is closed.
requestClose
in interface StateManagedComponent
public java.lang.String getLookupName()
JndiBindable
Context
.
Specifying a lookupName will not be modified at all when binding to jndi. Therefore you may want to prepend your own chosen subcontexts in this name e.g. "comp/env/"
getLookupName
in interface JndiBindable
public void setLookupName(java.lang.String lookupName)
If you don't know what to fill in here, leave it blank, and the adapter will use the unique-id instead.
lookupName
- the lookup name.